DPO (Direct Preference Optimization) reparameterizes the KL-regularized RLHF objective into a closed-form loss over policy probability ratios, removing the reward model and the online RL loop. Derivation chain (3 steps) showing how the partition function
Z(x) cancels:
① The KL-regularized RLHF objective
maxπEx,y∼π[r(x,y)]−βDKL(π∥πref) has the closed-form optimum
π∗(y∣x)=Z(x)1πref(y∣x)er(x,y)/β, where the partition function
Z(x)=∑yπref(y∣x)er(x,y)/β depends only on
x, not on
y;
② rearrange to get the implicit reward
r(x,y)=βlogπref(y∣x)π∗(y∣x)+βlogZ(x);
③ substitute into the Bradley-Terry preference model
P(yw≻yl)=σ(r(x,yw)−r(x,yl)): subtracting the two terms cancels
βlogZ(x) exactly (since
Z does not depend on
y), leaving a preference probability over ratios —
P(yw≻yl)=σ(βlogπref(yw∣x)π∗(yw∣x)−βlogπref(yl∣x)π∗(yl∣x))
Replacing
π∗ with
πθ and maximizing the likelihood on preference data gives the DPO loss:
LDPO(θ)=−E(x,yw,yl)∼D[logσ(βlogπref(yw∣x)πθ(yw∣x)−βlogπref(yl∣x)πθ(yl∣x))]
yw/
yl are the chosen/rejected of a preference pair;
πref is the reference policy (usually the SFT model);
β is the temperature/regularization strength: larger
β keeps the policy closer to
πref with smaller KL but weaker preference exploitation; smaller
β fits preferences aggressively with higher gains but risks overfitting, style drift, and degradation (e.g. length bias and reward mimicry).