Skip to main content

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 Model consisting of layers of class Layer.
  • Layer is instantialized by layer = Layer(a, b=b, c=c).
  • Layer has a 2D parameter L.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vlora-0.1.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vlora-0.1.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

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

Hashes for vlora-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e949f1b7702184da6485eff699702dc0421c0a315b65aa59058231f6d058a6ad
MD5 1b2a07ea23376fe6139208cea9ae05d3
BLAKE2b-256 aa5a7554819f19ab7c38961e2e37d3a408c9543a6700f0318da091683d68455b

See more details on using hashes here.

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

Hashes for vlora-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 22df6b3cb0abb9917b2ec1333da4a3edf4fa22fa59a99ba32328746ac3a37cbe
MD5 1c0f8d304f17d2edbc3def9104536d25
BLAKE2b-256 2014f43489a1cec47eec18358ac04abf7ad14ee9c53a3abb9a6690ac4f3d319c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page