Direct Preference Optimization

2 min read

DPO (Rafailov et al., 2023) trains directly on preference pairs without a separate reward model or RL loop.

Key insight: the KL-regularized RLHF objective has a closed-form optimum,

π(yx)=1Z(x)πref(yx)exp ⁣(1βr(x,y))\pi^*(y|x) = \frac{1}{Z(x)}\pi_\text{ref}(y|x)\exp\!\left(\tfrac{1}{\beta}r(x,y)\right)

Rearranging to solve for the reward gives

r(x,y)=βlogπ(yx)πref(yx)+βlogZ(x)r^*(x, y) = \beta \log\frac{\pi^*(y|x)}{\pi_\text{ref}(y|x)} + \beta\log Z(x)

The intractable partition function Z(x)Z(x) is the same for ywy_w and yly_l, so it cancels in the Bradley-Terry preference probability — letting us reparameterize the reward in terms of the policy itself and drop the reward model entirely.

DPO loss:

LDPO(θ)=E(x,yw,yl)[logσ(βlogπθ(ywx)πref(ywx)βlogπθ(ylx)πref(ylx))]L_\text{DPO}(\theta) = -\mathbb{E}_{(x,y_w,y_l)}\left[\log\sigma\left(\beta\log\frac{\pi_\theta(y_w|x)}{\pi_\text{ref}(y_w|x)} - \beta\log\frac{\pi_\theta(y_l|x)}{\pi_\text{ref}(y_l|x)}\right)\right]

where ywy_w = preferred response, yly_l = dispreferred response.

Intuition: increase the relative probability of preferred responses over dispreferred ones, relative to the reference model.

DPO vs RLHF:

RLHFDPO
Reward modelRequired (separate training)Implicit
RL loopPPO (complex, unstable)Supervised loss (simple)
StabilityHarder to tuneMore stable
PerformancePotentially more powerfulCompetitive, sometimes better

DPO is simpler: one supervised training stage on preference data, no separate reward model, no RL. This has made it the default for many alignment setups.

See also: RLHF Pipeline, KL Penalty, Supervised Fine-Tuning

Linked from