Chapter 17 · Section 17.5 · 60 min

Online, offline, and iterative preference learning

The derivation in §17.2 is exact. DPO and RLHF with PPO aim at the same optimal policy, π⋆∝πref er/β\pi^\star \propto \pi_{\text{ref}}\,e^{r/\beta}, and DPO gets there with one supervised loss instead of four models and a sampling loop. So why did Xu et al. (2024) find that a well-tuned PPO beat DPO on every benchmark they tried? Why do Llama 3 and Tülu 3, both of which chose DPO, go to the trouble of generating fresh preference data from their own latest models? And why, in the healthy toy run of §17.3, did the chosen responses end up less likely than under the reference?

The answer to all three is one sentence of the derivation that is easy to read past. DPO recovers π⋆\pi^\star if the loss is minimized over all responses. A real dataset covers a vanishing fraction of them, and DPO never looks at anything else, in particular not at the responses its own policy would generate. This section is about what that costs, how to see it coming, and how online and iterative DPO buy most of it back by sampling from the model being trained. It ends with the evidence on DPO versus PPO, which is the question every post-training interview eventually asks.

Throughout, πθ\pi_\theta is the policy, πref\pi_{\text{ref}} the frozen reference, β>0\beta > 0 the KL strength, a dataset D\mathcal{D} holds triples (x,yw,yl)(x, y_w, y_l) of a prompt with chosen and rejected responses, r^θ(x,y)=βlog⁡πθ(y∣x)πref(y∣x)\hat r_\theta(x,y) = \beta\log\frac{\pi_\theta(y\mid x)}{\pi_{\text{ref}}(y\mid x)} is the implicit reward, hθh_\theta is a pair's log-ratio difference (chosen log-ratio minus rejected log-ratio, in nats, so that the DPO loss is −log⁡σ(βhθ)-\log\sigma(\beta h_\theta)), and μ\mu denotes the distribution that produced the responses in the dataset, often called the behavior distribution.

What the offline loss can see

Look at the DPO loss as a function of the policy. It depends on πθ\pi_\theta only through the probabilities it assigns to the responses that appear in D\mathcal{D}. Two policies that agree on those responses have the same loss, however differently they behave everywhere else. For an expressive model trained on a finite dataset, the set of minimizers is enormous, and which one gradient descent finds depends on how the network generalizes, not on the preferences.

Xu et al. (2024) make this concrete with a three-response example and prove that every policy PPO can reach with a reward model fit to the data also minimizes the DPO loss, but not the other way around. Here is a version of their argument with numbers. Take a uniform reference over three responses and a dataset that only ever compares y1y_1 with y2y_2, always preferring y1y_1. The DPO loss is −log⁡σ(βlog⁡π(y1)π(y2))-\log\sigma\big(\beta\log\frac{\pi(y_1)}{\pi(y_2)}\big), which goes to zero as π(y2)→0\pi(y_2)\to0 regardless of π(y1)\pi(y_1). The policy (0.1,0,0.9)(0.1, 0, 0.9) minimizes it exactly as well as (1,0,0)(1, 0, 0) does. Nothing in the data mentions y3y_3, so nothing in the loss stops the policy from putting 90% of its mass there. PPO, by contrast, optimizes a reward model's opinion of y3y_3 under a KL penalty to the reference, and its optimum gives y3y_3 exactly what that reward and the reference justify.

Whether the policy actually drifts to y3y_3 depends on the parameterization. In a tabular softmax, raising y1y_1 and lowering y2y_2 leaves y3y_3's logit alone (§17.2). In a real network, the parameters are shared, and the update that separates y1y_1 from y2y_2 also moves every response that shares their features. A small model shows what can go wrong. Four responses are described by two features, helpfulness and length, and the policy is a softmax over a linear function of the features. The true reward is helpfulness only. But in the offline dataset, as in many real ones, the preferred response is also the longer one.

Python · cell 1

Offline DPO puts essentially all its mass on the unhelpful, very long response, a response that appears nowhere in the data, and the true reward falls from 1.5 to zero. The mechanism is the shared parameterization. The only direction the data push is ϕ(yw)−ϕ(yl)=(1,1)\phi(y_w) - \phi(y_l) = (1, 1), "more helpful and longer", and the response with the most of that direction is the long one, whose length feature of 2.5 outweighs the helpful one's combined 2. This is a cartoon of a real phenomenon. Park et al. (2024) found that DPO exploits the length bias of preference data, producing answers far longer than the reference, and tie it to exactly this kind of out-of-distribution extrapolation.

Notice that the loss cannot detect the problem. On the dataset, the policy ranks the pair perfectly and the loss goes to zero. Only samples from the policy itself would reveal that it now writes something nobody preferred.

Distribution shift

The example has no distribution shift, since it is already broken by coverage alone, but real offline data add a second problem. Preference datasets are usually built from responses written by other models, for example UltraFeedback's responses from a pool of open and closed models rated by GPT-4. Those responses come from a behavior distribution μ\mu that differs from the reference πref\pi_{\text{ref}} the loss measures against. On pairs that the reference finds unlikely, the log-ratios start in an unusual place, the implicit rewards of the data are not centered where the policy actually generates, and the policy is trained on text it would never write.

The DPO paper's own recommendation targets this. When the dataset was not sampled from the SFT model, first fine-tune the reference on the chosen responses, which pulls πref\pi_{\text{ref}} toward μ\mu. Xu et al. measured the effect directly. On the SafeRLHF dataset, DPO's results improved substantially when the base model was first fine-tuned on data from the same distribution, and when preference labels were regenerated on the model's own outputs.

There is a quantitative consequence worth deriving, because it explains a curve every DPO practitioner has seen. Take the expected implicit reward of responses drawn from the reference itself,

Ey∼πref[βlog⁡πθ(y∣x)πref(y∣x)]=−β Ey∼πref[log⁡πref(y∣x)πθ(y∣x)]=−β DKL(πref(⋅∣x) ∥ πθ(⋅∣x))≤0.\mathbb{E}_{y\sim\pi_{\text{ref}}}\Big[\beta\log\frac{\pi_\theta(y\mid x)}{\pi_{\text{ref}}(y\mid x)}\Big] = -\beta\,\mathbb{E}_{y\sim\pi_{\text{ref}}}\Big[\log\frac{\pi_{\text{ref}}(y\mid x)}{\pi_\theta(y\mid x)}\Big] = -\beta\, D_{\mathrm{KL}}\big(\pi_{\text{ref}}(\cdot\mid x)\,\Vert\,\pi_\theta(\cdot\mid x)\big) \le 0 .

In plain words, averaged over what the reference would say, the implicit reward can only go down as the policy moves away from the reference, and it is zero only if nothing has changed. Rafailov, Hejna, Park, and Finn (2024) point out the consequence. If the data are sampled from the reference, as DPO recommends, the average implicit reward of the data must become negative during training. And if the reference was fine-tuned on the chosen responses, it is the chosen responses whose implicit reward must fall on average. The falling chosen reward of §17.3 is not a bug. It is arithmetic.

Python · cell 2

Likelihood displacement

The falling chosen likelihood has a name, likelihood displacement, and it is sometimes harmless and sometimes not. Razin, Malladi, Bhaskar, Chen, Arora, and Hanin (2024) define it as the situation in which the margin log⁡πθ(yw∣x)−log⁡πθ(yl∣x)\log\pi_\theta(y_w\mid x) - \log\pi_\theta(y_l\mid x) grows while both log-probabilities fall, as reported by Pal et al. (2024), Rafailov et al. (2024), Tajwar et al. (2024), and others. Probability is conserved, so if the chosen and rejected responses both lose mass, something else gains it. The question is what.

Their analysis is clean enough to reproduce. Take a single prompt and single-token responses. The model produces a hidden vector h∈Rd\mathbf{h}\in\R^d for the prompt, and the next-token distribution is softmax⁡(Wh)\operatorname{softmax}(\mathbf{W}\mathbf{h}), with wz∈Rd\mathbf{w}_z \in \R^d the unembedding row of token zz (§6.2). Treat h\mathbf{h} as the trainable quantity and hold W\mathbf{W} fixed for now. The score of a token with respect to h\mathbf{h} is

∇hlog⁡π(z)=wz−wˉ,wˉ=∑z′π(z′) wz′,\nabla_{\mathbf{h}}\log\pi(z) = \mathbf{w}_z - \bar{\mathbf{w}}, \qquad \bar{\mathbf{w}} = \sum_{z'}\pi(z')\,\mathbf{w}_{z'},

the token's unembedding minus the probability-weighted average. For a DPO pair (y+,y−)(y^+, y^-), the averages cancel in the difference of scores, so the DPO gradient (§17.2) moves the hidden vector along the difference of the two unembeddings, h˙=c (wy+−wy−)\dot{\mathbf{h}} = c\,(\mathbf{w}_{y^+} - \mathbf{w}_{y^-}) with c=βσ(−βhθ)>0c = \beta\sigma(-\beta h_\theta) > 0. Keep the two hh's apart. The bold h\mathbf{h} is the hidden vector, and the italic hθh_\theta is the scalar margin of the pair. Now ask how fast each token's log-probability changes. By the chain rule,

ddtlog⁡π(z)=⟨∇hlog⁡π(z), h˙⟩=c ⟨wz−wˉ,  wy+−wy−⟩.\frac{d}{dt}\log\pi(z) = \big\langle\nabla_{\mathbf{h}}\log\pi(z),\, \dot{\mathbf{h}}\big\rangle = c\,\big\langle\mathbf{w}_z - \bar{\mathbf{w}},\; \mathbf{w}_{y^+} - \mathbf{w}_{y^-}\big\rangle .

In plain words, every token's log-probability changes in proportion to how well its unembedding aligns with the direction wy+−wy−\mathbf{w}_{y^+} - \mathbf{w}_{y^-}, relative to the average token. Two consequences follow.

  • The preferred token can fall. For z=y+z = y^+ the rate is c(∥wy+∥2−⟨wy+,wy−⟩−⟨wˉ,wy+−wy−⟩)c\big(\lVert\mathbf{w}_{y^+}\rVert^2 - \langle\mathbf{w}_{y^+}, \mathbf{w}_{y^-}\rangle - \langle\bar{\mathbf{w}}, \mathbf{w}_{y^+} - \mathbf{w}_{y^-}\rangle\big). When y+y^+ and y−y^- are similar, the first two terms nearly cancel, and the third, which grows as aligned tokens gain probability, can make the whole rate negative.
  • The winner may be a third token. The token whose log-probability rises fastest is the one most aligned with wy+−wy−\mathbf{w}_{y^+} - \mathbf{w}_{y^-}. That direction can have a large component orthogonal to wy+\mathbf{w}_{y^+}, contributed by −wy−-\mathbf{w}_{y^-}, so the winner can be unrelated, or opposite in meaning, to y+y^+.

Razin et al. observed exactly this in real models. Training to prefer No over Never often sharply increased the probability of Yes. Their analysis also lets W\mathbf{W} train, which adds the unembedding similarity ⟨wy+,wy−⟩\langle\mathbf{w}_{y^+}, \mathbf{w}_{y^-}\rangle to the conditions for displacement (the PyTorch block below shows that in a small toy, trainable unembeddings can be enough to prevent it, which real models are not). The cell builds a two-dimensional version in which No and Never point in nearly the same direction, starting from a model that, after SFT, gives them equal probability.

Python · cell 3

For the first hundred steps everything looks right. No rises from 0.49 to 0.72 and Never falls. Then Yes, whose unembedding is the most aligned with wNo−wNever\mathbf{w}_{No} - \mathbf{w}_{Never}, overtakes, and by step 400 the model answers Yes 89% of the time, while the DPO margin, the only thing the loss measures, has grown every step.

When DPO prefers one answer over a similar one, where does the probability go?
A single prompt, five single-token answers with two-dimensional unembeddings, and DPO on one pair, No preferred over Never, starting from a model that splits its mass between them. Left, log-probabilities over training. Right, the unembeddings and the path of the prompt's hidden vector.
Loading interactive figure…

For real sequences, Razin et al. turn the analysis into a score that can be computed for every pair in a dataset. With hx,y<k\mathbf{h}_{x, y_{<k}} the model's hidden state after the prompt and the first k−1k-1 tokens of a response, the centered hidden embedding similarity is

CHES⁡x(y+,y−)=⟨∑k=1∣y+∣hx,y<k+,  ∑k′=1∣y−∣hx,y<k′−⟩−∥∑k=1∣y+∣hx,y<k+∥2,\operatorname{CHES}_x(y^+, y^-) = \Big\langle \sum_{k=1}^{|y^+|}\mathbf{h}_{x, y^+_{<k}},\; \sum_{k'=1}^{|y^-|}\mathbf{h}_{x, y^-_{<k'}}\Big\rangle - \Big\lVert\sum_{k=1}^{|y^+|}\mathbf{h}_{x, y^+_{<k}}\Big\rVert^2 ,

the inner product of the summed hidden states of the two responses minus the squared norm of the preferred one's. It plays the role for whole sequences that ⟨wy+,wy−⟩−∥wy+∥2\langle\mathbf{w}_{y^+}, \mathbf{w}_{y^-}\rangle - \lVert\mathbf{w}_{y^+}\rVert^2 plays for single tokens (minus the first two terms of the preferred token's rate above), measured on the model's hidden states, which is where two similar responses overlap in a real network. A higher score means the two responses look more alike to the model and the pair is more likely to displace likelihood. On UltraFeedback and AlpacaFarm, the score identified the samples that contributed most to displacement, where simpler similarity measures did not.

How bad can it get? In their most striking experiment, training Llama-3-8B-Instruct with DPO to refuse unsafe prompts lowered its refusal rate on SORRY-Bench from 74.4% to 33.4%, because probability mass moved from the preferred refusals to compliant, harmful responses. Filtering out the pairs with the highest CHES scores prevented this, more effectively than adding an SFT term to the loss. Displacement is benign when the mass moves to responses as good as the chosen one (as in the toy of §17.3, where it went to short, high-reward answers) and catastrophic when it moves to responses that are worse. The training log cannot tell the two apart, so the only reliable check is to sample.

Three things help, listed in rough order of how directly they attack the cause.

  • Distinct pairs. Pairs whose responses differ in meaning, not just in a few tokens, displace less. Llama 3's safety team reports a related practice, crafting response pairs that are nearly orthogonal in an embedding space. CHES-based filtering does this systematically.
  • On-policy pairs. Pairs sampled from the current model show it its own likely outputs, so displaced mass shows up in the next round's data and gets corrected (next part).
  • A likelihood term on the chosen response. An NLL term (Llama 3's weight 0.2, Exercise 17.3c) or DPO-Positive's penalty (§17.4) keeps the chosen likelihood from falling, though Razin et al. found it a weaker fix than data filtering for their unalignment case.
Research

Where does the probability go?

For the single-token model above, implement logprob_velocity(W, h, h_ref, pos, neg, beta). W has shape (V, d), h and h_ref have shape (d,), and the reference distribution is softmax⁡(Whref)\operatorname{softmax}(\mathbf{W}\mathbf{h}_{\text{ref}}). Suppose h\mathbf{h} follows gradient flow on the DPO loss of the single pair (pos preferred to neg), h˙=−∇hL\dot{\mathbf{h}} = -\nabla_{\mathbf{h}}\mathcal{L}, with W\mathbf{W} fixed. Return the vector of ddtlog⁡π(z)\frac{d}{dt}\log\pi(z) for every token zz, shape (V,), using the formulas derived above. The tests compare with a tiny explicit step.

Hidden tests, hints, and AI help, from $1.99 a month.

Overoptimization without a reward model

One hope for DPO was that, with no explicit reward model, there would be nothing to hack, and the overoptimization curves of §16.5 would not apply. They do. DPO still fits a reward model, its implicit one, on a finite dataset, and that reward is accurate only near the data. As training moves the policy further from the reference, its own samples leave the region where the implicit reward was fit, which is the same situation as a PPO policy outrunning its reward model.

Rafailov, Chittepu, Park, Sikchi, Hejna, Knox, Finn, and Niekum (2024) measured it. Training direct alignment algorithms across a range of KL budgets and model sizes, and judging the results with a stronger model, they found the same hump that Gao et al. found for RLHF. Quality rises with KL from the reference and then falls at higher budgets, and the decline often starts before a single epoch over the dataset is complete. In practice this is one more reason to choose β\beta and the number of steps by evaluating samples from checkpoints, not by the training loss, which keeps falling through the decline.

Online and iterative DPO

Every failure so far has the same root. The policy is never shown its own outputs. The fix is to show them. Instead of a fixed dataset, sample responses from the current policy, label them, and train DPO on those pairs.

Online DPO does this at every step. Guo et al. (2024) call their version online AI feedback (OAIF). At each training step they sample two responses per prompt from the current policy, ask an LLM annotator which is better, and take a DPO (or IPO, or SLiC) step on the result. In human evaluations, the online versions of the three methods beat their offline versions about 66% of the time on average, and on TL;DR summarization human raters preferred online DPO over the SFT baseline, RLHF, and RLAIF 58% of the time in a four-way comparison.

Iterative DPO does it in rounds, which is cheaper to engineer because generation and training alternate instead of interleaving. A typical round, following the recipe of Xiong et al. (2024) and Dong et al. (2024), looks like this.

  1. Take a batch of prompts and sample nn responses to each from the current policy πt\pi_t.
  2. Score every response with a reward model, an LLM judge, or a verifier.
  3. Pair the best response with the worst, dropping prompts where they tie or nearly tie. (Dong et al. describe n=8n = 8, half sampled at temperature 1.0 and half at 0.7, and generate 16 responses per prompt in their experiments.)
  4. Train with DPO on the new pairs (often together with earlier rounds' data, as Dong et al. do), initialized from πt\pi_t, to get πt+1\pi_{t+1}.
  5. Repeat for a few rounds (three in Dong et al.).

Which reference should round tt use? Dong et al. keep the original SFT model π0\pi_0 as the reference in every round while initializing from the latest policy, so every round optimizes toward the same target π⋆∝π0er/β\pi^\star \propto \pi_0 e^{r/\beta}. The alternative is to reset the reference to πt\pi_t each round, which makes each round a small trust-region step from the previous policy and lets the total distance from π0\pi_0 accumulate, a different and more aggressive objective. A middle ground updates the reference during training, as in TR-DPO (Gorbatovski et al. 2024). Llama 3 follows the iterative pattern at scale, with six rounds, each training DPO mostly on the newest preference data collected with the best models of the previous rounds, so that, in the report's words, the training data conform better to the distribution of the policy being optimized. Tülu 3 found that adding on-policy pairs, sampled from its own SFT model, improved DPO over off-policy data alone.

Back to the four-response example. Replace the fixed dataset by pairs sampled from the current policy and labeled by Bradley-Terry with the true reward.

Python · cell 4

Online DPO puts its mass on the two helpful responses, splitting it almost evenly, which is the optimal policy π⋆\pi^\star for this reward and β\beta. As soon as the policy started to favor the long, unhelpful response, it began to sample it, the labels compared it with helpful responses and rejected it, and the length feature was unlearned. Coverage now follows the policy wherever it goes.

What does offline DPO do to responses its data never mention, and does sampling from the policy fix it?
Five responses described by helpfulness and length, a softmax policy over a linear function of the two, and a uniform reference. The true reward is 3 times helpfulness. Offline DPO trains on fixed pairs, online DPO on 32 fresh pairs per step sampled from the current policy and labeled by Bradley-Terry.
Loading interactive figure…

Why does sampling help so much? Tajwar et al. (2024) compared supervised, contrastive, and RL fine-tuning methods across didactic bandits and full-scale LLM problems and identified two ingredients that matter. One is on-policy sampling, and the other is a negative gradient, pushing down the likelihood of specific bad responses, which plain maximum likelihood on good responses lacks. Methods with either ingredient, which they unify as mode-seeking, moved probability mass between regions of the output space much faster than maximum likelihood. Online DPO has both. In a separate study from the GPO paper of §17.4, Tang et al. (2024), working at Google DeepMind with matched budgets, found that the advantage of online over offline methods could not be explained by data coverage or data quality alone, persisted across contrastive and non-contrastive losses, and did not go away with larger policies. They observed an interesting split. Offline-trained policies became good at the discriminative task, ranking pairs, but worse at generating, while online-trained policies were better generators and worse rankers.

There is a deeper reason, too. Online DPO with a reward model is no longer reward-model-free. It is a policy improvement method that uses the reward model on the policy's own samples, in pairs, which makes it close kin to the RL methods of Chapter 16 and to the group-relative methods of §18.4, where several responses to the same prompt serve as each other's baseline. The line between "DPO" and "RL" blurs once you sample.

The loop can even close on itself. A model can act as its own judge, labeling its own samples with an LLM-as-a-judge prompt, and train on the resulting pairs with iterative DPO. Yuan et al. (2024) did this for three iterations starting from Llama 2 70B, and the final model outperformed several strong systems on the AlpacaEval 2.0 leaderboard, including Claude 2, Gemini Pro, and GPT-4 0613. Whether such loops keep improving or collapse onto their own biases is one of the central questions of self-rewarding models and synthetic data pipelines, which are built on exactly this iteration.

Core

Best-versus-worst pairs for an iterative round

Implement best_worst_pairs(rewards, min_gap). rewards has shape (P, n), the scores of nn sampled responses for each of PP prompts. Return (chosen, rejected, keep), three arrays of shape (P,). chosen[p] is the index of the highest-scoring response and rejected[p] of the lowest (ties go to the lowest index), and keep[p] is a boolean that is true only when the gap between them is at least min_gap. Prompts whose responses all score the same must never be kept, even when min_gap is 0, because a pair of equal responses teaches nothing.

Hidden tests, hints, and AI help, from $1.99 a month.

A toy that recovers the optimum

With full coverage the derivation's promise is exact, and it is worth seeing it kept. On a categorical policy over KK responses with labels drawn from Bradley-Terry on a reward rr, the population DPO loss, the expectation over labels of each compared pair, is

L(z)=∑(i,j)[−pijlog⁡σ(βhij)−(1−pij)log⁡σ(−βhij)],pij=σ(ri−rj),\mathcal{L}(\mathbf{z}) = \sum_{(i,j)}\Big[-p_{ij}\log\sigma(\beta h_{ij}) - (1-p_{ij})\log\sigma(-\beta h_{ij})\Big], \qquad p_{ij} = \sigma(r_i - r_j),

where hijh_{ij} is the log-ratio difference of responses ii and jj. For each pair it is minimized when σ(βhij)=pij\sigma(\beta h_{ij}) = p_{ij}, which is βhij=ri−rj\beta h_{ij} = r_i - r_j. If the compared pairs connect all KK responses, those differences pin down every log-ratio up to one shared constant, which normalization removes, so the minimizer is πθ=π⋆=πrefer/β/Z\pi_\theta = \pi^\star = \pi_{\text{ref}}e^{r/\beta}/Z. Exercise 17.5c asks you to train it and check.

Interview

A full DPO training loop that recovers the closed-form optimum

Implement fit_dpo_categorical(pi_ref, r, beta, pairs, steps=4000). The policy is a softmax over logits z∈RK\mathbf{z}\in\R^K, initialized at log⁡πref\log\pi_{\text{ref}}. pairs is an integer array of shape (P, 2) listing which responses are compared. Each pair (i,j)(i, j) carries the soft label pij=σ(ri−rj)p_{ij} = \sigma(r_i - r_j), the Bradley-Terry probability that ii wins. Minimize the mean over pairs of the expected DPO loss above by gradient descent on z\mathbf{z} for steps steps, and return the final policy, shape (K,). The tests check that you recover π⋆=πrefer/β/Z\pi^\star = \pi_{\text{ref}}e^{r/\beta}/Z to within 10−310^{-3}, for complete and for chain-shaped comparison graphs and for several β\beta. Choose a step size that converges in the given number of steps.

Hidden tests, hints, and AI help, from $1.99 a month.

DPO versus PPO, the evidence

Here is what controlled comparisons have found, in roughly chronological order. Read the settings carefully, because the conclusions depend on them.

studysettingfinding
Rafailov et al. (2023)IMDb sentiment, TL;DR, Anthropic HH, models up to 6BDPO's reward-KL frontier dominates PPO's on IMDb, even PPO with the true reward. TL;DR win rate about 61% for DPO against 57% for PPO at their best temperatures.
Xu et al. (2024)dialogue (HH-RLHF, SafeRLHF) and code (APPS, CodeContests)Well-tuned PPO beats DPO in every testbed. Key PPO ingredients are advantage normalization, large batches, and an exponential moving average of the reference. A 34B PPO model raises CodeContests 10@1k from 16.4% (AlphaCode-41B) to 22.4%. DPO is hurt by distribution shift. Iterative DPO reaches PPO's safety rate on SafeRLHF, but with a much lower helpfulness reward.
Ivison et al. (2024), Tülu 2.513B models, many preference datasets, a broad evaluation suitePreference data quality matters most, then the algorithm, then the reward model, then extra prompts. PPO beats DPO by up to 2.5% on math and 1.2% overall. Larger reward models give up to 5% on math and little elsewhere.
Tajwar et al. (2024)bandits to full LLM fine-tuningOn-policy sampling and negative gradients are what matter. Offline maximum-likelihood methods lag.
Tang et al. (2024)Google DeepMind, matched budgetsOnline methods beat offline ones, and the gap is not explained by coverage or data quality alone and persists across losses and model sizes.
Llama 3 (2024)frontier scale, six roundsChose DPO over PPO, reporting that it needed less compute for large models and performed better, especially on instruction following (IFEval), with data refreshed each round.
Tülu 3 (2024)8B and 70B, open recipeIn a controlled comparison, PPO reached about the same average score as DPO, slightly lower, at roughly 28 hours on two nodes against DPO's 4 hours on one. Kept length-normalized DPO, and used RL with verifiable rewards where answers can be checked.

Put together, the evidence supports a fairly clear picture. With stale, off-policy preference data, online RL tends to win, because it sees and corrects its own outputs. With fresh, on-policy pairs, regenerated every round, DPO comes close to PPO at a fraction of the cost and complexity, which is why the frontier recipes that use DPO all iterate. For tasks with checkable answers, the field has moved to online RL with verifiable rewards, where there is no preference data to go stale at all (§18.3). And everywhere, data quality matters more than the choice of algorithm.

offline DPOiterative or online DPORLHF with PPO
models in memorypolicy, referencepolicy, reference, plus a judge or reward model for labelingpolicy, reference, reward model, value model
generation during trainingnoneevery round or every stepevery step
sees its own outputsneveryesyes
can use unlabeled promptsnoyes, any prompt the judge can scoreyes
main failure modescoverage gaps, distribution shift, length exploitation, likelihood displacementjudge bias, reward hacking of the labelerreward hacking, instability, many hyperparameters
cost and engineeringlowestmoderate (a generation pipeline)highest
typical usequick alignment from a good public datasetmost current open and frontier recipeswhen the reward is cheap to query and the budget allows tuning

In PyTorch

The cell above moved only the hidden vector. Here the same toy is trained with autograd and an optimizer, once with the unembeddings frozen, as in the analysis, and once with them trainable too, and with an NLL term of weight α\alpha on the chosen token added to the loss.

🔥 In PyTorchfor a machine with PyTorch

With the unembeddings frozen and no NLL term, the optimizer reproduces the displacement, and Yes ends at 0.89. An NLL weight of 0.01 already keeps No on top at 0.65, and 0.1 holds it at 0.96, which is why recipes like Llama 3's add such a term. When the unembeddings are trainable, the chosen token's own unembedding moves toward the hidden vector and raises its logit directly, and in this two-dimensional toy that is enough to prevent displacement altogether. Real models are less forgiving. Razin et al. trained OLMo-1B, Gemma-2B, and Llama-3-8B with all parameters free, on a single prompt with single-token responses, and the preferred token's probability fell by between 0.21 and 0.96 in every run. Toys show the mechanism, not its size, and the only reliable check in a real run is to sample from the model.

Read more

Watch next

🎬 An update on DPO vs PPO for LLM alignment · Nathan LambertA co-author of the Tulu 2.5 study walks through what the controlled comparison of DPO and PPO found.
🎬 Iterative preference learning methods for large language model post training · Simons Institute for the Theory of ComputingWei Xiong on why online exploration helps RLHF in theory, and the iterative DPO framework built on it.
🎬 Noam Razin: Unintentional Unalignment: Likelihood Displacement in Direct Preference Optimization · NiklasOPFThe first author explains likelihood displacement, its theory, and the CHES score for filtering data.