07 · DPO & RL-Free Preference Optimization
What you're learning
How the entire RLHF back half — reward model plus the PPO loop — collapses into a single supervised classification loss on preference pairs. The load-bearing fact: the KL-regularized RLHF objective has a closed-form optimal policy, so the reward is redundant with the policy itself. You’ll derive that optimum, invert it to read the reward off the policy, substitute into Bradley-Terry to watch the partition function cancel, and land on the DPO loss. Then: what its gradient does, where it breaks (likelihood displacement, offline distribution shift, the on-policy debate), and the zoo of variants (IPO, KTO, ORPO, SimPO, CPO) — each a targeted patch on one crack.
This is Tier 2, lesson 07. It assumes the full RLHF pipeline from 06-rlhf-pipeline — the Bradley-Terry reward model, the SFT→RM→PPO staging, and the leash — and the token-level MDP + reference-KL plumbing from 05-rl-on-token-sequences. Lesson 06 built the four-model machine; this lesson deletes three of the four models.
1. Learning map
graph TD A["RLHF pipeline (06):<br/>RM + PPO + KL, four models"] --> B["Observation: the RL objective<br/>max E[r] − β·KL(π‖π_ref)<br/>has a KNOWN optimum"] B --> C["Derive π*(y|x) =<br/>(1/Z) π_ref exp(r/β)"] C --> D["Invert: r(x,y) =<br/>β log(π*/π_ref) + β log Z"] D --> E["Substitute into Bradley-Terry<br/>P(y_w≻y_l)=σ(r_w−r_l)"] E --> F["Z(x) CANCELS<br/>(same x, appears in both terms)"] F --> G["DPO loss:<br/>−log σ(β Δlog-ratio)<br/>supervised, on pairs"] G --> H["'Implicit reward'<br/>r̂_θ = β log(π_θ/π_ref)"] G --> I["Gradient: up y_w, down y_l,<br/>weighted by how wrong<br/>the implicit ordering is"] G --> J["Failure modes"] J --> J1["Offline / off-policy<br/>distribution shift"] J --> J2["Likelihood displacement<br/>(both logp's can drop)"] J --> J3["Overfit deterministic prefs<br/>→ IPO"] J --> J4["Reference sensitivity /<br/>SFT coverage"] J1 --> K["Iterative / online DPO"] J3 --> V["Variants:<br/>IPO · KTO · ORPO · SimPO · CPO"] J4 --> V style B fill:#44a,color:#fff style F fill:#a44,color:#fff style G fill:#4a4,color:#fff style J2 fill:#a64,color:#fff
Prerequisites (assumed): the Bradley-Terry preference model and RM loss (06-rlhf-pipeline §6), the KL-to-frozen-reference reward shaping and the reward-vs-KL trade-off (05-rl-on-token-sequences §5, kl-regularization-rlhf), and sequence log-probs as sums of per-token log-probs (05-rl-on-token-sequences §4).
2. Why this matters: the reward model was never the point
Recall the operational weight of RLHF-PPO from lesson 06: four models resident at once (trainable policy + value head, frozen reference, frozen reward model), a generation-bound online loop, and notorious sensitivity to , advantage normalization, and reward scaling. And recall its defining pathology: the reward model is a learned proxy, PPO is an adversary, and the policy drifts into the RM’s blind spots (reward overoptimization / Goodhart, §8 of lesson 06).
Now ask the subversive question. In the RLHF pipeline we (1) fit a reward model to preferences, then (2) optimize a policy to maximize that reward under a KL leash. But step (2) is a known optimization problem with a closed-form answer. If we can write the optimal policy as an explicit function of the reward, maybe we can also invert it — write the reward as an explicit function of the optimal policy — and skip ever materializing at all. If the reward is just a reparameterization of the policy, then the policy is secretly its own reward model. (That is literally the DPO paper’s subtitle: Your Language Model is Secretly a Reward Model, arXiv:2305.18290.)[
If that works, the entire back half of RLHF becomes a supervised loss on the preference pairs you already collected for the reward model — no separate RM to train, no sampling from the policy during training, no value head, no PPO clip, no online adversary to hold at bay with a KL budget. One model being trained, one frozen reference for log-ratios, and a binary-cross-entropy loss. That is the DPO bet.
The one-sentence thesis
The KL-regularized reward-maximization objective and the policy are two coordinates for the same object; DPO changes variables from “reward space” to “policy space” before fitting, so preference learning becomes direct maximum likelihood on the policy — no RL, no RM, no sampling loop.
Here is the contrast we are about to earn, in one picture:
flowchart TD subgraph PPO["RLHF-PPO (lesson 06) — online RL loop"] direction TB A1["Preference pairs (x, y_w, y_l)"] --> A2["Train reward model r_φ<br/>(Bradley-Terry loss)"] A2 --> A3["Freeze r_φ"] A3 --> A4["LOOP: sample y ~ π_θ"] A4 --> A5["Score r_φ(x,y) at EOS<br/>− β·KL to π_ref per token"] A5 --> A6["GAE + value head V_φ"] A6 --> A7["PPO-clip update π_θ"] A7 -->|"refresh, repeat"| A4 A7 --> A8["Aligned policy"] end subgraph DPO["DPO (this lesson) — one supervised loss"] direction TB B1["Preference pairs (x, y_w, y_l)"] --> B2["Compute log π_θ, log π_ref<br/>on y_w and y_l (forward passes)"] B2 --> B3["L = −log σ(β·[Δ_w − Δ_l])<br/>Δ = log(π_θ/π_ref)"] B3 --> B4["Backprop, SGD on π_θ"] B4 --> B5["Aligned policy"] end style A4 fill:#a44,color:#fff style A2 fill:#a64,color:#fff style B3 fill:#4a4,color:#fff
Four models and an online sampling loop on the left; two forward passes and a classification loss on the right. The rest of this lesson is (a) why the right column is a valid stand-in for the left, and (b) exactly when it isn’t.
3. The centerpiece: deriving the closed-form optimal policy
Everything hinges on one classical result. We derive it slowly because every later step is an algebraic consequence.
3.1 The objective
The RLHF objective from lesson 05/06 — reward maximization with a KL leash to a frozen reference — is, per prompt and with the KL written out:
The expectation over decouples the problem: we can solve it independently for each prompt , because for different share no constraint other than each being a distribution. So fix and expand the KL as an expectation:
Crucially, this is a variational problem over the function — a distribution over the (astronomically large but finite) space of responses — with the single constraint . We are not parameterizing by yet; we ask what the unconstrained optimal distribution is.
3.2 Complete the square into a single KL
Divide the objective by (doesn’t change the argmax) and flip the sign to make it a minimization:
Now the trick: fold the reward term inside the logarithm by writing :
The denominator is almost a probability distribution over — it’s a non-negative function of — but it doesn’t normalize to 1. Fix that by dividing and multiplying by its normalizer. Define the partition function
which depends on (and on and ) but not on — it’s a constant with respect to the thing we’re optimizing. And define the distribution
which is a valid distribution by construction (, sums to 1 because normalizes it). Substitute into the objective:
3.3 Read off the optimum
We’ve rewritten the whole regularized objective as . The second term doesn’t depend on . The first term is a KL divergence, which is and equals iff . Therefore the minimizer is immediate:
This is the exact, closed-form optimal policy of the KL-regularized RLHF objective — no approximation, no RL. It’s a Boltzmann / Gibbs tilt of the reference: take , reweight each response by , renormalize. Two sanity checks that make it memorable:
- As (infinite KL penalty), for all , so : crank the leash tight and you never leave the reference.
- As (no penalty), becomes a hard max — collapses onto : no leash and you go to the single highest-reward response.
is literally the temperature of this Boltzmann distribution over responses. That is the cleanest possible statement of the reward-vs-KL trade-off from lesson 06.
Why this is a derivation, not a training algorithm — yet
is a beautiful closed form, but you cannot sample from it or train it directly, because sums over all possible responses — an intractable sum over sequences. This is precisely why classical RLHF resorts to PPO: it approximates iteratively without ever computing . DPO’s genius (next section) is to make cancel so we never need it.
Quiz 1: Where exactly in the derivation did we use that is independent of , and what breaks if it weren't?
Answer
It was used in the final step of §3.2–§3.3: after substituting , we split and pulled out of the minimization as a constant. That’s the only reason the objective reduces to “minimize plus a constant,” whose solution is trivially . is -independent because it is a sum over of quantities (, ) that don’t involve at all — the optimization variable has been integrated out. If depended on , you could not treat it as a constant: the "" term would contribute to the gradient w.r.t. , the problem would no longer be a plain KL-to-a-fixed-target, and would not be the optimum. (The same -only dependence is what makes cancel in the next section — hold that thought.)
4. Inverting the optimum: the policy is a reward model
We have as a function of . DPO’s move is to solve for as a function of . Take logs of the boxed optimum:
Isolate :
Read this carefully. It says: any reward function is expressible in terms of its own induced optimal policy , plus a term that depends only on the prompt , not on the response . The reparameterization is exact and invertible — reward space and (optimal-policy, prompt-constant) space are in bijection. There is no information in that isn’t in .
This is the sense in which “your language model is secretly a reward model”: if you had the optimal policy for some reward, you could read that reward straight off it via , up to the prompt-only offset .
Connect to lesson 06's gauge freedom
In lesson 06 we noted the Bradley-Terry reward is identified only up to a per-prompt additive constant — adding to every response’s reward leaves all comparison probabilities unchanged. Here that same gauge freedom reappears as the term : it is a response-independent, prompt-dependent offset. The reparameterization respects exactly the symmetry BT already had. This is the structural reason the next step works.
5. Substitute into Bradley-Terry: the partition function cancels
Now the reward model’s whole job in lesson 06 was to feed a Bradley-Terry preference model:
Bradley-Terry depends only on the difference of rewards for two responses to the same prompt . And our inverted reward has an offset that depends only on . So plug in for both and and take the difference:
The terms are identical — same prompt , same — so they subtract to zero. The intractable partition function is gone, exactly, with no approximation:
Substitute into Bradley-Terry:
The preference probability is now written entirely in terms of the optimal policy — no reward model anywhere. The final step is to stop treating as an object we already have and instead parameterize it as and fit it by maximum likelihood on the preference dataset, exactly as lesson 06 fit the reward model by MLE. Minimizing the negative log-likelihood of the observed preferences gives the DPO loss[
That’s the whole method. Compare it side-by-side with the reward-model loss from lesson 06 §6:
\qquad\longrightarrow\qquad \mathcal{L}_\text{DPO}(\theta)=-\,\mathbb{E}\Big[\log\sigma\big(\hat r_\theta(x,y_w)-\hat r_\theta(x,y_l)\big)\Big],$$ where $\hat r_\theta(x,y)\equiv\beta\log\frac{\pi_\theta(y\mid x)}{\pi_\text{ref}(y\mid x)}$. **It is literally the same Bradley-Terry classification loss** — only the scorer changed: instead of an explicit scalar head $r_\phi$, the scorer is the $\beta$-scaled log-ratio of the policy to the reference. Fitting the reward and fitting the policy have become the *same optimization*. > [!question]- Quiz 2: Precisely why does $Z(x)$ cancel, and would it still cancel if the two responses in a pair came from *different* prompts? > > > [!success]- Answer > > $Z(x)$ cancels because of two facts acting together: **(1)** the inverted reward $r(x,y)=\beta\log\frac{\pi^*(y|x)}{\pi_\text{ref}(y|x)}+\beta\log Z(x)$ has an offset $\beta\log Z(x)$ that depends on the prompt $x$ but **not on the response $y$**; and **(2)** the Bradley-Terry model consumes only the **difference** $r(x,y_w)-r(x,y_l)$ of two rewards *conditioned on the same $x$*. Because both responses share the identical $x$, they share the identical $\beta\log Z(x)$, and the difference annihilates it. This is the payoff of §3's observation that $Z$ depends only on $x$: the intractable normalizer lives entirely in the per-prompt gauge freedom that BT is already invariant to. **If the two responses came from different prompts** $x_w\ne x_l$, the offsets would be $\beta\log Z(x_w)\ne\beta\log Z(x_l)$ and they would **not** cancel — you'd be left with an intractable $\beta(\log Z(x_w)-\log Z(x_l))$ term. This is exactly why DPO requires preference pairs on a *shared prompt*, and why the "unpaired" setting needs a genuinely different construction (that's KTO, §9). --- ## 6. The implicit reward, and what the DPO gradient does ### 6.1 The implicit reward The quantity $$\hat r_\theta(x,y)\;\equiv\;\beta\,\log\frac{\pi_\theta(y\mid x)}{\pi_\text{ref}(y\mid x)}$$ is DPO's **implicit reward**. You never train it as a separate object, but it *is* a valid reward model — the one whose KL-regularized optimum is $\pi_\theta$ — recoverable from the trained policy for free (up to the unknowable per-prompt $\beta\log Z(x)$, which is fine because, as always, reward is only meaningful up to that offset). Some practical uses fall right out: you can use $\hat r_\theta$ to *rank* candidate responses, to do best-of-$n$ with your DPO model as its own scorer, or to filter data — no reward-model checkpoint needed. Note the implicit reward is a **sequence-level** quantity: $\log\pi_\theta(y\mid x)=\sum_t\log\pi_\theta(y_t\mid x,y_{<t})$, so $\hat r_\theta$ is the $\beta$-scaled sum of per-token log-ratios over the whole response. DPO is doing token-level updates in service of a sequence-level implicit reward. ### 6.2 Role of $\beta$ $\beta$ plays the *same* role as in RLHF — the strength of the KL leash to $\pi_\text{ref}$ — but it enters DPO as the **scale of the logits fed to the sigmoid**. Large $\beta$: the log-ratio differences are amplified, the model is strongly penalized for moving $\pi_\theta$ far from $\pi_\text{ref}$ (tight leash, stays near SFT). Small $\beta$: the log-ratios are damped, the loss tolerates large deviations from the reference (loose leash). It is the *identical* reward-vs-KL knob from lesson 06, now a single hyperparameter of a supervised loss rather than a coefficient in an RL reward. Typical values sit around $\beta\in[0.05, 0.5]$; $0.1$ is the common default. ### 6.3 The gradient Let $u\equiv\hat r_\theta(x,y_w)-\hat r_\theta(x,y_l)$ be the implicit-reward margin. Since $\frac{d}{du}\log\sigma(u)=\sigma(-u)=1-\sigma(u)$, the gradient of the DPO loss is: $$\nabla_\theta\mathcal{L}_\text{DPO} =-\,\beta\,\mathbb{E}_{(x,y_w,y_l)}\Big[\;\underbrace{\sigma\big(\hat r_\theta(x,y_l)-\hat r_\theta(x,y_w)\big)}_{\text{weight: how wrong the ordering is}}\;\Big(\underbrace{\nabla_\theta\log\pi_\theta(y_w\mid x)}_{\uparrow\text{ push up chosen}}\;-\;\underbrace{\nabla_\theta\log\pi_\theta(y_l\mid x)}_{\downarrow\text{ push down rejected}}\Big)\Big].$$ Decode it. The bracketed vector part **raises the log-probability of the chosen response $y_w$ and lowers that of the rejected $y_l$** — a contrastive update. The scalar weight $\sigma(\hat r_l - \hat r_w) = \sigma(-u)$ is the **per-example importance weight**: it is large ($\to 1$) exactly when the implicit reward has the pair *ordered wrongly* ($\hat r_l > \hat r_w$, i.e. the model currently prefers the rejected response), and small ($\to 0$) when the pair is already correctly and confidently ordered ($\hat r_w \gg \hat r_l$). This is the identical self-focusing dynamic as the RM's logistic loss in lesson 06 §6.2 — DPO spends gradient on the pairs it currently gets wrong. > [!tip] Why the importance weight matters — DPO is not naive log-likelihood > > A tempting-but-wrong objective is "just maximize $\log\pi_\theta(y_w)-\log\pi_\theta(y_l)$" (an unweighted contrastive loss). The DPO paper shows that objective degenerates — it drives the difference to infinity and destroys the model.[^dpo] The sigmoid's weight $\sigma(-u)$ is what saves it: once a pair is correctly ordered, its gradient vanishes, so the model doesn't endlessly inflate the margin on already-solved pairs. The nonlinearity is load-bearing, not cosmetic. --- ## 7. Failure modes and criticisms DPO is not a strict improvement on RLHF — it trades one set of problems for another. Every criticism below traces to one root: **DPO is offline and reward-free**, so it never samples from the current policy and never sees a signal outside the fixed preference dataset. ### 7.1 Offline / off-policy distribution shift (the big one) PPO is **on-policy**: it scores the policy's *own current samples*, so it always gets feedback exactly where the policy currently lives. DPO is **offline**: the pairs $(y_w, y_l)$ were generated once, by some *other* model (often the SFT model, or a mix of models), and never refreshed. So DPO optimizes the implicit reward only on the support of that fixed dataset. As $\pi_\theta$ moves during training, it generates responses the dataset never covered — and DPO has *nothing to say* about them, because there's no reward model to query on fresh samples and no sampling loop to surface them. The theory in §3–5 assumes access to the true preference distribution over *all* responses; in practice you have a finite, off-policy sample, and the closed-form equivalence to RLHF holds only to the extent that sample covers the relevant response space. > [!warning] Offline distribution shift is DPO's defining limitation > > The elegant derivation assumes you can fit the implicit reward everywhere it matters. With a fixed offline dataset you fit it only where the data lives — typically the SFT distribution — while the policy is free to move elsewhere, into regions where the implicit reward is *unconstrained* and can behave arbitrarily. This is the DPO analogue of RLHF's reward-model-blind-spot problem (lesson 06 §8.3), except you can't even *detect* it with a held-out RM score, because there is no RM. It is the single strongest argument for **iterative/online DPO** (§10) and for why well-tuned PPO can still win. ### 7.2 Likelihood displacement (the counter-intuitive one) You'd expect DPO to *raise* $\log\pi_\theta(y_w\mid x)$. Empirically, **the log-probability of the chosen response often goes *down* during training — and so does the rejected one, just faster.** The DPO loss only constrains the *difference* $\hat r_w - \hat r_l$; it is perfectly happy to *decrease both* absolute log-probs as long as $y_l$ drops more than $y_w$. This is **likelihood displacement** (Razin et al., 2024, [arXiv:2410.08847](https://arxiv.org/abs/2410.08847), also called the "squeezing effect" by Ren & Sutherland).[^likedisp][^squeeze] The consequence is not benign. When $y_w$ and $y_l$ are *semantically similar* (share tokens/embeddings — high "CHES" score in Razin et al.), pushing them apart bleeds probability mass off *both* and onto some third response — potentially one with the *opposite meaning*. In an AI-safety setting, DPO-training a model to prefer refusals over harmful completions was shown to *lower* the refusal rate, because mass displaced from the preferred refusal landed on a non-refusal — "unintentional unalignment."[^likedisp] The mechanism is intuitive once named: maximizing a margin between two nearby points can be achieved by evacuating the whole neighborhood. > [!warning] Likelihood displacement: rising margin ≠ rising chosen-likelihood > > Do not monitor only the reward margin $\hat r_w - \hat r_l$ (it will rise — that's what you optimized). **Track the absolute** $\log\pi_\theta(y_w\mid x)$ **too.** If it's falling, you are displacing mass, possibly toward off-target responses. Mitigations: filter pairs where $y_w,y_l$ are near-duplicates (high embedding similarity), add an SFT/NLL term on $y_w$ (as CPO/ORPO do — §9), or use a variant that pins the chosen likelihood. ### 7.3 Overfitting to (near-)deterministic preferences Bradley-Terry assumes preferences are *probabilistic*. If your labels are effectively deterministic ($P(y_w\succ y_l)\approx 1$ — the annotators always agree, or the data is synthetic and clean), the DPO loss wants $\sigma(u)\to 1$, i.e. $u=\hat r_w-\hat r_l\to+\infty$. Since $\hat r=\beta\log(\pi_\theta/\pi_\text{ref})$, driving the margin to infinity means driving $\pi_\theta(y_l)\to 0$ — the policy overfits, collapses probability off the rejected responses unboundedly, and the KL leash effectively fails to bind (this is worse for small $\beta$). This is the specific pathology **IPO** was designed to fix (§9). ### 7.4 Sensitivity to the reference and to SFT coverage DPO's implicit reward is $\beta\log(\pi_\theta/\pi_\text{ref})$ — the reference $\pi_\text{ref}$ is *inside the objective*, not just a leash. Consequences: (a) if $\pi_\text{ref}$ assigns very low probability to the chosen responses (e.g. the preference data is off-distribution from the SFT model that serves as reference), the log-ratios are ill-behaved and training is unstable; DPO implicitly assumes the SFT model already covers the preferred responses reasonably. (b) The common practice is $\pi_\text{ref}=\pi_\text{SFT}$, and DPO is typically run *right after* SFT on the same or related data; skipping a good SFT stage, or using a mismatched reference, degrades it sharply. (c) Reference-free variants (ORPO, SimPO, CPO — §9) exist precisely to remove this dependency and the memory cost of a second model. ### 7.5 When PPO / online RL still wins The on-policy-vs-offline debate is live and not settled in DPO's favor. The key empirical finding (e.g. Xu et al. 2024 "Is DPO Superior to PPO?"[^dpovsppo], and the Tülu/Llama post-training reports[^tulu3][^llama3]): **well-tuned on-policy methods (PPO, and online/iterative DPO) tend to beat vanilla offline DPO**[^dpovsppo], especially on harder capabilities (reasoning, code) and out-of-distribution generalization, precisely because they get fresh feedback where the policy currently is (§7.1). DPO's advantages are *operational* — simplicity, stability, cost, no reward model — not a guarantee of higher ceiling. The honest summary as of 2026: DPO (and its variants) is the **default for accessible, cheap alignment**; PPO-class online RL is retained where the extra quality justifies the machinery, and the frontier increasingly uses **online/iterative** preference optimization to get the best of both. > [!question]- Quiz 3: Give two mechanistically distinct reasons a DPO model can end up *worse* than its SFT starting point even while the training loss decreases monotonically. > > > [!success]- Answer > > **(1) Offline distribution shift (§7.1).** The loss decreases because the implicit-reward margin on the *fixed dataset pairs* is being maximized, but that says nothing about the policy's behavior on the *new* responses it now generates (which the offline data never covered). The policy can move into an unconstrained region of the implicit reward and degrade on real use while the training loss — computed only on stale pairs — keeps falling. There is no on-policy sample and no RM to catch it. **(2) Likelihood displacement (§7.2).** The loss only requires the *margin* $\hat r_w-\hat r_l$ to grow; it can achieve this by pushing $\log\pi_\theta(y_w)$ *down* as long as $\log\pi_\theta(y_l)$ falls faster. If $y_w,y_l$ are semantically similar, the displaced mass can land on a third, off-target (even opposite-meaning) response — so the model gets *worse at producing the preferred behavior* while the DPO loss looks healthy. Both show why "training loss down" is not a success criterion for DPO; you must monitor absolute chosen-likelihood and evaluate on held-out / on-policy signals. (A third acceptable answer: overfitting near-deterministic pairs (§7.3) driving $\pi_\theta(y_l)\to 0$ and collapsing the KL leash.) > [!question]- Quiz 4: DPO deletes the reward model, the value head, and the sampling loop from RLHF-PPO. For each, name the single biggest thing you *give up* by deleting it. > > > [!success]- Answer > > **Delete the reward model** → you give up an **explicit, queryable proxy that generalizes to unseen responses.** The RM can score *any* new sample (including the policy's fresh on-policy generations), enabling online correction and held-out overoptimization monitoring (Gao et al.'s gold-RM curves). DPO's implicit reward is only fit where the offline data lives; you can't query it meaningfully off-support, and you lose the ability to detect overoptimization by comparing to a gold RM. **Delete the value head / GAE** → you give up **per-token credit assignment and variance reduction.** PPO's critic converts the sparse terminal reward into a dense, localized per-token advantage (lesson 05 §5.2); DPO has only a sequence-level implicit reward (sum of token log-ratios) with no per-token attribution — coarser credit. **Delete the sampling loop (go offline)** → you give up **on-policy feedback.** PPO always evaluates the policy's *current* samples, so it never optimizes in a region it isn't actually visiting; DPO optimizes on a fixed off-policy dataset and suffers distribution shift (§7.1). The recurring theme: everything deleted was buying you *coverage/feedback outside the fixed dataset* — which is exactly what iterative/online DPO tries to buy back. --- ## 8. Worked practice > [!example]- Problem 1: Rederive the cancellation, and locate the exact assumption that makes DPO "RL-free" > > > **Problem.** (a) Starting from the KL-regularized objective for a single prompt, show $\pi^*(y\mid x)\propto \pi_\text{ref}(y\mid x)\exp(r(x,y)/\beta)$ using the "complete the KL" trick. (b) Invert to get $r$ in terms of $\pi^*$. (c) Show the DPO loss follows by substitution into Bradley-Terry, identifying the precise step where $Z(x)$ disappears. (d) Name the one property of $Z(x)$ that the entire construction relies on. > > > > **Worked solution.** > > **(a)** Fix $x$. Maximize $\mathbb{E}_{y\sim\pi}[r]-\beta\,\mathbb{E}_{y\sim\pi}[\log(\pi/\pi_\text{ref})]$. Divide by $\beta$, negate → $\min_\pi \mathbb{E}_{y\sim\pi}[\log\frac{\pi}{\pi_\text{ref}\exp(r/\beta)}]$. Define $Z(x)=\sum_y\pi_\text{ref}(y)\exp(r/\beta)$ and $\pi^*=\frac{1}{Z}\pi_\text{ref}\exp(r/\beta)$; substitute to get $\min_\pi \mathrm{KL}(\pi\|\pi^*)-\log Z(x)$. KL $\ge 0$ with equality iff $\pi=\pi^*$, and $\log Z$ is constant in $\pi$, so $\pi^*=\frac{1}{Z}\pi_\text{ref}\exp(r/\beta)$. ∎ > > **(b)** $\log\pi^*=\log\pi_\text{ref}+r/\beta-\log Z \Rightarrow r(x,y)=\beta\log\frac{\pi^*(y|x)}{\pi_\text{ref}(y|x)}+\beta\log Z(x)$. > > **(c)** BT: $P(y_w\succ y_l\mid x)=\sigma(r(x,y_w)-r(x,y_l))$. Substitute (b); the two $\beta\log Z(x)$ terms are identical (same $x$) and cancel — **this is the step** — leaving $\sigma(\beta\log\frac{\pi^*_w}{\pi_{\text{ref},w}}-\beta\log\frac{\pi^*_l}{\pi_{\text{ref},l}})$. Parameterize $\pi^*\to\pi_\theta$, take negative log-likelihood over $\mathcal{D}$ → $\mathcal{L}_\text{DPO}$. ∎ > > **(d)** $Z(x)$ depends **only on $x$** (and $r,\pi_\text{ref}$), **not on the response $y$** — because $\pi$ (hence any $y$-dependence of the optimizer) has been summed out. That $y$-independence is what makes it a per-prompt constant that BT's difference annihilates. This is also *exactly* why DPO never needs to compute the intractable $Z$ — the property that made it uncomputable (it's a full sum over responses) is the same property that makes it cancel. > > > > **The "RL-free" assumption, stated sharply:** DPO is RL-free because it replaces "*find* the policy that optimizes the reward" (an intractable optimization requiring sampling → RL) with "*express* the reward via the policy and fit the policy by MLE" (a supervised classification). This is valid **only if** the parameterized $\pi_\theta$ is expressive enough to represent the true optimal $\pi^*$, **and** the finite offline preference dataset adequately covers the response space where the implicit reward must be accurate. When either fails (limited coverage, off-policy drift), the exact equivalence to RLHF degrades — which is §7 in one sentence. > [!example]- Problem 2: β, the leash, and a numerical gradient step > > > **Problem.** A single pair $(x, y_w, y_l)$. Suppose the current per-response log-ratios are $\log\frac{\pi_\theta(y_w|x)}{\pi_\text{ref}(y_w|x)}=0.4$ and $\log\frac{\pi_\theta(y_l|x)}{\pi_\text{ref}(y_l|x)}=1.0$ (note: the model currently *prefers the rejected response* in implicit-reward terms). Use $\beta=0.1$. (a) Compute the implicit-reward margin $u$ and the DPO loss for this pair. (b) Compute the gradient weight $\sigma(-u)$ and interpret it. (c) Redo (a)–(b) with $\beta=1.0$ and explain what changed and why a practitioner might prefer the smaller $\beta$ here. (d) What does likelihood displacement warn you to check after the update? > > > > **Worked solution.** > > **(a)** $u=\beta(0.4-1.0)=0.1\cdot(-0.6)=-0.06$. Loss $=-\log\sigma(u)=-\log\sigma(-0.06)$. $\sigma(-0.06)\approx0.485$, so loss $\approx-\log(0.485)\approx0.724$ nats. (Above $\log 2\approx0.693$, as expected for a wrongly-ordered pair.) > > **(b)** Gradient weight $\sigma(-u)=\sigma(0.06)\approx0.515$. It's near $0.5$ (actually slightly above), i.e. **large** — signaling the pair is essentially mis-ordered/uncertain, so this example contributes a strong contrastive gradient: push $\log\pi_\theta(y_w)$ up, $\log\pi_\theta(y_l)$ down. (Weight would $\to 0$ only once $y_w$ is confidently ahead.) > > **(c)** With $\beta=1.0$: $u=1.0\cdot(-0.6)=-0.6$; loss $=-\log\sigma(-0.6)\approx-\log(0.354)\approx1.04$ nats; weight $\sigma(0.6)\approx0.646$. Larger $\beta$ **amplifies the same log-ratio gap into a bigger logit**, so both the loss and the gradient weight are larger — the model is penalized more strongly for the same deviation from $\pi_\text{ref}$, i.e. a **tighter KL leash**. A practitioner tuning on data where the SFT reference is decent and preferences are moderately noisy often prefers the *smaller* $\beta$ (looser leash) to let the policy actually move; too large a $\beta$ keeps $\pi_\theta$ glued to $\pi_\text{ref}$ and barely learns, while too small risks the overfitting/displacement pathologies of §7.3. ($\beta=0.1$ is the common default for exactly this balance.) > > **(d)** After the step, don't just confirm the margin $u$ increased — **check that $\log\pi_\theta(y_w\mid x)$ (absolute) did not *decrease*.** If it fell (with $\log\pi_\theta(y_l)$ falling faster), you're seeing likelihood displacement (§7.2): the margin improved by evacuating mass from *both* responses, which — if $y_w,y_l$ are similar — may be dumping probability onto an off-target third response rather than teaching the preferred behavior. --- ## 9. The variant zoo — one line each on what it fixes Every variant below is a targeted patch on one crack from §7. Verified current (Sept 2026) status and arXiv IDs: | Method | Ref-free? | Paired? | Core change | Fixes / motivation | |---|:--:|:--:|---|---| | **DPO** | no | yes | BT on implicit reward $\beta\log(\pi_\theta/\pi_\text{ref})$ | the baseline (§3–6) | | **IPO** | no | yes | replace $-\log\sigma$ with a **squared/regression** loss to a target margin | fixes BT **overfitting** on (near-)deterministic prefs (§7.3): bounds the objective so it can't drive $\hat r_w-\hat r_l\to\infty$ | | **KTO** | no* | **no (unpaired)** | **prospect-theoretic** utility on individual desirable/undesirable examples | removes the **paired-data** requirement; matches real feedback (thumbs up/down); risk-asymmetric (losses weighted heavier than gains) | | **ORPO** | **yes** | yes | **odds-ratio** penalty added to the SFT loss; **no reference model** | folds SFT + preference into **one stage, one model**; halves memory; its NLL term resists likelihood displacement / math-skill loss | | **SimPO** | **yes** | yes | reward = **length-normalized average** log-prob + a **target margin**; no reference | removes reference model **and** DPO's **length bias**; cheaper, strong benchmarks | | **CPO** | **yes** | yes | contrastive loss **+ behavior-cloning (NLL) regularizer** on $y_w$; no reference | reference-free; the NLL term pins chosen-likelihood (counters displacement); originated for machine translation | *KTO still uses a reference model for its implicit reward but needs no paired data. **One-line whats/whys:** - **IPO**[^ipo] — *Identity Preference Optimization*, Azar et al. 2024, [arXiv:2310.12036](https://arxiv.org/abs/2310.12036) ("A General Theoretical Paradigm..."). Swaps DPO's sigmoid-log link for a bounded regression toward a fixed margin $\tfrac{1}{2\beta}$, giving optimization a **well-defined stopping point** so deterministic-ish preferences can't push the model to collapse $\pi_\theta(y_l)\to 0$. The clean theoretical fix for §7.3. - **KTO**[^kto] — *Kahneman-Tversky Optimization*, Ethayarajh et al. 2024, [arXiv:2402.01306](https://arxiv.org/abs/2402.01306). Uses a **prospect-theory value function** over *unpaired* binary labels (this response is good / bad), so you can train on the thumbs-up/down signals production systems actually collect, and it bakes in human **loss-aversion asymmetry**. The fix for "I don't have clean pairs" (§5's shared-prompt requirement). - **ORPO**[^orpo] — *Odds Ratio Preference Optimization*, Hong et al. 2024, [arXiv:2403.07691](https://arxiv.org/abs/2403.07691). Adds a log-**odds-ratio** term to the plain SFT cross-entropy — **no reference model, no separate preference stage.** One model, one pass; the strongest single-stage simplification, and empirically the most resistant to the math/reasoning degradation other variants show. Fix for §7.4 (reference cost/sensitivity) + pipeline weight. - **SimPO**[^simpo] — *Simple Preference Optimization*, Meng et al. 2024, [arXiv:2405.14734](https://arxiv.org/abs/2405.14734) (NeurIPS 2024). Reference-free reward = **average per-token log-prob** (length-normalized) with an added target margin $\gamma$. Length normalization directly attacks DPO's **verbosity/length bias**; strong AlpacaEval-2/Arena-Hard numbers at lower cost. Fix for §7.4 + length bias. - **CPO**[^cpo] — *Contrastive Preference Optimization*, Xu et al. 2024, [arXiv:2401.08417](https://arxiv.org/abs/2401.08417). Reference-free contrastive loss **plus a behavior-cloning NLL term** on the preferred response; the NLL anchor keeps $\pi_\theta$ near the preferred-data distribution (a hedge against likelihood displacement). Introduced for MT where it beat DPO. > [!tip] The unifying view (RainbowPO, ICLR 2025) > > These are not seven unrelated algorithms — they're points in a small design space along a few axes: **(i) the link function** ($-\log\sigma$ for DPO, squared for IPO), **(ii) reference vs reference-free** (DPO/IPO/KTO vs ORPO/SimPO/CPO), **(iii) length normalization** (SimPO), **(iv) an added SFT/NLL anchor** (ORPO/CPO), **(v) paired vs unpaired** (KTO). RainbowPO ([arXiv](http://www.columbia.edu/~wt2319/RainbowPO.pdf)) ablates these and cautions that headline "beats DPO" claims are setup-sensitive; notably it found DPO's $-\log\sigma$ link often *empirically* beats IPO's regression link despite the weaker theory.[^rainbowpo] Treat the table as a menu of patches, not a strict ranking. --- ## 10. Practical guidance - **Iterative / online DPO is the real answer to §7.1.** Run DPO in rounds: after a round, **sample fresh responses from the current $\pi_\theta$**, get them labeled (by humans or a judge/RM — "online DPO" uses an on-the-fly preference signal), and DPO again on these *on-policy* pairs. This reintroduces the on-policy feedback that vanilla offline DPO threw away, and closes most of the gap to PPO. This is the dominant frontier recipe (Llama-3/Tülu-style post-training pipelines) as of 2026 — offline DPO is increasingly a *first* pass, not the whole thing.[^tulu3][^llama3] - **Data quality dominates.** DPO has no reward model to average out label noise and no online loop to self-correct, so it is *more* sensitive to preference-data quality than RLHF. **Filter aggressively:** drop pairs where $y_w\approx y_l$ semantically (high embedding similarity) — these are the ones that cause likelihood displacement (§7.2) — and ensure the chosen responses are actually in $\pi_\text{ref}$'s support. - **Tune $\beta$ deliberately.** It *is* the KL leash. Start at $\beta=0.1$. Too small → overfitting/displacement, unbounded margin growth, KL leash fails (§7.3); too large → policy barely moves off SFT. Sweep $\beta\in\{0.05,0.1,0.3,0.5\}$ and, as in RLHF, **report the operating point** (effective KL from $\pi_\text{ref}$). - **Monitor absolute chosen-likelihood, not just the loss/margin.** (§7.2 warning.) A falling $\log\pi_\theta(y_w)$ is the displacement alarm. - **Reference and SFT hygiene.** Use a *good* SFT model as $\pi_\text{ref}$, ideally SFT'd on data compatible with the preferred responses. If memory is the constraint, consider a reference-free variant (ORPO folds SFT in; SimPO/CPO drop the reference) — but know you're trading away the explicit KL-to-SFT anchor. - **Pick the variant by your constraint, not by leaderboard:** unpaired feedback → KTO; single-stage / memory-bound → ORPO; length bias hurting you → SimPO; deterministic/synthetic preferences overfitting → IPO; want a safety hedge on chosen-likelihood → CPO/ORPO's NLL anchor. --- ## 11. Reading order Work through these in order: 1. **The paper — start here:** [Direct Preference Optimization: Your Language Model is Secretly a Reward Model — Rafailov et al., 2023 (arXiv:2305.18290)](https://arxiv.org/abs/2305.18290). Read §4 and **Appendix A.1** for the exact derivation you just did (the "complete-the-KL" step and the $Z(x)$ cancellation), and §5 for the gradient interpretation. This lesson *is* that appendix, expanded. 2. **The overfitting critique + IPO:** [A General Theoretical Paradigm to Understand Learning from Human Preferences — Azar et al., 2023 (arXiv:2310.12036)](https://arxiv.org/abs/2310.12036). The $\Psi$PO framework; DPO and IPO as special cases; why the BT/sigmoid link overfits deterministic preferences (§7.3). 3. **Unpaired preference learning — KTO:** [KTO: Model Alignment as Prospect Theoretic Optimization — Ethayarajh et al., 2024 (arXiv:2402.01306)](https://arxiv.org/abs/2402.01306). The move away from paired Bradley-Terry data entirely. 4. **Reference-free / single-stage — ORPO:** [ORPO: Monolithic Preference Optimization without Reference Model — Hong et al., 2024 (arXiv:2403.07691)](https://arxiv.org/abs/2403.07691). Folding SFT and preference into one loss. 5. **Reference-free + length-debiased — SimPO:** [SimPO: Simple Preference Optimization with a Reference-Free Reward — Meng et al., 2024 (arXiv:2405.14734)](https://arxiv.org/abs/2405.14734). The length-normalized implicit reward. 6. **The failure mode to internalize:** [Unintentional Unalignment: Likelihood Displacement in DPO — Razin et al., 2024 (arXiv:2410.08847)](https://arxiv.org/abs/2410.08847). Why chosen-likelihood drops and how it can flip alignment; the CHES data-filtering fix. This is §7.2 in full. --- ## 12. What's next DPO closed the loop on *preference* optimization by deleting the RL machinery. The remaining threads pull on the two things DPO still needs — **human labels** and **preference pairs at all**: 1. **[[learn/rl/08-scaling-rlhf-and-alternatives]]** — **RLAIF / Constitutional AI replace the human labeler with an AI judge**, generating the very preference pairs DPO (or the RM) consumes. The natural sequel: DPO cut the *optimizer* cost; this cuts the *labeling* cost (the §10 bottleneck). Also covers the on-policy-vs-offline debate (§7.5) at scale and where the field's frontier post-training stack actually sits in 2026. 2. Circle back to **[[learn/rl/06-rlhf-pipeline]]** — reread §8 (reward overoptimization) now that you've seen DPO. Ask yourself: does DPO *escape* Goodhart, or just *hide* it inside an implicit reward you can no longer monitor with a gold RM? (Answer: mostly the latter — §7.1.) And once you hold both the RM-based and RL-free paradigms, the last deletion in the series — **[[learn/rl/09-rl-for-reasoning]]** (RLVR/GRPO: replace the *learned* reward with a *verifier*, drop the critic) — reads as the third corner of the design space: RLHF keeps all four models, DPO deletes three, GRPO keeps the loop but deletes the value head and the learned RM. --- ## 13. References [^dpo]: Rafailov, Sharma, Mitchell, Ermon, Manning, Finn — "Direct Preference Optimization: Your Language Model is Secretly a Reward Model" (2023), [arXiv:2305.18290](https://arxiv.org/abs/2305.18290). NeurIPS 2023. Origin of the DPO loss, the closed-form optimal policy / $Z(x)$-cancellation derivation (Appendix A.1), the implicit reward $\beta\log(\pi_\theta/\pi_\text{ref})$, and the degeneracy of the unweighted contrastive objective. [established] [^ipo]: Azar, Guo, Piot, Munos, Rowland, Valko, Calandriello — "A General Theoretical Paradigm to Understand Learning from Human Preferences" (2023), [arXiv:2310.12036](https://arxiv.org/abs/2310.12036). The $\Psi$PO framework; IPO as a bounded regression link that fixes DPO's overfitting on (near-)deterministic preferences. [established] [^kto]: Ethayarajh, Xu, Muennighoff, Jurafsky, Kiela — "KTO: Model Alignment as Prospect Theoretic Optimization" (2024), [arXiv:2402.01306](https://arxiv.org/abs/2402.01306). Prospect-theory utility over unpaired binary (desirable/undesirable) labels; removes the shared-prompt paired-data requirement. [established] [^orpo]: Hong, Lee, Thorne — "ORPO: Monolithic Preference Optimization without Reference Model" (2024), [arXiv:2403.07691](https://arxiv.org/abs/2403.07691). Odds-ratio penalty folded into the SFT loss; single-stage, reference-free. [established] [^simpo]: Meng, Xia, Chen — "SimPO: Simple Preference Optimization with a Reference-Free Reward" (2024), [arXiv:2405.14734](https://arxiv.org/abs/2405.14734). NeurIPS 2024. Length-normalized average-log-prob reward with a target margin; reference-free and length-debiased. [established] [^cpo]: Xu, Sharaf, Chen, Tan, Shen, Van Durme, Murray, Kim — "Contrastive Preference Optimization: Pushing the Boundaries of LLM Performance in Machine Translation" (2024), [arXiv:2401.08417](https://arxiv.org/abs/2401.08417). Reference-free contrastive loss plus a behavior-cloning NLL anchor on the preferred response. [established] [^likedisp]: Razin, Malladi, Bhaskar, Chen, Arora, Hanin — "Unintentional Unalignment: Likelihood Displacement in Direct Preference Optimization" (2024), [arXiv:2410.08847](https://arxiv.org/abs/2410.08847). ICLR 2025. Chosen-response log-prob can fall during DPO; CHES-score data filtering; the refusal-rate flip. [recent] [^squeeze]: Ren, Sutherland — "Learning Dynamics of LLM Finetuning" (2024), [arXiv:2407.10490](https://arxiv.org/abs/2407.10490). ICLR 2025. The "squeezing effect": negative gradients on rejected responses redistribute probability mass off both chosen and rejected. [recent] [^dpovsppo]: Xu, Fu, Gao, Ye, Liu, Mei, Wang, Yu, Wu — "Is DPO Superior to PPO for LLM Alignment? A Comprehensive Study" (2024), [arXiv:2404.10719](https://arxiv.org/abs/2404.10719). ICML 2024. Well-tuned PPO surpasses DPO across testbeds, especially code; DPO hurt by pretraining/SFT/preference distribution mismatch. [contested] [^rainbowpo]: Zhao, Winata, Das, Zhang, Yao, Tang, Sahu — "RainbowPO: A Unified Framework for Combining Improvements in Preference Optimization" (2024), [arXiv:2410.04203](https://arxiv.org/abs/2410.04203). ICLR 2025. Ablates the DPO-variant design space; finds "beats DPO" claims setup-sensitive and DPO's log-sigmoid link often beats IPO's regression link empirically. [recent] [^tulu3]: Lambert, Morrison, et al. (Allen Institute for AI) — "Tülu 3: Pushing Frontiers in Open Language Model Post-Training" (2024), [arXiv:2411.15124](https://arxiv.org/abs/2411.15124). Open post-training recipe combining SFT, DPO, and RLVR; frontier use of online/iterative preference optimization. [recent] [^llama3]: Grattafiori, Dubey, et al. (Meta) — "The Llama 3 Herd of Models" (2024), [arXiv:2407.21783](https://arxiv.org/abs/2407.21783). Post-training pipeline uses iterative rounds of rejection sampling + DPO on on-policy data. [recent] --- *Topic hub: [[topics/rl-for-llms]] | Reference pages: [[concepts/rlhf]], [[concepts/reward-model]], [[concepts/kl-regularization-rlhf]] | Filed: 2026-09-02*