IN THIS BREAKDOWN · 10 SECTIONS
You can read 21% of this breakdown.
The paper in one minute
Fine-tuning adapts a pretrained model to a task by continuing to train it. Doing that the usual way updates every weight. For GPT-3, with 175 billion parameters, that means each fine-tuned version is a new 350 GB model, and training needs memory for gradients and optimizer state for all of them. A company with a hundred tasks would store 35 TB of near-identical models.
LoRA (low-rank adaptation), from Edward Hu and colleagues at Microsoft, starts from an observation: the change fine-tuning makes to a weight matrix seems to have a low "intrinsic rank". So instead of learning the full change ΔW, which is as big as the layer, LoRA learns it as the product of two thin matrices: B (d × r) and A (r × d), where r is tiny, often 1 to 8, against a layer width of 12,288 in GPT-3. The pretrained weights stay frozen. A starts random and B starts at zero, so training begins exactly at the pretrained model. When training is done, BA can be added into the original weight, so the served model has exactly the same shape and speed as before.
The paper applied LoRA to the attention projection matrices, mostly just the query and value matrices. On GPT-3 175B, with 4.7 million trainable parameters, it matched or beat full fine-tuning on three tasks: SQL generation (WikiSQL), natural-language inference (MultiNLI) and dialogue summarization (SAMSum). Training memory fell from 1.2 TB to 350 GB, a task checkpoint from 350 GB to about 35 MB, and training ran about 25% faster. Unlike adapter layers, it adds no inference latency; unlike prefix tuning, it uses none of the input length.
A rank as small as one was enough on those tasks, and the learned changes amplified directions already present in the pretrained weights but not emphasized there.
Research notes: the problem, approach and results
fewer trainable parameters than full fine-tuning of GPT-3 175B
size of a task-specific checkpoint for GPT-3 (r = 4, two attention matrices)
rank that already performed competitively on GPT-3's WikiSQL and MultiNLI
Fine-tuning a large model updates every weight, so each task needs a full copy of the model and training needs memory for the optimizer state of every parameter. For GPT-3, that is 350 GB per task.
Freeze the pretrained weights. Represent each layer's change as the product of two small matrices B and A with a tiny inner rank r, train only those, and add BA back into the weight when serving.
On GPT-3 175B, LoRA matched or exceeded full fine-tuning on WikiSQL, MultiNLI and SAMSum, cut training memory from 1.2 TB to 350 GB and a task checkpoint from 350 GB to about 35 MB, with no added latency.
Why it matters to an FDE
LoRA is the default way to fine-tune open models, and most customer conversations about "training a model on our data" end up being about LoRA or its quantized cousin, QLoRA. Understanding it lets you set expectations on cost, hardware and serving.
It makes fine-tuning a small artifact. The output of a LoRA run is an adapter measured in megabytes, not a new model. You can keep many adapters, one per customer, product line or task, on top of one shared base model, version them like code, and roll them back.
It changes what serving looks like. Merge the adapter into the weights for a single task with no extra latency. Or keep adapters separate and swap them per request on one GPU holding the base model, which is how multi-tenant adapter serving works; the paper notes that batching requests for different adapters in one forward pass requires not merging.
It lowers the hardware bar, not the data bar. LoRA reduces memory and storage. It does not reduce the need for good training examples or an evaluation that shows the fine-tune beats prompting and retrieval.
Low rank is a finding about these tasks, not a law. The authors warn that a task far from pretraining, their example being a different language, may need much more capacity. Treat rank as a hyperparameter to test.
Fine-tune for form, retrieve for facts. LoRA is good at teaching formats, styles and task behavior. Knowledge that changes often is still better served by retrieval.
Understand the mechanism. Try it on a real problem.
Unlock this breakdown and 49 more papers.
Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.
6 months · One payment · No auto-renewal
- ◇1 architecture diagram
- </>1 runnable code experiment
- ▦6 results tables
- ?5 interview questions with answers
- 03Key takeaways
How LoRA compares with other methods, what the experiments show, and the misreadings to avoid
Free account - 04How it works
The math, the initialization, merging, and the rank analysis
Premium - 05The numbers that matter
The GPT-3 results, the weight-type and rank tables, and the latency study
Premium - 06Try it yourself
Reproduce the GPT-3 parameter counts, then train LoRA at several ranks against full fine-tuning
Premium - 07Where it breaks
The limits the authors state, and the ones practice has added
Premium - 08Using it on a deployment
Running a LoRA fine-tune for a customer, from the decision to serving
Premium - 09Interview angles
Five questions this paper prepares you for, with answer hints
Premium - 10Read next
Where to go from here on this site
Premium
