No project description provided
Project description
Intro
Official repository for the paper Vertical LoRA: Dense Expectation-Maximization Interpretation of Transformers. VLoRA reduces the parameter count of Transformers by about 75% while preserving their performance.
Install
Run
pip install vlora
Out-of-box usage
VLoRA has some built-in models you can use directly. The following example imports, init a VLoRA-ViT model and performs a forward pass.
from vlora.models import VisionTransformerVLoRA
vit = VisionTransformerVLoRA()
x = torch.randn((1, 3, 224, 224))
y = vit(x)
Customized usage
You can apply VloRA to your own layer and use it as the building block of your model.
Assume
- you have a model of class
Modelconsisting of layers of classLayer. Layeris instantialized bylayer = Layer(a, b=b, c=c).Layerhas a 2D parameterL.mod.param, which you want to vlorafy.
You can create a VLoRA Compound from your layer:
from vlora.models import VLoRACompound
comp = VLoRACompound(
a,
b=b,
c=c,
vl_base_cls=Layer,
vl_param_name='mod.param',
vl_size=3, # compound size
vl_rank=2, # low rank r
vl_alpha=1,
)
Then replace the layer with the compound in your model. Note if your model has L layers, you should have L/vl_size compounds in the vlorofied model.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vlora-0.1.2.tar.gz.
File metadata
- Download URL: vlora-0.1.2.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/5.10.16.3-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e949f1b7702184da6485eff699702dc0421c0a315b65aa59058231f6d058a6ad
|
|
| MD5 |
1b2a07ea23376fe6139208cea9ae05d3
|
|
| BLAKE2b-256 |
aa5a7554819f19ab7c38961e2e37d3a408c9543a6700f0318da091683d68455b
|
File details
Details for the file vlora-0.1.2-py3-none-any.whl.
File metadata
- Download URL: vlora-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/5.10.16.3-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22df6b3cb0abb9917b2ec1333da4a3edf4fa22fa59a99ba32328746ac3a37cbe
|
|
| MD5 |
1c0f8d304f17d2edbc3def9104536d25
|
|
| BLAKE2b-256 |
2014f43489a1cec47eec18358ac04abf7ad14ee9c53a3abb9a6690ac4f3d319c
|