- Key idea
- Direct Preference Optimisation: the policy is its own reward model
- Real world
- Learning to cook for a friend. You could build a scoring system for dishes and then optimise against it, or simply make more of what they picked in each taste test and less of what they turned down.
- In an LLM
- The same pairs used to train a reward model (prompt, chosen answer, rejected answer) train the chat model directly with one supervised-style loss. No sampling, no critic, no reward model.
The trick
The KL page showed that the best policy under a KL penalty has a simple exact formula: . Turn it around and the reward can be read off the policy:
Plug that into the Bradley–Terry loss and the constant cancels, because only reward differences matter. What's left is a loss on the policy alone: make the chosen answer's log-ratio bigger than the rejected answer's.
Try it
β = 0.1. During training, the chosen answer's log-probability rose from −40 to −38 (log-ratio +2), and the rejected answer's fell from −35 to −39 (log-ratio −4).
- Implicit reward gap:
- Loss:
- The pair still pushes at strength: it has learned some of the preference, not all of it.
Set the widget's sliders to +2 and −4 to check these numbers.
A taste test with 30 pairs of dishes doesn't tell you a score for any dish. It tells you that your friend liked the lemon chicken more than the curry, and the curry more than the stew. DPO uses exactly this kind of information: never "how good", only "better than".
Variants you'll see in papers
| Method | What changes |
|---|---|
| IPO | Squared loss on the gap instead of log-sigmoid, so it stops pushing once the gap reaches a target. Less overfitting to noisy pairs. |
| KTO | Needs only "good" or "bad" labels on single answers, not pairs. |
| SimPO | No reference model: uses the length-normalised log-probability plus a margin. |
| ORPO | Folds a preference term into the ordinary fine-tuning loss, in one stage. |
| Online / iterative DPO | Regenerates pairs from the current policy each round, so the data stays on-policy. |
Offline vs online
Standard DPO trains on a fixed dataset of answers that some other model wrote. That data is off-policy, and it never shows the model its own new mistakes. Two practical consequences:
- Both answers can become less likely. DPO only cares about the gap, so the chosen answer's probability can fall too, as long as the rejected one falls faster. Tick "shared drift" in the widget and take a few steps to see it.
- It doesn't explore. It can only prefer among answers someone already wrote.
So DPO remains a cheap, stable stage for style and helpfulness: Olmo 3, for example, runs SFT, then DPO, then RL with verifiable rewards. But the big gains in reasoning since 2024 have come from online RL such as GRPO.
The DPO loss
Its gradient weights each pair by , which is the "still pushing" number in the widget: pairs the model already gets right fade out.
Papers
- Direct Preference Optimization (Rafailov et al., 2023)
- IPO, KTO, SimPO, ORPO