AI State of the Art
Fundamentals/LLM: Understanding Large Language Models/26 min
Section 52

Full Fine-tuning vs Parameter-Efficient Fine-tuning

Listen as a podcast →

The Base Model Is an Unusable Genius

After pre-training, you have a model that has read the entire Internet and knows an enormous amount... but it doesn't know how to answer your questions. Ask it "What is the capital of Germany?" and instead of saying "Berlin," it's likely to continue with "What is the capital of Italy? What is the capital of Spain?", because in its training data, lists of questions were common, and that is the most likely continuation.

The base model is a text completer, not an assistant. It doesn't understand that it's being spoken to. It doesn't know it should be helpful. It doesn't know it shouldn't generate toxic content. Fine-tuning is the process that transforms it into a tool usable by real humans.

There are two major families of approaches, and the choice between them has major consequences on cost, required resources, and performance: full fine-tuning (you modify all the model's parameters) and PEFT methods (Parameter-Efficient Fine-Tuning) like LoRA (you modify only a tiny fraction, often less than 1%).

Full Fine-tuning: Heavy Surgery

The Principle

You take the pre-trained model and continue training on a specialized dataset (conversations, instructions, domain-specific data). Every parameter of the model can be modified, the billions of weights learned during pre-training are all "unfrozen" and subject to adjustment. It's the equivalent of deeply re-educating someone: you're not just changing their specialty, you're potentially modifying their entire internal functioning.

The Real Cost, and This Is Where It Hurts

Let's do the full arithmetic for a 7-billion-parameter model with the AdamW optimizer, line by line. Everything reduces to one multiplication: bytes per parameter × 7 billion.

ComponentBytes per parameterGraphics memory
Model weights, in 16 bits22×7×109=142 \times 7 \times 10^9 = 14 GB
Gradients, in 16 bits214 GB
Optimizer states: AdamW keeps two running averages per parameter, each in 32 bits2×4=82 \times 4 = 856 GB
Intermediate activations (depends on sequence length and on whether they are recomputed)varies10 to 30 GB
Totalroughly 95 to 115 GB

Two comments, because it is the optimizer-state line that always surprises people. Where do those 8 bytes come from? AdamW does not just use the current gradient: for every parameter it stores an average of past gradients and an average of their squares, two numbers, kept in full precision so they don't drift, hence 4 bytes each. The heaviest item in training is therefore not the model: it is the optimizer's bookkeeping, four times larger than the weights themselves.

This memory is the graphics card's own, its VRAM (Video Random Access Memory). It tops out at 80 GB on the most common data-centre cards, so even a 7-billion-parameter model does not fit on a single card under full fine-tuning.

A 70-billion-parameter model? Multiply everything by 10, close to a terabyte: you need a cluster of cards.

Catastrophic Forgetting

Another danger of full fine-tuning: specializing the model on one task can cost it capabilities acquired during pre-training. This is catastrophic forgetting. A model fine-tuned only on medical text may become unable to draft a professional email, the weights that carried that skill have been overwritten.

Two remedies: mix a fraction of general data into the specialization set, and use a very low learning rate (the size of each weight correction).

LoRA: The Genius of Minimalist Adaptation

A Surprising Observation

In 2021, researchers at Microsoft (Hu et al.) made a discovery that would change fine-tuning practice: when you adapt a pre-trained model to a new task, the resulting weight changes have a particular mathematical structure, they are low-rank. In simple terms, even though the model has billions of parameters, the modifications needed to adapt it live in a very small-dimensional subspace.

It's as if, to redirect a general medicine expert toward cardiology, you only needed to adjust a few key connections rather than rewiring their entire brain. So why modify the billions of original parameters if the actual adaptation only touches a tiny corner of the parameter space?

The LoRA Solution

LoRA: Low-Rank Adaptation of Large Language Models (Hu et al., 2021)

LoRA (Low-Rank Adaptation) does not touch the original weights WW. Instead it adds a low-rank correction to them:

Wnew=Woriginal+B×AW_{\text{new}} = W_{\text{original}} + B \times A
MatrixDimensionsStatus
WoriginalW_{\text{original}}d×dd \times da parameter learned during pre-training, then frozen, never modified by LoRA
BBd×rd \times ra parameter learned by LoRA
AAr×dr \times da parameter learned by LoRA
rr (the rank)usually 8, 16, or 64much smaller than dd

"Rank" here means the intermediate dimension rr that you force the computation through: the product B×AB \times A has the same shape as WW but can only represent a subspace of dimension rr. That is exactly the paper's hypothesis, adaptation lives in such a subspace.

You train only the small matrices AA and BB. The original weights stay frozen. The arithmetic, with concrete numbers: if d=4,096d = 4{,}096 (the dimension of a 7-billion-parameter model) and r=16r = 16, then instead of modifying

4 096×4 096=16 777 216≈16.7 million parameters4\,096 \times 4\,096 = 16\,777\,216 \approx 16.7 \text{ million parameters}

you train only

4 096×16⏟B+16×4 096⏟A=131 072\underbrace{4\,096 \times 16}_{B} + \underbrace{16 \times 4\,096}_{A} = 131\,072

which is 16 777 216/131 072=12816\,777\,216 / 131\,072 = 128 times fewer. LoRA is applied to the attention weight matrices WQW_Q, WKW_K, WVW_V, WOW_O of each layer, note that it is those weight matrices that are targeted, not the activations QQ, KK, VV they produce.

Two diagrams side by side. On the left, Full fine-tuning: the input features flow through one large Pretrained weights block to the outputs (blue arrows, forward pass), and backpropagation (green arrows) flows straight back down into that block of pre-trained weights. On the right, LoRA: the same input feeds the Pretrained weights block and a small LORA weights block drawn as two stacked trapezoids in parallel; the two contributions are summed before the outputs, and backpropagation flows back only into the LORA weights block.
Compare the green arrows, the backpropagation path. On the left, full fine-tuning sends them straight through the pre-trained weight block: every parameter gets updated. On the right, LoRA sends them only into the small added module; the original weights are traversed on the way forward but never modified. The two outputs are then simply summed.Source : Zilliz, Introduction to LLM Customization
What the Paper Actually Claims

Here are the figures as the authors state them; better to stick to these than to the approximate percentages that circulate. On GPT-3 at 175 billion parameters, LoRA:

  • reduces the number of trainable parameters by a factor of 10,000;
  • reduces the graphics memory required by a factor of 3;
  • achieves quality "on par or better" than full fine-tuning on the models tested (RoBERTa, DeBERTa, GPT-2, GPT-3);
  • adds no inference latency, unlike adapters.

The reasoning behind it: adapting a pre-trained model is not a rebuild, it is a slight refocusing, and that refocusing fits in a low-dimensional subspace.

The Practical Advantages

  • Memory: optimizer states are kept only for the trained weights, that is, for 0.1 to 1% of the model. Look back at the table above: the 56 GB line drops to a few hundred megabytes
  • Portability: the LoRA adapter (the AA and BB matrices) weighs a few dozen megabytes, not dozens of gigabytes
  • Modularity: one base model can carry ten different adapters, one per client, per language, per task
  • No inference overhead: since B×AB \times A has exactly the shape of WW, you can add the two together before deployment and serve a single model, indistinguishable from an ordinary one

QLoRA: Fine-tuning a 70B on a Single GPU

QLoRA: Efficient Finetuning of Quantized LLMs (Dettmers et al., 2023)

QLoRA (Quantized LoRA) pushes LoRA further by combining two ideas:

  1. The base model is quantized to 4 bits instead of 16, that is, half a byte per parameter: four times less space. The weights are encoded in a format called NF4 (NormalFloat 4-bit), designed for the particular statistical distribution of neural network weights, they are roughly Gaussian, so the quantization levels are spaced accordingly rather than uniformly.
  2. The LoRA adapters stay in 16 bits, which preserves the precision of learning. The frozen model is compressed; what you learn is not.

The headline result the authors report: fine-tuning a 65-billion-parameter model on a single 48 GB card, while matching the quality of 16-bit fine-tuning.

Figure 1 of the QLoRA paper. Three columns compare memory requirements. Full Finetuning: one large 32-bit optimizer state block updates a 16-bit base model directly, with no adapters. LoRA: the 16-bit base model is frozen, only three small 16-bit adapters receive updates, and the associated optimizer states are tiny. QLoRA: the base model is 4-bit, the adapters stay 16-bit, and the optimizer states can be paged out to CPU memory, shown by a pink arrow.
The QLoRA paper figure sums up the three regimes. On the left, full fine-tuning: a huge 32-bit optimizer state for the whole model. In the middle, LoRA: gradients (green) only flow back into the small adapters. On the right, QLoRA: the base model drops to 4 bits, and optimizer states can spill over to CPU memory when the GPU runs out of room.Source : QLoRA paper (Dettmers et al., 2023), figure 1, via Cameron R. Wolfe

The orders of magnitude, set against the detailed table at the top of this page:

ModelFull fine-tuningLoRAQLoRA
7 billion parametersabout 100 GBabout 16 GBabout 6 GB
70 billion parametersabout 1 TBabout 160 GBabout 48 GB

The QLoRA column can be recovered in your head: the quantized weights of a 70-billion-parameter model take 0.5×70=350.5 \times 70 = 35 GB, plus activations and adapters. The 48 GB figure for a 65-billion model is the one the QLoRA authors actually report.

QLoRA Made Fine-tuning Accessible

A consumer card with 24 GB is enough to fine-tune a 7-to-13-billion-parameter model with QLoRA; an 80 GB data-centre card gets you to 70 billion. What required a cluster of machines a few years ago now fits on a desktop.

We give no prices: they move too fast for any figure written into a course to stay correct.

Other PEFT Methods in Brief

LoRA and QLoRA aren't the only PEFT approaches. Here are others, in chronological order:

Adapters (Houlsby et al., 2019): small modules are inserted between the existing Transformer layers. Each one squeezes the vector down and expands it again, hence the name bottleneck. This is the original PEFT method, predating LoRA. Its drawback: those modules remain layers to traverse at inference time, which adds latency. LoRA avoids this, because its correction is added to the original weights rather than stacked behind them.

Prefix tuning (Li and Liang, 2021): you learn "virtual tokens" placed at the start of the context, which correspond to no real word but steer the model's behaviour. Very lightweight, generally less effective than LoRA.

Prompt tuning (Lester et al., 2021): more minimal still, you learn only the embeddings of a few tokens prepended to the input, a few thousand parameters in all. The paper's title says the essential thing: The Power of Scale. The method becomes comparable to full fine-tuning only from several billion parameters upward (the authors go as far as T5-XXL, 11 billion). Below that, LoRA is clearly better.

A five-set coloured Venn diagram classifying parameter-efficient fine-tuning methods. The large blue Addition-based circle contains LeTS, AttentionFusion, Ladder-Side Tuning and (IA)3. It encloses the purple Adapters circle (Adapters, Parallel Adapters, AdaMix, Compacter, PHM Adapter) and the teal Soft prompts circle (Prefix-Tuning, Prompt-tuning, P-tuning, WARP, Spot, IPT). The yellow Selection-based circle groups BitFit, LN Tuning, Attention Tuning, Diff-Pruning, Fish-Mask and LT-SFT. The red Reparametrization-based circle holds LoRa, QLoRa, ReLoRa, KronA and Intrinsic-SAID. Overlap regions hold hybrid methods such as UniPELT, Sparse Adapter and Sparse LoRa.
A map of the PEFT landscape. The methods listed above fall into families: those that add modules (adapters), those that learn fake tokens (soft prompts, where Prefix-Tuning and Prompt-tuning live), those that unfreeze only a small selection of existing weights, and those that reparametrize the weights in low rank, the family of LoRA and QLoRA.Source : PEFT survey Scaling Down to Scale Up (Lialin et al., 2023), extended version via Eva Koroleva

How to Choose?

CriterionFull fine-tuningLoRAQLoRA
Parameters modified100%0.1 to 1%0.1 to 1%
VRAM for a 7-billion modelabout 100 GBabout 16 GBabout 6 GB
Quality obtainedthe referenceon par, per the LoRA authorsslightly below LoRA
What you have to move aroundthe whole model (14 GB)an adapter (a few dozen MB)an adapter (a few dozen MB)

We do not put percentages on the quality row: the gaps depend entirely on the task, and the figures in circulation ("95 to 99%") do not come from any particular published measurement.

Choose full fine-tuning if: you're a lab with GPU clusters, you're building a foundation model for a highly specialized domain (medical, legal, proprietary code), and you have hundreds of thousands of training examples.

Choose LoRA/QLoRA if: you're adapting an existing model to a specific use case, your resources are limited, you need to iterate quickly, or you have multiple adapters for multiple different tasks.

What the Industry Actually Does

The vast majority of fine-tuning in industry uses LoRA or QLoRA. Full fine-tuning is reserved for major players (OpenAI, Google, Meta, Anthropic, Mistral) for their main models. For any specific use case, PEFT methods have become the absolute standard.

What's Next?

Choosing between full fine-tuning and LoRA is only the first technical decision. The real strategic question is: what to fine-tune on, and with what objective? There are two major steps after pre-training:

  1. SFT (Supervised Fine-Tuning): teaching the model to follow instructions, hold a conversation, and answer in the right format. You show it examples of good question-answer pairs. Covered on the instruction tuning page.
  2. Alignment: teaching the model to be helpful, honest and harmless, via RLHF (Reinforcement Learning from Human Feedback) or DPO (Direct Preference Optimization).

Both are covered on the following pages. But take away the key point of this one: LoRA and QLoRA made fine-tuning accessible. What was reserved for the largest players now fits on a good graphics card.

Check your understanding0 / 4

1. In full fine-tuning of a 7-billion-parameter model with AdamW, what is the heaviest memory item?

2. What exactly does LoRA modify in the model?

3. Why does LoRA add no inference latency, unlike adapters?

4. What is the key idea of QLoRA?