RLHF and preference optimization (DPO)
Aligning language models with human preferences, either by fitting a reward model and optimising it with RL (RLHF, usually PPO) or by optimising the policy directly on preference pairs (DPO and relatives).
On this page17 sections
Every deployed instruction-following or chat model uses some form of preference optimisation after pretraining; reward models and DPO-style losses are the standard post-training tools for non-verifiable behaviour such as helpfulness and style.
Teaching a chatbot what people prefer by showing it which of two answers people like more.
- 1People compare two answers
- 2Learn what people prefer
- 3Train model toward preferred answers
- 4Keep it close to the original
- 5Watch for reward hacking
What it is for. A language model trained only to predict the next word of internet text will happily continue a prompt with something rude, wrong or unhelpful. Qualities people want, such as helpfulness or a suitable tone, cannot be checked by a program, so they cannot simply be scored. Reinforcement learning from human feedback (RLHF) turns human comparisons ("answer A is better than answer B") into a training signal.
Example. For the prompt "explain photosynthesis to a ten-year-old", a labeller sees two model answers and picks the clearer one. Thousands of such choices become the data.
The three-stage recipe (InstructGPT, 2022).
- Supervised fine-tuning: continue training the model on human-written example answers.
- Reward model: train a second network that scores answer to prompt . It uses the Bradley–Terry model, : the probability that the preferred answer wins is the logistic (S-shaped) function of the score difference. Training adjusts until preferred answers get higher scores.
- RL: optimise the language model (the policy) with PPO to raise the reward, minus a penalty . The KL divergence measures how far the new model's word probabilities drift from the supervised model's; the penalty stops the model wandering into strange text that happens to fool the reward model.
InstructGPT's labellers preferred a 1.3B-parameter model trained this way to the 175B-parameter GPT-3.
DPO. Rafailov et al. (2023) showed that the best policy for the KL-penalised objective has a closed form, so the reward can be rewritten in terms of the policy itself, . Substituting this into the Bradley–Terry loss gives Direct Preference Optimisation: an ordinary supervised loss on preference pairs, with no separate reward model and no sampling during training. It is cheaper and simpler than PPO.
Open tension. DPO learns from a fixed set of answers; PPO keeps sampling new answers from the current model and scoring them. Two careful comparisons (Xu et al., 2024; Ivison et al., NeurIPS 2024) found PPO ahead, by up to 2.5% in maths and 1.2% in general domains in the second, with preference-data quality mattering most.
Overoptimisation. A reward model is only a proxy for what people want. Gao, Schulman and Hilton (2022) showed that optimising hard against a proxy first raises and then lowers true quality, a measured case of Goodhart's law: when a measure becomes a target, it stops being a good measure.
Go deeper
The full technical text.
From preferences to a reward
Many behaviours we want from a language model, such as helpfulness or tone, cannot be scored by a program. Reinforcement learning from human feedback (RLHF) turns pairwise human comparisons into a training signal. Christiano et al. (2017) showed that an agent can learn Atari and simulated-robot behaviours from a small number of human comparisons of trajectory segments. Ziegler et al. (2019) and Stiennon et al. (2020) applied the same idea to language models for stylistic continuation and summarisation.
The standard three-stage recipe
The InstructGPT pipeline (Ouyang et al., 2022) is the template most later systems follow:
- Supervised fine-tuning on human demonstrations.
- Reward modelling. Labellers rank several model outputs for a prompt. A reward model is trained under a Bradley-Terry assumption, .
- RL. The policy is optimised with PPO to maximise minus a KL penalty that keeps it close to the supervised model.
The InstructGPT paper reports that labellers preferred outputs from a 1.3B-parameter InstructGPT model to those of the 175B GPT-3, which established the method's practical value.
Direct preference optimisation
Rafailov et al. (2023) observed that the KL-regularised objective has a closed-form optimum, so the reward can be written in terms of the policy: . Substituting into the Bradley-Terry loss gives DPO, a supervised classification-style loss on preference pairs that needs no separate reward model and no sampling during training. This is cheaper and simpler than PPO, and variants followed, including IPO (Azar et al., 2023) which addresses overfitting to deterministic preferences, and KTO (Ethayarajh et al., 2024) which uses unpaired good/bad labels.
Open tension: offline preference losses versus online RL
DPO trains on a fixed dataset of responses, whereas PPO samples fresh responses from the current policy. Controlled comparisons disagree in size but, in two independent studies, favour careful PPO: Xu et al. (ICML 2024) report PPO surpassing other alignment methods across their testbeds, and Ivison et al. (2024) report PPO ahead of DPO by up to 2.5% in math and 1.2% in general domains while finding preference data quality to matter most (NeurIPS 2024). Reward-model quality is measured with benchmarks such as RewardBench (Lambert et al., 2024) and RewardBench 2 (2025), whose authors report that benchmark accuracy correlates with downstream best-of-N and PPO results.
Overoptimization
A reward model is a proxy. Gao, Schulman and Hilton (2022) used a fixed "gold" reward model to label data for a proxy and measured how gold reward changes as the policy is optimised against the proxy, by RL or by best-of- sampling. The relationship follows different functional forms for the two methods and their coefficients scale smoothly with reward-model size. This quantifies Goodhart's law for RLHF and motivates early stopping, KL control and reward-model ensembles.
Practice
Open implementations are in TRL (Hugging Face), OpenRLHF and AI2's open-instruct, which also publish the evaluation suites used in the comparisons above.
Words on this page (12)
- language model
- A neural network trained to predict the next piece of text, which can then write answers, code and essays.
- policy
- The rule an agent uses to choose an action in each situation. In deep RL it is usually a neural network.
- reward
- A number the environment gives after each action, telling the agent how well it is doing.
- KL divergence
- A measure of how different one probability distribution is from another. Used to keep a new policy close to an old one.
- PPO
- Proximal Policy Optimization: a popular RL algorithm that limits how far each update can move the policy.
- reward model
- A neural network trained to score how much people would like a response.
- Bradley-Terry model
- A simple model that turns the difference of two scores into the probability that one item wins a comparison.
- fine-tuning
- Further training of an already trained model on a narrower task or data set.
- Goodhart's law
- When a measure becomes a target, it stops being a good measure.
- DPO
- Direct Preference Optimisation: trains the model directly on preferred/rejected answer pairs with a supervised loss, without a separate reward model or RL loop.
- logistic function
- The S-shaped curve σ(x) = 1/(1+e^(−x)), which squashes any number into a probability between 0 and 1.
- supervised learning
- Training a model on inputs paired with the correct outputs, adjusting it to reduce the error on those examples.
New to this? Read first (3)
- Illustrating Reinforcement Learning from Human FeedbackStep-by-step walkthrough with diagrams.
- Wikipedia: Reinforcement learning from human feedbackOverview and history.
- Direct Preference Optimization (arXiv)The DPO paper; the abstract explains the idea.
Understanding map
map of the whole wiki →What to read before RLHF and preference optimization (DPO) (left), and what builds on it: entries that depend on it and its open problems (right). Every box links to its page.
- Start with
- Fast matrix multiplicationAlgorithm
- Reverse-mode automatic differentiationAlgorithm
- Step 2
- The transformer architectureAlgorithm
- Policy gradient methods and PPOAlgorithm
- Step 3
- RLHF and preference optimization (DPO)You are here
- Then
Open problems & questions
Progress timeline
- Jun 13, 2024Controlled DPO versus PPO comparisonsource
Ivison et al. (NeurIPS 2024) find PPO outperforms DPO by up to 2.5% in math and 1.2% in general domains, with preference data quality the largest factor.
- Jun 13, 2024Component-wise comparisonRelated to: A controlled DPO versus PPO comparison that attributes the gap to online sampling or to the reward modelsource
Ivison et al. (preprint) separate data, algorithm, reward model and prompts and report PPO ahead by up to 2.5% in math.
- Apr 16, 2024PPO versus DPO studyRelated to: A controlled DPO versus PPO comparison that attributes the gap to online sampling or to the reward modelsource
Xu et al. (preprint) report PPO outperforming DPO across testbeds.
- May 29, 2023DPOsource
Rafailov et al. show the KL-regularised RLHF optimum can be fit with a supervised loss on preference pairs, removing the reward model and RL loop.
- Oct 19, 2022Overoptimization scaling lawssource
Gao et al. measure gold reward against proxy-reward optimisation for RL and best-of-n and find smooth scaling of the fit coefficients.
- Oct 19, 2022Overoptimization scaling lawsRelated to: Do reward-model overoptimization laws hold for modern RLHF and DPO-style training?source
Synthetic gold-versus-proxy setup shows smooth coefficient scaling for best-of-n and RL.
- Mar 4, 2022InstructGPTsource
OpenAI reports that labellers prefer a 1.3B InstructGPT to the 175B GPT-3 baseline.
- Sep 2, 2020Summarisation from human feedbacksource
Stiennon et al. optimise a summarisation policy against a learned reward model with PPO and report gains over supervised baselines.
- Jun 12, 2017RL from human preferencessource
Christiano et al. train agents on Atari and simulated robotics from human comparisons of trajectory segments.