# Direct Preference Optimization in One Minute

The [Direct Preference Optimization (DPO) paper](https://arxiv.org/pdf/2305.18290.pdf) promises a more simple and efficient alternative to proximal policy optimization that is able to void the reward modeling phase, and thus optimize directly for the preferences expressed in preference data. This is achieved through the loss function:

$L_{DPO}(\pi_{\theta};\pi_{ref}) = -\mathbb{E}_{(x,y_w,y_l) \sim 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]$

Where:

*   $x$ is some prompt
*   $\pi_{\theta}(y_w | x)$ and $\pi_{\theta}(y_l | x)$ are the probabilities of the preferred and dispreferred completions under the current model.
*   $\beta$ is controls the deviation from the reference policy $\pi_{ref}$.

In essence, DPO computes the log probabilities of preferred and dispreferred completions under the current model and optimizes parameters to increase the likelihood of the preferred completions and decrease the likelihood of the dispreferred completions.

The authors share the following results:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/ee5e46dbd66b4b7744a332e1273ca692246e84dde7f134a9.png)

"Figure 2: **Left.** The frontier of expected reward vs KL to the reference policy. DPO provides the highest expected reward for all KL values, demonstrating the quality of the optimization. **Right.** TL;DR summarization win rates vs. human-written summaries, using GPT-4 as evaluator. DPO exceeds PPO’s best-case performance on summarization, while being more robust to changes in the sampling temperature."

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/f660b3c62052393df1983d25a2cfca04a08199bf5ffb0ab6.png)

"Figure 3: **Left.** Win rates computed by GPT-4 for Anthropic-HH one-step dialogue; DPO is the only method that improves over chosen summaries in the Anthropic-HH test set. **Right.** Win rates for different sampling temperatures over the course of training. DPO’s improvement over the dataset labels is fairly stable over the course of training for different sampling temperatures."

> We evaluate different methods by sampling completions on the test split of TL;DR summarization dataset, and computing the average win rate against reference completions in the test set. The completions for all methods are sampled at temperatures varying from 0.0 to 1.0, and the win rates are shown in **Figure 2 (right)**. DPO, PPO and Preferred-FT all fine-tune the same GPT-J SFT model. We find that DPO has a win rate of approximately 61% at a temperature of 0.0, exceeding the performance of PPO at 57% at its optimal sampling temperature of 0.0. DPO also achieves a higher maximum win rate compared to the best of N baseline. **We note that we did not meaningfully tune DPO’s β hyperparameter, so these results may underestimate DPO’s potential.** Moreover, we find DPO to be much more robust to the sampling temperature than PPO, the performance of which can degrade to that of the base GPT-J model at high temperatures.

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/9abd9fe57bc9ced872a56312a5657b233baa8af7d9375ea1.png)

"Comparing human and GPT-4 win rates and per-judgment agreement on TL;DR summarization samples. Humans agree with GPT-4 about as much as they agree with each other. Each experiment compares a summary from the stated method with a summary from PPO with temperature 0."