Suppose you ask a model, "How do I undo my last git commit?" and it gives you two answers. The first is one line, git reset --soft HEAD~1. The second is the same command, plus a sentence on what it keeps, plus a warning about the --hard flag, which throws your changes away. Both are correct and both are well written, but if you asked ten people which one they'd rather get, most of them would probably have a clear opinion. How would you teach a model to share it?
The obvious tool, from chapter 10, is supervised fine-tuning (SFT for short): show the model a prompt with a good answer and train it to predict that answer token by token. We'll see in the first section why that can't express a preference between two answers that are both good. What can express it is a comparison, a person looking at two answers and picking one, and everything in this chapter is a way of turning piles of those picks into a better model.
There are four such methods, and they're easiest to understand as one idea with a shrinking amount of machinery around it. The shared idea is to push the model toward the answers people prefer while keeping it close to where it started, where "close" is measured by KL divergence, a number from chapter 01 that says how far apart two probability distributions are. RLHF does this the long way, by training a second model to score answers and then running reinforcement learning against it. DPO shows that the scoring model can be cancelled out of the maths. GRPO keeps the reinforcement learning but throws away one of its helper networks. RLVR replaces the learned scorer with a program that checks whether the answer is right.
We'll build up in that order, using the two git answers whenever we need something concrete, and each method will come from asking what the one before it cost and whether we can do without it. It took the field about three years to find out how much of the original RLHF pipeline could be removed, and the answer was most of it.
01Why supervised fine-tuning can't tell the two answers apart
Chapter 10 covers SFT. You collect prompts with responses written by people, then train the model with next-token prediction on those responses, and it learns to answer in the right shape. This works because there's a target to imitate: for each prompt, one specific sequence of tokens that the loss tries to make more likely.
Now go back to our two git answers. If both appear in the training data, SFT raises the likelihood of both. If only one does, SFT raises that one and does nothing about the other. In neither case does the model learn that people like the thorough answer better, because the loss only knows how to say "produce this". It has no way to say "produce this and not that". A preference is a relation between two outputs, and a per-token label on a single output can't carry a relation.
There's a second problem, and it's the more practical one. Training on demonstrations usually pulls the model toward the average of whoever wrote them. If your annotators are good but not exceptional, imitating them gets you a model that's good but not exceptional. Comparisons don't have that ceiling, because people can reliably tell which of two answers is better long after they'd be able to write the better one themselves. Judging quality is easier than producing it, and that gap is what preference optimisation turns into a training signal.
So we want to train on "A beat B". How should the model use that?
02The bargain: move toward what people prefer, but not far
One half of the answer is easy to say. Whatever the method, some notion of reward, a number that's higher for answers people prefer, should go up as training proceeds. In our example the thorough git answer should earn more reward than the one-liner, at least for the people who asked.
Then there's a constraint, and it matters as much as the first. The model should also stay close to the one we started from, the SFT model, so we'll call that one the reference model and write it . Here stands for a policy, which in this chapter just means a language model viewed as a rule for choosing the next token given the text so far.
Why can't we just maximise the reward as hard as possible?
Mostly because the reward is only ever a rough measure of what people want, and an optimiser with no constraint will find every place where the measure and the want come apart. It might, for instance, learn that flattering phrases score well, or that longer answers score well, or some other surface pattern the reward happens to correlate with. It would score brilliantly and be useless. Keeping the model near the reference keeps it in the region where the reward still means something, and KL divergence is the usual way to measure that distance: it's zero when two models behave identically and grows as their outputs diverge.
Most of the history of this field is a sequence of answers to one question: how much apparatus do we need to run this bargain? The first serious answer came from Ouyang et al. (2022). They trained a model on human comparisons to produce reward scores, then optimised the language model against those scores with reinforcement learning. In the InstructGPT results, a 1.3B model tuned this way was preferred to a 175B model that hadn't been. Before that, instruction-tuned models were trained purely by imitation, so their quality was bounded by the demonstrations. After it, preference tuning became the default last stage of every serious model, and most of the work since has been about removing pieces of the pipeline while keeping the result. To see which pieces can go, we need the whole pipeline in front of us first.
03The pipeline, and where each method cuts into it
A modern chat model goes through four stages. Pretraining is next-token prediction on a large corpus, and it produces a base model that can continue text but doesn't follow instructions. SFT then fine-tunes on demonstrations, which produces a model that answers in the right shape. That checkpoint matters later, because it becomes the reference model that everything else is measured against. Third comes reward modelling: collect comparisons and train a model to score responses. Last is policy optimisation, which updates the SFT model to score well under that reward while being penalised for drifting from the reference.
RLHF runs all four stages as written. Each of the other three methods deletes something. DPO deletes stage 3 and replaces stage 4 with a supervised loss on the preference pairs, and as we'll see, the reward model doesn't merely get skipped, it provably cancels. GRPO keeps stages 3 and 4 but deletes the value network inside stage 4, using the average reward of several sampled answers as its baseline instead. RLVR deletes stage 3 by replacing the learned reward model with a program that checks whether the answer is correct. The diagram below lays the four side by side.
From here we'll take the stages in order, starting with stage 3. Before any of the cuts make sense, we need to know what a reward model is and what it assumes.
04The reward model, and the assumption underneath it
Why not ask people to score each answer out of ten?
Because people are inconsistent at absolute judgements, and their scale drifts over a session. A thorough git answer might get a 7 in the morning and a 5 after lunch. People are far more reliable at comparisons. So the data comes as pairs: a prompt , a preferred response (w for won), and a dispreferred one (l for lost). For our example, is the git question, is whichever answer the annotator picked, and is the other.
But we want a single number per answer, so we need a model of how preferences relate to scores. The standard choice is Bradley-Terry. It says that the probability of preferring one answer is the sigmoid (the S-shaped function that squeezes any number into the range 0 to 1) of the difference between their underlying scores:
Notice that only the difference in rewards appears. Add a constant to every reward and every preference probability stays the same. That's why reward-model outputs have no absolute meaning and can't be compared across training runs.
To fit this, we pick the reward model's parameters so the pairs in the dataset are as likely as possible (maximum likelihood). That gives the reward model's training loss:
Here is the average over all the pairs in the dataset , and stands for the reward model's parameters. That loss is small when the model gives the winner a clearly higher score than the loser. Architecturally, the reward model is usually the SFT model with the token-prediction head swapped for a single scalar output, read off the final token.
That scalar is a neat tool, but it rests on an assumption worth naming. Bradley-Terry assumes a single consistent quality score exists and that everyone is noisily measuring the same one. That's false in an interesting way. Annotators often disagree about tone, caution and verbosity, so one person might prefer the one-line git answer and another prefers the long one, and averaging their disagreement produces a reward model that represents nobody's actual preference. It also can't represent intransitive preferences, where A beats B, B beats C, and C beats A. Both limits are inherited by every method on this page that fits a Bradley-Terry reward, DPO included, and we'll come back to them. For now, suppose we have a reward model. How do we use it?
05RLHF with PPO: four models in the loop
With a reward model in hand, we can write the bargain from section 02 as an equation:
Read it as: choose the policy that maximises the average reward of the answers it generates, minus times its KL divergence from the reference model. Think of as the exchange rate between the two halves of the bargain, and it's probably the most consequential hyperparameter in the whole pipeline. A small lets the model chase reward, and a large one keeps it near the reference.
To optimise this, RLHF uses PPO, the reinforcement-learning algorithm from chapter 15, so everything there applies directly. Here the language model is the policy, generating a token is an action, and the text so far is the state. PPO's clipped surrogate objective stops any single update from moving the policy too far, which chapter 15 derives.
Usually the KL term isn't added as a separate penalty on the whole objective. It's folded into the reward at each token. Scoring happens once, on the finished answer, by the reward model, at the end of the sequence, and at every token the reward also has times the log-ratio between policy and reference subtracted from it. RL then optimises that single shaped reward.
You pay for all this in memory, because you hold four models in memory at once. One is the policy, the model being trained, and it needs gradients and optimiser state. A reference is a frozen copy of the SFT checkpoint, kept for the KL term. A reward model is also frozen and scores completions. A value model estimates the expected return from a state, which PPO uses to compute the advantage, and it's trained alongside the policy. (Chapter 15 explains advantage: how much better an action did than expected.) Two of these need gradients and two are frozen, but all four occupy memory, and the loop also has to generate rollouts, meaning full answers sampled from the policy, and that part is slow.
For our git question, one step means the policy writes an answer, the reward model scores it, the reference model says how unlike its own habits that answer was, and the value model supplies the baseline. That's a lot of equipment for one update, so a natural next question is whether any of it can go. First to go is the reward model, and the route there is a piece of algebra.
06DPO: making the reward model cancel
One result changed practice: you don't need the reward model, and this isn't an approximation. Chapter 10 states the DPO loss and explains each term. What follows is probably the shortest route to why it's true, because the derivation is short and it's the difference between using DPO and understanding when it will fail.
Here's the idea: take the RLHF objective, which has a known best answer in terms of the reward, and turn that around so the reward is expressed in terms of the policy. Reward then appears only as a difference between two answers, and the awkward part of the expression cancels in that difference. The derivation below shows each step.
Derivation How the reward model disappears from the RLHF objective
The claim is that optimising the RLHF objective in section 05 is equivalent to a supervised loss on preference pairs. The path runs through the closed-form solution of the KL-constrained objective.
-
Where we start: the RLHF objective, over all possible policies rather than a parameterised family. This is the step that makes the result exact but also marks its limit, since a real network cannot represent every distribution.
-
Why: this objective has a known closed-form maximiser. It is the reference distribution reweighted by exponentiated reward, a Gibbs distribution, with normalising it. Computing requires summing over every possible response, so this formula cannot be used directly. That is the whole obstacle.
-
Why: rearrange the previous line for . Read it in this direction and it says something surprising: any policy implicitly defines a reward function, namely its log-ratio against the reference. The intractable is still here, but note it depends only on the prompt.
-
Why: bring in Bradley-Terry from section 04, the same model the reward model was fitted with. Preferences depend only on a difference of rewards, which is what the next step exploits.
-
The step that does the work: substitute step 3 into step 4. Both responses share the same prompt , so both carry the identical term, and subtracting removes it. The intractable normaliser is gone, and with it the need for a reward model at all.
-
Where we land: maximum likelihood on the preference data under this reparameterisation, with in place of the unknown optimum. Every quantity is a log-probability the policy can compute directly. No reward model, no rollouts, no value network.
At the bottom of the derivation, the loss involves only log-probabilities that the policy can compute directly, so training is ordinary supervised learning on the preference pairs. For our git question, DPO raises the policy's probability of the thorough answer relative to the reference, and lowers it for the one-liner, with no reward model and no sampling.
One consequence is worth holding on to. Look at the quantity : it's DPO's implicit reward. You never train a reward model, but you can read one off the policy at any point, and the gap between the implicit rewards of the chosen and rejected responses is the margin. Watching the margin is how you tell whether training is working, and section 10 is built around it. DPO is cheap and simple, but it can only learn from the fixed pairs it was given. What if we want to keep the loop that samples from the model itself, and we want a cheaper baseline than a whole value network?
07GRPO: dropping the value model too
DPO removes the RL loop, and GRPO keeps it and removes something else. Group Relative Policy Optimization was introduced in the DeepSeekMath paper and is the method behind DeepSeek-R1. It starts from a question about PPO: what is the value model for?
Its job is to provide a baseline. An answer's advantage is its reward minus the reward we expected, and subtracting that baseline stops every token in a good answer from being reinforced equally regardless of how hard the prompt was. PPO learns the baseline with a second network, roughly the size of the policy.
GRPO's observation is that for language you can get a baseline for free. Sample a group of responses to the same prompt, score them all, and use the group's own statistics:
Response 's advantage is how much better it was than its siblings, in units of the group's own spread (its standard deviation). No learned value function appears anywhere. To see how it behaves, take a maths question and give four sampled answers a reward of 1 if correct and 0 if not. If two are right, the mean is 0.5, and the right answers sit as far above it as the wrong ones sit below it. If only one is right, the mean is 0.25, so the single correct answer is 0.75 above the mean while each wrong one is only 0.25 below it, and the rare success earns the most credit. That's what we'd want from a baseline that reflects how hard this particular prompt is.
From there the advantage goes into a PPO-style clipped objective with a KL term to the reference. Clipping and the KL constraint are unchanged, and only the source of the baseline differs.
Why does this fit reasoning so well?
For a maths or code problem you can sample sixteen attempts and grade every one automatically. The group mean then estimates how hard this specific prompt is, and that's what a value model spends its capacity trying to learn. Normalising within the group also makes easy and hard prompts contribute comparably, so easy prompts don't dominate through higher absolute rewards. You get a per-prompt difficulty baseline for the price of sampling, and you delete a network the size of your policy.
Now the cost moves to generation. Every optimisation step needs full completions per prompt where PPO needed one, so GRPO is inference-heavy in a way DPO isn't. In practice, the throughput ideas in chapter 31 apply directly to your training loop, and serious GRPO setups run a dedicated inference engine to produce rollouts.
DeepSeek-R1 pushed this further than most people expected. Its central claim is that reasoning ability can be incentivised through reinforcement learning alone, without human-labelled reasoning traces to imitate. It rewards the model for reaching correct answers and lets it develop the intermediate reasoning by itself. Notice what the group of sixteen attempts needed, though: a way to grade each one automatically. If grading is that easy, maybe we don't need a trained reward model for it at all.
08RLVR: when the reward is a checker, not a model
A learned reward model stands in for a human judgement that you can't query at training speed. For a whole class of tasks, though, no judgement is needed, only a fact. A maths answer either matches the reference or it doesn't. Code either passes the test suite or it doesn't. Output either parses as valid JSON against a schema or it doesn't.
Reinforcement learning with verifiable rewards (RLVR) uses that check as the reward directly. Tulu 3 applies it as a named stage in an open post-training recipe, and it's central to how recent reasoning models are trained.
What this buys is a reward you can't hack in the usual way. A learned reward model is an imperfect proxy, and enough optimisation pressure will probably find the gap between the proxy and the thing it stands for. A test suite has no gap of that kind, because passing the tests is the objective.
It doesn't buy safety from all gaming. A model can still special-case the visible tests, hard-code expected outputs, or find a degenerate answer format that the checker accepts. Pressure moves from exploiting a reward model's blind spots to exploiting a verifier's incompleteness. That's a narrower target, though not an empty one.
Scope is the bigger limit. Verifiable rewards work where correctness is decidable, which excludes most of what preference tuning was invented for, and our git example is a case in point: no program can check whether the thorough answer was better. In practice the two are combined, with verifiable rewards for reasoning and code and preference data for tone and helpfulness.
09Summary
- SFT can say "produce this" but not "this and not that". A preference is a relation between two outputs, and a per-token label on one output can't carry it.
- Imitation is capped by the demonstrators, while comparisons aren't, because people can judge which answer is better long after they could write it.
- Every method makes the same bargain: raise a reward, but stay close to the reference model, measured by KL divergence. Without the second half the optimiser exploits the reward and the model becomes useless.
- A reward model turns comparisons into a number using Bradley-Terry, where the probability of preferring one answer is the sigmoid of the reward difference. Only differences are identified, so the scores have no absolute meaning.
- Bradley-Terry assumes one consistent quality scale. It can't represent annotator disagreement or intransitive preferences, and every method that fits such a reward inherits that limit.
- RLHF with PPO holds four models: policy, reference, reward model and value model. The KL penalty is folded into the per-token reward, and is the exchange rate between reward and staying close.
- DPO cancels the reward model. The intractable normaliser depends only on the prompt, so it drops out of the reward difference, leaving a supervised loss on preference pairs.
- DPO has an implicit reward, , and the margin between chosen and rejected is what to watch. Because it only sees fixed pairs, it can't notice when its own samples get worse.
- GRPO replaces the value model with the group's own statistics. Sample answers, subtract the mean reward and divide by the spread. It costs generation instead of a network.
- RLVR replaces the learned reward with a checker wherever correctness is decidable. It's harder to hack than a reward model, though not impossible, and it can't cover things like tone.
- Four methods, one objective, less machinery each time. In practice they're combined: verifiable rewards for reasoning, preference data for helpfulness.
10Build this
DPO has a pathology you will not believe until you plot it, and plotting it takes one afternoon.
Run DPO on a small instruction-tuned model with a public preference dataset. Then log three quantities every step: the log-probability of the chosen response, the log-probability of the rejected one, and the margin between their implicit rewards. Most tutorials plot only the margin, and the margin is the least interesting of the three.
- Take a small instruction-tuned model, 0.5B to 1.5B, and a standard preference dataset with prompt, chosen and rejected fields. A free Colab GPU is enough at this size with LoRA.
- Set up
DPOTrainerfrom TRL with . With LoRA you can skip loading a separate reference model, since disabling the adapter recovers the base policy. - Log
logps/chosen,logps/rejectedand the reward margin every step, and plot all three on shared axes. - Train well past the point where the margin looks healthy, then read the two log-probability curves and not the margin.
- Now sweep with a much smaller value and a much larger one, and at each setting generate a few completions and read them.
11The variants
DPO spawned a large family. Most differ in one specific way, and knowing which is enough.
Identifies that DPO's sigmoid loss can be driven arbitrarily far when a pair is perfectly separable, which overfits the preference data. Replaces it with a bounded objective that cannot run away.
Relevant when preference pairs are clean and the model overfits them quickly.
Drops the need for pairs entirely. Learns from individual responses labelled good or bad, using an objective drawn from prospect theory.
Reach for it when you have thumbs-up/thumbs-down production feedback, which is far cheaper to collect than matched pairs.
Removes the reference model, and folds preference optimization into SFT as a single stage with an odds-ratio penalty on the rejected response.
Reach for it to halve memory and collapse two training stages into one.
Also reference-free, using length-normalised average log-probability as the implicit reward. The normalisation directly targets DPO's tendency to reward longer responses.
Reach for it when outputs are drifting longer without getting better.
A caution applies to all of them, including the numbers in their papers: preference-tuning results are usually reported on judge-scored benchmarks, and LLM judges have documented biases, length being the best known. A method that produces longer answers can post better numbers without producing better answers. Page 25 covers why that happens. Treat published win rates as a reason to try something on your own data and not as a ranking.
12What breaks
The failure modes are shared across methods, because they come from the objective and not from the algorithm.
- Reward hacking. The policy finds where the reward model is wrong and lives there. Classic symptom: reward climbing steadily while sampled outputs get worse. Always read generations; never trust the reward curve alone.
- Length bias. Human annotators mildly prefer longer answers, reward models learn that preference and amplify it, and the policy exploits it. Length is the single most common confound in this entire area.
- Both log-probabilities falling in DPO. This is the section 10 phenomenon, where the margin looks fine while the model becomes less likely to produce either response.
- KL collapse and lost diversity. Too much optimisation pressure and the model converges on one safe phrasing for everything. Benchmarks may not notice; users do.
- Reward model distribution shift. The reward model was trained on SFT-era outputs. As the policy improves it generates text unlike anything the reward model scored, and the scores become unreliable exactly when the policy is doing best.
- Preference data quality. Annotator agreement on subjective comparisons is often modest, and a reward model fitted to noisy labels is a noisy reward model. This is usually the binding constraint, more than the choice of algorithm.
Keep a fixed set of prompts and generate from them at every checkpoint, then read the outputs yourself. Every failure above is visible in generations long before it shows up in a metric, and several of them never show up in a metric at all.
13Where you meet this in the wild
Which method fits depends almost entirely on what kind of signal you can get.
You have a house style and some examples of good and bad replies. Start with SFT, then DPO on a few thousand pairs. The reward model is not worth building at this scale, and DPO is stable enough to run without an RL specialist.
Answers are checkable, so use GRPO with verifiable rewards. There is no reward model and no value model, and the signal is exactly right and not a proxy. Budget for generation: this is where most of the compute goes.
You have thumbs-up and thumbs-down on individual responses and no matched pairs. KTO is built for this shape of data, and constructing artificial pairs from unpaired signals usually loses more than it gains.
Full RLHF still appears here, because online methods can learn from the model's own current samples and not a fixed dataset. Constitutional AI adds a further step, using AI feedback against a written set of principles to reduce how much human labelling is needed.
14Interview questions
BeginnerWhy is supervised fine-tuning not enough to align a model?
Because SFT can only raise the likelihood of one target sequence, and preference is a relation between two acceptable outputs rather than a property of one. Given a concise answer and a thorough one that are both correct, SFT has no way to express that people prefer one. There is also a ceiling effect: imitation pushes the model toward the average of its demonstrators, whereas people can reliably judge which of two answers is better long past the point where they could write the better one. Preference optimization converts that judging ability into training signal.
BeginnerWhat is the KL term in the RLHF objective for?
It keeps the policy close to the SFT reference model, and it is what stops the method from destroying the model. The reward model is an imperfect proxy, so an unconstrained optimiser will find where the proxy is wrong and exploit it, producing text that scores highly and reads badly. The coefficient sets the exchange rate between reward and drift. Too low and the model degenerates; too high and it barely moves from where it started.
IntermediateHow does DPO eliminate the reward model, and is it an approximation?
It is not an approximation on the stated objective. The KL-constrained RLHF objective has a closed-form optimal policy, the reference distribution reweighted by exponentiated reward. Rearranging gives the reward as a log-ratio between policy and reference, plus a normalising term that depends only on the prompt. Substituting that into the Bradley-Terry preference model leaves a difference of two rewards for the same prompt, so the intractable normaliser cancels, and what remains is a supervised loss on the policy's own log-probabilities. The caveats are that the equivalence assumes an unconstrained policy class, and that DPO learns only from the fixed dataset rather than from its own samples.
IntermediateWhat does GRPO remove relative to PPO, and what does it cost?
It removes the value network. That network exists to provide a baseline for the advantage, and GRPO gets a baseline instead by sampling a group of responses to the same prompt and normalising each reward by the group's mean and standard deviation. That deletes a model roughly the size of the policy and gives a per-prompt difficulty baseline, which is exactly what the value function was trying to learn. The cost is generation: every step needs several full completions per prompt rather than one, so GRPO is inference-heavy and serious setups run a dedicated inference engine for rollouts.
IntermediateReward is climbing steadily during RLHF but the outputs look worse. What is happening?
Reward hacking. The policy has found a region where the reward model is wrong and is optimising the proxy rather than the thing it stands for. A related cause is distribution shift: the reward model was trained on SFT-era outputs, and as the policy moves away its scores become unreliable. Check whether the KL from the reference is growing, look for the usual exploits such as length inflation or repeated flattering phrasing, and read generations from a fixed prompt set at every checkpoint. Remedies are raising , stopping earlier, or refreshing the reward model on samples from the current policy.
DeepIn DPO, both chosen and rejected log-probabilities decrease during training. Is that a bug?
It is a real and commonly observed property of the objective rather than an implementation error. The loss depends only on the difference between the two implicit rewards, so it is satisfied equally well by raising the chosen response's likelihood or by lowering the rejected one further, and gradient descent frequently does the latter to both. The consequence is that the model can become less likely to produce the preferred response while the margin looks healthy. It is a good argument for monitoring the raw log-probabilities rather than only the margin, and part of the motivation for reference-free variants and for online methods that sample from the current policy.
DeepWhat does the Bradley-Terry assumption commit you to, and when does it fail?
It assumes a single scalar of quality exists and that every annotator noisily measures the same one, with preference probability given by the sigmoid of a reward difference. Two consequences follow. Only differences are identified, so reward-model outputs have no absolute meaning and cannot be compared across runs. More seriously, genuine disagreement about tone, caution or verbosity gets averaged into a reward that represents nobody's actual preference, and intransitive preferences cannot be represented at all. Every method fitting a Bradley-Terry reward inherits this, DPO included, since the derivation runs straight through it.
DeepWhen would you use verifiable rewards instead of a learned reward model?
Whenever correctness is decidable by a program: maths answers checked against a reference, code run against a test suite, output validated against a schema. The advantage is that the reward is not a proxy, so the usual form of reward hacking, exploiting the gap between a learned model and what it stands for, has nothing to exploit. It does not eliminate gaming entirely, since a model can special-case visible tests or find a degenerate format the checker accepts, so the pressure moves to the verifier's incompleteness. The real limit is scope: nothing verifies whether an answer was appropriately tactful, so production recipes combine verifiable rewards for reasoning and code with preference data for tone.
15Go deeper
●Now write it yourself
Reading the derivation and being able to produce it are different skills. These are Deep-ML problems that exercise what this page covers — each one is checked against real test cases, not multiple choice.
Matched to this page from Deep-ML's catalogue of 1,380 problems. More at deep-ml.com, and Where to practise covers the other platforms and what each one trains.