TL;DR
Fine-tuning a large model normally updates every weight, which means storing and optimising a full copy of billions of numbers for each new task. LoRA freezes the pretrained weights and learns only a correction to each weight matrix, and it constrains that correction to be low rank. The correction is a product of two thin matrices, so the number of trainable parameters can fall by a factor of hundreds while the model keeps the behaviour it learned in pretraining.
Where you'll see it: in adapting open language models to a new style or domain on a single GPU, in shipping many small task-specific adapters on top of one shared base model, and in the image diffusion community, where LoRA files customise a style or a character.
Intuition
Change the model by a small note
A pretrained model is like a skilled editor. Retraining it from scratch for each new job would be like hiring a new editor each time. Fine-tuning changes the editor's habits directly, which is costly because every habit is a number you must store. LoRA leaves the editor alone and hands over a short sheet of corrections: "when you see this kind of sentence, do this extra adjustment." The sheet is small to write, small to store, and can be swapped out.
In the language of Fine-Tuning, the question is what the update to the weights looks like. Full fine-tuning allows the update to be any matrix of the same shape as the weight. LoRA's bet is that the update needed for a new task does not need that freedom. It can live in a small subspace of directions, which is the same as saying the update has low rank.
Why low rank is plausible
Recall from Matrix Rank that the rank of a matrix counts the independent directions its outputs can reach. A weight matrix of size has rank up to 4096. An update of rank 8 can only add changes along 8 directions. That sounds restrictive, but a task usually asks the model to shift a few behaviours, not to rebuild everything. Hu et al. (2021) found that small ranks often matched full fine-tuning on the tasks they tested, and that the useful updates were concentrated in few directions.
There is an earlier clue. Aghajanyan et al. (2020) measured the intrinsic dimension of fine-tuning: they found that a model could be tuned to a task while training only a random projection of a much smaller number of parameters. Low intrinsic dimension says the task itself lives in a small space, and LoRA is a structured way to search there.
The construction is cheap to run. The base weight is never modified during training, so gradients and optimiser state exist only for the small factors. At inference the update can be added into the base weight, so the adapted model runs at the same speed as the original.
flowchart LR X[Input x] --> W0[Frozen weight W0] X --> A[Down projection A] A --> B[Up projection B] W0 --> S[Sum] B --> S S --> Y[Output h]
The math
The update
Let be a pretrained weight matrix in a layer that computes for an input . Full fine-tuning learns an update of the same size, so the layer becomes .
LoRA constrains the update to a product of two thin matrices,
and computes the layer as
The rank is a hyperparameter and is a fixed scale. Only and are trained.
Here is the output size of the layer, its input size, and the rank chosen by the practitioner, often between 1 and 64. The factor keeps the size of the update roughly stable as changes, so one learning rate can be reused across ranks. The product has rank at most , because every column of is a combination of the columns of . That is the whole constraint.
Initialisation
The two factors start in a specific way. is filled with small random values, and is filled with zeros. Then at step zero
so the adapted model starts exactly where the pretrained model is. Training then moves away from zero. If both factors started random, the model would begin with a random perturbation of its learned behaviour, and that perturbation would have to be unlearned first.
Parameter count
A full update has parameters. The LoRA update has . The fraction of trainable parameters is therefore
For a square layer this equals . The formula shows why the approach scales: the saving grows as the layer gets wider, and it is controlled entirely by .
Low-rank approximation
Why should a rank- update be enough? The Eckart–Young theorem gives a precise answer for approximating a fixed matrix. Among all matrices of rank at most , the closest one to a given matrix (in Frobenius norm) is obtained by keeping its top singular values and vectors from the singular value decomposition. The squared Frobenius error of that best rank- approximation is the sum of the squared discarded singular values, so the error is small when the spectrum decays fast.
LoRA does not compute an SVD of the update. It learns the factors directly by gradient descent. The theorem says what is possible; the experiments say the required spectrum is usually fast-decaying enough for the task.
- trainable fraction, d = k = 4096
Worked examples
Take a square projection with , and set and .
- Full update: parameters.
- LoRA update: parameters.
- Ratio: . LoRA trains 256 times fewer parameters for this layer.
- Scale factor: , so the layer computes .
- Start of training: gives , the pretrained output exactly.
Interpretation: the layer's output changes only through a rank-8 term, and the optimiser tracks only 65,536 numbers for it instead of 16.8 million. Repeating this for every projection in a model keeps the total small in the same proportion.
Take , , . Let and .
- .
- The rank is 1, since the second row is zero and the first row is nonzero.
- Apply to : .
- Then . With , the correction to is .
- The full update has 4 entries, but the LoRA form uses numbers. At this size the saving is zero; it appears only when and are large.
Interpretation: the correction always points along the single direction , however varies. Step 5 is a useful reminder that low rank pays off only at scale.
Tradeoffs and failure modes
LoRA is cheap, but the constraint is real. The table covers the usual decisions.
| Situation | What goes wrong | Better choice |
|---|---|---|
| The new task needs behaviour far from pretraining | Rank 8 cannot express the change and the loss plateaus | Raise , or fine-tune more layers |
| Only attention projections are adapted | Some tasks respond better to the feed-forward layers | Adapt the feed-forward projections too |
| Learning rate copied from full fine-tuning | Adapter learns too slowly or too unstably | Tune the rate separately; it is often larger |
| Many adapters loaded at once | Memory and merging logic get complicated | Merge one adapter into the base, or batch the adapters explicitly |
| Base model quantised to low precision | Frozen weights limit accuracy | Use a quantised LoRA variant, which keeps the adapter in higher precision |
The method also changes what the model can forget. Because the base is frozen, the original capabilities are largely preserved, which is an advantage. It is also a limit: if the new task requires rewriting a capability, the low-rank correction may be the wrong tool.
History
Adapter layers came first. Houlsby et al. (2019) inserted small trainable bottleneck modules between the layers of a frozen pretrained model, and showed that they matched full fine-tuning on many tasks with a small fraction of the parameters. Aghajanyan et al. (2020) then measured how many parameters a task really needs, the intrinsic dimension, and found it was often small.
Hu et al. (2021) at Microsoft proposed LoRA. Its advantages over adapter layers were that it adds no extra depth at inference, because the update can be merged into the base weights, and that it applies directly to the weight matrices that already exist. It caught on quickly in open-source language model work, where a single GPU could fine-tune a model that was too large to copy in full for each user. Its use then spread to image generation, which is why many shared LoRA files now customise diffusion models.
Check yourself
QuestionRecall: what does the initialisation accomplish at the start of training?Show answer
It makes the product zero, so the layer output is exactly . The adapted model begins identical to the pretrained model, and training moves it away from that point in small steps.
QuestionCompute: a layer has and . How many parameters does a rank-16 LoRA update train, and how many does the full update have?Show answer
LoRA trains parameters. The full update has . The LoRA count is about 2 percent of the full count.
QuestionWhy: the scale is rather than a fixed constant. What problem does that solve?Show answer
The size of the update tends to grow with the rank, because more terms add together. Dividing by keeps the effect of the correction roughly stable as changes, so the same learning rate and can be used when a practitioner tries a different rank.
QuestionApplied: you adapt a model to a new domain and find the loss stops improving at rank 4 but drops at rank 64. What do you conclude, and what would you check next?Show answer
The task needs more directions of change than rank 4 provides, so the rank is a bottleneck. Raise the rank, which increases the trainable count proportionally. Also check that the learning rate is appropriate for the chosen rank and that the adapted layers include the projections that matter for this task. Rank 64 is still far fewer parameters than full fine-tuning.
Sources
- LoRA: Low-Rank Adaptation of Large Language Models, Hu et al. (2021)
- Parameter-Efficient Transfer Learning for NLP, Houlsby et al. (2019)
- Intrinsic Dimensionality Explains the Effectiveness of Language Model Fine-Tuning, Aghajanyan et al. (2020)
- Low-rank approximation (Wikipedia)
- Singular value decomposition (Wikipedia)