Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

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

  • Problem Standard RLHF fits a reward model to human preference pairs and then runs reinforcement learning against it, a pipeline that is costly and often unstable.
  • Method Reparameterizes the reward through the log-ratio of the policy to a reference model, so a binary cross-entropy loss on preference pairs trains the policy directly.
  • Results Reached a GPT-4 win rate of 61% against reference summaries on TL;DR summarization at sampling temperature 0.0, versus 57% for PPO at its best temperature.

Figure 1: DPO optimizes for human preferences while avoiding reinforcement learning. Existing methods
for fine-tuning language models with human feedback first…

Figure 1 : DPO optimizes for human preferences while avoiding reinforcement learning. Existing methods for fine-tuning language models with human feedback first fit a reward model to a dataset of prompts and human preferences over pairs of responses, and then use RL to find a policy that maximizes the learned reward. In contrast, DPO directly optimizes for the policy best satisfying the preferences with a simple classification objective, fitting an implicit reward model whose corresponding optimal policy can be extracted in closed form.

Original paper · CC BY 4.0 · Rafael Rafailov, Archit Sharma, Eric Mitchell, Stefano Ermon, Christopher D. Manning, Chelsea Finn · Direct Preference Optimization: Your Language Model is Secretly a Reward Model · Original paper figure · Extracted the figure area from page 2 of the original PDF.

Why RLHF is costly to run

Standard RLHF first fits a reward model to pairs of human preferences, then optimizes the language model against that learned reward with reinforcement learning. The RL stage usually runs PPO with a KL penalty against the supervised starting model, which keeps the policy close to the region where the reward model is trusted. Figure 1 sets this two-stage pipeline beside DPO, which replaces both stages with one classification objective applied to the policy.

The pipeline trains several language models and samples from the policy during training, and the authors describe the result as complex and often unstable. DPO keeps the same goal, reward maximization with a KL-divergence constraint, but drops the separate reward model and the RL loop.

Turning the reward into a function of the policy

The starting point is the KL-constrained reward maximization problem, where the policy is pushed toward high reward while a KL term against the reference policy is weighted by β. Its optimal solution has a closed form: the reference policy reweighted by the exponentiated reward, divided by a normalizer Z(x) that depends only on the prompt.

\[\pi_r(y\mid x)=\frac{1}{Z(x)}\,\pi_{\mathrm{ref}}(y\mid x)\exp\!\Big(\tfrac{1}{\beta}\,r(x,y)\Big)\] Taking logarithms and rearranging expresses the reward through the optimal policy and the reference policy, up to a term that depends only on the prompt. \[r(x,y)=\beta\log\frac{\pi_r(y\mid x)}{\pi_{\mathrm{ref}}(y\mid x)}+\beta\log Z(x)\]

The Bradley-Terry model depends only on the difference between the rewards of two completions for the same prompt, so the Z(x) term cancels. The preference probability then depends only on the optimal policy and the reference policy. \[p^*(y_1\succ y_2\mid x)=\frac{1}{1+\exp\!\Big(\beta\log\frac{\pi^*(y_2\mid x)}{\pi_{\mathrm{ref}}(y_2\mid x)}-\beta\log\frac{\pi^*(y_1\mid x)}{\pi_{\mathrm{ref}}(y_1\mid x)}\Big)}\]

A trainable policy π_θ replaces the optimal policy, and maximum likelihood on the preference dataset gives a binary cross-entropy loss. \[L_{\mathrm{DPO}}(\pi_\theta;\pi_{\mathrm{ref}})=-\mathbb{E}_{(x,y_w,y_l)\sim D}\Big[\log\sigma\Big(\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)}\Big)\Big]\] The policy itself carries the reward: the implicit reward is β times the log-ratio of π_θ to π_ref, so no separate reward network is trained.

What the gradient pushes on

The gradient of the loss raises the log-likelihood of the preferred completion and lowers the log-likelihood of the dispreferred one. \[\nabla_\theta L_{\mathrm{DPO}}=-\beta\,\mathbb{E}\Big[\sigma\big(\hat r_\theta(x,y_l)-\hat r_\theta(x,y_w)\big)\big(\nabla_\theta\log\pi_\theta(y_w\mid x)-\nabla_\theta\log\pi_\theta(y_l\mid x)\big)\Big]\]

The sigmoid factor weights each example by how strongly the implicit reward ranks the dispreferred completion above the preferred one, so mis-ordered pairs get larger updates. The authors report that a naive version of the method without this weighting can make the language model degenerate, which they show in an appendix table.

Running DPO on a preference dataset

Completions are sampled from the reference policy for each prompt, labeled with human preferences, and collected into an offline dataset. The language model is then optimized to minimize the DPO loss for the chosen reference policy and β. Public preference datasets can be reused in place of new sampling and labeling.

The reference policy is set to the SFT model whenever that model is available, because the preference data was sampled from it. Without an SFT model, the reference is obtained by maximizing the likelihood of the preferred completions, which reduces the mismatch between the true reference distribution and the one DPO uses. Implementation details and hyperparameters are in Appendix B.

Why the reparameterization keeps every reward class

Two reward functions are equivalent when their difference depends only on the prompt x.

The Plackett-Luce family is under-specified, so identifiability constraints are usually needed before maximum likelihood estimates from the reward loss carry guarantees. The argument therefore selects one representative reward from each class rather than a unique reward.

Under mild assumptions, every reward class consistent with the Plackett-Luce models, and so with Bradley-Terry, can be written as β log π(y|x)/π_ref(y|x) for some model π. The projection that achieves this subtracts a prompt-only term from the reward, so the projected reward stays in the same equivalence class. \[f(r;\pi_{\mathrm{ref}},\beta)(x,y)=r(x,y)-\beta\log\sum_y\pi_{\mathrm{ref}}(y\mid x)\exp\!\Big(\tfrac{1}{\beta}r(x,y)\Big)\]

The selected reward is the one for which the sum over completions of π_ref(y|x) exp((1/β) r(x,y)) equals 1, which makes the induced π a valid distribution. The key step is to constrain the under-determined preference family so that the optimal policy stays analytically tractable for every prompt while the set of representable rewards is unchanged.

Why the PPO-style objective needs a normalizer

Viewing RL fine-tuning through control as inference, the objective maximizes expected reward minus a log-sum term over the reference policy, minus a KL term. \[\max_{\pi_\theta}\ \mathbb{E}_{\pi_\theta(y\mid x)}\Big[r_\phi(x,y)-\beta\log\sum_y\pi_{\mathrm{ref}}(y\mid x)\exp\!\Big(\tfrac{1}{\beta}r_\phi(x,y)\Big)-\beta\log\frac{\pi_\theta(y\mid x)}{\pi_{\mathrm{ref}}(y\mid x)}\Big]\]

The log-sum term acts as a soft value function of the reference policy, and it does not change the optimal solution. Without it the policy gradient can have high variance, and a learned value function is hard to optimize, so prior work normalized rewards with a human completion baseline. The DPO reparameterization gives a reward that needs no baseline.

Tasks, baselines and evaluation

In controlled sentiment generation, the prefix is a movie review from the IMDb dataset and the policy must generate positive text, with preference pairs labeled by a pre-trained sentiment classifier. The SFT model is GPT-2-large, fine-tuned until convergence on IMDb training reviews.

For summarization, the input is a Reddit forum post, the Reddit TL;DR dataset is used, and human preferences come from samples of a different but similarly trained SFT model. Single-turn dialogue uses the Anthropic Helpful and Harmless dataset of 170k dialogues, where no pre-trained SFT model exists, so an off-the-shelf model is fine-tuned on the preferred completions.

Sentiment is scored against the ground-truth classifier, while summarization and dialogue use GPT-4 win rates against a baseline, since the true reward is unknown. Baselines include zero-shot GPT-J for summarization, 2-shot Pythia-2.8B for dialogue, the SFT model, and Preferred-FT. Unlikelihood, PPO with a learned reward, PPO-GT, and Best of N, which samples N responses and returns the highest-scoring one, are also compared.

Reward against KL in sentiment generation

Each method was run with a sweep of conservativeness settings: target KL in {3, 6, 9, 12} for PPO, β in {0.05, 0.1, 1, 5} for DPO, and α in {0.05, 0.1, 0.5, 1} for unlikelihood. The sweep covers 22 runs in total, and each policy was evaluated every 100 training steps until convergence.

DPO gives the highest expected reward at every KL value examined on the frontier. The authors describe DPO as producing by far the most efficient frontier, with the highest reward while keeping KL low.

DPO and PPO optimize the same objective, and the authors find DPO's reward and KL trade-off strictly better than PPO's. DPO also gives a better frontier than PPO even when PPO is given the ground-truth reward (PPO-GT).

TL;DR summarization win rates

Samples were drawn at temperatures from 0.0 to 1.0 and judged by GPT-4 against the reference completions in the test split. DPO, PPO and Preferred-FT all fine-tune the same GPT-J SFT model.

DPO reached a win rate of about 61% at temperature 0.0, while PPO reached 57% at its optimal temperature of 0.0. DPO also reached a higher maximum win rate than the best of N baseline. The authors did not meaningfully tune DPO's β, so these numbers may understate what DPO can do.

Preferred-FT does not improve much over the SFT model.

In a human study, DPO samples at temperature 0.25 were preferred over PPO samples at temperature 0 in 58% of comparisons.

Anthropic HH dialogue results

The base model is Pythia-2.8B, and Preferred-FT trains a reference model on the chosen completions so that DPO starts within the model's distribution. Win rates are judged by GPT-4 against the preferred completions in the test subset with one step of interaction.

DPO is compared with the best of 128 Preferred-FT completions and with a 2-shot prompted Pythia-2.8B model, and performs as well or better at each method's best-performing temperature. A PPO-trained model on the Anthropic HH dataset could not beat the base Pythia-2.8B model at any tried prompt or temperature. Because both methods optimize the same reward, the authors treat Best of 128 as a rough proxy for PPO-level performance.

DPO is the only computationally efficient method evaluated that improves over the preferred completions, and it is similar to or better than the computationally demanding Best of 128 baseline. DPO converges to its best performance relatively quickly.

The figure shows GPT-4 win rates across sampling temperatures on the left and win rates over fine-tuning steps on the right, where DPO is the only method reported to improve over the chosen responses.

Shift to CNN/DailyMail news

The PPO and DPO summarization policies, trained on Reddit TL;DR, were evaluated on news articles from the CNN/DailyMail test split at temperatures 0 and 0.25. Win rates were computed against the ground-truth summaries with the GPT-4 (C) prompt, with the words forum post replaced by news article.

DPO does not use the unlabeled Reddit TL;DR prompts that PPO uses, so this is initial evidence of similar generalization, not a comparison of equal training data.

Checking GPT-4 judgments against humans

Two GPT-4 prompts were used, the simple GPT-4 (S) prompt and the concise GPT-4 (C) prompt.

Only the DPO and PPO-1 comparisons received multiple human judgments because of limited human raters.

Open questions and limits

The β hyperparameter was not meaningfully tuned in the summarization runs, so the reported DPO numbers may be conservative. The derivation assumes that human preferences follow the Bradley-Terry or Plackett-Luce model over latent rewards.

Models were evaluated only up to 6B parameters, and scaling DPO to much larger models is left to future work.

GPT-4 win rates depend on the wording of the prompt, and the authors note that future work should study how to elicit high-quality judgments. Reward over-optimization under DPO, including whether the slight drop in Figure 3 (right) is an instance of it, is an open question.

Paper info

Authors
Rafael Rafailov, Archit Sharma, Eric Mitchell, Stefano Ermon, Christopher D. Manning, Chelsea Finn
Venue
arXiv · Preprint
First published
2023-5-29
Added
2026-10-20
Updated
2024-7-29
Version
v3
arXiv
2305.18290
Category
cs.LG · cs.AI · cs.CL
Original paper terms
CC BY 4.0
What we show
Paper info, commentary and permitted figures from the original paper

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Abstract

While large-scale unsupervised language models (LMs) learn broad world knowledge and some reasoning skills, achieving precise control of their behavior is difficult due to the completely unsupervised nature of their training. Existing methods for gaining such steerability collect human labels of the relative quality of model generations and fine-tune the unsupervised LM to align with these preferences, often with reinforcement learning from human feedback (RLHF). However, RLHF is a complex and often unstable procedure, first fitting a reward model that reflects the human preferences, and then fine-tuning the large unsupervised LM using reinforcement learning to maximize this estimated reward without drifting too far from the original model. In this paper we introduce a new parameterization of the reward model in RLHF that enables extraction of the corresponding optimal policy in closed form, allowing us to solve the standard RLHF problem with only a simple classification loss. The resulting algorithm, which we call Direct Preference Optimization (DPO), is stable, performant, and computationally lightweight, eliminating the need for sampling from the LM during fine-tuning or performing significant hyperparameter tuning. Our experiments show that DPO can fine-tune LMs to align with human preferences as well as or better than existing methods. Notably, fine-tuning with DPO exceeds PPO-based RLHF in ability to control sentiment of generations, and matches or improves response quality in summarization and single-turn dialogue while being substantially simpler to implement and train.

Quote from the paper

Rafael Rafailov, Archit Sharma, Eric Mitchell, Stefano Ermon, Christopher D. Manning, Chelsea Finn (2023). Direct Preference Optimization: Your Language Model is Secretly a Reward Model. arXiv:2305.18290v3. https://arxiv.org/abs/2305.18290v3

BibTeX
@misc{rafailov2023direct,
  title = {{Direct Preference Optimization: Your Language Model is Secretly a Reward Model}},
  author = {Rafael Rafailov and Archit Sharma and Eric Mitchell and Stefano Ermon and Christopher D. Manning and Chelsea Finn},
  year = {2023},
  eprint = {2305.18290},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.18290v3}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up