Paper commentary
LoRA: Low-Rank Adaptation of Large Language Models
- Problem Full fine-tuning gives every downstream task a full-size copy of a large pre-trained model, which is impractical at GPT-3 scale, while adapter and prompt-style alternatives add inference latency or reduce the sequence length available to the task.
- Method Freezes the pre-trained weight matrix and trains two small matrices B and A whose product BA is added to the frozen path as the weight update, then merges BA into the weight for deployment.
- Results Reached 91.7 MNLI-m accuracy on GPT-3 175B with 4.7M trainable parameters, against 89.5 for full fine-tuning with 175,255.8M parameters.
Why full fine-tuning and adapters both fall short
Adapting a large pre-trained language model usually means fine-tuning it, which updates every parameter, so each task ends up with a model as large as the original. With GPT-3 at 175 billion trainable parameters, keeping and serving one full copy per task becomes a deployment problem rather than a training detail.
Efficient alternatives that add layers or change the input often trade speed or sequence length for fewer trainable parameters, and they often fall short of fine-tuning quality. Adapter layers add sequential compute at inference time, and that cost is most visible when the batch size is one. Prefix-style methods are hard to optimize, and the prompt positions they reserve take sequence length away from the downstream task.
The authors hypothesize that the change in weights during adaptation also has a low intrinsic rank, which they connect to earlier evidence that over-parametrized models sit on a low intrinsic dimension. If that hypothesis holds, the update can be described by far fewer numbers than the full weight matrix.
A low-rank update beside frozen weights
For a pre-trained matrix W0 of shape d by k, the weight is kept frozen and its update is written as the product BA, with B of shape d by r and A of shape r by k, where r is much smaller than min(d,k). The layer output is the frozen path plus the low-rank path, so \\(h = W_0 x + BAx\\), and only A and B receive gradient updates. Figure 1 draws the two paths side by side and marks that only A and B are trained.
A is drawn from a random Gaussian and B starts at zero, so the update BA is zero at the beginning and training starts from the pre-trained model. The update is scaled by \\(\\frac{\\alpha}{r}\\), where α is a constant; the authors set α to the first r they try and do not tune it, since this scaling reduces the need to retune hyperparameters when r changes.
In the Transformer, LoRA is applied to the attention projections Wq, Wk, Wv and Wo, while the MLP modules stay frozen, and most experiments adapt only Wq and Wv. The trainable count is \\(|\\Theta| = 2 \\hat{L}_{LoRA} d_{model} r\\), where \\(\\hat{L}_{LoRA}\\) is the number of weight matrices that receive LoRA.
The authors argue that when every attention weight is adapted and r reaches the rank of the pre-trained matrices, LoRA roughly recovers the expressiveness of full fine-tuning.
After training, BA is added to W0 once to give a single matrix W, so inference runs as it does for the original model with no added latency. Switching tasks means subtracting the current BA from W and adding a different B′A′, which needs little memory.
Memory, storage and training cost
Because gradients and optimizer states are needed only for the injected matrices, the savings reach up to 3 times for the hardware barrier to entry with adaptive optimizers. For a large Transformer trained with Adam, VRAM usage drops by up to 2/3 when r is much smaller than d_model, since optimizer states for frozen parameters are not stored.
On GPT-3 175B, training VRAM consumption falls from 1.2TB to 350GB. With r = 4 and only the query and value projections adapted, the checkpoint shrinks from 350GB to 35MB, which the authors describe as roughly 10,000 times smaller.
Deployment still needs the 350GB base model, but storing 100 adapted models takes about 354GB, against about 35TB for 100 fully fine-tuned copies.
Training on GPT-3 175B is 25% faster than full fine-tuning because gradients are not computed for most parameters. In the authors' throughput measurement with the same number of weight shards, full fine-tuning reached 32.5 tokens/s per V100 GPU and LoRA reached 43.1 tokens/s per V100 GPU.
GLUE results for RoBERTa and DeBERTa
The RoBERTa base and large checkpoints come from the HuggingFace Transformers library.
To compare with adapters on the authors' terms, all tasks share one batch size, the sequence length is 128, and MRPC, RTE and STS-B start from the pre-trained model rather than an MNLI-adapted one; those runs are marked with a dagger.
Rows marked with an asterisk are numbers published in prior work, so the full fine-tuning rows are not reruns by the authors.
Under the dagger setup, RoBERTa large with LoRA averages 88.6, above the 88.4 and 87.9 of two AdapterP rows and the 87.8 and 86.4 of two AdapterH rows. Per-task standard deviations for LoRA reach 2.5 on RTE for RoBERTa large, so the averages differ by less than a point from full fine-tuning in several cases.
E2E NLG results on GPT-2
The setup stays close to Li and Liang (2021) for a direct comparison, and the E2E NLG Challenge is evaluated with BLEU, NIST, METEOR, ROUGE-L and CIDEr. WebNLG and DART results are in an appendix and are not part of this comparison.
Rows with an asterisk are numbers from prior work, while the LoRA and AdapterH rows carry confidence intervals from the authors' own runs.
GPT-3 175B results
On GPT-3 175B, LoRA with 4.7M trainable parameters reaches 73.4 on WikiSQL and 91.7 on MNLI-m, while full fine-tuning with 175,255.8M parameters reaches 73.8 and 89.5. The WikiSQL gap is within the ±0.5% fluctuation the authors report for that task.
With 37.7M trainable parameters, LoRA reaches 74.0 on WikiSQL, 91.6 on MNLI-m and 53.4/29.2/45.1 on SAMSum. Standard deviations are reported only as a typical value per dataset over random seeds, because each GPT-3 run is costly.
Figure 2 plots validation accuracy against the number of trainable parameters on WikiSQL and MNLI-matched. Performance does not rise monotonically with parameter count for prefix methods: a significant drop appears beyond 256 special tokens for prefix-embedding tuning and beyond 32 for prefix-layer tuning. The authors suspect that more special tokens push the input distribution further from the pre-training data.
Inference latency of adapters and LoRA
Latency was measured for a single forward pass of GPT-2 medium on an NVIDIA Quadro RTX8000, averaged over 100 trials.
At batch size 1 and sequence length 128, Fine-Tune/LoRA took 19.8 ms, AdapterL 23.9 ms (+20.7%) and AdapterH 25.8 ms (+30.3%). Figure 1 of the table layout is Table 1, which lists these measurements next to larger batch and sequence settings.
At batch size 32 and sequence length 512, the overhead is smaller: AdapterL is at 1482.0 ms (+2.2%) and AdapterH at 1492.2 ms (+3.0%) against 1449.4 ms for Fine-Tune/LoRA. The overhead comes from adapter layers being processed one after another, which matters most in the online, batch-size-one setting.
How small the rank can be
On GPT-3 175B the authors set a budget of 18M parameters, roughly 35MB in FP16, which corresponds to r = 8 for one attention type or r = 4 for two, across 96 layers.
At r = 8, adapting Wv gives 73.0 on WikiSQL and 91.0 on MultiNLI, and adapting Wq gives 70.4 and 91.0. Adapting Wq and Wv together at r = 4 gives 73.7 and 91.3, and the authors conclude that this pairing gives the best overall result, although Wq, Wk, Wv and Wo at r = 2 ties on WikiSQL and scores 91.7 on MultiNLI.
Overlap between learned subspaces
The authors take the right-singular matrices of the learned A for r = 8 and r = 64 and measure how much of the top-i subspace of one lies in the top-j subspace of the other, using a normalized similarity that ranges from 0 to 1. This is written as \\(\\phi = \\|U^{i\\top}_{A_{r=8}} U^{j}_{A_{r=64}}\\|_F^2 / \\min(i,j)\\).
Figure 3 shows the comparison in layer 48 for ΔWq and ΔWv; the top direction overlaps strongly, while other directions overlap less. The shared one-dimensional subspace of ΔWv for r = 8 and r = 64 reaches normalized similarity above 0.5, which the authors use to explain why r = 1 works well on GPT-3.
How the update sits relative to W
To test this, W is projected onto the r-dimensional subspace of ΔW by computing \\(U^\\top W V^\\top\\), where U and V are the left and right singular-vector matrices of ΔW, and the Frobenius norm of the result is compared with \\(\\|W\\|_F\\).
In layer 48 of GPT-3 at r = 4, the projected norm is 0.32 for ΔWq, 21.67 for Wq and 0.02 for a random matrix, with \\(\\|W_q\\|_F = 61.95\\) and \\(\\|\\Delta W_q\\|_F = 6.91\\). At r = 64 the same norms are 1.90, 37.71 and 0.33, with \\(\\|\\Delta W_q\\|_F = 3.57\\).
ΔW correlates with W more than a random matrix does, but it amplifies directions that W does not emphasize, rather than repeating its top singular directions. The amplification factor is 21.5 at r = 4, computed as 6.91 divided by 0.32, and the factor is smaller at r = 64, a difference the authors explain in an appendix section.
Limitations
The latency comparison covers only GPT-2 medium on a single GPU, and the sharded case is described as worse but is not measured in Table 1.
Once BA is absorbed into W, a single batch cannot mix inputs for different tasks with different A and B in one forward pass; keeping them unmerged allows this but adds latency, which the authors accept only when latency is not critical.
The authors do not expect a small rank to work for every task or dataset; for a task in a language other than the pre-training language, retraining the whole model could outperform LoRA with a small r.
Only attention weights are adapted; MLP layers, LayerNorm layers and biases are left to future work. The mechanism by which pre-trained features become useful downstream remains unclear, which the authors name as an open question.
Paper info
- Authors
- Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, Weizhu Chen
- Venue
- arXiv · Preprint
- First published
- 2021-6-17
- Added
- 2026-10-18
- Updated
- 2021-10-16
- Version
- v2
- arXiv
- 2106.09685
- Category
- cs.CL · cs.AI · cs.LG
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, Weizhu Chen (2021). LoRA: Low-Rank Adaptation of Large Language Models. arXiv:2106.09685v2. https://arxiv.org/abs/2106.09685v2
BibTeX
@misc{hu2021lora,
title = {{LoRA: Low-Rank Adaptation of Large Language Models}},
author = {Edward J. Hu and Yelong Shen and Phillip Wallis and Zeyuan Allen-Zhu and Yuanzhi Li and Shean Wang and Lu Wang and Weizhu Chen},
year = {2021},
eprint = {2106.09685},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2106.09685v2}
}