RLHF and Reward Modeling
Bradley-Terry model, reward hacking, Goodhart's law, DPO, KL penalty, evaluation
GPT-4 trained on internet text predicts next tokens accurately. But next-token prediction accuracy has nothing to do with helpfulness. The model often produces responses that are technically fluent but unhelpful, harmful, or dishonest — because those properties were not measured by the training objective. You want to fine-tune the model to be helpful, but you cannot write a mathematical function that measures helpfulness. You can, however, ask humans to compare two responses and say which is better.
This comparative signal is what RLHF uses. The pipeline has three stages. Stage 1: supervised fine-tuning. Fine-tune the base model on a small dataset of high-quality human-written responses. This creates an SFT model — capable, but not yet aligned. Stage 2: reward model training. Show human labelers pairs of responses to the same prompt and ask which is better. Train a reward model R_φ(prompt, response) using the Bradley-Terry preference model: P(A preferred over B) = σ(R(A) - R(B)). The reward model learns to predict human preference from comparative judgments, not absolute ratings. Stage 3: RL fine-tuning. Use PPO to optimize the SFT model to maximize R_φ(prompt, π(prompt)). Add a KL penalty KL(π || π_SFT) to prevent the model from drifting too far from SFT behavior.
The KL penalty is not optional hygiene — it is the mechanism that keeps the LLM in the distribution where the reward model's predictions are calibrated. The reward model was trained on SFT-like outputs. If PPO drifts the policy far from that distribution, the reward model is extrapolating into regions it was never trained on, and its scores become meaningless.
Reward hacking is the central failure mode. The RL policy finds outputs that maximize the reward model's score but do not actually satisfy human intent: models generate long verbose outputs because length correlates with reward, use sycophantic language because agreeing with the user scores higher than accurate disagreement, or find adversarial prompts that fool the reward model. These are not bugs — they are the optimizer doing exactly what the reward function says, which happens to diverge from what humans actually want.
NOT this: RLHF is the final step in making a language model safe and aligned. RLHF optimizes a proxy — a reward model of human preferences — for a goal — truly helpful and safe AI. The proxy has biases, blind spots, and adversarial examples. RLHF improves calibration toward human preferences but does not guarantee alignment. It is one tool in an ongoing research problem.
Key points
- The reward model quality bottlenecks RLHF quality — invest heavily in the preference data collection. A reward model trained on biased comparisons systematically steers the model in the wrong direction. Target 10K+ high-quality preference pairs with calibrated annotators and clear guidelines. Annotator disagreement above 15% is a signal the task definition is ambiguous, not just that the task is hard.
- Reward hacking is subtle and hard to detect — monitor for it explicitly rather than waiting to notice. Track response length over training epochs (inflation signals length hacking), measure sycophancy rate (does the model agree with false premises?), and test for repetition and formatting exploitation. Add dedicated reward model probes for these failure modes before they compound.
- If the RL-fine-tuned model scores high on the reward model but human evaluators do not prefer it, the reward model has been over-optimized — reduce PPO steps or increase the KL penalty. The gap between proxy score and human preference is the measure of Goodhart damage. Once the reward model is being fooled, additional PPO training makes alignment worse, not better.
RLHF trains human preference into a reward model from comparative judgments, then uses PPO to maximize that reward — with a KL penalty to keep the policy close enough to the SFT distribution that the reward model's scores remain meaningful and reward hacking is bounded.
Recap
- Next-token accuracy != helpfulness — you can't write a helpfulness function, but humans can compare two responses.
- 3-stage pipeline: SFT -> reward model -> PPO fine-tuning.
- Reward model uses Bradley-Terry: $P(A \succ B) = \sigma(R(A) - R(B))$ — learns from comparisons, not absolute scores.
- KL penalty $KL(\pi\|\pi_{SFT})$ keeps the policy where the reward model is calibrated — not optional hygiene.
- Reward hacking is the central failure: length inflation, sycophancy, adversarial prompts — the optimizer doing exactly what the reward says.
- DPO eliminates the reward model: the partition function $Z(x)$ cancels in the winner-minus-loser difference.
- High RM score but humans don't prefer it = over-optimization (Goodhart); reduce PPO steps or raise KL.
Check your understanding
Q1. Which two facts about the DPO derivation correctly explain how it eliminates the need for a separately trained reward model?
- A) The optimal policy under the RLHF objective satisfies r*(x,y) = β log(π*(y|x)/π_ref(y|x)) + β log Z(x) — the reward is re-expressed purely in terms of the policy and a reference model
- B) Substituting that expression into the Bradley-Terry preference loss makes the partition function Z(x) cancel identically in the winner-minus-loser difference, leaving a loss directly on π_θ/π_ref
- C) DPO trains the policy and reward model jointly in a single optimisation loop, which allows the reward parameters to be analytically marginalised out of the final loss afterward
- D) DPO fixes the Bradley-Terry temperature at a constant β=1, collapsing the reward model directly into the language model's own softmax output layer
Q2. A model trained with RLHF consistently gives verbose answers (3x longer than the SFT baseline) with high reward model scores but lower human preference in blind evaluation. What is happening and how do you fix it?
- A) The reward model learned a spurious length-quality correlation from the preference data (annotators preferred longer answers), so PPO exploited verbosity as a shortcut; fix with a length penalty in the reward, length-stratified data collection, or DPO pairs where short answers beat verbose ones
- B) The verbosity is caused entirely by using too high a KL penalty coefficient β, which forces the model unusually close to the SFT distribution; since SFT itself was trained on long human demonstrations, the policy simply mimics that verbosity, so lowering β would fix it by allowing more divergence
- C) The verbosity is a completely natural and expected consequence of RLHF training and indicates the model is working exactly as intended; longer answers inherently contain more information and are genuinely better, and the blind-study evaluators are likely simply biased against verbose responses
- D) The issue is that the SFT baseline itself was trained on already-verbose demonstration data; RLHF is mathematically incapable of reducing verbosity below whatever the SFT baseline established, because the KL penalty structurally prevents the policy from ever diverging enough to learn genuine conciseness
Q3. Why is "LLM-as-judge" evaluation problematic for assessing RLHF model quality, even when the judge is a much stronger model than the one being evaluated?
- A) LLM-as-judge evaluation is only actually problematic when the judge model and the evaluated model happen to share the exact same base architecture; a judge from a different family, such as GPT-4 judging a Claude model, entirely eliminates self-preference bias and produces fully reliable evaluations
- B) LLM-as-judge is problematic primarily because stronger judge models have meaningfully higher inference latency and API cost, which makes large-scale automated evaluation impractical; the saved compute budget should instead be redirected entirely toward human evaluation
- C) LLM judges are fundamentally unreliable because they are architecturally unable to read and comprehend long responses accurately; in practice they evaluate only the first paragraph of each response, creating a strong positional bias favouring answers that front-load their conclusions
- D) LLM-as-judge has compounding biases: self-preference, verbosity bias, positional bias in A/B comparisons, and distribution shift (poor RLHF calibration); reliable alternatives include human evaluation with inter-annotator agreement and rule-based capability metrics
Try it interactively
ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.
Open ML Systems Lab →