Direct Preference Optimization: Your Language Model is Secretly a Reward Model

Rafael Rafailov, Archit Sharma, Eric Mitchell, Stefano Ermon, Christopher D. Manning, Chelsea Finn

2023 · NeurIPS

Direct Preference Optimization: Your Language Model is Secretly a Reward Model

Problem

Framing

RLHF alignment needs a reward model, on-policy sampling, and PPO tuning. DPO removes that stack by reparameterizing the KL-constrained reward objective as a single preference-classification loss. On TL;DR, it reaches about 61% GPT-4 win rate, above PPO's 57%.

Currently Used Methods

Foundational

Proposed Method

Architecture

DPO keeps the standard causal LM policy and a frozen reference policy πref\pi_{\mathrm{ref}}. The only new ingredient is a preference dataset (x,yw,yl)(x, y_w, y_l) and a classifier-style objective over sequence log-probability ratios.

Verified schematic: RLHF fits a reward model then uses RL, while DPO maps preference data directly to a final LM with maximum-likelihood-style training.

Loss / Objective

The paper optimizes preferred responses against rejected responses through the policy-relative log-ratio:

LDPO(πθ;πref)=E(x,yw,yl)D[logσ(βlogπθ(ywx)πref(ywx)βlogπθ(ylx)πref(ylx))]\mathcal{L}_{\mathrm{DPO}}(\pi_{\theta}; \pi_{\mathrm{ref}}) = - \mathbb{E}_{(x,y_w,y_l)\sim \mathcal{D}} \left[ \log \sigma \left( \beta \log \frac{\pi_{\theta}(y_w \mid x)}{\pi_{\mathrm{ref}}(y_w \mid x)} - \beta \log \frac{\pi_{\theta}(y_l \mid x)}{\pi_{\mathrm{ref}}(y_l \mid x)} \right) \right]

Sampling Rule / Algorithm

Its key change-of-variables gives the optimal policy for a reward under a KL penalty:

π(yx)=1Z(x)πref(yx)exp(1βr(x,y))\pi^{\ast}(y \mid x) = \frac{1}{Z(x)} \, \pi_{\mathrm{ref}}(y \mid x) \, \exp \left( \frac{1}{\beta} r(x,y) \right)

Training Procedure

Evaluation

Datasets

Metrics

Headline results

Verified results figure: left panel plots reward against \mathrm{KL}(\pi_{\theta}\|\pi_{\mathrm{ref}}) on IMDb sentiment; right panel plots TL;DR win rate versus sampling temperature for DPO, PPO, SFT, and baselines.

Ablations

Method Strengths and Weaknesses

Strengths

Weaknesses

Suggestions from the authors

Links

Prior Papers

Further Papers