TL;DR
Adapting a large pretrained language model to a task usually means updating every weight, which produces a full copy of the model for each task. LoRA keeps the pretrained weights frozen and learns the change to each chosen weight matrix as the product of two thin matrices. Only those thin matrices are trained and stored.
On GPT-3 175B the paper reports results on par with or better than full fine-tuning on three tasks, with 4.7 million trainable parameters instead of 175 billion. After training, the thin matrices can be merged into the frozen weights, so inference costs the same as the original model.
Where you'll see it: parameter-efficient fine-tuning of open language and image models, where one base model is shared and many small adapter files are swapped in per task.
The problem
Full fine-tuning updates all the parameters of a pretrained model. That is fine for a small model, but for GPT-3 with 175 billion parameters each task needs its own 175-billion-parameter copy. Storing, loading and serving many such copies is expensive. Training them also needs optimizer state for every parameter, which for Transformer models trained with Adam takes a large share of GPU memory.
Earlier fixes trade off against quality. Adapter layers insert small modules into the network, but they add depth and so add inference latency. Prompt and prefix methods shrink the usable input length. Methods that train only some existing parameters, such as BitFit, often fall short of full fine-tuning. The paper wants something that is cheap to store, cheap to train, adds no latency, and matches full fine-tuning in quality.
Key idea
The authors guess that the change a model needs for a task has low intrinsic rank. The full update to a weight matrix may be a large matrix, but the useful part could be captured by a few directions. If that is true, the update can be written as a product of two thin matrices, and only those two need training.
flowchart LR X["Input x"] --> W0["Frozen W0 x"] X --> A["A: r by k, trained"] A --> B["B: d by r, trained"] B --> S["Scale by alpha over r"] W0 --> SUM["Sum"] S --> SUM SUM --> H["Output h"]
The frozen path computes the original layer. The side path is a narrow bottleneck of width r. The paper's name, low-rank adaptation, refers to that bottleneck.
The method
Low-rank update
Take a pretrained weight matrix . Full fine-tuning would learn an update of the same size, which is numbers. LoRA constrains the update to
where the rank is much smaller than . During training gets no gradient. Only and are updated. The forward pass for an input is
Here is a constant that does not change with , so the scale shrinks as the rank grows. The paper sets to the first rank it tries and does not tune it, which reduces the need to retune hyperparameters when changes. The paper argues that with Adam, tuning is roughly the same as tuning the learning rate when the initialization is scaled to match.
Initialization
is initialized from a random Gaussian and is set to zero. The product is therefore zero at the start, so the model begins exactly at the pretrained function. Training then moves away from zero.
Parameter count
For a single layer, full fine-tuning trains parameters, and LoRA trains . The saving is largest when and are large and is small. Take , which the paper cites as the width of GPT-3 175B. Full update: parameters. LoRA with : parameters. The ratio is , which equals .
Over the whole of GPT-3 175B (96 layers), adapting and at gives M trainable parameters, which is the "LoRA 4.7M" row in the results below. At the same recipe gives about 18.9M parameters, which is the 35 MB checkpoint quoted next (the paper rounds this to 18M).
Why no latency
LoRA is linear, so once training finishes the product can be added to :
Inference then runs the single merged matrix, and the cost matches the original model. Adapter layers cannot do this, because they add sequential computation. Switching tasks means subtracting one and adding another, which is a small and quick operation.
Where LoRA is applied
In a Transformer, the paper adapts only the attention projections , , and , and freezes the MLP blocks. It treats as a single matrix even though it is split into heads. The authors leave adapting the MLP, LayerNorm and biases to future work. In the experiments, the default is to adapt the query and value projections.
Practical benefits and limits
The paper reports that for a large Transformer trained with Adam, LoRA reduces VRAM use by up to two thirds when is much smaller than , because frozen weights need no optimizer state. On GPT-3 175B, training VRAM falls from 1.2 TB to 350 GB. With on the query and value projections, the checkpoint shrinks from 350 GB to 35 MB. The paper also reports about a 25 percent training speedup on GPT-3 compared with full fine-tuning.
The limit is batching across tasks. If the adapters are merged into , a single batch cannot mix inputs for different tasks. The paper notes that unmerged LoRA modules can be chosen per sample when latency is less important.
Results
Numbers below are from the paper's tables.
RoBERTa and DeBERTa on GLUE (Table 2). LoRA is compared with full fine-tuning and several parameter-efficient baselines. Average GLUE score: RoBERTa-base 87.2 with LoRA (0.3M parameters) against 86.4 for full fine-tuning (125M); RoBERTa-large 89.0 (0.8M) against 88.9 (355M); DeBERTa XXL 91.3 (4.7M) against 91.1 (1.5B). LoRA does not win every task, for example RoBERTa-large full fine-tuning is better on SST-2 and QQP.
GPT-2 on the E2E natural language generation challenge (Table 3). On GPT-2 medium, LoRA with 0.35M parameters scores 70.4 BLEU against 68.2 for full fine-tuning (354.92M). On GPT-2 large, LoRA with 0.77M parameters scores 70.4 BLEU against 68.5.
GPT-3 175B. The paper's Table 4 gives the comparison that matters most:
| Method | Trainable parameters | WikiSQL accuracy | MNLI-m accuracy | SAMSum R1/R2/RL |
|---|---|---|---|---|
| Full fine-tuning | 175,255.8M | 73.8 | 89.5 | 52.0/28.0/44.5 |
| BitFit | 14.2M | 71.3 | 91.0 | 51.3/27.4/43.5 |
| Prefix (layer) | 20.2M | 70.1 | 89.5 | 50.8/27.3/43.5 |
| Adapter (H) | 40.1M | 73.2 | 91.5 | 53.2/29.0/45.1 |
| LoRA | 4.7M | 73.4 | 91.7 | 53.8/29.8/45.9 |
| LoRA | 37.7M | 74.0 | 91.6 | 53.4/29.2/45.1 |
The 4.7M model has about 37,000 times fewer trainable parameters than full fine-tuning (175,255.8M / 4.7M). The abstract instead says "10,000 times", and the introduction ties that figure to the checkpoint size at (350 GB to 35 MB), so the two numbers come from different configurations and are both consistent with the tables. Going from 4.7M to 37.7M parameters changes the scores by less than a point and not always upward (MNLI-m and SAMSum drop slightly).
Which matrices to adapt (Table 5). With a fixed budget of 18 million parameters on GPT-3, adapting both and at rank 4 gives 73.7 on WikiSQL, against 70.4 for alone and 70.0 for alone at rank 8. Single matrices (73.0) and (73.2) are close. Adapting all four attention matrices at rank 2 also gets 73.7 on WikiSQL and the best MultiNLI score (91.7).
How small can be. Table 6 shows that rank 1 is already competitive when both and are adapted. On WikiSQL, rank 1 gives 73.4 against 73.8 at rank 8. Adapting alone needs a larger rank, and the gap is larger on WikiSQL than on MultiNLI. The paper calls this surprising, and it is the main evidence for the low intrinsic rank hypothesis.
Why it mattered
LoRA became the default way to adapt large models cheaply. Because the adapter is a small file that merges into the base weights, people share one base model and many lightweight adapters. Later toolkits adopted the same pattern widely for open-weight language models. The paper also shipped a PyTorch package and checkpoints for RoBERTa, DeBERTa and GPT-2, which made adoption easy.
The analysis in Section 7 matters as much as the method. The authors ask whether the learned update is really low rank and whether it relates to the pretrained weights. Table 7 (layer 48 of GPT-3, ) projects onto the directions of . The projection has Frobenius norm 0.32, more than for random directions (0.02) but far less than for 's own top singular directions (21.67). So the update overlaps with somewhat, yet mostly points along directions the pretrained matrix does not emphasise. The update's norm is 6.91, so it amplifies those directions by roughly 6.91 / 0.32, which the paper quotes as 21.5 (the ratio of the rounded table values is 21.6). The paper reads this as the update amplifying task-relevant features that pretraining learned but did not stress. That reading is the authors' interpretation, not a proven mechanism.
Reading guide
Read the paper in this order, with these prerequisites:
- Introduction and problem statement (Sections 1 and 2). Needs Language Model and Fine-Tuning for the adaptation setup. Transfer Learning helps with the motivation.
- Existing solutions (Section 3). Needs Attention Mechanism for the Transformer layers the adapters sit in, and Adam Optimizer for the memory discussion.
- The method (Section 4). Needs Low-Rank Adaptation (LoRA) and Matrix Rank for the factorization, Matrix Multiplication for the forward pass, and Stochastic Gradient Descent for training. The Gaussian initialization needs Gaussian (Normal) Distribution.
- Experiments (Section 5). Needs Transformer for the architectures tested.
- Understanding the low-rank updates (Section 7). Needs Matrix Rank for the singular value comparison.
Check yourself
QuestionRecall: what does LoRA train, and what does it keep frozen?Show answer
LoRA keeps every pretrained weight matrix frozen and trains two thin matrices and for each adapted layer. Their product is the learned update. Only those small matrices receive gradients and are stored per task.
QuestionComputation: a layer has . How many parameters does a full update train, and how many does LoRA train with ?Show answer
A full update trains parameters. LoRA trains . The ratio is , which equals .
QuestionWhy: why does initializing to zero matter for training?Show answer
With the product is zero, so the adapted model equals the pretrained model at the first step. Training starts from the pretrained function rather than from a perturbed one, which avoids damaging the features the model already has. Gradients still reach through , so moves away from zero as training proceeds.
QuestionApplied: you need to serve 100 customer-specific versions of a 175 billion parameter model. Using the paper's storage numbers, why is LoRA cheaper than full fine-tuning, and what is the main serving constraint?Show answer
Full fine-tuning needs 100 full copies, about GB, or roughly 35 TB. LoRA needs one 350 GB base model plus 100 adapters of about 35 MB each, roughly 354 GB in total. The constraint is batching: if adapters are merged into the base weights, a single batch cannot mix customers. Serving unmerged adapters chosen per sample avoids that, at some latency cost.
Sources
- Hu, E. J., Shen, Y., Wallis, P., Allen-Zhu, Z., Li, Y., Wang, S., Wang, L., and Chen, W. (2021). LoRA: Low-Rank Adaptation of Large Language Models. arXiv:2106.09685
- Brown, T. et al. (2020). Language Models are Few-Shot Learners (GPT-3). arXiv:2005.14165. Cited in the paper for the 175 billion parameter model.