Back to Reinforcement Learning Mind Map
中文·English
🎮 Reinforcement LearningID: dpo

Direct Preference Optimization

DPO 直接偏好优化
🎯Core Definition
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)Z(x) cancels: ① The KL-regularized RLHF objective maxπEx,yπ[r(x,y)]βDKL(ππref)\max_\pi \mathbb{E}_{x, y \sim \pi}[r(x,y)] - \beta\, D_{KL}(\pi \| \pi_{ref}) has the closed-form optimum π(yx)=1Z(x)πref(yx)er(x,y)/β\pi^*(y|x) = \frac{1}{Z(x)}\, \pi_{ref}(y|x)\, e^{r(x,y)/\beta}, where the partition function Z(x)=yπref(yx)er(x,y)/βZ(x) = \sum_y \pi_{ref}(y|x)\, e^{r(x,y)/\beta} depends only on xx, not on yy; ② rearrange to get the implicit reward r(x,y)=βlogπ(yx)πref(yx)+βlogZ(x)r(x,y) = \beta \log \frac{\pi^*(y|x)}{\pi_{ref}(y|x)} + \beta \log Z(x); ③ substitute into the Bradley-Terry preference model P(ywyl)=σ(r(x,yw)r(x,yl))P(y_w \succ y_l) = \sigma\left(r(x, y_w) - r(x, y_l)\right): subtracting the two terms cancels βlogZ(x)\beta \log Z(x) exactly (since ZZ does not depend on yy), leaving a preference probability over ratios — P(ywyl)=σ(βlogπ(ywx)πref(ywx)βlogπ(ylx)πref(ylx))P(y_w \succ y_l) = \sigma\left( \beta \log \frac{\pi^*(y_w|x)}{\pi_{ref}(y_w|x)} - \beta \log \frac{\pi^*(y_l|x)}{\pi_{ref}(y_l|x)} \right) Replacing π\pi^* with πθ\pi_\theta and maximizing the likelihood on preference data gives the DPO loss: LDPO(θ)=E(x,yw,yl)D[logσ(βlogπθ(ywx)πref(ywx)βlogπθ(ylx)πref(ylx))]\mathcal{L}_{DPO}(\theta) = -\mathbb{E}_{(x, y_w, y_l) \sim \mathcal{D}}\left[ \log \sigma\left( \beta \log \frac{\pi_\theta(y_w|x)}{\pi_{ref}(y_w|x)} - \beta \log \frac{\pi_\theta(y_l|x)}{\pi_{ref}(y_l|x)} \right) \right] ywy_w/yly_l are the chosen/rejected of a preference pair; πref\pi_{ref} is the reference policy (usually the SFT model); β\beta is the temperature/regularization strength: larger β\beta keeps the policy closer to πref\pi_{ref} with smaller KL but weaker preference exploitation; smaller β\beta fits preferences aggressively with higher gains but risks overfitting, style drift, and degradation (e.g. length bias and reward mimicry).
💡Use Cases
offline preference alignment (safety, helpfulness, style) whenever contrastive preference pairs exist; the 'SFT → DPO' recipe is the low-cost open-source default, and DPO can be mixed with GRPO (online RLVR + offline preference regularization).
Key Problems Solved
RLHF's four-stage pipeline (reward-model training → online sampling → PPO → KL tuning) is complex, unstable, and memory-hungry; DPO performs alignment in one supervised step — no reward model, no RL loop, no online sampling, with dramatically lower memory and compute — at the cost that preference-data quality directly determines the outcome: label noise, length bias, and reference-model bias are amplified.
🎯5 High-Frequency Exam Points
1
Write the DPO loss and explain every symbol (y_w/y_l/π_ref/β)?
2
Derivation: how does Z(x) cancel? Give the closed-form solution and the 3-step chain?
3
What does β mean? Effects of large vs small β?
4
Why does DPO need no reward model or RL? Its relation to the RLHF objective?
5
DPO vs GRPO selection criteria? DPO's main limitations (data quality, length bias, role of the reference model)?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Direct Preference Optimization"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardGroup Relative Policy OptimizationNext CardCoT & Reasoning RL

🔗 More Reinforcement Learning Knowledge Cards

Actor-CriticBehavioral CloningContextual BanditConservative Q-Learning