Kinds of fine-tuning
9 min read
Two questions decide the method
Every fine-tuning method answers two separate questions.
- What do the examples teach? A label, a reply to a request, a preference between two replies, or just more text.
- Which weights change? All of them, or a small added set.
Keeping the questions apart avoids a common muddle. "LoRA" answers the second question. "Instruction tuning" answers the first. You can combine them, and most practical projects do: instruction examples, trained with LoRA.
What the examples teach
Classification tuning. Each example is a text and one label from a fixed list, such as billing, access or technical. The model gets a small output layer, called a head, that produces one score per label. It is the cheapest kind and the easiest to measure, because an answer is either the right label or not. The Lesson Fine-tune a classifier builds one.
Instruction tuning. Each example is a request and the reply you want. The model learns to follow your kind of request in your style and format. This is how a base model that only continues text becomes an assistant. Fine-tune a model to follow instructions walks through it. Chat tuning is the same idea with several turns, written in the chat format the model expects.
Continued pre-training. The examples are plain text from your field, such as maintenance manuals or legal filings. The goal is the same as pre-training, to predict the next token, but on narrower text. It can help a model with unfamiliar vocabulary. It does not teach a response format, because the text has no requests or replies.
Preference tuning. Each example is a request with a better reply and a worse one. The model learns to prefer the better. It comes after instruction tuning, and Tuning with preferences: RLHF and DPO covers it.
Which weights change
Full fine-tuning updates every weight. It is the most flexible method. It is also the hungriest, because the training run must hold the gradients and optimiser state for all of them in memory, which costs several times the size of the model.
Parameter-efficient fine-tuning freezes the base weights and trains a small added set. LoRALow-rank adaptation. A method that trains small matrices on selected layers while keeping the base model weights frozen. is the most used. You save only the small set, called an adapter, and load it on top of the unchanged base model. The Lessons Why train fewer parameters and How LoRA works explain why this works so well.
How much each method trains
The program below counts the trainable weights for three choices on a model with 32 layers and a width of 4,096, about the size of a 7 billion parameter model. The full count uses the common estimate of 12 times the width squared per layer. The LoRA count adds a rank 8 adapter to two matrices per layer. The head count is a single layer from width to three labels.
layers, width = 32, 4096
full = 12 * width * width * layers
lora = 2 * (2 * width * 8) * layers
head = width * 3 + 3
for name, count in [("full fine-tuning", full), ("LoRA, rank 8", lora), ("classification head", head)]:
print(f"{name:20} {count:>14,} trainable ({count / full:.4%} of full)")It prints:
full fine-tuning 6,442,450,944 trainable (100.0000% of full)
LoRA, rank 8 4,194,304 trainable (0.0651% of full)
classification head 12,291 trainable (0.0002% of full)A LoRA adapter here trains less than a tenth of one percent as many weights as full fine-tuning. A head on a frozen model trains almost nothing. These figures are rough, because real models differ in layout, but the scale of the difference is the point.
| Share trained | What you save | |
|---|---|---|
| Full fine-tuning | 100% | A full copy of the model |
| LoRA, rank 8 | about 0.07% | A small adapter file |
| Classification head | about 0.0002% | A small added layer |
Choosing between them
| Use it when | Watch for | |
|---|---|---|
| Classification head | The output is one label from a fixed list | Needs labelled examples, and a fixed label set |
| Instruction tuning | You want a style, format or behaviour in replies | Examples must match real requests |
| Continued pre-training | The field has words and facts the model lacks | Does not teach it to answer |
| Preference tuning | Replies are fine but not the ones people prefer | Needs pairs, and a sound way to judge them |
| LoRA or other PEFT | You have limited memory, or several tasks | Small adapters may fall short on large shifts |
| Full fine-tuning | You have the memory and a large, clean dataset | Higher cost, and more forgetting risk |
When in doubt, start small: a prompt, then a classification head or an instruction-tuned LoRA adapter. Compare each with the untuned model on the same test questions. RAG or fine-tuning? helps with the earlier decision of whether to train at all.
For the library behind the efficient methods, see the Hugging Face PEFT overview.
Which kind fits this goal?
You want a model that answers in your company's format after seeing example question and answer pairs.
Supervised tuning on prompt and reply pairs is the usual way to teach a format or a task.
What does a classifier head do?
You attach a small layer to a model to label tickets as billing, access or technical.
A classifier outputs one of a fixed set of labels instead of free text.
Which change is the cheapest to try first?
Your classifier output is inconsistent, and you have not yet tried a prompt with examples.
Try the cheapest option first and move to training only when it falls short.
Your reading position is saved
0 of 36 complete
Lesson complete
Kinds of fine-tuning
Up next