All papersFoundations Classic
Tune a model to human taste without reinforcement learning Paper: Direct Preference Optimization: Your Language Model is Secretly a Reward Model
Rafael Rafailov, Archit Sharma, Eric Mitchell, Stefano Ermon, Christopher D. Manning, Chelsea Finn · NeurIPS 2023 · Posted 29 May 2023 · 20 min read · arXiv 2305.18290
1 The problem Show in original Language models copy all the habits in their text. Teams steer them with RLHF , using human preference labels. RLHF trains several models and uses reinforcement learning. It is complex , costly and often unstable . 61% DPO summaries win 61% of GPT-4 comparisons. PPO wins 57% .
2 What they tested Show in original They test 3 tasks : sentiment, summarization and dialogue. The models have up to 6B parameters. They compare DPO with PPO and other baselines. GPT-4 and human raters judge the answers. 3 What they found Show in original DPO matches or beats PPO on all three tasks. It needs no reward model and no RL loop . It is more robust than PPO to the sampling temperature. GPT-4 agrees with humans about as often as humans agree. In a chart DPO summaries win more often than PPO summaries From Section 6.2 0 25 50 75 100 Win rate vs reference summaries (%) DPO 61% PPO 57%
Hover, tap or focus a bar to read its exact value.
Show as table Method Win rate (%) DPO 61 PPO 57
5 Watch out Show in original The tests used models up to 6B parameters. Much larger models are not tested . GPT-4 win rates depend on the prompt . The out-of-distribution result is only initial evidence . Jump to A The abstract1 Introduction2 Related work3 Preliminaries: how RLHF works4 Direct Preference Optimization5 Theoretical analysis of DPO5.1 Your language model is secretly a reward model5.2 Instability of actor-critic algorithms6 Experiments: set-up6.1 How well can DPO optimize the RLHF objective?6.2 Can DPO scale to real preference datasets?6.3 Generalization to a new input distribution6.4 Validating GPT-4 judgments with human judgments7 Discussion and limitationsA.1 Appendix A.1: best policy of the KL-limited reward goalA.2 Appendix A.2: DPO under Bradley-TerryA.3 Appendix A.3: DPO under Plackett-LuceA.4 Appendix A.4: gradient of the DPO lossA.5 Appendix A.5: proof of Lemma 1 and Lemma 2A.6 Appendix A.6: proof of Theorem 1B Appendix B: implementation detailsC.1 Appendix C.1: IMDb sentiment set-upC.2 Appendix C.2: GPT-4 promptsC.3 Appendix C.3: the unlikelihood baselineD.1 Appendix D.1: best of N for different ND.2 Appendix D.2: sample answers and GPT-4 judgmentsD.3 Appendix D.3: human study detailsW Words to knowEvery detail from the paper Cards follow the paper's own order. Dotted words link to Words to know. Numbers match the paper.
A The abstract Show in original The background Big language models learn broad knowledge from text with no labels. It is hard to control their behavior precisely. Today's fix: collect human labels on which answers are better. Then fine-tune the model with RLHF (reinforcement learning from human feedback). The problem RLHF is complex and often unstable . First it fits a reward model of human preferences. Then it fine-tunes the model with RL to maximize that reward. The model must not drift too far from the original. The idea The authors give the reward model a new form (a new parameterization ). This lets them write the best Policy in closed form . So the standard RLHF problem needs only a simple classification loss . The method is Direct Preference Optimization (DPO) . DPO is stable, performant and light on compute. It needs no sampling from the model during fine-tuning and little tuning. The results DPO aligns models with human preferences as well as or better than existing methods. It beats PPO -based RLHF at controlling the sentiment of generations. It matches or improves quality in summarization and single-turn dialogue. It is much simpler to implement and train. 1 Introduction Show in original The problem Large unsupervised LMs gain surprising abilities from huge datasets. But they train on data written by people with many goals and skill levels. Some of those goals are not worth copying. Two examples Example: an AI coding assistant should know common mistakes, to fix them. But when it writes code, it should aim at the rare good code. Example: a model may know a common false belief held by 50% of people. It must not say the belief is true in 50% of answers about it. Why it matters Choosing the wanted behavior from wide knowledge is crucial. It is key to AI systems that are safe, performant and controllable. Most methods steer LMs with reinforcement learning (RL). The authors show the RL goal has an exact solution. It needs only a simple binary cross-entropy loss. How it is done now Existing methods teach behavior with curated sets of human preferences. This comes after pre-training on a large text set. The simplest way is supervised fine-tuning on good human answers. The most successful way is RLHF, or RLAIF (feedback from AI). RLHF fits a reward model, then uses RL to get high-reward answers without drifting far. The cost The RLHF pipeline is much more complex than supervised learning. It trains several LMs. It samples from the LM policy inside the training loop. This costs a lot of compute. The proposal DPO directly optimizes an LM to follow human preferences. It uses no explicit reward model and no RL. It implicitly optimizes the same goal as RLHF: reward maximization with a KL-divergence limit. It is simple to implement and train. How the update works The DPO update raises the relative log probability of preferred answers over dispreferred ones. It adds a dynamic per-example importance weight. That weight stops the model degeneration seen with a naive probability ratio goal. How it differs DPO relies on a preference model, such as Bradley-Terry . RLHF uses it to train a reward model, then trains a policy on that reward. DPO uses a change of variables. That writes the preference loss as a function of the policy directly. So DPO needs only a simple binary cross entropy loss. The main contribution The main contribution is DPO, a simple RL-free algorithm. It is at least as effective as existing methods, including PPO-based RLHF. The tasks are sentiment modulation, summarization and dialogue. The models have up to 6B parameters. 3 Preliminaries: how RLHF works Show in original The three phases of RLHF From Section 3 Phase 1 Fine-tune on good data Phase 2 Humans pick better answers Phase 2 Train a reward model Phase 3 PPO maximizes reward Phase 3 limits drift from the start model with a KL penalty.
Overview RLHF usually has three phases. 1) supervised fine-tuning (SFT). 2) preference sampling and reward learning. 3) RL optimization. Phase 1: SFT RLHF starts by fine-tuning a pre-trained LM with supervised learning. The data is high-quality for the task, such as dialogue or summarization. The result is the model pi-SFT. Phase 2: reward modelling The SFT model gets prompts x and writes pairs of answers (y1, y2). Human labelers pick one answer. yw is the preferred answer. yl is the dispreferred answer. The picks are assumed to come from a hidden reward r*, which we cannot see. The preference model The Bradley-Terry (BT) model is a popular choice. Plackett-Luce models also fit if we have several ranked answers. BT says: the chance that y1 wins is exp(reward of y1) divided by exp(reward of y1) plus exp(reward of y2). This is Equation 1. Fitting the reward model We have a fixed dataset of comparisons. We build a reward model and fit its parameters by maximum likelihood. As binary classification, the loss is the negative log-likelihood. The loss is minus the expected log sigmoid of (reward of yw minus reward of yl). The sigma is the logistic function. This is Equation 2. In practice In LMs, the reward network starts from the SFT model. A linear layer on top of the last transformer layer gives one reward number. To lower variance, prior work normalizes rewards. The expected reward becomes 0 for all x. Phase 3: RL fine-tuning The learned reward gives feedback to the LM. The goal: maximize the expected reward minus beta times the KL divergence. The KL term compares the policy with the reference policy. This is Equation 3. The role of beta Beta controls the drift from the reference policy. The reference policy is the initial SFT model. The policy also starts from the SFT model. Why the limit matters The limit matters for three reasons. It keeps the model where the reward model is accurate. It keeps the generations diverse. It stops mode collapse to single high-reward answers. How it is solved today Language generation is discrete, so this goal is not differentiable. It is usually solved with RL. The standard way builds a new reward. It is the learned reward minus beta times (log policy minus log reference). Then it maximizes this with PPO. 4 Direct Preference Optimization Show in original DPO training in two steps From Section 4 Step 1 Sample answer pairs Step 1 Humans pick the better Step 2 Minimize the DPO loss No reward model. No RL loop. The policy is both the LM and the implicit reward.
The goal RL is hard to apply to large LMs. So the goal is a simple way to optimize a policy from preferences directly. Old methods learn a reward, then optimize it with RL. DPO uses a special reward form whose best policy has a closed form. So it needs no RL training loop. The key insight The key insight is a mapping from reward functions to best policies. It turns a loss over rewards into a loss over policies. This change of variables avoids a separate reward model. It still uses preference models such as Bradley-Terry. The policy network stands for both the LM and the implicit reward. Deriving the DPO objective Step 1: the best policy for any reward Start with the RL goal (Equation 3) under a general reward r. Its best solution has this form (Equation 4). Best policy = (1 / Z(x)) x reference policy x exp(reward / beta). Z(x) is the partition function : the sum of the right-hand side over all answers y. Appendix A.1 has the full derivation. Step 2: solve for the reward Z(x) is expensive to estimate, even with the best reward estimate. So Equation 4 is hard to use directly. But we can turn it around (Equation 5). Reward = beta x log (best policy / reference policy) + beta x log Z(x). Step 3: the partition function cancels The Bradley-Terry model uses only the difference of two rewards. So when we put Equation 5 into Equation 1, the partition function cancels. The preference chance then needs only the best policy and the reference policy. This is Equation 6. The derivation is in Appendix A.2. Plackett-Luce models give a similar result (Appendix A.3). Step 4: the DPO loss Now we have preference chance in terms of the policy, not a reward model. So we can write a maximum likelihood goal for a policy pi-theta. It is like the reward-model goal in Equation 2. Loss = -log sigmoid(beta x (preferred log ratio - dispreferred log ratio)) A log ratio is the log of policy probability over reference probability. This is Equation 7. What this means This fits an implicit reward under a new parameterization. The best policy for that reward is simply pi-theta. It equals fitting a reparameterized Bradley-Terry model. So it has theory properties, such as consistency under suitable assumptions on the preference data. What does the DPO update do? The direction The paper analyzes the gradient of the DPO loss. The update raises the likelihood of the preferred answer yw. It lowers the likelihood of the dispreferred answer yl. The weight Each example has a weight. The weight is high when the implicit reward model ranks the dispreferred answer higher. So it counts how wrong the implicit reward model is, scaled by beta. This accounts for the strength of the KL limit. Why the weight matters The weight matters. A naive version with no weight can make the LM degenerate (Appendix Table 3). The DPO pipeline Two steps 1) Sample answers y1 and y2 from the reference policy for every prompt x. Label them with human preferences to build an offline dataset D. 2) Optimize the LM to minimize the DPO loss. The loss uses the given reference, D and beta. Public datasets In practice, people reuse public preference datasets. They do not generate samples and gather human labels. Those datasets come from the SFT model. So the reference is set to the SFT model when it exists. No SFT model With no SFT model, set the reference by maximizing the likelihood of preferred answers. This helps cut the shift between the true reference distribution and the one DPO uses. Appendix B has details and hyperparameters. 5 Theoretical analysis of DPO Show in original This section gives more meaning to DPO and some theory. It also links DPO's strengths to problems of actor-critic algorithms such as PPO. 5.1 Your language model is secretly a reward model Show in original The claim DPO skips both the explicit reward and the RL step. It uses one maximum likelihood goal. Equation 5 equals a Bradley-Terry model with reward = beta x log (policy / reference). The authors build the theory for this change of variables. They show it does not limit the class of learned reward models. It allows exact recovery of the best policy. Equivalent rewards Definition 1. Two rewards are equivalent if they differ only by f(x).Here f(x) is any function of the prompt. This splits the set of reward functions into classes. Two lemmas Lemma 1. Two rewards of one class give the same preference distribution.This holds under Plackett-Luce, and under Bradley-Terry in particular. Lemma 2. Two rewards of one class give the same best policy.This holds under the constrained RL problem. What the lemmas say The proofs are in Appendix A.5. Lemma 1 is a known under-specification issue of the Plackett-Luce family. So we usually need extra identifiability constraints for MLE guarantees. Lemma 2 says all rewards of a class give the same best policy. So we only need to recover any one reward from the best class. The main theorem Theorem 1. Under mild assumptions, every reward class can be written in one form.The classes are those consistent with Plackett-Luce (and Bradley-Terry). The form is: reward = beta x log (policy / reference). The proof is in Appendix A.6. Proof sketch Take any reward r. It gives a best model by Equation 4. A projection f subtracts beta times the log of the partition function (Equation 8). The subtracted term depends only on the prompt x. So the new reward stays in the class of r. Put in Equation 5 and it equals beta x log (best policy / reference). So no generality is lost. Which reward DPO picks Another view: Theorem 1 names which reward in each class DPO picks. It is the reward where a sum equals 1 (Equation 9). The sum runs over y of reference x exp(reward / beta). That means the policy is a valid distribution: positive and summing to 1. By Equation 4, that sum is the partition function of the best policy. The key insight The key insight: add constraints to the under-constrained Plackett-Luce family. This keeps the class of representable rewards. But it makes the best policy analytically tractable for all prompts x. 5.2 Instability of actor-critic algorithms Show in original The setup The framework can also explain the instability of actor-critic algorithms such as PPO. The focus is the RL fine-tuning step from Section 3. They use the control as inference view. They minimize the KL between the policy and the best policy. This gives the goal in Equation 10. The normalization term Equation 10 is the goal used in prior work. It uses the DPO-equivalent reward for the class of the learned reward. It has a normalization term. That term is the soft value function of the reference policy. Why it matters The term does not change the best solution. Without it, the policy gradient can have high variance. That makes learning unstable. Fixes and DPO Option 1: use a learned value function. It is also hard to optimize. Option 2: normalize rewards with a human completion baseline. That is a single-sample Monte-Carlo estimate of the normalizing term. DPO gives a reward that needs no baselines . 6 Experiments: set-up Show in original The questions The authors test how well DPO learns policies straight from preferences. First: a controlled text task. How well does DPO trade reward against KL, compared with PPO? Next: larger models and harder RLHF tasks, such as summarization and dialogue. With almost no tuning, DPO does as well or better than PPO-based RLHF. It also matches returning the best of N samples under a learned reward. The three tasks Sentiment In controlled sentiment generation , x is the start of an IMDb movie review. The policy must write y with positive sentiment. A pretrained sentiment classifier makes preference pairs. It marks pairs where the chance of positive is higher for yw than for yl. For SFT, they fine-tune GPT-2-large until convergence on IMDb train reviews. Summarization In summarization , x is a Reddit forum post. The policy writes a summary y of the main points. They use the Reddit TL;DR dataset and human preferences from Stiennon et al. The SFT model is fine-tuned on human summaries with the TRLX framework. The preferences came from samples of a different but similar SFT model. Dialogue In single-turn dialogue , x is a human query. It can be a question about astrophysics or a request for relationship advice. The policy writes an engaging and helpful answer. The data is the Anthropic Helpful and Harmless set, with 170k dialogues. Each ends with a pair of answers from an unknown large LM. A preference label marks the better answer. No pre-trained SFT model exists. So they fine-tune an off-the-shelf LM on preferred answers only. How they evaluate Sentiment In the sentiment task, they know the true reward (the classifier). So they plot the frontier of reward against KL from the reference policy. Summarization and dialogue In the real world the true reward is unknown. So they use the win rate against a baseline policy. GPT-4 acts as a proxy for human judges of summary quality and answer helpfulness. For summarization, the baseline is the reference summary in the test set. For dialogue, it is the preferred answer in the test set. Is GPT-4 a fair judge? A human study in Section 6.4 checks the use of GPT-4. GPT-4 judgments correlate strongly with humans. Human agreement with GPT-4 is typically similar to or higher than agreement between humans. The methods they compare Simple baselines Zero-shot prompting with GPT-J (summarization).2-shot prompting with Pythia-2.8B (dialogue).SFT : the supervised model.Supervised variants Preferred-FT : supervised fine-tuning on the chosen answer yw.It starts from the SFT model, or from a generic LM in dialogue. Unlikelihood : raise the probability of yw and lower that of yl.It has an optional coefficient alpha between 0 and 1. PPO versions PPO uses a reward learned from the preference data.PPO-GT is an oracle that learns from the true reward in the sentiment task.They use two PPO-GT versions: an off-the-shelf one and a modified one. The modified one normalizes rewards and tunes hyperparameters. They also use these changes for normal PPO with learned rewards. Best of N Best of N : sample N answers from the SFT model (or Preferred-FT in dialogue).Return the one with the highest learned reward. It separates reward model quality from PPO optimization. It is too costly even for moderate N. It needs N answers for every query at test time. 6.1 How well can DPO optimize the RLHF objective? Show in original How to compare The RLHF goal balances reward against drift from the reference policy. So a fair comparison must look at both reward and KL. A little more reward with much more KL is not clearly good. The sweep Figure 2 (left) shows the reward-KL frontier in the sentiment task. They train many runs per method, each with a different setting for caution. PPO: target KL in {3, 6, 9, 12}. DPO: beta in {0.05, 0.1, 1, 5}. Unlikelihood: alpha in {0.05, 0.1, 0.5, 1}. Preferred-FT: random seeds. The sweep has 22 runs in total. The measures After each 100 training steps until convergence, they test each policy. They compute the average true reward on test prompts. They also compute the average sequence-level KL to the reference policy. Sequence-level KL is the sum of the per-timestep KL values. The result DPO gives by far the most efficient frontier . It reaches the highest reward at low KL, for all KL values. DPO and PPO optimize the same goal, but DPO is much more efficient. DPO's reward and KL tradeoff strictly dominates PPO. DPO beats PPO even when PPO can use the true rewards (PPO-GT). 6.2 Can DPO scale to real preference datasets? Show in original DPO summaries win more often than PPO summaries From Section 6.2 0 25 50 75 100 Win rate vs reference summaries (%) DPO 61% PPO 57%
Hover, tap or focus a bar to read its exact value.
Show as table Method Win rate (%) DPO 61 PPO 57
Summarization: the test ROUGE and similar scores correlate poorly with human preferences. Past work found RL on human preferences gives better summaries. They sample answers on the TL;DR test split. They compute the average win rate against reference summaries. Samples use temperatures from 0.0 to 1.0 (Figure 2, right). DPO, PPO and Preferred-FT fine-tune the same GPT-J SFT model. Summarization: the result DPO wins about 61% at temperature 0.0. PPO wins 57% at its best temperature, also 0.0. DPO also has a higher maximum win rate than the best of N baseline. They did not meaningfully tune beta, so DPO may be underrated. DPO is much more robust to temperature than PPO. PPO can fall to the level of base GPT-J at high temperatures. Preferred-FT does not improve much over SFT. In Section 6.4, humans compared DPO at temperature 0.25 with PPO at temperature 0. They preferred DPO 58% of the time. Dialogue: the test They test on the Anthropic HH test subset with one step of interaction. GPT-4 uses the preferred test answers as the reference. No standard SFT model exists. So they start from pre-trained Pythia-2.8B. They use Preferred-FT on chosen answers to build a reference model. Then they train with DPO. Dialogue: baselines They compare with the best of 128 Preferred-FT answers. Best of N stops improving at 128 (Appendix Figure 4). They also compare with 2-shot prompted base Pythia-2.8B. DPO does as well or better at each method's best temperatures. They also tried a public PPO model on Anthropic HH. No prompt or temperature made it beat base Pythia-2.8B. So they treat Best of 128 as a rough stand-in for PPO-level quality. Dialogue: the result DPO is the only computationally efficient method that beats the preferred answers in Anthropic HH. It gives similar or better results than the costly Best of 128. Figure 3 shows DPO reaches its best performance fairly quickly. 6.3 Generalization to a new input distribution Show in original The test They test PPO and DPO under a shift in the input data. They take the policies trained on Reddit TL;DR. They run them on news articles from the CNN/DailyMail test split. They use the best temperatures from TL;DR: 0 and 0.25. They use the same GPT-4 (C) prompt, with "forum post" changed to "news article". They compute the GPT-4 win rate against ground-truth summaries. DPO beats PPO on news articles it never trained on From Table 1 Temp 0 Temp 0.25
0 0.1 0.2 0.3 0.4 0.5 GPT-4 win rate vs ground truth DPO 0.36 win rate 0.31 win rate PPO 0.26 win rate 0.23 win rate
Hover, tap or focus a bar to read its exact value.
Show as table Method Temp 0 (win rate) Temp 0.25 (win rate) DPO 0.36 0.31 PPO 0.26 0.23
Algorithm Temp 0 Temp 0.25 DPO 0.36 0.31 PPO 0.26 0.23
Table 1: GPT-4 win rates against ground truth summaries, out of distribution
The result DPO still beats PPO by a significant margin. This is initial evidence that DPO policies generalize about as well as PPO policies. That holds although DPO does not use the extra unlabeled Reddit TL;DR prompts. PPO uses those prompts. 6.4 Validating GPT-4 judgments with human judgments Show in original The study They ran a human study on the TL;DR summarization results. They used two GPT-4 prompts. GPT-4 (S), simple: which summary better covers the key points? GPT-4 (C), concise: it also asks which summary is more concise. With the (S) prompt, GPT-4 prefers longer and more repetitive summaries than humans do. Appendix C.2 has the full prompts. The setup Three comparisons cover a range of quality. Highest: DPO at temperature 0.25. Lowest: PPO at temperature 1.0. Middle: SFT at temperature 0.25. All three face greedily sampled PPO, its best temperature. They gathered several human judgments only for DPO and PPO-1, due to few raters. The result With both prompts, GPT-4 agrees with humans about as often as humans agree with each other. So GPT-4 is a reasonable stand-in for human judges. The (C) prompt gives win rates closer to human ones. So they use it for the main results in Section 6.2. Appendix D.3 has more detail. GPT-4 (C) win rates track human win rates From Table 2 Human GPT-4 (S) GPT-4 (C)
0 25 50 75 100 Win rate vs PPO at temperature 0 (%) DPO 58% 47% 54% SFT 43% 27% 32% PPO-1 17% 13% 12%
Hover, tap or focus a bar to read its exact value.
Show as table Method Human (%) GPT-4 (S) (%) GPT-4 (C) (%) DPO 58 47 54 SFT 43 27 32 PPO-1 17 13 12
Measure DPO SFT PPO-1 N respondents 272 122 199 GPT-4 (S) win % 47 27 13 GPT-4 (C) win % 54 32 12 Human win % 58 43 17 GPT-4 (S)-H agree 70 77 86 GPT-4 (C)-H agree 67 79 85 H-H agree 65 - 87
Table 2: human and GPT-4 win rates, and per-judgment agreement, on TL;DR summaries
Each row compares a summary from the named method with a summary from PPO at temperature 0. H means human. A dash means no number.
7 Discussion and limitations Show in original The conclusion Learning from preferences is a powerful, scalable way to train capable, aligned LMs. DPO trains from preferences with a simple cross-entropy loss, with no RL. It finds a mapping between LM policies and reward functions. That keeps full generality. With almost no hyperparameter tuning, it matches or beats RLHF methods. That includes PPO. So it lowers the barrier to training more models from human preferences. Open questions How does the DPO policy generalize out of distribution, compared with an explicit reward? Early results suggest it is similar to PPO models. More study is needed. Can self-labeling from the DPO policy use unlabeled prompts well? How does reward over-optimization show up in DPO? Is the slight drop in Figure 3 (right) an example of it? Limits and future work They tested models up to 6B parameters. Scaling DPO to state-of-the-art models far larger is a future direction. GPT-4 win rates depend on the prompt. Future work may study how to get good judgments from automated systems. DPO may also apply beyond text, for example to generative models in other modalities. A.1 Appendix A.1: best policy of the KL-limited reward goal Show in original This derives Equation 4. They start from the goal: maximize expected reward minus beta times KL (Equation 11). They rewrite it as minimizing an expected log ratio. The ratio is policy over (reference x exp(reward / beta)). That equals the log ratio to a normalized best policy, minus log Z(x) (Equation 12). Z(x) depends only on x and the reference, not on the policy. So the best policy only minimizes the KL to that normalized policy. These are Equations 13 and 14. Gibbs' inequality says KL is smallest (0) only when two distributions match. So the best policy equals the normalized form (Equation 15). A.2 Appendix A.2: DPO under Bradley-Terry Show in original Start from the Bradley-Terry preference chance (Equation 16). Put in the reward written with its best policy (Equation 17). The beta x log Z(x) terms cancel in numerator and denominator. The result is a sigmoid. It takes beta x log ratio of y1 minus beta x log ratio of y2. The last line is the per-example loss of Equation 7. A.3 Appendix A.3: DPO under Plackett-Luce Show in original Plackett-Luce extends Bradley-Terry from pairs to full rankings. People pick an answer with chance proportional to a hidden reward value. With a prompt x and K answers, a user gives a ranking tau. The chance of a ranking is a product of terms (Equation 18). For K = 2 it reduces to Bradley-Terry. Using Equation 5, the constant Z(x) cancels again (Equation 19). With a dataset of rankings, they can fit a policy by maximum likelihood (Equation 20). A.4 Appendix A.4: gradient of the DPO loss Show in original They derive the gradient of Equation 7 (Equations 21 and 22). They use two sigmoid rules. Its slope is sigma x (1 - sigma). And sigma(-x) = 1 - sigma(x). After the reward substitution, they get the final gradient from Section 4. A.5 Appendix A.5: proof of Lemma 1 and Lemma 2 Show in original Lemma 1 Lemma 1. Say r' = r + f(x).In the ranking chance, exp(f(x)) cancels top and bottom. So both rewards give the same preference distribution. Lemma 2 Lemma 2. For r' = r + f(x), the best policy has a normalizer too.The exp(f(x) / beta) factor cancels between the numerator and the normalizer. So both rewards give the same best policy. A.6 Appendix A.6: proof of Theorem 1 Show in original The proof Assume the reference gives every answer a chance above 0. Assume beta is above 0. Take any reward r with best model pi-r (Equation 4). Take logs: r = beta x log(pi-r / reference) + beta x log Z(x). Define r' = r minus beta x log Z(x). It is in the class of r. And r' = beta x log(pi-r / reference). That ends the proof. A further result The operator f maps all rewards of a class to the same reward. That follows from Lemma 2. Uniqueness Proposition 1. Each class has a unique reward of one form.The form is beta x log(policy / reference). Proof by contradiction: take two such rewards in one class. Then the two policies differ by the factor exp(f(x) / beta). Both are distributions, so summing over y gives exp(f(x) / beta) = 1. Since beta is above 0, f(x) = 0 for all x. So the rewards are equal. B Appendix B: implementation details Show in original The loss code DPO is simple to implement. The paper gives PyTorch code for the loss. Inputs: policy log probs, reference log probs, indices of preferred and dispreferred answers, and beta. The code takes the log ratios of preferred minus dispreferred answers, for policy and reference. The loss is minus the log sigmoid. It takes beta x (policy log ratios minus reference log ratios). The rewards are beta x (policy log probs minus reference log probs), with no gradient. Default settings By default: beta = 0.1, batch size 64, and the RMSprop optimizer. The learning rate is 1e-6. They warm up the learning rate linearly from 0 to 1e-6 over 150 steps. For TL;DR summarization, beta = 0.5. The rest stays the same. C.1 Appendix C.1: IMDb sentiment set-up Show in original Models Prompts are IMDb prefixes of length 2-8 tokens. The true reward model is the classifier siebert/sentiment-roberta-large-english. The base model is gpt2-large. They use larger models because the default ones wrote poor text. The default ones also gave inexact rewards. Data First, SFT on a subset of IMDb for 1 epoch. Then they sample 4 answers for 25000 prefixes. They make 6 preference pairs for each prefix, using the true reward model. The RLHF reward model starts from gpt2-large and trains for 3 epochs on these pairs. They keep the checkpoint with the best validation accuracy. PPO runs The "TRL" run uses the hyperparameters of the TRL library. Their own code uses larger batches: 1024 samples per PPO step. C.2 Appendix C.2: GPT-4 prompts Show in original Set-up They use gpt-4-0314 for all experiments. The order of the two summaries or answers is random each time. The three prompts Summarization prompt (S): which summary better covers the most important points of the post?Summarization prompt (C): same, but with no unimportant or irrelevant details.It adds: a good summary is precise and concise. Dialogue prompt: which answer to a chatbot query is more helpful?The answer format Each prompt asks for two things. First, a one-sentence comparison that says which one is preferred and why. Second, on a new line, only "A" or "B" as the choice. C.3 Appendix C.3: the unlikelihood baseline Show in original What it is Unlikelihood maximizes log p(yw | x) and minimizes log p(yl | x). They use it in the sentiment tests only. They leave it out of summarization and dialogue. It makes mostly meaningless answers there. They think this comes from unconstrained likelihood minimization. Table 3 Table 3 shows samples on TL;DR prompts at temperature 1.0. The samples are mostly the word "when" repeated. So unlikelihood fails to give meaningful answers for harder tasks. D.1 Appendix D.1: best of N for different N Show in original Best of N is a strong but costly baseline. Figure 4 shows it for Anthropic-HH and TL;DR. The values of N are 1, 4, 16, 64 and 128 (and 256 on TL;DR). Performance plateaus after roughly 64-128 samples. D.2 Appendix D.2: sample answers and GPT-4 judgments Show in original Summaries Tables 4 to 6 compare DPO and PPO (temperature 0) summaries. In all three, GPT-4 prefers the DPO summary. The PPO samples in Tables 4 and 5 repeat themselves or run on. Dialogue Tables 7 to 10 compare DPO and the chosen answer (GT) in dialogue. Tables 7 and 8: GPT-4 prefers DPO. Table 9: GPT-4 prefers GT. The DPO answer is long and plausible but wrong. Table 10: GPT-4 prefers GT. It wrongly says GT is correct. The longer DPO output is wrong. D.3 Appendix D.3: human study details Show in original The matchups They test three matchups against PPO at temperature 0. The three are DPO (temperature 0.25), SFT (temperature 0.25) and PPO (temperature 1.0). This covers a wide range of win rates and of methods. The samples They sample 150 random comparisons of DPO against PPO-0. They sample 100 random comparisons of PPO-1 against PPO-0. Two humans judge each one. That gives 275 judgments for DPO-PPO and 200 for PPO-PPO. One volunteer did not respond for the DPO-PPO comparison. They sample 125 SFT comparisons, with one human each. The measures They ignore ties. Ties are only about 1% of judgments. They measure raw agreement between human A and human B. They also measure agreement between each human and GPT-4. The raters There are 25 volunteer raters. Each compares 25 summaries. One volunteer finished late and is not in the final analysis. The raters are Stanford students, graduates or visitors, mostly in computer science and other STEM. Figure 5 shows the SurveyMonkey layout. Each person did 25 similar judgments. Words to know Bradley-Terry model: A model that turns two reward scores into a chance that one answer wins.Closed form: An exact formula. You need no search or training loop to find it.Few-shot: The prompt holds a few worked examples of the task.KL divergence: A number that shows how far two probability distributions differ.Language model: A model that predicts the next token of text.Parameterization: A choice of how to write something with trainable numbers.Partition function: A sum that turns raw scores into probabilities that add to 1.Policy: The model's rule for choosing an answer. Here, the language model itself.PPO: Proximal policy optimization. A common RL method used in RLHF.Pre-training: The first stage of training on a very large text set.Reward model: A model that scores an answer. A higher score means people like it more.RLHF: Reinforcement learning from human feedback. Models learn from human picks of better answers.Supervised fine-tuning: Extra training on good example answers.Win rate: The share of head-to-head comparisons that a method wins.Zero-shot: The prompt describes the task but gives no examples.Ask AI about this paper Stuck on a word or an idea? Ask in plain words. The answer comes from the write-up on this page.
Ask AI about this paper Explain it like I am new to AI How would a finance team use this? What are the limits?
Jump to