LLM Alignment: From PPO to DPO

On this page

Policy Gradients in Reinforcement Learning derived policy updates from sampled rewards. Language-model feedback often compares two responses instead of assigning a reward. We study two ways to learn from these comparisons: fit a reward model and optimize the policy with proximal policy optimization (PPO), or fit the policy directly with direct preference optimization (DPO).

The two approaches are connected by a reward objective that penalizes departure from a reference model using Kullback–Leibler (KL) divergence. We derive its optimal policy, use that policy to rewrite preference probabilities, and distinguish this population relationship from what either training procedure estimates.

Recap: Differentiating an expected reward

For a fixed prompt xx and reward rr that does not depend on the policy parameters, the score-function identity gives

∇θEY∼πθ(⋅∣x)[r(x,Y)]=EY∼πθ(⋅∣x)[r(x,Y)∇θlog⁡πθ(Y∣x)].\nabla_\theta\mathbb E_{Y\sim\pi_\theta(\cdot\mid x)}[r(x,Y)] =\mathbb E_{Y\sim\pi_\theta(\cdot\mid x)} [r(x,Y)\nabla_\theta\log\pi_\theta(Y\mid x)].

The expectation changes with the policy. Section 4 applies this calculation to a reward with a parameter-dependent KL penalty, whose derivative must also be included. The finite-support assumptions below justify differentiation.

1. Prompts, responses, and three different policies

To keep the derivations finite, let X\mathcal X be a finite prompt set and Yx\mathcal Y_x a finite set of valid responses to prompt xx. A finite vocabulary and maximum generation length TT suffice. A response includes its end-of-sequence token, with stopping forced by the horizon, and is padded after termination; padding is deterministic and contributes log-probability zero. We use undiscounted finite-episode returns.

For y=(y1,…,yT)y=(y_1,\ldots,y_T), an autoregressive language-model policy factors as

πθ(y∣x)=∏t=1Tπθ(yt∣ht),ht=(x,y<t).\pi_\theta(y\mid x)=\prod_{t=1}^T \pi_\theta(y_t\mid h_t),\qquad h_t=(x,y_{<t}).

The prefix hth_t is the state, the next token is the action, and appending the token determines the next state. This is the finite-horizon interpretation from RL Foundations. Assume positive probabilities on the common valid-response support and differentiability in θ\theta.

Keep three policies distinct:

SymbolRoleWhat stays fixed during an update?
q=πrefq=\pi_{\rm ref}Reference language model, often obtained by supervised fine-tuning (SFT)Frozen throughout the alignment phase considered here
πk\pi_kPolicy that generated PPO's current rollout batchFrozen while that batch is reused
πθ\pi_\thetaPolicy being optimizedIts parameters change

The reference and rollout policies may coincide initially but need not coincide later. All logarithms are natural; all response log-probabilities below are sums over generated tokens, not length averages.

The preference-data distribution

Fix an arbitrary ordering of Yx\mathcal Y_x. A canonical pair (U,V)(U,V) has U<VU<V, so its orientation is recorded before its preference label. Define the population sampling law

X∼ρpref,(U,V)∣X=x∼Qpair(⋅∣x),C∣X=x,U=u,V=v∼Bernoulli⁡(p∗(x,u,v)).\begin{aligned} X&\sim\rho_{\rm pref},\\ (U,V)\mid X=x&\sim Q_{\rm pair}(\cdot\mid x),\\ C\mid X=x,U=u,V=v &\sim\operatorname{Bernoulli}(p^*(x,u,v)). \end{aligned}

Here C=1C=1 means uu is preferred to vv. The preferred and rejected responses are (Yw,Yl)=(U,V)(Y_w,Y_l)=(U,V) when C=1C=1, and (V,U)(V,U) otherwise. Together, the prompt, pair, and label draws define the comparison distribution PprefP_{\rm pref}.

The pair distribution QpairQ_{\rm pair} describes how the data were collected, including their fixed ordering. It need not sample from the current policy. For example, the pairs may have been collected earlier from an SFT model.

For the empirical analysis, assume independent comparisons Oi=(Xi,Ui,Vi,Ci)∼iidPprefO_i=(X_i,U_i,V_i,C_i)\overset{\mathrm{iid}}\sim P_{\rm pref}. Write D={(xi,yw,i,yl,i)}i=1n\mathcal D=\{(x_i,y_{w,i},y_{l,i})\}_{i=1}^n for their realized, oriented form. An empirical average is over these fixed records, not newly sampled model responses. Repeated judgments or dependent annotators require a different sampling analysis.

2. From comparisons to a reward model

The Bradley–Terry model assumes a finite latent score r∗:{(x,y):y∈Yx}→Rr^*:\{(x,y):y\in\mathcal Y_x\}\to\mathbb R such that

p∗(x,u,v)=exp⁡(r∗(x,u))exp⁡(r∗(x,u))+exp⁡(r∗(x,v))=σ(r∗(x,u)−r∗(x,v)),σ(z)=11+e−z.\begin{aligned} p^*(x,u,v) &=\frac{\exp(r^*(x,u))}{\exp(r^*(x,u))+\exp(r^*(x,v))}\\ &=\sigma(r^*(x,u)-r^*(x,v)),\qquad \sigma(z)=\frac1{1+e^{-z}}. \end{aligned}

This is a modeling assumption about comparisons, not a consequence of language-model pretraining. We use unit logistic scale; any alternative preference-noise scale must be included explicitly or absorbed into r∗r^*.

For a fitted reward model rϕr_\phi, the conditional Bernoulli negative log-likelihood becomes

L^RM(ϕ)=−1n∑i=1n[Cilog⁡σ(Δϕ,i)+(1−Ci)log⁡σ(−Δϕ,i)]=−1n∑i=1nlog⁡σ(rϕ(xi,yw,i)−rϕ(xi,yl,i)),\begin{aligned} \widehat L_{\rm RM}(\phi) &=-\frac1n\sum_{i=1}^n \left[C_i\log\sigma(\Delta_{\phi,i}) +(1-C_i)\log\sigma(-\Delta_{\phi,i})\right]\\ &=-\frac1n\sum_{i=1}^n \log\sigma(r_\phi(x_i,y_{w,i})-r_\phi(x_i,y_{l,i})), \end{aligned}

where Δϕ,i=rϕ(xi,ui)−rϕ(xi,vi)\Delta_{\phi,i}=r_\phi(x_i,u_i)-r_\phi(x_i,v_i). The equality follows by orienting each pair according to its label. Adding any prompt-only constant c(x)c(x) to rϕ(x,y)r_\phi(x,y) leaves every comparison probability unchanged.

In reinforcement learning from human feedback (RLHF), this reward model can then score newly generated responses. Ouyang et al. (2022), Section 3.5 describe this SFT–reward-model–PPO pipeline. Their PPO-ptx variant also includes a pretraining-data term; the derivation here isolates the reward-minus-KL objective without that extra term.

Original Ouyang et al. Figure 2 shows three columns: human demonstrations train a supervised policy; labelers rank sampled responses to train a reward model; and a policy generates new responses whose reward-model scores guide PPO updates. Blue arrows mark data used to train each model.
Figure 1. Supervised fine-tuning, reward modeling, and PPO in InstructGPT. Original figure from Ouyang et al. (2022), Training language models to follow instructions with human feedback, Figure 2. This is the source's training pipeline, not an experiment run for this note. The article analyzes the reward-minus-KL component; InstructGPT's PPO-ptx variant includes an additional pretraining objective. Full resolution ↗Figure excerpt for discussion; copyright remains with the authors/rightsholder.

3. Solve the KL-regularized reward problem

For now fix a reward function rr, reference q(y∣x)>0q(y\mid x)>0, coefficient β>0\beta>0, and target prompt distribution ρ\rho. Define

Jr(π)=EX∼ρ[EY∼π(⋅∣X)[r(X,Y)]−βDKL(π(⋅∣X)∥q(⋅∣X))],DKL(π(⋅∣x)∥q(⋅∣x))=∑y∈Yxπ(y∣x)log⁡π(y∣x)q(y∣x).\begin{aligned} J_r(\pi) &=\mathbb E_{X\sim\rho}\left[ \mathbb E_{Y\sim\pi(\cdot\mid X)}[r(X,Y)] -\beta D_{\rm KL}(\pi(\cdot\mid X)\Vert q(\cdot\mid X))\right],\\ D_{\rm KL}(\pi(\cdot\mid x)\Vert q(\cdot\mid x)) &=\sum_{y\in\mathcal Y_x}\pi(y\mid x) \log\frac{\pi(y\mid x)}{q(y\mid x)}. \end{aligned}

Here the inner expectation draws a response from the candidate policy, while the outer expectation draws a prompt from ρ\rho. Neither distribution is automatically PprefP_{\rm pref}. In PPO-based RLHF, rr is typically a reward model fitted before the policy update. For the population connection to DPO, we will instead use the latent r∗r^*.

An exact optimizer and an exact objective gap

For each prompt define the partition function and exponentially tilted reference:

Zr(x)=∑y∈Yxq(y∣x)er(x,y)/β,πr(y∣x)=q(y∣x)er(x,y)/βZr(x).Z_r(x)=\sum_{y\in\mathcal Y_x}q(y\mid x)e^{r(x,y)/\beta},\qquad \pi_r(y\mid x)=\frac{q(y\mid x)e^{r(x,y)/\beta}}{Z_r(x)}.

Finiteness of Yx\mathcal Y_x and rr ensures 0<Zr(x)<∞0<Z_r(x)<\infty. Normalization makes πr\pi_r a positive probability distribution. Taking logarithms gives

log⁡πr(y∣x)q(y∣x)=r(x,y)β−log⁡Zr(x).\log\frac{\pi_r(y\mid x)}{q(y\mid x)} =\frac{r(x,y)}{\beta}-\log Z_r(x).

Next substitute this identity into the prompt-specific objective Jr,xJ_{r,x}. For any response distribution π\pi, with 0log⁡0=00\log0=0,

Jr,x(π)=∑yπ(y∣x)[r(x,y)−βlog⁡π(y∣x)q(y∣x)]=∑yπ(y∣x)[βlog⁡Zr(x)−βlog⁡π(y∣x)πr(y∣x)]=βlog⁡Zr(x)−βDKL(π(⋅∣x)∥πr(⋅∣x)).\begin{aligned} J_{r,x}(\pi) &=\sum_y\pi(y\mid x) \left[r(x,y)-\beta\log\frac{\pi(y\mid x)}{q(y\mid x)}\right]\\ &=\sum_y\pi(y\mid x) \left[\beta\log Z_r(x)-\beta\log\frac{\pi(y\mid x)}{\pi_r(y\mid x)}\right]\\ &=\beta\log Z_r(x) -\beta D_{\rm KL}(\pi(\cdot\mid x)\Vert\pi_r(\cdot\mid x)). \end{aligned}

Nonnegativity of KL divergence establishes the optimizer and its gap:

arg max⁡π(⋅∣x)Jr,x(π)=πr(⋅∣x),Jr(πr)−Jr(π)=βEX∼ρDKL(π(⋅∣X)∥πr(⋅∣X)).\boxed{ \begin{aligned} \operatorname*{arg\,max}_{\pi(\cdot\mid x)}J_{r,x}(\pi)&=\pi_r(\cdot\mid x),\\ J_r(\pi_r)-J_r(\pi) &=\beta\mathbb E_{X\sim\rho} D_{\rm KL}(\pi(\cdot\mid X)\Vert\pi_r(\cdot\mid X)). \end{aligned}}

Equality requires π=πr\pi=\pi_r on prompts with positive ρ\rho probability. This is an unrestricted-policy result; a neural policy class may not contain πr\pi_r. The reward–policy transformation is developed in Rafailov et al. (2023), Section 4 and Appendix A.1.

What the reference does

For two responses u,vu,v, the optimizer satisfies

πr(u∣x)πr(v∣x)=q(u∣x)q(v∣x)exp⁡ ⁣(r(x,u)−r(x,v)β).\frac{\pi_r(u\mid x)}{\pi_r(v\mid x)} =\frac{q(u\mid x)}{q(v\mid x)} \exp\!\left(\frac{r(x,u)-r(x,v)}{\beta}\right).

The reward changes the reference odds rather than replacing them. For fixed r,qr,q, πr→q\pi_r\to q as β→∞\beta\to\infty; as β↓0\beta\downarrow0, mass concentrates on the reward maximizers, preserving their relative reference weights. A zero reference probability would exclude a response from any policy with finite forward KL. Positivity avoids that support obstruction in our derivations.

4. PPO: optimize the reward using rollouts

Evaluating the closed-form optimizer requires the sum over responses in Zr(x)Z_r(x), whereas PPO updates a parameterized model from sampled responses. To connect that update to the objective, we first differentiate the regularized expected reward, then introduce the clipped surrogate.

The sequence-level score identity

Let PθP_\theta denote the joint rollout law

X∼ρ,Y∣X=x∼πθ(⋅∣x).X\sim\rho,\qquad Y\mid X=x\sim\pi_\theta(\cdot\mid x).

Hold r,q,β,ρr,q,\beta,\rho fixed while differentiating. Write

wθ(x,y)=r(x,y)−βlog⁡πθ(y∣x)q(y∣x),Sθ(x,y)=∇θlog⁡πθ(y∣x).w_\theta(x,y)=r(x,y)-\beta\log\frac{\pi_\theta(y\mid x)}{q(y\mid x)},\qquad S_\theta(x,y)=\nabla_\theta\log\pi_\theta(y\mid x).

Differentiating both the sampling probabilities and the log penalty gives

∇θJr(πθ)=E(X,Y)∼Pθ[wθ(X,Y)Sθ(X,Y)−βSθ(X,Y)]=E(X,Y)∼Pθ[(wθ(X,Y)−b(X))Sθ(X,Y)].\begin{aligned} \nabla_\theta J_r(\pi_\theta) &=\mathbb E_{(X,Y)\sim P_\theta} \left[w_\theta(X,Y)S_\theta(X,Y)-\beta S_\theta(X,Y)\right]\\ &=\mathbb E_{(X,Y)\sim P_\theta} \left[(w_\theta(X,Y)-b(X))S_\theta(X,Y)\right]. \end{aligned}

The second line uses normalization, exactly as in the policy-gradient derivation:

EY∼πθ(⋅∣x)[Sθ(x,Y)]=∑y∇θπθ(y∣x)=0.\mathbb E_{Y\sim\pi_\theta(\cdot\mid x)}[S_\theta(x,Y)] =\sum_y\nabla_\theta\pi_\theta(y\mid x)=0.

Thus both the extra −β-\beta term and any prompt-only baseline b(x)b(x) disappear after expectation. Discrete token sampling does not make the expected objective nondifferentiable; the score identity differentiates its probabilities without differentiating through a sampled token.

Why the KL cost can be assigned to tokens

The autoregressive factorization yields

log⁡πθ(y∣x)q(y∣x)=∑t=1Tlog⁡πθ(yt∣ht)q(yt∣ht).\log\frac{\pi_\theta(y\mid x)}{q(y\mid x)} =\sum_{t=1}^T\log\frac{\pi_\theta(y_t\mid h_t)}{q(y_t\mid h_t)}.

Let dπ,t(⋅∣x)d_{\pi,t}(\cdot\mid x) be the distribution of the prefix Ht=(x,Y<t)H_t=(x,Y_{<t}) generated by Y∼π(⋅∣x)Y\sim\pi(\cdot\mid x). The tower property gives the KL chain rule

DKL(π(⋅∣x)∥q(⋅∣x))=∑t=1TEY∼π(⋅∣x)log⁡π(Yt∣Ht)q(Yt∣Ht)=∑t=1TEH∼dπ,t(⋅∣x)DKL(π(⋅∣H)∥q(⋅∣H)).\begin{aligned} D_{\rm KL}(\pi(\cdot\mid x)\Vert q(\cdot\mid x)) &=\sum_{t=1}^T\mathbb E_{Y\sim\pi(\cdot\mid x)} \log\frac{\pi(Y_t\mid H_t)}{q(Y_t\mid H_t)}\\ &=\sum_{t=1}^T\mathbb E_{H\sim d_{\pi,t}(\cdot\mid x)} D_{\rm KL}(\pi(\cdot\mid H)\Vert q(\cdot\mid H)). \end{aligned}

An individual sampled log-ratio can be negative; its conditional expectation is a nonnegative KL divergence. The prefix law matters: averaging token KLs over unrelated fixed prefixes is not the sequence KL above.

At rollout iteration kk, freeze a fitted reward rϕr_\phi, reference qq, and old policy πk\pi_k. A standard reward shaping choice on a sampled sequence is

gk,t=−βlog⁡πk(Yt∣Ht)q(Yt∣Ht)+1{t=T}rϕ(X,Y).g_{k,t}=-\beta\log\frac{\pi_k(Y_t\mid H_t)}{q(Y_t\mid H_t)} +\mathbf1\{t=T\}r_\phi(X,Y).

It sums to wπk(X,Y)w_{\pi_k}(X,Y). The terminal score can equivalently be placed at the actual termination time before deterministic padding. The frozen shaped-reward policy gradient agrees with the regularized gradient at πk\pi_k, by the zero-score calculation above; away from that policy it is a local training construction, not the same objective for every θ\theta.

The clipped token update

Let PkP_k be X∼ρX\sim\rho, Y∣X∼πk(⋅∣X)Y\mid X\sim\pi_k(\cdot\mid X). The formulas assume responses are sampled from this policy. Changing the sampling temperature or removing tokens from its distribution changes that assumption.

Fit a value critic from the rollouts and obtain advantages A^k,t\widehat A_{k,t} for the shaped rewards. The critic targets the old policy's expected remaining return given HtH_t; the actor–critic note explains return and GAE estimators. In the expected surrogate below, we hold the critic fixed and treat each advantage estimate as a specified function of the rollout. During the actual batch update, we hold the recorded advantage estimates fixed.

The token likelihood ratio and clipped surrogate are

Rθ,k,t=πθ(Yt∣Ht)πk(Yt∣Ht),Lkclip(θ)=E(X,Y)∼Pk∑t=1Tmin⁡ ⁣{Rθ,k,tA^k,t,clip⁡(Rθ,k,t,1−ϵ,1+ϵ)A^k,t},0<ϵ<1.\begin{aligned} R_{\theta,k,t} &=\frac{\pi_\theta(Y_t\mid H_t)}{\pi_k(Y_t\mid H_t)},\\ L_k^{\rm clip}(\theta) &=\mathbb E_{(X,Y)\sim P_k}\sum_{t=1}^T \min\!\left\{R_{\theta,k,t}\widehat A_{k,t}, \operatorname{clip}(R_{\theta,k,t},1-\epsilon,1+\epsilon) \widehat A_{k,t}\right\},\quad 0<\epsilon<1. \end{aligned}

In implementation, the expectation is replaced by the rollout-batch average. Condition on that batch and its fitted advantages during the actor update. The critic, data collection, and subsequent rollout refresh are separate operations. This is the clipped actor objective of Schulman et al. (2017), Section 3, applied to the token process.

Original PPO Figure 1. With positive advantage the objective rises with the probability ratio and then plateaus above one plus epsilon. With negative advantage it is flat below one minus epsilon and decreases thereafter. Red markers indicate the initial ratio one.
Figure 2. The PPO paper's clipped-surrogate figure. Original figure from Schulman et al. (2017), Proximal Policy Optimization Algorithms, Figure 1. The horizontal axis is the new-to-old action-probability ratio r. These are the authors' original objective plots, not new experimental evidence. Full resolution ↗Figure excerpt for discussion; copyright remains with the authors/rightsholder.

The old policy in Rθ,k,tR_{\theta,k,t} is not the reference qq. Clipping discourages particular profitable ratio changes relative to πk\pi_k; it does not impose a hard KL bound relative to qq. Nor is a token ratio the whole-response ratio, which equals ∏tRθ,k,t\prod_t R_{\theta,k,t}. These distinctions parallel the local-versus-joint clipping discussion.

5. DPO: eliminate the explicit reward model

Now use the population reward r∗r^* from the Bradley–Terry model and let π∗=πr∗\pi^*=\pi_{r^*} be its unrestricted KL-regularized optimizer. The identity from Section 3 gives

r∗(x,y)=βlog⁡π∗(y∣x)q(y∣x)+βlog⁡Zr∗(x).r^*(x,y)=\beta\log\frac{\pi^*(y\mid x)}{q(y\mid x)} +\beta\log Z_{r^*}(x).

Because a comparison uses the same prompt for both responses, subtracting their rewards cancels the partition term:

r∗(x,u)−r∗(x,v)=β[log⁡π∗(u∣x)q(u∣x)−log⁡π∗(v∣x)q(v∣x)]+βlog⁡Zr∗(x)−βlog⁡Zr∗(x).\begin{aligned} r^*(x,u)-r^*(x,v) &=\beta\left[\log\frac{\pi^*(u\mid x)}{q(u\mid x)} -\log\frac{\pi^*(v\mid x)}{q(v\mid x)}\right]\\ &\quad+\beta\log Z_{r^*}(x)-\beta\log Z_{r^*}(x). \end{aligned}

Consequently, the preference probability can be parameterized by a policy alone. For a candidate πθ\pi_\theta define the pair margin

mθ(x,u,v)=β[log⁡πθ(u∣x)q(u∣x)−log⁡πθ(v∣x)q(v∣x)].m_\theta(x,u,v)=\beta\left[ \log\frac{\pi_\theta(u\mid x)}{q(u\mid x)} -\log\frac{\pi_\theta(v\mid x)}{q(v\mid x)}\right].

Substitute σ(mθ)\sigma(m_\theta) into the conditional Bernoulli likelihood. Orienting each observed pair yields

L^DPO(θ)=−1n∑i=1nlog⁡σ ⁣(β[log⁡πθ(yw,i∣xi)q(yw,i∣xi)−log⁡πθ(yl,i∣xi)q(yl,i∣xi)]).\boxed{\widehat L_{\rm DPO}(\theta) =-\frac1n\sum_{i=1}^n \log\sigma\!\left(\beta\left[ \log\frac{\pi_\theta(y_{w,i}\mid x_i)}{q(y_{w,i}\mid x_i)} -\log\frac{\pi_\theta(y_{l,i}\mid x_i)}{q(y_{l,i}\mid x_i)} \right]\right).}

This is the loss in Rafailov et al., equation (7) and Appendix A.2. It uses fixed preference pairs, with no newly sampled language-model rollout inside the standard DPO optimization loop. Collecting the original pairs may still have required generation and annotation.

Original Rafailov et al. Figure 1 compares two pipelines. On the left, preference pairs fit a reward model, then the language model samples completions and receives reward labels during reinforcement learning. On the right, preference data directly train the final language model by maximum likelihood.
Figure 3. The DPO paper's comparison of preference-learning pipelines. Original figure from Rafailov et al. (2023), Direct Preference Optimization: Your Language Model is Secretly a Reward Model, Figure 1. The figure illustrates the standard fixed-preference DPO loop. It does not mean that preference collection needs no generation, or that every empirical DPO solution recovers the unrestricted optimal policy. Full resolution ↗Figure excerpt for discussion; copyright remains with the authors/rightsholder.

For any positive normalized candidate policy π\pi, the implicit reward

r~π(x,y)=βlog⁡π(y∣x)q(y∣x)\widetilde r_\pi(x,y)=\beta\log\frac{\pi(y\mid x)}{q(y\mid x)}

has Zr~π(x)=∑yq(y∣x)π(y∣x)/q(y∣x)=1Z_{\widetilde r_\pi}(x)=\sum_y q(y\mid x)\pi(y\mid x)/q(y\mid x)=1. Its regularized optimal policy is therefore exactly π\pi. This representation is the reward-equivalence result underlying DPO; it does not say that an arbitrary learned r~π\widetilde r_\pi equals the true preference reward.

The DPO gradient

For one oriented pair, set m=mθ(x,yw,yl)m=m_\theta(x,y_w,y_l) and ℓ=−log⁡σ(m)\ell=-\log\sigma(m). Since dℓ/dm=σ(m)−1=−σ(−m)d\ell/dm=\sigma(m)-1=-\sigma(-m) and qq is frozen,

∇θℓ=−βσ(−m)[∇θlog⁡πθ(yw∣x)−∇θlog⁡πθ(yl∣x)].\boxed{\nabla_\theta\ell =-\beta\sigma(-m) \left[\nabla_\theta\log\pi_\theta(y_w\mid x) -\nabla_\theta\log\pi_\theta(y_l\mid x)\right].}

Each sequence score is a token sum:

∇θlog⁡πθ(y∣x)=∑t=1T∇θlog⁡πθ(yt∣x,y<t).\nabla_\theta\log\pi_\theta(y\mid x) =\sum_{t=1}^T\nabla_\theta\log\pi_\theta(y_t\mid x,y_{<t}).

A gradient-descent update increases this pair's margin to first order by ησ(−m)∥∇θm∥22\eta\sigma(-m)\|\nabla_\theta m\|_2^2 for learning rate η>0\eta>0. Poorly fitted or reversed comparisons receive more weight through σ(−m)\sigma(-m). Shared parameters mean that other pairs' margins, and even a preferred response's absolute probability, need not all increase. If πθ=q\pi_\theta=q initially, every initial pair margin is zero and its weight is 1/21/2.

6. When does population DPO identify the optimal policy?

Rewriting the reward gives a preference loss, but does not yet show that fitting it determines the optimal policy. That requires enough observed comparisons to identify relative response probabilities. The following finite-response result states the needed coverage conditions.

Proposition: identification from connected comparisons

Assume the finite setup of Section 1, β>0\beta>0, positive qq, and Bradley–Terry preferences generated by the finite reward r∗r^*. Suppose:

  • Every target prompt with ρ(x)>0\rho(x)>0 also has ρpref(x)>0\rho_{\rm pref}(x)>0.
  • At each such prompt, the undirected graph with response vertices and an edge {u,v}\{u,v\} whenever Qpair(u,v∣x)>0Q_{\rm pair}(u,v\mid x)>0 is connected.
  • We minimize the population DPO risk over all positive response distributions, or over a class containing π∗\pi^*, and a global minimum is attained.

Then every population minimizer equals π∗(⋅∣x)\pi^*(\cdot\mid x) on the target prompts. This is a population identification statement, not a finite-sample or optimization-rate guarantee.

The Bernoulli loss determines edge probabilities

First fix a prompt and a pair. Write p=p∗(x,u,v)∈(0,1)p=p^*(x,u,v)\in(0,1) and s=σ(mπ(x,u,v))s=\sigma(m_\pi(x,u,v)). Averaging only over C∼Bernoulli⁡(p)C\sim\operatorname{Bernoulli}(p) gives

ℓp(s)=EC∼Bernoulli⁡(p)[−Clog⁡s−(1−C)log⁡(1−s)]=−plog⁡s−(1−p)log⁡(1−s).\begin{aligned} \ell_p(s) &=\mathbb E_{C\sim\operatorname{Bernoulli}(p)} [-C\log s-(1-C)\log(1-s)]\\ &=-p\log s-(1-p)\log(1-s). \end{aligned}

Subtract its value at the true probability:

ℓp(s)−ℓp(p)=plog⁡ps+(1−p)log⁡1−p1−s=DKL(Bernoulli⁡(p)∥Bernoulli⁡(s))≥0,\begin{aligned} \ell_p(s)-\ell_p(p) &=p\log\frac p s+(1-p)\log\frac{1-p}{1-s}\\ &=D_{\rm KL}(\operatorname{Bernoulli}(p)\Vert \operatorname{Bernoulli}(s))\ge0, \end{aligned}

with equality only at s=ps=p. Let ν(x,u,v)=ρpref(x)Qpair(u,v∣x)\nu(x,u,v)=\rho_{\rm pref}(x)Q_{\rm pair}(u,v\mid x) be the prompt-pair law. Its population risk is

LDPO(π)=E(X,U,V)∼νℓp∗(X,U,V)(σ(mπ(X,U,V))).L_{\rm DPO}(\pi) =\mathbb E_{(X,U,V)\sim\nu} \ell_{p^*(X,U,V)}(\sigma(m_\pi(X,U,V))).

The policy π∗\pi^* realizes the true probability on every pair by Section 5. Consequently,

LDPO(π)−LDPO(π∗)=E(X,U,V)∼νDKL ⁣(Bernoulli⁡(p∗)∥Bernoulli⁡(σ(mπ))).L_{\rm DPO}(\pi)-L_{\rm DPO}(\pi^*) =\mathbb E_{(X,U,V)\sim\nu} D_{\rm KL}\!\left(\operatorname{Bernoulli}(p^*)\Vert \operatorname{Bernoulli}(\sigma(m_\pi))\right).

At a global minimum, the excess risk is zero. Each summand is nonnegative, so positive edge weights imply σ(mπ)=p∗\sigma(m_\pi)=p^* on every observed edge. Thus the loss is minimized only at the true preference probability for each compared pair. This property, called strict propriety, is also used in logistic regression.

Connectivity determines the remaining normalization

Because the sigmoid is one-to-one, matching the edge probabilities implies

βlog⁡π(u∣x)q(u∣x)−r∗(x,u)=βlog⁡π(v∣x)q(v∣x)−r∗(x,v)\beta\log\frac{\pi(u\mid x)}{q(u\mid x)}-r^*(x,u) =\beta\log\frac{\pi(v\mid x)}{q(v\mid x)}-r^*(x,v)

on every edge. Connectivity propagates this equality along paths, so the common value is a single constant c(x)c(x) across all responses. Thus

π(y∣x)=q(y∣x)er∗(x,y)/βec(x)/β.\pi(y\mid x)=q(y\mid x)e^{r^*(x,y)/\beta}e^{c(x)/\beta}.

Finally, summing over yy forces ec(x)/β=1/Zr∗(x)e^{c(x)/\beta}=1/Z_{r^*}(x), hence π=π∗\pi=\pi^*. Prompt coverage transfers the conclusion to every target prompt. The proof requires no assumption that the collection policy equals the optimal policy, but it does require enough comparisons to identify all relative response scores.

What missing comparisons leave unidentified

If only responses aa and bb are compared while cc is never compared, take a uniform reference. The policies

π1=(0.2,0.2,0.6),π2=(0.4,0.4,0.2)\pi_1=(0.2,0.2,0.6),\qquad \pi_2=(0.4,0.4,0.2)

have the same ratio π(a)/π(b)=1\pi(a)/\pi(b)=1 and therefore the same predicted aa-versus-bb preference probability 1/21/2. No number of those comparisons identifies the mass assigned to cc. Within a disconnected comparison graph, components can retain different normalizing constants.

Finite datasets introduce a further issue: a pair may have only one observed label even though its population preference probability is strictly between zero and one. Driving that empirical loss toward zero is not the same as recovering the population probability. With a restricted neural class, model misspecification, or incomplete optimization, the proposition's premises may also fail.

7. A two-response calculation

Fix one prompt with responses a,ba,b and reference probabilities q(a)=1/5q(a)=1/5, q(b)=4/5q(b)=4/5. Suppose

P(C=1∣a,b)=34,β=12.\mathbb P(C=1\mid a,b)=\frac34,\qquad \beta=\frac12.

The Bradley–Terry reward difference is r∗(a)−r∗(b)=log⁡3r^*(a)-r^*(b)=\log3. Choose the equivalent reward r∗(a)=log⁡3r^*(a)=\log3, r∗(b)=0r^*(b)=0. The regularized optimum is

Z=15e2log⁡3+45=135,π∗(a)=(1/5) 913/5=913,π∗(b)=413.\begin{aligned} Z&=\tfrac15 e^{2\log3}+\tfrac45=\tfrac{13}{5},\\ \pi^*(a)&=\frac{(1/5)\,9}{13/5}=\frac9{13},\qquad \pi^*(b)=\frac4{13}. \end{aligned}

Now recover the same policy from the population DPO loss. For p=π(a)p=\pi(a), the margin and conditional risk are

m(p)=12log⁡4p1−p,L(p)=−34log⁡σ(m(p))−14log⁡σ(−m(p)).m(p)=\frac12\log\frac{4p}{1-p},\qquad L(p)=-\tfrac34\log\sigma(m(p)) -\tfrac14\log\sigma(-m(p)).

The preceding Bernoulli argument minimizes this at σ(m(p))=3/4\sigma(m(p))=3/4, hence

m(p)=log⁡3⟹4p1−p=9⟹p=913.m(p)=\log3 \quad\Longrightarrow\quad \frac{4p}{1-p}=9 \quad\Longrightarrow\quad p=\frac9{13}.

The 75% preference probability does not mean a 75% generation probability. The latter also depends on the reference and regularization coefficient. Here it is about 69.23%.

8. The DPO training procedure

Algorithm 1 Standard offline DPO fine-tuning

Input: fixed preference dataset D\mathcal D, frozen reference qq, positive policy πθ0\pi_{\theta_0}, β>0\beta>0, learning rates, and update budget KK.

Output: fitted language-model policy πθK\pi_{\theta_K}.

  1. For each record, cache the reference response log-probabilities log⁡q(yw∣x)\log q(y_w\mid x) and log⁡q(yl∣x)\log q(y_l\mid x), or evaluate them with frozen reference parameters.
  2. For k=0,…,K−1k=0,\ldots,K-1:
  3. Draw a minibatch of record indices uniformly from {1,…,n}\{1,\ldots,n\}; do not generate new policy responses.
  4. Evaluate log⁡πθk(yw∣x)\log\pi_{\theta_k}(y_w\mid x) and log⁡πθk(yl∣x)\log\pi_{\theta_k}(y_l\mid x) by teacher forcing on the recorded tokens.
  5. Sum generated-token log-probabilities, including EOS; mask prompt and deterministic padding tokens.
  6. Compute each reference-adjusted margin mθkm_{\theta_k} and the minibatch average of −log⁡σ(mθk)-\log\sigma(m_{\theta_k}).
  7. Update θk+1=θk−ηk∇^θLk\theta_{k+1}=\theta_k-\eta_k\widehat\nabla_\theta L_k, or use a specified gradient-based optimizer.
  8. End for.
  9. Return πθK\pi_{\theta_K}.

Conditional on D\mathcal D and the current θ\theta, let I∼Unif⁡{1,…,n}I\sim\operatorname{Unif}\{1,\ldots,n\} select a record independently of previous update randomness. For its loss ℓI\ell_I, uniform sampling gives

EI∼Unif⁡{1,…,n}[∇θℓI(θ)∣D,θ]=1n∑i=1n∇θℓi(θ)=∇θL^DPO(θ).\mathbb E_{I\sim\operatorname{Unif}\{1,\ldots,n\}} [\nabla_\theta\ell_I(\theta)\mid\mathcal D,\theta] =\frac1n\sum_{i=1}^n\nabla_\theta\ell_i(\theta) =\nabla_\theta\widehat L_{\rm DPO}(\theta).

Averaging independently sampled indices preserves this equality. The gradient is unbiased for the empirical objective, not automatically for Jr∗J_{r^*}; it does not imply that optimization finds a global population minimizer. No separate learned reward network or value critic is required by this standard DPO procedure.

9. What is shared, and what is different?

QuestionPPO-based RLHFStandard offline DPO
How are preferences used?Fit an explicit reward model rϕr_\phiFit a policy-induced Bradley–Terry model
What is averaged during the actor update?Old-policy rollout tokens with fixed advantage estimatesRecorded preferred/rejected response pairs
Is new generation required during training?New rollout batches are collected as the policy changesNot inside the fixed-dataset optimization loop
What is the probability ratio?Current token policy divided by the old rollout policyCurrent response likelihood divided by the frozen reference
How does the reference enter?KL-based reward shaping or a specified regularized objectiveReference-adjusted pair margins
What does the central derivation establish?A policy-gradient identity and a practical clipped surrogateA reward–policy reparameterization and a preference likelihood

PPO is a general policy optimizer; DPO is a direct preference-learning construction, not a newer PPO clipping rule. Their shared population connection assumes the same preference reward, reference, and coefficient. Fitting rϕr_\phi with one restricted class and fitting πθ\pi_\theta by DPO with another need not yield identical fitted policies.

For a fixed reward, β\beta controls the exact optimizer's deviation from the reference, as Section 3 shows. In a finite-sample DPO run, however, changing β\beta changes both the classification margins and the learned implicit reward. The fixed-reward formula therefore does not guarantee monotone realized KL behavior for fitted DPO policies.

Finally, Bradley–Terry assumes a scalar reward can describe the comparisons. Annotator disagreement, systematic preference cycles, distribution shift and missing response coverage can challenge that model. Neither a lower empirical DPO loss nor a larger learned PPO reward is, by itself, a guarantee of truthfulness, safety, or improved human judgments outside the evaluated setting.

Continue with GRPO: Learning from Groups of Responses, which keeps rollout-based optimization but replaces the separately fitted value critic with group-relative comparisons of sampled rewards.

References

  1. Rafailov, R., Sharma, A., Mitchell, E., Ermon, S., Manning, C. D., and Finn, C. (2023). Direct Preference Optimization: Your Language Model is Secretly a Reward Model. Sections 3–5 and Appendices A.1–A.6; figure excerpt uses version 1.
  2. Ouyang, L., et al. (2022). Training language models to follow instructions with human feedback. RLHF pipeline, Figure 2, Section 3.5 of version 1 and equation (2).
  3. Schulman, J., Wolski, F., Dhariwal, P., Radford, A., and Klimov, O. (2017). Proximal Policy Optimization Algorithms. Clipped surrogate and original Figure 1.