📕 LoRA: Low-Rank Adaptation of Large Language Models
Paper authors
LoRA: Low-Rank Adaptation of Large Language Models
**Abstract
An important paradigm of natural language processing consists of large-scale pre-training on general domain data and adaptation to particular tasks or domains. As we pre-train larger models, full fine-tuning, which retrains all model parameters, becomes less feasible. Using GPT-3 175B as an example -- deploying independent instances of fine-tuned models, each with 175B parameters, is prohibitively expensive. We propose Low-Rank Adaptation, or LoRA, which freezes the pre-trained model weights and injects trainable rank decomposition matrices into each layer of the Transformer architecture, greatly reducing the number of trainable parameters for downstream tasks. Compared to GPT-3 175B fine-tuned with Adam, LoRA can reduce the number of trainable parameters by 10,000 times and the GPU memory requirement by 3 times. LoRA performs on-par or better than fine-tuning in model quality on RoBERTa, DeBERTa, GPT-2, and GPT-3, despite having fewer trainable parameters, a higher training throughput, and, unlike adapters, no additional inference latency. We also provide an empirical investigation into rank-deficiency in language model adaptation, which sheds light on the efficacy of LoRA. We release a package that facilitates the integration of LoRA with PyTorch models and provide our implementations and model checkpoints for RoBERTa, DeBERTa, and GPT-2 at https://github.com/microsoft/LoRA.
Notes
- During training, they initialize A to normal distribution $N(0, \sigma^2)$ and B to 0, so the first output will be the exact same as the original model
- A downscales the input to rank k and B upscales it back to original dimension.
- they apply the low rank adaptation to Wq and Wv. -> this changes in future papers
- during finetuning, most of the model is frozen and only LORA weights are trained (a fraction of original parameters)
- The formulation allows plug and play applying and removing LoRA to models based on the need
As mentioned in Section 4.2, we only apply LoRA to Wq and Wv in most experiments for simplicity
*Common values
- 8
- 16
- 32
- 64
LoRA paper — screenshot

Extracted text
Copy7.2 WHAT IS THE OPTIMAL RANK ? FOR LORA?
We turn Our attention to the effect of rank T On model performance.
(Wg, W, Ww, Wc}, and just W, for a comparison.
T = 1
68.8
73.4
74.1
90.7
91.3
91.2
Table 6: Validation accuracy on Wiki?QL and MultiNLI with different rank T. To our surprise, a.
rank as small as one suffices for adapting both W and W. on these datasets while training W, alone
needs a larger r. We conduct a similar experiment on GPT-2 in Section H.2.
Table 6 shows that, surprisingly, LoRA already performs competitively with a very small r (more
so for (Wg, W} than just W). This suggests the update matrix AW could have a very small
"intrinsic rank" 6 To further support this finding, we check the overlap of the subspaces learned by
different choices ofr and by different random seeds. We argue that increasing r does not cover a
more meaningful subspace, which suggests that a low-rank adaptation matrix Is sufficient.
We adapt (Wg,W},
T = 8
70.4
73.8
74.0
90.7
91.6
91.5
r = 2
69.6
73.3
73.7
90.9
91.4
91.7
r = 4
70.5
73.7
74.0
91.1
91.3
91.7
T = 64
70.0
73.5
73.9
90.7
91.4
91.4
Weight Type
Wa
Wa,Ww
Wa,Wk,Wu.Wo
Wo
Wo,Wy
Wa,Wr. Wo,Wo
WikiSQL(+0.5%)
MultiNLI (+0.1%