Fine-Tuning & LoRA
Read a little, play a little. No scary maths, and no rush.
The ceiling prompting can't fix
A good prompt plus RAG covers most of what a beginner needs. Fine-tuning earns its cost in three narrow cases: the model needs a voice or format no prompt reliably holds (your exact support-ticket schema, every time), it must get much faster/cheaper by shrinking to a smaller fine-tuned model that matches a bigger one on your task, or it needs knowledge too dense to fit in any context window (thousands of product SKUs with quirky naming). If none of those are true, fine-tuning is solving the wrong problem — go fix the prompt or the retrieval first.
Full fine-tune vs LoRA
Full fine-tune: every weight updates. Most capable, most expensive, and risks catastrophic forgetting — the model gets great at your task and quietly worse at everything else, because gradient steps nudge the whole network.
LoRA (Low-Rank Adaptation): freeze the base model, inject small trainable "adapter" matrices into each layer. You're training a few million parameters instead of billions. Cheaper to run, cheaper to store (one base model + many small adapters, swapped per customer or task), and because the base weights never move, general ability survives largely intact.
What you actually need
A clean dataset of input/output pairs (hundreds to low thousands, not millions — this isn't pretraining), a held-out eval set so you can tell "learned the task" from "memorized the training set," and a baseline comparison against the prompted version. If the fine-tune doesn't beat your best prompt on the eval set, you haven't earned the complexity yet.
A worked example: should we fine-tune?
A support team routes incoming tickets into 12 categories, and the output must be strict JSON. Here is how the decision plays out.
- Baseline first. A careful prompt with a few examples, run on a large model, scores 86% on a held-out set of 300 labeled tickets. Good, but each call is expensive and slow at their volume.
- Build the dataset. They export 2,000 past tickets with the category a human agent finally chose, remove duplicates, and keep 300 aside as the eval set.
- Train small. A LoRA adapter on a much smaller model trains in a couple of hours.
- Compare honestly. On the same 300 held-out tickets the tuned small model scores 91%, at a fraction of the cost per call.
That result earns the fine-tune. Had it scored 84%, the right move would have been to keep the prompt and look elsewhere for savings, however much work the training took.
Data quality beats data quantity
A fine-tune copies whatever patterns its examples contain, including the mistakes. A few habits matter more than doubling the dataset:
- Consistent labels. If two people would label the same ticket differently, the model learns the confusion.
- Cover the hard cases. A set of easy examples teaches the easy cases, which the base model already handled.
- One format everywhere. If half the outputs use one JSON shape and half another, the model will mix them.
- Read a random sample. Before training, read 50 examples yourself. Problems are usually obvious within minutes.
Remember this
- Fine-tune last, not first — prompting and RAG are cheaper levers.
- LoRA freezes the base, trains small adapters: cheap, swappable, forgetting-resistant.
- No eval set, no fine-tune — "it feels better" isn't a result.
Check your understanding
5 questions · first-try answers earn the most XP
My notes
Saved in this browser. Highlight a line above and save it, or write it in your own words.
Nothing saved yet. Your highlights will live here.
References
Finished reading?
Ticking it here also ticks the chapter in the sidebar, the section count and your streak — it is all one number.
End of How LLMs Work (Visual First)
Take the section checkpoint
A short mixed quiz on all 5 chapters, to check you are ready to move on.
Related chapters
Spotted a mistake or want a topic covered? Report an issue