Skip to content
DAH

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
Why other work relies on it

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.

  1. 1People compare two answers
  2. 2Learn what people prefer
  3. 3Train model toward preferred answers
  4. 4Keep it close to the original
  5. 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).

  1. Supervised fine-tuning: continue training the model on human-written example answers.
  2. Reward model: train a second network rϕ(x,y)r_\phi(x,y) that scores answer yy to prompt xx. It uses the Bradley–Terry model, P(yw≻yl)=σ(rϕ(x,yw)−rϕ(x,yl))P(y_w \succ y_l)=\sigma\big(r_\phi(x,y_w)-r_\phi(x,y_l)\big): the probability that the preferred answer wins is the logistic (S-shaped) function σ\sigma of the score difference. Training adjusts rϕr_\phi until preferred answers get higher scores.
  3. RL: optimise the language model (the policy) with PPO to raise the reward, minus a penalty β KL(πθ∥πref)\beta\,\mathrm{KL}(\pi_\theta\Vert\pi_{\text{ref}}). 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, r=βlog⁡(πθ/πref)+constr=\beta\log(\pi_\theta/\pi_{\text{ref}})+\text{const}. 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:

  1. Supervised fine-tuning on human demonstrations.
  2. Reward modelling. Labellers rank several model outputs for a prompt. A reward model rϕ(x,y)r_\phi(x,y) is trained under a Bradley-Terry assumption, P(yw≻yl∣x)=σ(rϕ(x,yw)−rϕ(x,yl))P(y_w\succ y_l\mid x)=\sigma\big(r_\phi(x,y_w)-r_\phi(x,y_l)\big).
  3. RL. The policy is optimised with PPO to maximise rϕr_\phi minus a KL penalty β KL(πθ∥πref)\beta\,\mathrm{KL}(\pi_\theta\Vert\pi_{\text{ref}}) 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: r(x,y)=βlog⁡πθ(y∣x)πref(y∣x)+constr(x,y)=\beta\log\frac{\pi_\theta(y\mid x)}{\pi_{\text{ref}}(y\mid x)}+\text{const}. 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-nn 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)
Words on this page
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)
New to this? Read first

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.

  1. Start with
  2. Step 2
  3. Step 3
  4. Then

Open problems & questions

Progress timeline

  1. Jun 13, 2024
    Controlled DPO versus PPO comparison

    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.

    source
  2. Jun 13, 2024
    Component-wise comparison
    Related to: A controlled DPO versus PPO comparison that attributes the gap to online sampling or to the reward model

    Ivison et al. (preprint) separate data, algorithm, reward model and prompts and report PPO ahead by up to 2.5% in math.

    source
  3. Apr 16, 2024
    PPO versus DPO study
    Related to: A controlled DPO versus PPO comparison that attributes the gap to online sampling or to the reward model

    Xu et al. (preprint) report PPO outperforming DPO across testbeds.

    source
  4. May 29, 2023
    DPO

    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.

    source
  5. Oct 19, 2022
    Overoptimization scaling laws

    Gao et al. measure gold reward against proxy-reward optimisation for RL and best-of-n and find smooth scaling of the fit coefficients.

    source
  6. Oct 19, 2022
    Overoptimization scaling laws
    Related to: Do reward-model overoptimization laws hold for modern RLHF and DPO-style training?

    Synthetic gold-versus-proxy setup shows smooth coefficient scaling for best-of-n and RL.

    source
  7. Mar 4, 2022
    InstructGPT

    OpenAI reports that labellers prefer a 1.3B InstructGPT to the 175B GPT-3 baseline.

    source
  8. Sep 2, 2020
    Summarisation from human feedback

    Stiennon et al. optimise a summarisation policy against a learned reward model with PPO and report gains over supervised baselines.

    source
  9. Jun 12, 2017
    RL from human preferences

    Christiano et al. train agents on Atari and simulated robotics from human comparisons of trajectory segments.

    source