Direct preference optimization (DPO)
Direct preference optimization is a way to train a language model on pairs of preferred and rejected answers directly, without a separate reward model or a reinforcement learning loop.
After pre-training and supervised fine-tuning, developers want a model to favour some kinds of answer over others: helpful over evasive, accurate over invented. The classic way to do that is RLHF. People judge which of two answers is better, a separate reward model learns to predict those judgements, and reinforcement learning, usually the PPO algorithm, then pushes the language model towards answers the reward model scores highly while keeping it close to where it started. It works, but it has many moving parts and can be unstable.
DPO was introduced in a May 2023 paper by Rafael Rafailov, Archit Sharma, Eric Mitchell and colleagues, titled Direct Preference Optimization: Your Language Model is Secretly a Reward Model. They showed that the reward model can be rewritten in terms of the language model itself, so the same goal can be reached with a simple classification-style loss. No reward model is trained, and the model does not have to generate new answers during training.
The training data is a set of examples, each with a prompt, a chosen answer and a rejected answer. Hugging Face's documentation uses a toy case: for the prompt What colour is the sky?, the chosen answer says blue and the rejected one says green. The loss widens the gap between how likely the model finds the chosen answer and how likely it finds the rejected one, measured against a frozen copy of the starting model called the reference model. A setting called beta controls how far the model may drift from that reference.
DPO is simpler and cheaper to run than PPO-based RLHF, and it has been used to train major models. Meta's Llama 3 paper, published in July 2024, describes post-training built on supervised fine-tuning, rejection sampling and DPO, and says DPO needed less compute than PPO for large models and did better on instruction-following benchmarks. Hugging Face's TRL library includes a DPO trainer along with many later variants of the loss.
DPO learns only from the preference pairs it is given, so it inherits the quality and the blind spots of that data. It is an offline method: it does not try out new answers and get feedback on them as on-policy reinforcement learning does. Its settings still need tuning: Meta's Llama 3 team, for example, used a beta of 0.1 and made its own changes to the loss.
Both use human preferences between pairs of answers. Classic RLHF first trains a reward model on those preferences and then uses reinforcement learning to optimise the language model against it. DPO skips both steps and trains the language model directly on the preference pairs with a single loss, which makes it simpler and usually cheaper to run. No separate one. The 2023 paper's point, captured in its title, is that the language model itself can serve as the reward model. How much more likely the trained model finds an answer than the reference model does acts as an implicit reward. A preference dataset: many prompts, each with one answer marked as preferred and another marked as rejected. The judgements can come from people or from another AI model. The quality and coverage of these pairs largely decide what the model learns. Yes. Meta's Llama 3 paper from July 2024 describes post-training rounds of supervised fine-tuning followed by DPO, chosen over PPO because it needed less compute at scale and performed better on instruction following.Common questions
What is the difference between DPO and RLHF?
Does DPO need a reward model?
What data does DPO need?
Is DPO used in real models?
Search for "direct preference optimization", "DPO vs PPO" or "preference optimization LLM" to follow the method and its variants. The original paper on arXiv and the documentation for open-source training libraries such as Hugging Face TRL explain the mechanics precisely. Model developers' technical reports show which post-training methods they actually used; treat comparisons between preference methods as specific to the models and data tested.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.