Fine-Tuning & Adaptation
Full fine-tuning, LoRA, and preference optimization from an infrastructure point of view — what each costs to train, and what each does to your serving stack.
#First: should you fine-tune at all?
Most fine-tuning projects should have been prompt engineering or retrieval projects. The honest decision table:
| Problem | Right tool |
|---|---|
| Model lacks knowledge of your data | Retrieval. Fine-tuning teaches style, not facts, and teaches them unreliably |
| Output format is wrong | Constrained decoding. Guaranteed, immediate, free |
| Model doesn't follow instructions well | Better prompt first; fine-tune only if a large prompt is the problem |
| You need a specific voice, tone, or domain style | Fine-tuning. This is what it's genuinely good at |
| Task is narrow and high-volume | Fine-tune a small model — often 10-50× cheaper to serve than prompting a large one |
| Latency or cost is unacceptable | Distil a large model's behaviour into a small one |
#Full fine-tuning: what it costs
Updating every parameter requires holding far more than the weights. Training needs a gradient for every parameter (which direction to nudge it). The standard optimizer, Adam, also keeps two running averages per parameter: momentum (the recent direction of updates) and variance (their recent size). And mixed-precision training keeps a full-precision FP32 "master" copy of the weights, so tiny updates aren't rounded away in BF16.
That ratio is why parameter-efficient methods exist, and why a 70B model that serves on one node needs a small cluster to fine-tune.
#LoRA
LoRA — low-rank adaptation — rests on one observation. Fine-tuning doesn't scatter arbitrary changes across a weight matrix; the adjustment it makes turns out to be describable by far fewer numbers than the matrix contains. So don't store the change as a full-size matrix. Store it as two thin ones whose product reconstructs it.
The saving is enormous: two 4096×16 matrices hold 131,000 numbers where the full change would need 16.8 million.
Frozen weight W (d × d, e.g. 4096 × 4096 = 16.8M params)
Instead of learning ΔW directly (16.8M params), learn:
ΔW = B · A where A is r × d
B is d × r
r ≪ d (typically 8-64)
With r = 16:
A: 16 × 4,096 = 65,536
B: 4,096 × 16 = 65,536
────────
131,072 params vs 16.8M
→ 0.8% of the full matrix
Forward pass: h = W·x + (B·A)·x · (α/r)
──── ───────
frozen trainableThe serving property is the one that matters architecturally. LoRA adapters are small — tens of megabytes — and can be applied to a shared base model at inference time.
MULTI-TENANT LoRA SERVING
one base model in GPU memory (14 GB)
+ adapter A (30 MB) → customer A's tuned behaviour
+ adapter B (30 MB) → customer B
+ ...
+ adapter Z (30 MB) → customer Z
Requests from different customers batch TOGETHER,
each with its own adapter applied in the kernel.
→ 100 fine-tuned "models" in the memory of one,
with near-full batching efficiency.This is how fine-tuning-as-a-service is economically possible. Serving 100 separately fine-tuned 7B models would need 100 × 14 GB; serving 100 LoRA adapters over one base needs 14 GB + 3 GB. Systems like S-LoRA and Punica implement the batched multi-adapter kernels.
The alternative — merging the adapter into the base weights — gives zero inference overhead but produces a distinct full model, losing the multi-tenancy. Merge when you're serving one tuned model at volume; keep adapters separate when you're serving many.
| Hyperparameter | Typical | Effect |
|---|---|---|
| Rank r | 8–64 | Capacity. Higher for large behaviour changes, lower for style |
| Alpha α | Often 2r | Scales the update; the effective learning rate for the adapter |
| Target modules | Attention projections, sometimes FFN too | More modules = more capacity and memory |
| Dropout | 0.05–0.1 | Regularisation on small datasets |
#Preference optimization
Supervised fine-tuning — showing the model correct examples and having it imitate them — can only express "this is right". It has no way to say "both of these are plausible, but this one is better", which is exactly the judgement that separates a helpful assistant from a merely accurate one. Teaching that requires comparisons rather than answers.
- 1 Pretrain next-token prediction on a large corpus
- 2 SFT imitate high-quality demonstrations
- 3 Reward model train a scorer on human A-vs-B preferences
- 4 RL (PPO) optimize the policy against the reward model
In reinforcement learning (RL) terms, the model being trained is called the policy. PPO's infrastructure cost is the thing to know: it requires four models in memory simultaneously:
- the policy being trained;
- a frozen reference copy of the starting model, used to penalise the policy for drifting too far from it (the "KL penalty");
- the reward model, which scores responses;
- a value model, which estimates how good a partial response is likely to end up, making training less noisy.
Plus a generation loop inside the training loop, since you must sample responses to score them. It is roughly 4–8× the cost of supervised fine-tuning and considerably harder to keep stable.
DPO (direct preference optimization) is the simplification that changed practice. The insight: for any reward model, the best possible policy can be written down directly as a formula. Run that formula backwards and the policy's own probabilities define a reward. So you can train directly on preference pairs with a simple classification loss: make the preferred answer more likely and the rejected one less likely, measured against the reference model. No reward model, no RL loop, no sampling during training.
PPO DPO
4 models in memory 2 models (policy + reference)
generate during training no generation, offline pairs
reward model to train first no reward model
unstable, needs careful tuning stable, looks like ordinary SFT
~4-8× SFT cost ~2× SFT cost
→ DPO is what most teams should use.
PPO retains an edge when you can generate fresh
on-policy data (responses sampled from the model as it
trains), which is why frontier labs still use it.Variants worth recognising: IPO (fixes a DPO overfitting failure mode), KTO (works from thumbs-up/down rather than pairs — much easier data to collect), and GRPO (group-relative: samples several answers to the same prompt and scores each against the group's average, so it needs no value model; used for reasoning training).
Reasoning models changed the picture in 2025. DeepSeek-R1 showed that reinforcement learning with verifiable rewards — grading maths answers against the known result, or code against its tests, instead of asking a learned reward model — can teach long step-by-step reasoning. The infrastructure looks like PPO's, with generation inside the training loop (and generation often dominating the cost), but there is no reward model to train or host. GRPO is the usual algorithm. The limit is the reward itself: it only works where an answer can be checked automatically. What these models do to serving infrastructure is the subject of serving reasoning models.
#Data is the whole thing
The consistent finding across the literature: a thousand carefully curated examples beat a hundred thousand mediocre ones.
- Quality over quantity. LIMA got strong instruction-following from 1,000 examples. Noisy data actively teaches the wrong behaviour.
- Diversity over volume. Covering the full range of inputs you'll actually see matters more than piling up examples of one kind. A few hundred examples of each of 10 ticket types beat thousands of examples of the most common type.
- Consistency. If two examples handle the same situation differently, you're teaching the model to be inconsistent.
- Format exactly as you'll serve. Training and serving prompt templates must match precisely, down to whitespace and special tokens. Mismatch here is the single most common cause of "the fine-tune didn't work."
- Held-out evaluation from the start. Not a benchmark — your task, your distribution, scored the way you actually care about.
#Check yourself
When is fine-tuning the right tool?Show answer
What is the strongest economic case for fine-tuning?Show answer
How much memory does full fine-tuning need?Show answer
How does LoRA work?Show answer
Why does LoRA matter for serving?Show answer
PPO versus DPO?Show answer
What are verifiable rewards?Show answer
How do you limit catastrophic forgetting?Show answer
#What to carry forward
- Fine-tuning teaches style and format, not facts. Facts are a retrieval problem.
- Training memory ≈ 16–20 bytes/parameter versus ~2 for inference — an 8–10× gap.
- LoRA trains ~0.3% of parameters and, crucially, lets many adapters share one base model in memory.
- DPO replaced PPO for most teams: two models instead of four, no RL loop, comparable results.
- Catastrophic forgetting is the default. Mix general data, keep ranks low, evaluate broadly.
- The strongest economic case is distillation — big model generates the data, small model serves it.