"What if we cut through all this complexity?"
RLHF works, but it is a Rube Goldberg machine. Let us recap the chain: you first need an SFT (Supervised Fine-Tuning) model, then you train a separate reward model on human preferences, then you run a reinforcement learning algorithm (PPO) that juggles four models in memory at once, the policy being trained, its frozen reference copy, the reward model, and the critic. Add a KL (Kullback-Leibler) penalty to stop the policy from drifting, plus the fact that you have to generate complete answers at every step to have them scored. And that is before the chronic stability problems, reward hacking (the model learns to fool the judge rather than improve), and the compute bill.
This page uses three terms borrowed from reinforcement learning, laid out in detail on the RLHF page. In brief:
- policy: the model itself, seen as a rule that produces a token given the text written so far. Written , the Greek letter pi. When you read "the policy", read "the model".
- reward model: a second network, trained separately, whose only job is to score an answer. Its score is called the reward, written .
- reference model: a frozen copy of the starting model, used as a yardstick for how far the model has moved. Written .
The whole DPO argument consists in making the second of these disappear.
In May 2023, a team at Stanford published a paper that surprised the community. Its contribution: a mathematical proof that the reward model is superfluous. The technique is called DPO (Direct Preference Optimization).
Direct Preference Optimization: Your Language Model Is Secretly a Reward Model (Rafailov et al., 2023)
The central idea: the model already is a reward model
Here is the idea behind DPO, one of those elegant observations that changes everything. Recall what RLHF is trying to do: adjust the model so that it earns the best possible rewards, without straying too far from what it was after SFT. Mathematically:
Term by term:
- : the prompt, that is, the text handed to the model
- : the answer produced
- : the reward, the score the reward model assigns to answer for prompt
- : the expectation, that is, the average of that score over all possible prompts and answers
- (beta): a hand-tuned coefficient that sets the strength of the constraint (the larger it is, the tighter the model is held)
- : the Kullback-Leibler divergence, a measure of the gap between the current model's probabilities and the reference model's . It is 0 if the two coincide and grows with the gap. It is not quite a distance: it is not symmetric
- : we are looking for the weights that make this quantity as large as possible
In one sentence: get the best scores you can, without moving away from your starting point. The arbitrates between the two demands.
Most researchers saw this problem as requiring iterative reinforcement learning: generate answers, score them, update the model, repeat. The DPO authors proved something remarkable: this optimization problem has an exact analytical solution. In other words, you can write down the formula for the optimal model directly, with no RL loop at all:
Let us read that formula. is the probability the optimal model gives answer when handed ; the symbol means "proportional to"; is the exponential function. Plainly: the optimal model's probability is the reference model's, multiplied by a factor that grows with the reward. A well-scored answer sees its probability shoot up; a badly scored one is crushed. And the in the denominator sets how brutal the operation is: a large flattens reward differences, a small exaggerates them.
The decisive trick: this equality can be inverted. So the reward can be expressed using nothing but the model's probabilities:
The ratio compares the probability the current model assigns to answer with the probability the reference would assign it. If the current model gives a probability ten times higher than the reference, this ratio is 10 and the "implicit reward" is high.
That leaves the term , and it is worth pausing on it for a second, because it is what makes the trick work. is a normalizing factor: it depends only on the prompt , never on the answer . In practice it is uncomputable, you would have to sum over every conceivable answer. But as soon as you subtract two rewards for the same prompt, it appears twice with opposite signs and cancels out. That is exactly what the loss in the next section does, and it is why its being uncomputable does not matter at all.
What does all this say concretely? That every language model implicitly defines a reward model, through the ratio of its probabilities to a reference's. No need to train a second network: the model already encodes its preferences in the way it spreads its probabilities.
This is not merely a computational trick. It says something strong: the way a model assigns its probabilities is its scoring scale. If the tuned model gives an answer a higher probability than the reference does, it prefers it, no need to ask an external judge. DPO exploits that structure directly.
The DPO loss: elegantly simple
Substituting the implicit reward into the Bradley-Terry model gives the DPO cost function (its loss) directly.
Bradley-Terry is a simple idea, the same one behind Elo ratings in chess: to predict who wins between A and B, you look only at the gap between their scores. Formally, the probability that A is preferred to B is , where is the sigmoid. If A is worth 8 and B is worth 3, the gap is 5, and : A wins almost every time. Note that only the gap matters, never the absolute values, which is precisely what lets the term from the previous section vanish.
The resulting loss:
Let us decode this piece by piece:
- : the prompt (the question put to the model)
- : the chosen answer (w for "win", the one humans prefer)
- : the rejected answer (l for "lose", the one humans dislike)
- : how much the current model has raised the good answer relative to the reference
- : how much it has raised the bad answer relative to the reference
- the subtraction between the two: the preference gap. We want the model to raise the good answer more than the bad one
- : the sigmoid, which converts that gap into a value between 0 and 1, readable as a probability
- : amplifies or dampens the gap, it is exactly the same as in the RLHF formula above, which is no coincidence: it still plays the part of the leash
- : the average over the whole preference dataset
In one sentence: the loss is low when the model has separated the good answer from the bad one more than the reference did. It is high when it cannot tell them apart, and worse still when it prefers the bad one.
Notice what the formula does not contain: no , no reward model. It is gone, replaced by the model's own probabilities. That is the paper's entire argument in one line.
The practical consequence: this is ordinary supervised learning with an unusual cost function. No reinforcement learning, no generating answers mid-training, no critic. Just a forward pass (running the data through the network to compute the loss) and a backward pass (going back through the network to correct the weights), over pairs that are already written.

The DPO pipeline: before vs after
Before (RLHF with PPO):
| Step | Consumes | Produces |
|---|---|---|
| 1. SFT | ideal answers written by annotators | a model that answers |
| 2. Annotation | answers generated by that model | a human ranking of those answers |
| 3. Reward model | those rankings | an automatic judge |
| 4. PPO | prompts alone + the judge | the final model |
| 5. Monitoring | weeks of engineer time | curves that do not collapse |

After (DPO):
| Step | Consumes | Produces |
|---|---|---|
| 1. SFT | ideal answers written by annotators | a model that answers, which will also serve as the frozen reference |
| 2. Annotation | pairs of answers | for each prompt, which one is preferred |
| 3. DPO | those pairs, directly | the final model |
That is all. Steps 1 and 2 are identical to RLHF's: DPO does not reduce the annotators' workload by one gram. What it removes is the intermediate judge and the reinforcement loop, steps 3 and 4 of the previous chain, folded into a single supervised training run.
Each training example is a triplet: (prompt, chosen answer, rejected answer). For instance: prompt = "Explain gravity to an 8-year-old", chosen = a clear explanation with analogies, rejected = an explanation full of physicist jargon.
Public datasets provide exactly this format: UltraFeedback, or Anthropic's HH-RLHF (the two Hs stand for helpful and harmless, the two axes along which annotators compared the answers).
The hyperparameters that matter
The values given here are common practice in training libraries, not results from a paper, treat them as a starting point to adjust, not as constants.
- beta (): the strength of the KL constraint, hence how free the model is to move away from the reference. Often around 0.1. Too low: the model strays too far and can lose its base capabilities. Too high: it stays glued to the reference and learns nothing from the preferences.
- Learning rate: the size of each weight correction. Much lower than for SFT, on the order of to . Alignment is a delicate adjustment; going too fast damages what SFT built.
- Number of epochs, an epoch being one complete pass over the dataset: 1 to 3 at most. Overfitting in DPO is fast and brutal; the model memorizes the pairs and loses diversity. Watch the validation loss closely.
Concrete advantages: what DPO really changes
Simplicity: DPO fits in a few dozen lines. No critic (PPO's fourth model, the one that predicts the expected score), no generating answers at each step, no clipping coefficient to calibrate.
Stability: DPO loss curves are smooth and regular. No sudden collapse, and no reward hacking, for the simplest reason in the world: there is no judge left to fool. The only yardstick is the frozen reference, and it does not move.
Memory: two models to keep loaded (the one being trained and its frozen copy) instead of four with PPO.
QLoRA compatibility: DPO combines naturally with quantization (storing each weight on fewer bits to save memory) and LoRA adapters (Low-Rank Adaptation, you train only a small matrix added alongside the original weights, described on the page about fine-tuning).
QLoRA is LoRA applied on top of a quantized model (Quantized LoRA). The order of magnitude can be worked out by hand: a 7-billion-parameter model stored on 4 bits, that is half a byte per parameter, occupies GB. The adapters and optimizer states concern only a fraction of a percent of the weights. So this fits comfortably on a 24 GB consumer card, all the more so since with LoRA you get the reference model for free, simply by switching the adapter off.
What took a laboratory a few years ago now fits on a desktop machine.
The honest limitations of DPO
Data sensitivity: if the chosen answer and the rejected answer are nearly equivalent, the gap to be maximized is tiny and the signal near zero. It is the contrast between the two answers, more than their absolute quality, that drives learning.
Distribution shift: DPO trains on pairs produced by the SFT model. But as the model changes, it no longer produces the same answers, so the pairs describe a model that no longer exists. RLHF with PPO does not have this problem, since it regenerates answers at every step with the current model. That is exactly the trade DPO accepts by removing the loop.
No reusable judge: RLHF's reward model has a life after alignment, filtering data, ranking answers, evaluating other models. With DPO you never build it, so you do not have it.
Possible collapse: with beta too low or too many epochs, the model finds it cheaper to crush the probability of the bad answers than to raise that of the good ones. The loss falls, the gap grows, and answer diversity collapses. This is precisely the flaw the DPOP variant, below, is meant to fix.
The variants born after DPO
DPO inspired a series of improvements:
- IPO (Identity Preference Optimisation, Azar et al. 2023): replaces the step through Bradley-Terry, which reduces overfitting on the pairs
- cDPO (conservative DPO): softens the labels to allow for the fact that an annotator may have got it wrong
- Online / iterative DPO: regenerates fresh pairs at each round, which catches up the distribution shift described above, at the cost, obviously, of the simplicity just gained
- DPOP (DPO-Positive): adds a term forbidding the model to lower the probability of the good answer, the collapse mode described above
DPO is used extensively in the open-model community: Zephyr-7B is the best-documented example, its technical report explicitly describing alignment by distilled DPO. Many other models published on Hugging Face follow the same recipe.
Some labs combine both families of methods, DPO for the bulk of the alignment, then online reinforcement for the final stretch. The exact division of labour is generally not published, so read this claim as a reported tendency rather than a verified fact.
DPO or RLHF: the verdict
| Criterion | RLHF (PPO) | DPO |
|---|---|---|
| Complexity | very high | low |
| Training stability | difficult | stable |
| Models held in memory | 4 | 2 |
| Online learning (fresh answers along the way) | yes | not by default |
| Reusable judge afterwards | yes | no |
| Maximum performance | -- see below -- |
The last row deserves an explicit caveat. The DPO paper reports results equal to or better than PPO on the tasks it tests; later work argues the opposite, holding that a well-tuned PPO retains an edge. The question is not settled, and any page that declares a winner goes beyond what the literature establishes.
For a modestly sized team, however, the choice is clear: DPO is the better starting point. It gives competitive results with a fraction of the resources and without RLHF's debugging burden. PPO remains relevant for labs that have the teams and infrastructure to exploit it, and that need an online loop.
1. What is the central discovery of the DPO paper?
2. What does DPO not remove from the RLHF pipeline?
3. Why does reward hacking disappear with DPO?
4. What trade-off does DPO accept by removing the reinforcement loop?