RLHF & Preference Optimization
Reward models, PPO and direct preference optimization.
Every method in this family, from PPO-based RLHF to DPO and its variants, approximates one object: the reference policy tilted by a learned reward, . Knowing that object exactly tells you what each method can and cannot do, and why all of them inherit the flaws of the reward.
What you’ll learn
- State the Bradley–Terry and Plackett–Luce preference models, what they identify, and how fast a reward model learns from comparisons.
- Prove the Gibbs variational principle for KL-regularized reward maximization and the concavity of the reward–KL frontier.
- Write the token-level PPO objective used for language models, and derive DPO's reparametrization, gradient and failure modes.
- Compute the KL cost of best-of- sampling, and state the empirical laws of reward-model overoptimization.
Preference models and what they identify
Statistically, rewards are learned at a parametric rate. For a linear reward in dimensions, the negative log-likelihood is convex, and the maximum-likelihood estimate's error, measured in the norm induced by the covariance of the feature differences , is (Zhu, Jordan & Jiao, 2023). The constant grows exponentially with the range of rewards, because confident comparisons, where is small, carry little information.
A bound in that norm says nothing about directions the data never covered, which is precisely where an optimized policy goes. Zhu et al. therefore optimize a pessimistic reward, a lower confidence bound, to obtain guarantees for the policy itself.
Think first Three responses have rewards , and . Under Plackett–Luce, what is the probability that a labeler ranks them in exactly that order?
. The last factor is 1. Even with clear reward gaps, the "correct" full ranking is less likely than a coin flip, so rankings carry far more noise than their length suggests.
The KL-regularized optimum
Policies with cannot be optimal, so take and expand using :
Rearrange. Gibbs' inequality, with equality iff the distributions coincide, finishes the proof:
Dually, let . KL is convex in and is linear, so a mixture of two feasible policies is feasible for the mixed budget and earns the mixed reward: is concave and nondecreasing. The tilted family traces it, with as the Lagrange multiplier, that is, the slope:
Diminishing returns are built in: each extra nat of divergence buys less reward, even of the proxy reward being optimized. Jensen's inequality places the optimal value , a soft maximum of , between and .
Two readings of the same formula. As inference, is a Bayesian posterior with prior and likelihood for an "optimality" event, so RLHF is variational inference, and the KL term is what stops it from collapsing onto the reward's maximum (Korbak, Perez & Buckley, 2022).
As control, the sequence-level problem is a token-level MDP with KL regularization at every step, and its optimum factorizes as with a soft Q-function over prefixes . A language model trained toward implicitly represents a value function (Rafailov et al., 2024).
Think first Sampling at temperature computes for each next token. For which reward is that a KL-regularized optimum, and is per-token temperature the same as tilting whole sequences?
With , , so , exactly, for a single next-token distribution. Over sequences the tilt gives the "power distribution" , but per-token sampling produces , and the normalizers depend on the prefix. The two differ: sharpening each step is not sharpening the sequence.
PPO for language models
Treat generation as an MDP: the state is , the action is the next token, transitions are deterministic, and the episode ends at an end-of-sequence token. The reward is sparse, plus a per-token KL term (Ziegler et al., 2019; Stiennon et al., 2020):
PPO (Schulman et al., 2017) maximizes a clipped surrogate on minibatches of tokens generated by the previous policy , with advantages from generalized advantage estimation (Schulman et al., 2016) and a learned value head; InstructGPT initialized the value function from the reward model:
| Method | Samples while training | Reward | Value network | Notes |
|---|---|---|---|---|
| PPO (Ouyang et al., 2022) | yes, on-policy | learned reward model | yes | four networks in memory; many hyperparameters |
| RLOO (Ahmadian et al., 2024); GRPO (Shao et al., 2024) | yes, responses per prompt | reward model or verifier | no | baseline from the other samples: in RLOO, group-normalized rewards in GRPO |
| Best-of-, rejection sampling | yes | reward model | no | keep the best of ; use at inference, or fine-tune on it and repeat (expert iteration) |
| DPO (Rafailov et al., 2023) | no, offline pairs | implicit, | no | a supervised loss; next step |
Think first RLOO's baseline for sample averages the other rewards. Why exclude ?
A baseline may depend on anything except the action it multiplies, because . The leave-one-out mean is independent of , so the estimator stays unbiased. Including correlates baseline and action and scales the expected gradient by : harmless in direction, but a bias all the same.
Direct preference optimization, precisely
So minimizing is maximum-likelihood estimation of a Bradley–Terry reward within the class , and when that class is rich enough, the population minimizer is the KL-optimal policy for the true reward. The gradient (derived in Fine-Tuning, RLHF & Prompting) raises the chosen response's log-probability and lowers the rejected one's, weighted by , the implicit reward model's probability of getting the pair wrong.
DPO with : training has raised by 2 nats relative to the reference and lowered by 3 nats. What probability does the implicit reward model assign to , in percent?
Show the answer
62 %
The implicit reward margin is , and ; this pair's loss is . Shifts of several nats in log-probability buy only a modest preference probability at small , which is why DPO moves log-probabilities a long way.
Three documented failure modes follow from the derivation:
- Deterministic preferences. When the data decide every pair the same way, the Bradley–Terry likelihood keeps improving as the margin grows, which drives whatever is: on finite data the KL regularization stops binding. IPO (Azar et al., 2024) replaces by a squared loss that regresses the log-ratio margin to a finite target , with playing the role of .
- Offline coverage. The loss sees only the dataset's responses. It can lower the probability of both and while mass moves to responses never shown, a widely reported effect (e.g., Pal et al., 2024), and it cannot correct the current policy's errors on responses the data lack. Iterated or online DPO, which relabels fresh samples, addresses this.
- Length. Sequence log-ratios scale with length, and preference data often favor longer answers; length-normalized, reference-free variants such as SimPO (Meng et al., 2024) respond to this.
Is offline preference optimization as good as on-policy RL? Careful comparisons found well-tuned PPO ahead on harder tasks such as code generation, and on-policy samples helpful in general (Xu et al., 2024; Tajwar et al., 2024), while several openly documented pipelines, such as Llama 3's (2024), ran DPO in rounds on freshly sampled, reward-ranked responses. As of the mid-2020s the question is contested and probably task-dependent.
Overoptimization, sycophancy and AI feedback
Let be the CDF of under , so that is uniform on . The best of has the largest , whose density is . With no ties, is one-to-one, so the likelihood ratio of responses is that of :
Take the expectation of its logarithm under , where and :
The divergence grows only logarithmically: best-of-1,000 costs about 5.9 nats. Best-of- is a gentle optimizer, which makes it a useful yardstick for how far RL has moved a policy.
Using the theorem, what is for best-of-16, in nats?
Show the answer
1.84 nats
nats, so on the axis Gao et al. used. Doubling adds only about nats.
Gao, Schulman & Hilton (2023) measured overoptimization in a synthetic setup: a large "gold" reward model stands in for human raters, and proxy reward models are trained on its labels. With , the gold reward of the optimized policy fit
Why does true quality fall? Regressional Goodhart: if proxy true reward independent noise, selecting high proxy scores also selects noise; in the Gaussian case the expected true reward given a proxy value is shrunk toward the mean, for centered variables. Extremal Goodhart: far from the training distribution the proxy's errors stop being small noise and become systematic, and an optimizer seeks them out.
Observed symptoms include reward that tracks length itself (Singhal et al., 2023) and sycophancy, telling users what they appear to want: it increased with model size and RLHF in model-written evaluations (Perez et al., 2023), and human preference data, and preference models trained on them, sometimes favor convincing sycophantic answers over correct ones (Sharma et al., 2024). Mitigations include reward-model ensembles and uncertainty penalties (Coste et al., 2024), held-out gold evaluations and early stopping on KL; see Specification Gaming & Reward Hacking.
AI feedback. Constitutional AI (Bai et al., 2022) replaces human harmlessness labels with model judgments guided by a short written list of principles: a supervised stage in which the model critiques and revises its own responses, then RL against a preference model trained on AI-chosen comparisons (RLAIF). Lee et al. (2023) reported RLAIF performing comparably to RLHF on summarization and dialogue. AI feedback scales and is auditable through its principles, but it imports the labeling model's own biases, such as a preference for its own style.
Key takeaways
- Preference models identify rewards only up to a per-prompt shift, and the shift changes neither the comparisons nor the KL-optimal policy.
- Gibbs variational principle: , attained only by ; the reward–KL frontier is concave with slope .
- PPO optimizes the token-level problem with a per-token KL penalty and a value head; RLOO and GRPO drop the value network; DPO reparametrizes the reward by the policy and needs no sampling, at the cost of offline coverage and unbounded margins on deterministic data.
- Best-of- costs exactly nats without ties. Under a proxy reward, true reward peaks and then falls as KL grows (Gao et al., 2023); length bias and sycophancy are common symptoms.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
What is the maximum over policies of ?
Show the answer
C.
By the Gibbs variational principle the value is , a soft maximum of that lies between (by Jensen) and , tending to them as and .
A policy returns the highest-reward response among 20 independent samples from , with no ties in reward. What is its KL divergence from ?
- nats
- nats
- nats
- nats
Show the answer
B. nats
. The likelihood ratio is at most , so is only an upper bound; the exact value subtracts .
Every pair in a preference dataset appears exactly once, so each comparison is decided one way in the data. What does the DPO objective do as training continues, whatever is?
- It converges to the KL-optimal policy for the true reward
- It stops once the margin reaches a value set by
- It raises the probability of both responses in each pair
- It keeps pushing down, because decreases for every finite margin
Show the answer
D. It keeps pushing down, because decreases for every finite margin
only as , so on such data empirical DPO has no finite minimizer, and the KL regularization, present only implicitly through the parametrization, stops binding (Azar et al., 2024). Early stopping, IPO's squared loss or label smoothing restore a finite target.
During PPO-based RLHF, a sampled response's summed KL term comes out positive. What does that mean?
- Nothing is wrong: it is a one-sample estimate of , and individual samples can have either sign
- The KL divergence has become negative, so there is a bug
- The policy has collapsed back onto the reference
- The reward model is being overoptimized
Show the answer
A. Nothing is wrong: it is a one-sample estimate of , and individual samples can have either sign
For this response , which happens for some responses whenever the two policies differ. Only the expectation is a divergence; some implementations use lower-variance estimators that are non-negative for every sample.
Further reading
- P. F. Christiano, J. Leike, T. B. Brown, M. Martic, S. Legg & D. Amodei, "Deep reinforcement learning from human preferences," NeurIPS (2017).
- L. Ouyang et al., "Training language models to follow instructions with human feedback," NeurIPS (2022).
- R. Rafailov, A. Sharma, E. Mitchell, S. Ermon, C. D. Manning & C. Finn, "Direct preference optimization: Your language model is secretly a reward model," NeurIPS (2023).
- L. Gao, J. Schulman & J. Hilton, "Scaling laws for reward model overoptimization," ICML (2023).
- S. Casper et al., "Open problems and fundamental limitations of reinforcement learning from human feedback," Transactions on Machine Learning Research (2023).