Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Learning what people prefer
It is hard to write down what makes an answer good, but easy for people to say which of two answers they prefer. A reward model learns from thousands of such choices and gives every answer a score: higher means people would like it more. Later the language model is trained to produce high-scoring answers. People disagree and make mistakes, so the reward model can only be as good as the choices it learns from. The demo shows how a score difference turns into a preference probability.
Preference data from engineers (clearer procedure, safer recommendation, correct citation) can train a reward model that scores an assistant’s answers for a specific organisation’s standards.
- 1. A reward model is trained on…
- 2. Its output for an answer is…
- 3. Human labels are limited by…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Data: prompts, several model responses, and human choices (pairwise, or rankings of k responses giving k(k − 1)/2 pairs: 36 for k = 9 in InstructGPT). Often with ties and confidence ratings.
- Bradley–Terry: P(A > B) = σ(r(A) − r(B)); a reward gap of 2 means 88% preference, and 75% preference corresponds to a gap of ln 3.
- Loss: −log σ(r(chosen) − r(rejected)), averaged over comparisons (the same as logistic regression on differences). Rewards are only defined up to a constant; normalise before RL.
- Architecture: usually the SFT model with its LM head replaced by a scalar head, fine-tuned for one epoch (more overfits).
- Evaluation: agreement with held-out human labels (typically 65–75%, near human inter-annotator agreement), and benchmarks such as RewardBench.
- Failure modes: label noise and inconsistency, annotator biases (length, confident tone), distribution shift once the policy improves, and exploitation by optimisation (F7-6).
- 1. Preference probability for a reward gap of 2:
- 2. Pairs from ranking 4 responses:
- 3. Typical reward-model agreement with held-out human labels:
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Reward models in code
Exercise 1.
- Compute Bradley–Terry probabilities.
- Compute the reward-model loss (ln 2 when the rewards tie).
- Measure agreement with chosen–rejected pairs.
Practice.
- TRL’s
RewardTrainerfine-tunesAutoModelForSequenceClassification(num_labels=1)on (chosen, rejected) pairs. - Train for about one epoch; check agreement on held-out pairs, and look at score distributions by length to detect length bias.
- Use several annotators per item and measure their agreement; drop or reweight ambiguous items.
- Refresh preference data with outputs of the current policy as it improves.
from trl import RewardTrainer, RewardConfig
from transformers import AutoModelForSequenceClassification
rm = AutoModelForSequenceClassification.from_pretrained("my-sft-model", num_labels=1)
RewardTrainer(model=rm, args=RewardConfig(output_dir="rm", num_train_epochs=1, learning_rate=1e-5),
train_dataset=prefs).train() # prefs: {"chosen": [...messages], "rejected": [...messages]}- 1. TRL's reward-model trainer:
- 2. Reward models are usually trained for about…
- 3. A common reward-model bias to check:
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Maximum likelihood under Bradley–Terry. If preferences follow σ(r*(A) − r*(B)), the log-likelihood of observed choices is concave in a linear reward model, and its maximiser converges to r* (up to a constant) as data grows, at a rate set by the label noise. Noisier annotators (larger temperature) flatten σ, so each label carries less information and more comparisons are needed.
Why agreement plateaus. Measured agreement against noisy labels can never exceed the agreement of the true reward with those labels. In exercise 2 that ceiling was about 0.72, even though the learned model ranked true preferences correctly 86% of the time. Low agreement scores do not necessarily mean a bad reward model.
Misspecification. A reward model can only represent what its architecture and features allow. Missing aspects of human preference (here an interaction term) remain invisible to it, and optimising against it ignores them, a seed of reward hacking (F7-6).
- 1. Noisier annotators make each label…
- 2. Agreement with noisy labels is capped by…
- 3. Preference aspects a reward model cannot represent are…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.How much preference data does a reward model need, and how good can it get?
History.
- R. A. Bradley and M. E. Terry, “Rank analysis of incomplete block designs” (Biometrika, 1952).
- P. Christiano et al., “Deep reinforcement learning from human preferences” (NeurIPS 2017).
- L. Ouyang et al., “InstructGPT” (NeurIPS 2022).
- N. Lambert et al., “RewardBench” (2024).
Exercise 2.
- Simulated preferences: responses are 16-dimensional feature vectors. The hidden human reward is linear plus an interaction term. Annotators prefer A with probability σ((r_A − r_B)/T), with T = 1 (consistent) or T = 3 (noisy).
- Reward models: linear Bradley–Terry models fitted on 50, 500 or 5000 comparisons.
- Metrics:
- accuracy on 5000 held-out noisy labels;
- accuracy against the true preference;
- the true reward of the best of 16 random responses chosen by the reward model.
| annotators | comparisons | accuracy (noisy labels) | accuracy (true preference) | best-of-16 true reward |
|---|---|---|---|---|
| T = 1 | 50 | 0.564 | 0.609 | 0.731 |
| T = 1 | 500 | 0.685 | 0.827 | 1.509 |
| T = 1 | 5000 | 0.692 | 0.860 | 1.577 |
| T = 3 | 50 | 0.519 | 0.528 | 0.348 |
| T = 3 | 500 | 0.654 | 0.747 | 1.276 |
| T = 3 | 5000 | 0.685 | 0.831 | 1.508 |
- References:
- true reward’s agreement with the noisy labels: 0.724;
- best-of-16 chosen by the true reward: 1.843;
- one random response: −0.009.
- More data, better reward models: true-preference accuracy rises from 0.61 to 0.86, and best-of-16 selection with them gets most of the oracle’s gain.
- Agreement with labels is capped: even the true reward agrees with the noisy labels only 72% of the time, so measured accuracies near 0.7 can hide a good model.
- Noisy annotators cost data: at T = 3, 500 comparisons give 0.75 instead of 0.83.
- Misspecification leaves a gap: the linear model cannot see the interaction term, so best-of-16 stays below the oracle (1.58 against 1.84).
- Seed 1: true-preference accuracy 0.736/0.845/0.876; noisy-label ceiling 0.738.
Reward models in AI, robotics and aerospace
- Organisation-specific quality: scoring answers for procedural correctness and safety wording preferred by engineers.
- Robotics: preference-based reward learning for behaviours that are hard to specify (smooth, safe manipulation).
- Design lesson: collect consistent comparisons, measure annotator agreement, and remember the reward model is a fallible proxy.
References
- R. A. Bradley and M. E. Terry (1952). “Rank analysis of incomplete block designs: I. The method of paired comparisons.” Biometrika 39.
- P. Christiano et al. (2017). “Deep reinforcement learning from human preferences.” NeurIPS.
- L. Ouyang et al. (2022). “Training language models to follow instructions with human feedback.” NeurIPS.
- N. Lambert et al. (2024). “RewardBench: evaluating reward models for language modeling.” arXiv:2403.13787.