Fine-Tuning / When & How
Learning from comparisons, not just correct answers.
Reviewed by Yuvaraj
Supervised fine-tuning (SFT) teaches a model to imitate good answers, but imitation has a ceiling. When you show the model a demonstration, it learns "this is a good response", it never learns "this response is better than that one." Yet almost everything humans care about (helpfulness, tone, honesty, refusing when appropriate) is a matter of relative quality. Preference optimization closes that gap: instead of single demonstrations, you train on pairs where a human marked one response as chosen () and one as rejected () for the same prompt, and you push the model to prefer the chosen one.
SFT maximizes the likelihood of one reference answer. It cannot express "answer A beats answer B," so it has no way to sharpen the margin between a great reply and a merely acceptable one, and it silently rewards confident-but-wrong completions that happen to look like the training text. Preference data carries exactly the signal SFT lacks.
Ask about this lesson, or about anything in AI. Answers cite the lessons they draw on.
Finished this lesson?
Mark it complete to earn XP, keep your streak, and schedule a review.
The original recipe (InstructGPT) turns preferences into a learned reward, then optimizes against it.
The KL term is load-bearing: without it, PPO discovers degenerate text that scores high on the reward model but reads as gibberish, classic reward hacking.
Direct Preference Optimization removes the separate reward model and the RL loop entirely. It optimizes the policy directly on preference pairs with one loss:
Here is the model being trained, is a frozen copy of the SFT model, and the temperature controls how far the policy may deviate from that reference. Minimizing this loss increases the log-probability margin of chosen over rejected, measured relative to what the reference already assigns.
For a curious beginner
How it is actually used
The underlying mechanism
Take one training example:
| Field | Content |
|---|---|
| Prompt | "Explain why the sky is blue to a 10-year-old." |
| Chosen | "Sunlight is made of many colors. Blue light bounces around the air more than the others, so it reaches your eyes from all over the sky." |
| Rejected | "Rayleigh scattering: intensity scales with , dominating at short wavelengths." (correct, but not for a child) |
During a DPO step the model computes log-probabilities for both responses under and under the frozen . The gradient raises and lowers , but always relative to the reference ratios. That reference anchor is what prevents collapse: the model cannot just crank the chosen answer's probability toward 1 and everything else toward gibberish, because both terms are divided by , so moving far from the reference distribution is implicitly penalized by . The result is a sharpened preference, not a broken language model.
EVOLVING, pick based on evidence, not fashion
The online-RL versus DPO tradeoff is an active research area. DPO is simpler and often matches RLHF on standard alignment benchmarks, but online RL can outperform it when you need fresh on-policy samples or rewards that DPO's offline pairs cannot express. Treat "which is better" as workload-dependent, not settled.
Common mistakes
DPOTrainer documentation, practical implementation and hyperparameters.