Reward models and preference data¶
A reward model turns thousands of human judgements of the form "answer A is better than answer B" into a function that scores any answer with one number. It is logistic regression on score differences, stacked on top of a language model. Everything downstream (PPO, best-of-n, rejection sampling) optimises that number, so the one idea to keep is this: a reward model is a proxy, accurate where its data was and exploitable everywhere else.
10,000 ft
Supervised fine-tuning can only imitate, and it has no way to say "this answer is worse than that one". Comparisons fix both problems. People find it much easier to recognise the better of two answers than to write the best one, so comparison data can push a model past its demonstrators. The idea of learning a reward from human comparisons comes from deep RL (Christiano et al., 2017). It became the centre of language-model alignment with summarisation (Stiennon et al., 2020) and InstructGPT (Ouyang et al., 2022). The reward model is the judge that RLHF with PPO optimises against, and DPO folds it into the policy itself. Constitutional AI has a model write the labels, and RL with verifiable rewards replaces the learned judge with a program wherever one exists. Its statistics come straight from logistic regression, and its failure (reward hacking) is a small, measurable version of the alignment problem.
2,000 ft
Sample two or more answers per prompt from the SFT model. Have people pick the better one (or rank several). Train a copy of the language model, with its vocabulary head replaced by a single linear output, so that the preferred answer scores higher: the loss is \(-\log\sigma(r_w - r_l)\), the Bradley–Terry model. Train for about one epoch, normalise the scores, and check accuracy on held-out comparisons (expect 65–75%, close to how often labellers agree with each other). Then use it: as the reward in RL, to pick the best of \(n\) samples, or to filter data. Always watch for the policy finding what the judge over-rewards: length, confidence, flattery.
Ground level¶
Why comparisons, not scores¶
The obvious way to get a reward is to ask people for one: "rate this answer from 1 to 7". It works badly. Each rater uses the scale differently, one person's 5 is another's 3, and the same person drifts over a session. Absolute scores also have no anchor: is this summary a 6 because it is good, or because the last three were bad?
Comparisons remove most of this noise. Shown two answers to the same prompt, people agree with each other much more often, because the shared prompt and the side-by-side view cancel out their personal offsets. In the TL;DR summarisation work, trained labellers agreed with the researchers 77% ± 2% of the time on comparison tasks (Stiennon et al., 2020). Christiano et al. showed the approach was cheap enough to matter: a simulated hopping robot learned to do backflips from 900 comparisons of short video clips, collected in under an hour (Christiano et al., 2017), a behaviour nobody knew how to write a reward function for.
There is also an economic argument, which Meta's Llama 2 team made explicit: once the SFT model writes about as well as the annotators, paying people to write answers buys little, while paying them to compare the model's own answers buys signal at the frontier of what it can do (Touvron et al., 2023).
The Bradley–Terry model¶
To learn from comparisons we need a model of how a reward turns into a choice. The standard one is the Bradley–Terry model (Bradley and Terry, 1952), the same model behind Elo ratings in chess: each answer has a latent score \(r\), and
Worked example: if the reward model gives answer A a score of 1.2 and answer B 0.4, it predicts that a labeller prefers A with probability \(\sigma(0.8) = 0.690\). If the labeller did pick A, the loss on this pair is \(-\log 0.690 = 0.371\), and its gradient pushes \(r_A\) up and \(r_B\) down, each by a factor \(1 - 0.690 = 0.310\). Had the labeller picked B, the loss would be \(-\log\sigma(-0.8) = 1.171\) and the gradient factor 0.690: wrong, confident predictions are corrected hardest, exactly as in logistic regression.
Three properties of this model shape everything that follows.
- Only differences matter. Adding 5 to every score changes no prediction. The reward has an arbitrary zero, which is why InstructGPT normalised its reward model "using a bias so that the labeler demonstrations achieve a mean score of 0 before doing RL" (Ouyang et al., 2022).
- The scale is set by the noise. A difference of 1 means "preferred 73% of the time"; a difference of 2 means 88%. If labellers were perfectly consistent, the scores would be pushed to infinity, so a reward model trained on clean, near-deterministic data has a large scale and one trained on noisy data a small one. The reward's units are "log-odds of a labeller preferring it".
- It is a one-dimensional ranking. Bradley–Terry assumes every answer sits on one line. Real preferences are not always like that (see first principles).
What a reward model looks like inside¶
Take the SFT model (or a pre-trained model), remove the unembedding layer that maps a hidden state to \(V\) vocabulary logits, and put a linear layer with one output in its place. Feed in the prompt and response, and read the output at the final token, after the whole answer has been seen. That position is the only one whose hidden state has attended to every token of the response; reading the reward anywhere else scores a partial answer. Re-implementations get this wrong often enough that Huang et al. list "extract reward from the EOS token" as an explicit detail (Huang et al., 2024, detail 12).
Why start from a language model at all? Because judging an answer requires understanding it. A reward model has to know that a summary contradicts its source or that code will not run, and all of that knowledge lives in the pre-trained weights. Reward models are typically the same size as the policy or somewhat smaller. InstructGPT used a 6B reward model for policies up to 175B, because 175B reward models trained less stably and would have multiplied the cost of RL (Ouyang et al., 2022, appendix C.2).
Training is short. InstructGPT trained "for a single epoch" because "multiple epochs quickly overfit the model to the training data". A reward model memorises its training pairs fast, and an overfitted judge is worse than an undertrained one when a policy is about to search for its mistakes.
Collecting preference data¶
A preference dataset is a list of \((x, y_w, y_l)\) triples: a prompt, the chosen ("winning") answer and the rejected ("losing") one. How you collect them decides what the reward model learns.
Where the answers come from. Answers should come from the model you are about to optimise, or one close to it, because the reward model has to be accurate on that model's outputs. Llama 2's team noted that the role of their reward signal was "to learn human preference for Llama 2-Chat outputs rather than any model outputs", and they refreshed preference data from the latest model at every iteration (Touvron et al., 2023). Anthropic went further with iterated online training, updating "preference models and RL policies … on a weekly cadence with fresh human feedback data" (Bai et al., 2022).
Pairs or rankings. InstructGPT showed labellers between \(K = 4\) and \(K = 9\) answers to rank, which yields \(\binom{K}{2}\) comparisons (6 to 36) per screen. Because those comparisons share answers, they are highly correlated; shuffled into one dataset, "a single pass over the dataset caused the reward model to overfit". The fix was to put all \(\binom{K}{2}\) comparisons from one prompt into the same batch element, scoring each answer once. A batch of 64 prompts could then hold up to 2,304 comparisons (Ouyang et al., 2022).
Strength of preference. Llama 2 asked annotators how much better: significantly, better, slightly, or negligibly better/unsure. They used it in two ways: as a margin in the loss (below), and to diagnose accuracy. Their helpfulness reward model was right 80.7% of the time on "significantly better" pairs and 54.7% on "negligibly better" ones, near a coin flip (Touvron et al., 2023, table 8). The pairs that matter most for RL, between two good answers, are the ones a reward model finds hardest.
What the labellers are told. Guidelines define the reward. InstructGPT's labellers were told to prioritise helpfulness during training-data labelling but truthfulness and harmlessness in final evaluations. Anthropic collected helpfulness and harmlessness comparisons separately and found a measurable tension between them (Bai et al., 2022); Llama 2 trained two separate reward models for the same reason. A single "which is better?" question hides a policy decision about how to trade those values, and whoever writes the guidelines makes it.
| Dataset | Who labelled | Size | Notes |
|---|---|---|---|
| InstructGPT (OpenAI, 2022) | ~40 contractors | 33k training prompts, ranked 4–9 ways | The canonical recipe; not released |
| Anthropic HH-RLHF (2022) | Crowdworkers | Released publicly | Helpful and harmless subsets, collected separately |
| Llama 2 (Meta, 2023) | Vendor annotators | 1,418,091 Meta comparisons, plus open data | Four-level strength ratings; separate safety data |
| UltraFeedback (2023) | GPT-4 | Over 1M feedback annotations on 250k conversations | AI feedback at scale; widely used for open DPO models |
| HelpSteer2 (NVIDIA, 2024) | Human annotators | About 10,000 response pairs | Multi-attribute scores; CC-BY-4.0 |
Sources: Ouyang et al., Bai et al., Touvron et al., Cui et al., Wang et al.. Labelling operations, quality control and annotator management are covered in labelling and human feedback.
How good can a reward model be?¶
The ceiling is set by people, not by the model. If two labellers agree only 73% of the time, no reward model can predict a held-out labeller much better than that. The numbers line up:
| Study | Labeller–labeller agreement | Best reward model accuracy |
|---|---|---|
| TL;DR summaries (Stiennon et al., 2020), on CNN/DM transfer | 66.9% | 66.5% (6.7B RM) |
| InstructGPT (Ouyang et al., 2022) | 72.6% ± 1.5% (training labellers) | 69.6% ± 0.9% on held-out labellers |
| Llama 2 (Touvron et al., 2023), Meta Helpful test set | — | 63.2% average; 80.7% on clear-cut pairs |
So 65–75% accuracy is not a weak reward model; it is close to the irreducible noise in the task. The Build it section below reproduces this: a reward model fitted on simulated labellers reaches 71.8% held-out accuracy against a ceiling of 72.7%.
Within that ceiling, scale helps steadily. Stiennon et al. trained reward models from 160M to 13B parameters on 8k to 64k comparisons and found that doubling the data gave about 1.1% more validation accuracy, while doubling the model size gave about 1.8%.
Evaluating a reward model¶
Held-out accuracy is necessary and not sufficient. Three further checks matter.
- Accuracy by difficulty. Report accuracy separately for clear and close pairs, as Llama 2 did. A model at 65% overall can be at 55% on the pairs RL will actually generate.
- Benchmarks. RewardBench scores a reward model on curated chosen/rejected pairs in four categories: Chat, Chat Hard, Safety and Reasoning (Lambert et al., 2024); its leaderboard is public. Models quickly saturated it, and RewardBench 2 (2025) uses new, unseen human prompts; models score "about 20 points on average lower" on it, and its scores correlate with downstream best-of-\(n\) and PPO results (Malik et al., 2025).
- Use it and look. The test that matters is downstream: run best-of-\(n\) with the reward model, or a short RL run, and have people (or a strong judge) compare the outputs with the unoptimised ones. A reward model can rank fixed pairs well and still have exploitable blind spots that only appear when something searches for them.
Reward hacking and overoptimisation¶
Goodhart's law in one line: when a measure becomes a target, it stops being a good measure. A reward model is trained on answers from the SFT model; RL and best-of-\(n\) then search for answers it scores highly. The highest-scoring answers are, increasingly, the ones where the reward model is wrong, because its errors are the only direction in which its score can keep rising once the real improvements are used up.
Stiennon et al. saw it directly: "as we optimize further, true preferences fall off compared to the prediction, and eventually the reward model becomes anti-correlated with human preferences". Gao, Schulman and Hilton then measured it cleanly (Gao et al., 2022). They used a large "gold" reward model in place of humans, trained smaller proxy reward models on its labels, optimised against the proxy, and tracked the gold score. Writing \(d = \sqrt{\mathrm{KL}(\pi\,\|\,\pi_{\text{init}})}\) for how far the policy has moved, they found the gold score follows
rising, peaking and then falling, while the proxy score keeps going up. The coefficients varied smoothly with reward-model size, larger reward models reached higher gold scores overall, and the size of the policy barely changed how much overoptimisation occurred.
The things a reward model over-rewards are not random. They are the systematic biases of the people (or models) who labelled the data, amplified.
- Length. Longer answers look more thorough. Singhal et al. found that "even a purely length-based reward reproduces most downstream RLHF improvements over supervised fine-tuned models", and traced the bias mainly to reward models (Singhal et al., 2023).
- Agreement with the user. Sharma et al. found that "when a response matches a user's views, it is more likely to be preferred", and that both humans and preference models sometimes prefer "convincingly-written sycophantic responses over correct ones" (Sharma et al., 2023).
- Confidence and format. Lists, headers and assertive tone read as competence; a judge that cannot check facts rewards the look of correctness.
The defences, each with its limits:
| Defence | How it helps | Limit |
|---|---|---|
| KL penalty to the SFT model (RLHF page) | Keeps the policy where the RM was trained | Gao et al. found it did not improve the gold-reward-versus-KL frontier; it is mostly early stopping |
| Early stopping on held-out human or gold evals | Stops near the peak | Needs a trustworthy eval |
| Ensembles of reward models | Optimise the worst case or penalise disagreement; Coste et al. report this "practically eliminates overoptimization" for best-of-\(n\) in their synthetic setup (Coste et al., 2023) | Members share blind spots; ensembles "do not eliminate reward hacking" (Eisenstein et al., 2023) |
| Fresh preference data on the current policy | Patches the holes the policy found | Costs a labelling round per iteration |
| Explicit length control | Penalise or normalise length | Fixes one bias out of many |
| Replace the judge with a verifier | No learned errors to exploit | Only where correctness is checkable (RLVR) |
Beyond one number per answer¶
Process reward models score each step of a chain of reasoning rather than only the final answer. OpenAI's Let's Verify Step by Step collected PRM800K, "800,000 step-level human feedback labels", and found process supervision "significantly outperforms" outcome supervision on MATH: their process-supervised reward model, used to rerank samples, solved 78% of a representative subset of the MATH test set (Lightman et al., 2023). Step labels give denser credit assignment but are expensive, and in 2025 most reasoning-model training moved to outcome checks instead (see RLVR).
Generative judges use a language model's ability to write: prompt a strong model to compare two answers, explain, and give a verdict. Zheng et al. found GPT-4 as a judge agreed with human preferences over 80% of the time, "the same level of agreement between humans", while documenting position, verbosity and self-enhancement biases (Zheng et al., 2023). Training the judge to produce reasoning before the verdict, rather than a bare score, is the idea behind generative verifiers and generative reward models (Zhang et al., 2024; Mahan et al., 2024). When the judge's labels train another model, you have RLAIF; constitutional AI is the canonical recipe, and evals in practice covers judges as evaluation tools.
Verifiers are programs. They are the strongest reward when they exist, which is why reasoning models are trained mostly where they do.
Common misconceptions¶
- "A reward model with 70% accuracy is a bad reward model." It is close to human agreement on the same task. The question is whether its errors are random (harmless on average) or systematic (exploitable).
- "The reward is a measure of quality." It is a measure of what the labelling process preferred, including its biases, on the distribution it saw. Off that distribution it is an extrapolation.
- "Higher reward during RL means a better model." Only up to a point. Reward rising while human evaluations stall or fall is the signature of overoptimisation.
- "Bigger policies are harder to hack the reward with." Gao et al. found policy size made little difference to how much overoptimisation occurred; reward-model size and data mattered.
- "Reward models are obsolete now that we have DPO." DPO trains an implicit reward model; the data, the biases and the overoptimisation are the same. Explicit reward models remain central for best-of-\(n\), rejection sampling, online RL and data filtering.
First principles¶
Why a logistic of a difference? Start from a random utility model: a labeller's momentary judgement of answer \(y\) is its true score plus noise, \(u = r + \varepsilon\), and they choose the answer with the higher \(u\). Which noise? If \(\varepsilon\) is Gaussian you get the probit (Thurstone) model. If it is Gumbel-distributed you get Bradley–Terry exactly, because the difference of two independent Gumbel variables has a logistic distribution (derived below). The logistic version wins in practice because its log-likelihood is smooth and convex in the scores, its gradient is the simple error \(1 - \sigma(\Delta)\), and it extends to rankings (the Plackett–Luce model). It also satisfies Luce's choice axiom, independence of irrelevant alternatives: the odds of choosing A over B do not depend on what other options are on the screen, which is what makes it consistent to train on pairs drawn from rankings.
What can be learned. Bradley–Terry identifies scores only up to an additive constant per prompt. Within a prompt this is harmless. Across prompts it means nothing pins the reward of a great answer to a hard question against a mediocre answer to an easy one, unless some answers are shared or normalised. Policy-gradient methods do not care, since a per-prompt constant cancels in the advantage, but anything that compares rewards across prompts (filtering a dataset by reward, for instance) inherits this arbitrariness.
What cannot be represented. A scalar reward imposes a total order. Three things break it:
- Intransitive preferences: A over B, B over C, C over A. Individuals produce these occasionally; populations produce them easily (Condorcet's paradox).
- Disagreement: if half the labellers prefer concise answers and half prefer detailed ones, the reward model learns an average that may match nobody. Siththaranjan et al. prove that preference learning implicitly aggregates such "hidden context" by the Borda count, a specific voting rule, and that this can give counter-intuitive results (Siththaranjan et al., 2023).
- Context-dependent value: whether a refusal is right depends on who is asking and why, which the reward model never sees.
Why it must be a proxy. The reward model is fitted to answers from one distribution (the SFT model's) and then queried on answers from another (the optimised policy's). Any learned function extrapolates, and optimisation selects precisely the inputs where extrapolation errs upwards. This is not a fixable bug in a particular model; it is what optimising a learned function does. The question is only how fast, which is what Gao et al. measured and what the KL leash in RLHF controls.
The maths¶
Notation. Prompt \(x\); chosen and rejected responses \(y_w, y_l\); reward model \(r_\phi(x, y) \in \mathbb{R}\) with parameters \(\phi\); logistic sigmoid \(\sigma(z) = 1/(1+e^{-z})\); preference dataset \(\mathcal{D}\).
Bradley–Terry negative log-likelihood:
Write \(\Delta = r_\phi(x, y_w) - r_\phi(x, y_l)\). Since \(\frac{d}{dz}\log\sigma(z) = 1 - \sigma(z)\),
Each pair pushes the chosen score up and the rejected score down, weighted by how wrong the model currently is (\(1-\sigma(\Delta)\) is the predicted probability of the wrong label).
InstructGPT's \(K\)-wise version. With \(K\) ranked responses per prompt, average over all \(\binom{K}{2}\) pairs from the same prompt in one batch element:
Llama 2's margin loss. With a rating-dependent margin \(m(\text{rating}) \ge 0\), larger for "significantly better":
The model is only satisfied once the chosen answer beats the rejected one by at least the margin, so clear-cut pairs get pulled further apart.
Plackett–Luce, for a full ranking \(y_{\tau(1)} \succ y_{\tau(2)} \succ \dots \succ y_{\tau(K)}\):
Pick the best from all \(K\) with a softmax, remove it, pick the best of the rest, and so on. For \(K = 2\) it reduces to Bradley–Terry.
Derivation: Bradley–Terry from Gumbel noise
Let \(u_A = r_A + \varepsilon_A\) and \(u_B = r_B + \varepsilon_B\) with \(\varepsilon_A, \varepsilon_B\) independent standard Gumbel, CDF \(F(\varepsilon) = \exp(-e^{-\varepsilon})\) and density \(f(\varepsilon) = e^{-\varepsilon}F(\varepsilon)\). The labeller chooses A when \(\varepsilon_B < r_A - r_B + \varepsilon_A\). Conditioning on \(\varepsilon_A = t\),
Substitute \(s = e^{-t}\), \(ds = -e^{-t}dt\):
The same argument with \(K\) options gives the softmax, which is why the Plackett–Luce model is the "pick the max of noisy utilities" model for rankings.
Derivation: the KL divergence of best-of-n
Let the base policy \(\pi\) produce responses whose reward \(r(y)\) has a continuous distribution with CDF \(F\). Best-of-\(n\) keeps the highest-reward of \(n\) independent samples, so its density is \(\pi_n(y) = n\,F(r(y))^{\,n-1}\pi(y)\) (the chosen one must beat the other \(n-1\)). Then
Under \(\pi_n\), \(U = F(r(y))\) is the maximum of \(n\) uniform variables, with density \(nu^{n-1}\), so \(\mathbb{E}[\log U] = \int_0^1 n u^{n-1}\log u\, du = -1/n\). Hence
This is the formula Stiennon et al. and Gao et al. use. It is exact when the reward is continuous (as in our toy), and Beirami et al. showed that in general, with ties or discrete outputs, it is an upper bound on the true KL (Beirami et al., 2024). Note how slowly it grows: \(n = 1{,}000\) is under 6 nats. Best-of-\(n\) buys a lot of reward per nat, which is one reason it is the standard baseline for RL.
Normalisation. Before RL, shift the reward so that a reference set (InstructGPT: the labellers' demonstrations; many open recipes: SFT samples) has mean 0, and optionally scale to unit variance. Llama 2 also inverted the sigmoid ("whiten the final linear scores … by reversing the sigmoid with the logit function") to balance the reward against the KL term.
Build it¶
First, fit a reward model to comparisons from simulated labellers, using the same four answer styles as the SFT page. The labellers are Bradley–Terry with a utility that mostly tracks quality but also likes length a little (NumPy):
import numpy as np
rng = np.random.default_rng(0)
# The four answer styles from the SFT page, now with a length in tokens.
styles = ["correct+concise", "correct+rambling", "wrong+confident", "refuses"]
quality = np.array([1.0, 0.6, -1.0, -0.3]) # what we actually want
length = np.array([60, 240, 70, 20]) # tokens
# Labellers are Bradley-Terry with a utility that also likes length a little.
u = 2.0 * quality + 0.004 * length
sft_p = np.array([0.55, 0.30, 0.10, 0.05]) # the SFT policy we sample pairs from
def make_pairs(n):
a, b = rng.choice(4, n, p=sft_p), rng.choice(4, n, p=sft_p)
keep = a != b # identical answers carry no signal
a, b = a[keep], b[keep]
a_wins = rng.random(len(a)) < 1 / (1 + np.exp(-(u[a] - u[b])))
return np.where(a_wins, a, b), np.where(a_wins, b, a) # (chosen, rejected)
w_tr, l_tr = make_pairs(4000)
w_te, l_te = make_pairs(2000)
r = np.zeros(4) # tabular reward model: one score per style
for step in range(3000): # gradient ascent on BT log-likelihood
p = 1 / (1 + np.exp(-(r[w_tr] - r[l_tr]))) # P(chosen beats rejected) under the model
g = np.zeros(4)
np.add.at(g, w_tr, 1 - p); np.add.at(g, l_tr, -(1 - p))
r += 0.5 * g / len(w_tr)
r -= r @ sft_p # normalise: mean reward 0 under the SFT policy
print("style fitted r labeller utility (centred)")
for s, ri, ui in zip(styles, r, u - u @ sft_p):
print(f"{s:17s} {ri:+8.3f} {ui:+8.3f}")
acc = np.mean(r[w_te] > r[l_te])
ceiling = np.mean(np.maximum(1, np.exp(u[w_te] - u[l_te])) /
(1 + np.exp(u[w_te] - u[l_te]))) # Bayes-optimal accuracy
print(f"held-out accuracy {acc:.3f} ceiling set by labeller noise {ceiling:.3f}")
print(f"rambling vs concise: true quality says concise by {quality[0]-quality[1]:.1f}, "
f"RM says concise by {r[0]-r[1]:+.3f}")
style fitted r labeller utility (centred)
correct+concise +0.549 +0.558
correct+rambling +0.440 +0.478
wrong+confident -3.322 -3.402
refuses -2.041 -2.202
held-out accuracy 0.718 ceiling set by labeller noise 0.727
rambling vs concise: true quality says concise by 0.4, RM says concise by +0.109
Three things to read off. The fitted scores recover the labellers' utility (up to sampling noise), including their taste for length. Accuracy, 71.8%, sits just under the 72.7% that a perfect model could reach given the labellers' noise, the same gap InstructGPT reports (69.6% against 72.6%). And the concise answer, which is clearly better, wins by only 0.109 in reward: a small error in the data has become a small gap a policy can exploit. The RLHF page optimises a policy against exactly these scores.
Second, overoptimisation with best-of-\(n\). Each candidate has a hidden quality \(g\) and a standardised length \(z\); the proxy has learned "longer is better" linearly (NumPy):
import numpy as np
rng = np.random.default_rng(0)
# Each candidate answer has a hidden true quality g and a (standardised) length z.
# Gold reward (what people really want): quality, with moderate length mildly good
# and extreme length bad. Proxy reward model: learned "longer is better" linearly.
def gold(g, z): return g + 0.3 * z - 0.5 * z**2
def proxy(g, z): return g + 1.0 * z
trials = 4000
print(" n KL_bon(nats) proxy score gold score")
for n in [1, 2, 4, 8, 16, 32, 64, 128, 256, 1024, 4096]:
g = rng.normal(size=(trials, n)); z = rng.normal(size=(trials, n))
pick = proxy(g, z).argmax(axis=1) # best-of-n by the reward model
rows = np.arange(trials)
kl = np.log(n) - (n - 1) / n # exact KL of best-of-n from the base policy
print(f"{n:5d} {kl:10.2f} {proxy(g, z)[rows, pick].mean():11.2f}"
f" {gold(g, z)[rows, pick].mean():10.2f}")
n KL_bon(nats) proxy score gold score
1 0.00 0.00 -0.52
2 0.19 0.81 0.02
4 0.64 1.45 0.34
8 1.20 2.02 0.45
16 1.84 2.50 0.51
32 2.50 2.93 0.52
64 3.17 3.31 0.46
128 3.86 3.67 0.40
256 4.55 3.99 0.31
1024 5.93 4.59 0.09
4096 7.32 5.13 -0.21
The proxy score climbs without limit; the gold score peaks around \(n = 32\) (2.5 nats from the base policy) and by \(n = 4096\) is worse than taking the first sample. Nothing about the proxy's own numbers warns you.
Finally, the reward head and loss in PyTorch (standard code; not run here):
import torch, torch.nn as nn, torch.nn.functional as F
class RewardModel(nn.Module):
def __init__(self, body, d_model):
super().__init__()
self.body = body # a transformer returning hidden states (B, T, d)
self.head = nn.Linear(d_model, 1) # replaces the vocabulary projection
def forward(self, input_ids, attention_mask):
h = self.body(input_ids, attention_mask=attention_mask) # (B, T, d)
last = attention_mask.sum(dim=1) - 1 # index of final real token
h_last = h[torch.arange(h.size(0)), last] # (B, d)
return self.head(h_last).squeeze(-1) # (B,)
def bradley_terry_loss(r_chosen, r_rejected, margin=0.0):
return -F.logsigmoid(r_chosen - r_rejected - margin).mean()
Things to try
- In the first program, set the length coefficient to 0.01. At what value does the reward model rank "correct+rambling" above "correct+concise"?
- Replace the labellers' noise with a mixture: half the labellers like length, half dislike it. What does the fitted reward model say about rambling, and does it match either group?
- In the second program, add an ensemble: three proxies with length weights 0.6, 1.0 and 1.4, and pick by their minimum. Where does the gold score now peak?
- Train a real reward model with TRL's RewardTrainer on a small preference set, then score 20 answers of very different lengths. Plot reward against length.
Check yourself¶
Why does the Bradley–Terry model only determine rewards up to a constant, and what do practitioners do about it?
The likelihood depends on \(r_A - r_B\) only, so adding any constant to every score (per prompt, even) leaves every prediction unchanged. Practitioners normalise: shift so that a reference set (demonstrations or SFT samples) has mean reward 0, and often scale to unit variance, so that the reward and the KL penalty in RL have comparable magnitudes.
Your reward model reaches 68% held-out accuracy. Your labellers agree with each other 71% of the time. Is the reward model good?
Very likely yes on that distribution: it is near the ceiling the label noise allows. Next check accuracy on close pairs, accuracy on samples from the policy you will optimise (not just the SFT model), and a downstream test such as best-of-\(n\) judged by people.
Why did InstructGPT put all comparisons from one ranking in the same batch element?
The \(\binom{K}{2}\) comparisons share responses, so they are highly correlated. Shuffled into the dataset as independent examples, each response contributes to \(K-1\) gradient updates in an epoch, and the model overfitted after a single pass. Grouping them also means each response is scored by one forward pass instead of \(K-1\).
Give the KL divergence of best-of-16 from the base policy, and explain why best-of-n is a hard baseline for RL to beat.
\(\log 16 - 15/16 = 2.773 - 0.938 = 1.84\) nats (an upper bound in general, exact for continuous rewards). Best-of-\(n\) reaches high reward at small KL, needs no training, and cannot drift into states far from the base model. RL has to beat it per unit of KL, and Gao et al. found RL is "slower than best-of-n sampling at both optimization and overoptimization" as a function of KL.
Gao et al. found the KL penalty did not improve the gold-reward-versus-KL frontier. Why use one at all?
A KL penalty changes where along the frontier training ends up (it caps how far the policy moves) without moving the frontier itself. That still matters: it stabilises training, keeps outputs fluent, and acts as a soft form of early stopping, so you land nearer the peak. What it does not do is make a given amount of movement safer.
Hard: half your labellers prefer concise answers and half prefer detailed ones, each strongly. What does a single Bradley–Terry reward model learn, and what does a policy optimised against it do?
It learns a compromise ranking that is the Borda-count-like aggregate of both groups (Siththaranjan et al.), with a small score difference between concise and detailed answers, because the pooled labels look like noise. The policy then optimises other features that both groups weakly agree on, and may settle on a middle length that neither group prefers. Fixes include conditioning on user context, distributional reward models, or separate models per objective with an explicit trade-off.
Hard: why does reading the reward from the final token matter, and what goes wrong in PPO if responses are truncated before the end-of-turn token?
Only the final position has attended to the whole response, so it is the only one whose hidden state summarises it. If a response is truncated at the length limit without an end-of-turn token, the reward model scores a partial answer it never saw in training, and the score is meaningless. Implementations therefore give truncated responses a fixed penalty or discard them (the "EOS trick", detail 23 in Huang et al., 2024).
Go deeper¶
Papers
- Deep reinforcement learning from human preferences — Christiano et al., 2017. Where learning a reward from comparisons started; section 2 is the whole method.
- Learning to summarize from human feedback — Stiennon et al., 2020. The first convincing language result; read section 4.3 on what the reward model learned and its overoptimisation curve.
- Training language models to follow instructions with human feedback — Ouyang et al., 2022. Section 3.5 and appendix C.2 for reward-model training details.
- Training a Helpful and Harmless Assistant with RLHF — Bai et al., 2022. Preference-model scaling, calibration and the helpfulness/harmlessness tension.
- Scaling Laws for Reward Model Overoptimization — Gao, Schulman and Hilton, 2022. The gold-versus-proxy experiment. Short; read all of it.
- Llama 2: Open Foundation and Fine-Tuned Chat Models — Touvron et al., 2023. Section 3.2: the margin loss, two reward models, and accuracy by preference strength.
- Let's Verify Step by Step — Lightman et al., 2023. Process versus outcome reward models, and PRM800K.
- RewardBench and RewardBench 2 — Lambert et al., 2024; Malik et al., 2025. How reward models are evaluated, and why accuracy on fixed pairs is not enough.
- A Long Way to Go: Investigating Length Correlations in RLHF — Singhal et al., 2023. The length-only reward experiment.
- Towards Understanding Sycophancy in Language Models — Sharma et al., 2023. How human preference data rewards agreement over truth.
- Open Problems and Fundamental Limitations of RLHF — Casper et al., 2023. A taxonomy of everything that can go wrong with human feedback and reward models.
Videos and lectures
- Stanford CS224N (2023), Lecture 10: Prompting, Reinforcement Learning from Human Feedback — Stanford Online. Reward modelling in the context of the whole pipeline, at lecture pace.
- Reinforcement Learning from Human Feedback: From Zero to chatGPT — Hugging Face. A practitioner walkthrough of reward models and RLHF.
- John Schulman: Reinforcement Learning from Human Feedback: Progress and Challenges — UC Berkeley EECS. Why comparisons, and what reward models get wrong, from an InstructGPT author.
Articles
- Illustrating Reinforcement Learning from Human Feedback — Hugging Face blog. Clear diagrams of the reward-model stage.
- Reward Hacking in Reinforcement Learning — Lilian Weng, 2024. A comprehensive survey of reward hacking, from classic RL to RLHF.
- RLHF: Reinforcement Learning from Human Feedback — Chip Huyen, 2023. The pipeline from an engineer's point of view, with the data-collection details.
Books
- RLHF book: Reward Modeling and Preference Data — Nathan Lambert. The two chapters that go with this page.
Code
- allenai/reward-bench — Evaluation code for RewardBench; useful for seeing how reward models are actually called.
- huggingface/trl — RewardTrainer: the Bradley–Terry loss, margins and centring in a few hundred lines.
Where this leads¶
- RLHF with PPO: optimise a policy against the reward model, with a KL leash.
- DPO and direct preference optimisation: skip the explicit reward model and fit the preferences directly.
- Constitutional AI and RLAIF: let a model, guided by written principles, produce the comparisons.
- RL with verifiable rewards: replace the learned judge with a checker where one exists.