Learning to Summarize: A Reward Model from Human Preferences, Optimized with PPO
OpenAI ran the full RLHF pipeline on Reddit TL;DR summaries: collect human pairwise comparisons, train a reward model, then optimize the policy with KL-penalized PPO. A 1.3B human-feedback model beat a supervised model 10 times larger. Code checks the KL optimum and over-optimization.
On this page
Why this paper matters
Fine-tuning a language model by maximum likelihood on human-written summaries optimizes for text that looks human-written, not for summaries humans find good. The objective makes no distinction between serious errors such as making up facts and irrelevant ones such as choosing among synonyms, and the usual metric, ROUGE, is only a rough proxy. This paper (Stiennon et al., OpenAI, posted in September 2020, NeurIPS 2020) optimizes human preferences directly, runs through what later became known as RLHF in full, and adds extensive analysis. Two years later InstructGPT (see the InstructGPT breakdown) applied the same recipe to general instruction following.
Method: a three-step loop
Step one, collect human comparisons. For a Reddit post, two summaries are sampled from various models and a human labeler picks the better one. The paper releases a dataset of 64,832 summary comparisons. Labelers came from Upwork and two labeling services, and the agreement between labelers and researchers was monitored throughout.
Step two, train a reward model. Start from the supervised model, add a linear head, and train on the comparison data with the loss
Step three, optimize the policy with PPO. The reward model’s output is the reward for the whole summary, each BPE token is a time step, PPO maximizes it, and a KL penalty to the supervised model is added:
The value function is a separate Transformer initialized from the reward model, and an ablation in the paper shows this avoids value-function updates damaging the pre-trained policy. After generating samples from the new policy, more human data can be collected and the whole process repeated.
Experiments and findings
The models are GPT-3-style decoders with 1.3B and 6.7B parameters. Evaluation asks humans to choose between a policy’s summary and the dataset’s reference summary.
- A smaller model can win. The 1.3B human-feedback model is preferred over the reference summaries 61% of the time, against 43% for a supervised model 10 times its size, and the 6.7B human-feedback model is significantly better than the 1.3B one.
- Length is a confounder. The human-feedback models learned to write longer summaries. Controlling for length lowers the preference rate by about 5 points, and the 6.7B model is still preferred about 65% of the time. The appendix also says that length differences explain about a third of the gap between human feedback and supervised learning at 6.7B.
- It transfers to news. Models trained on Reddit produce summaries on CNN/DM that approach the reference summaries in quality without any news fine-tuning.
- Reward-model scaling. Doubling the training data raises validation accuracy by about 1.1 points and doubling the model size raises it by about 1.8 points. On CNN/DM the 1.3B and 6.7B reward models agree with labelers 62.4% and 66.5% of the time, and labelers agree with each other 66.9% of the time.
- Labeling quality. On a subset, labelers agree with researchers 77% ± 2% of the time and researchers agree with each other 73% ± 4% of the time.
- Over-optimization. As the reward model is optimized harder, true preference first rises and then falls, until the reward model is anti-correlated with human preference, and the same happens when ROUGE is the target.
Checking it with code
Several core claims of the paper have a simple mathematical skeleton, which the code below checks (note that part 4 is a toy model of mine, not an experiment of the paper): (1) agreement between labelers caps the accuracy of a reward model; (2) the optimum of the KL-penalized objective is ; (3) how far best-of- rejection sampling drifts from the base model, exact value against the closed form ; (4) when the proxy reward’s error is heavy-tailed, the harder you optimize the more the true reward first rises and then falls.
import math
import numpy as np
# ---- 1) Labeler agreement caps the accuracy of a reward model ----
# Say the better summary of every pair is picked by one labeler with
# probability p (Bradley-Terry). Two labelers agree with probability
# p^2 + (1-p)^2, while an ideal reward model matches one labeler with
# probability p. Given the agreement a we can solve for p.
for a in (0.669, 0.73, 0.77):
p = (1 + math.sqrt(2 * a - 1)) / 2
print(f"inter-labeler agreement {a:.3f} -> oracle accuracy {p:.3f}")
# ---- 2) KL-penalised objective, optimum pi* ∝ pi_ref * exp(r / beta) ----
rng = np.random.default_rng(0)
k, beta = 8, 0.5
pi_ref = rng.dirichlet(np.ones(k)) # reference policy (the SFT model)
r = rng.normal(size=k) # reward of each candidate summary
star = pi_ref * np.exp(r / beta)
star /= star.sum()
obj = lambda pi: pi @ r - beta * (pi * np.log(pi / pi_ref)).sum(-1)
rand = rng.dirichlet(np.ones(k), size=200_000) # 200k random policies
print(f"objective: pi* {obj(star):.4f}, best of 200k random "
f"{obj(rand).max():.4f}")
# ---- 3) How far best-of-n drifts from the base model: exact vs formula ----
m = 100_000 # discretise the base model into m equally likely reward levels
j = np.arange(1, m + 1)
for n in (2, 16, 64, 256):
q = (j / m) ** n - ((j - 1) / m) ** n # probability that level j is picked
kl = np.sum(q[q > 0] * np.log(q[q > 0] * m))
print(f"best-of-{n:3d}: KL {kl:.4f} log n-(n-1)/n "
f"{math.log(n) - (n - 1) / n:.4f}")
for kl_ppo in (14.0, 18.0): # KL(ppo, sup) values in the appendix table
n = math.exp(kl_ppo + 1) # solves log n - (n-1)/n = KL for large n
print(f"KL {kl_ppo}: best-of-n with n = {n:.2e}")
# ---- 4) Toy over-optimisation: proxy reward = true reward + error ----
rng = np.random.default_rng(1)
errors = {"gauss": lambda s: rng.normal(size=s),
"heavy": lambda s: rng.standard_t(1.5, size=s)} # heavy-tailed error
for name, err in errors.items():
row = []
for n in (1, 4, 16, 64, 256, 1024):
t = rng.normal(size=(20_000, n)) # true reward
proxy = t + err((20_000, n))
pick = proxy.argmax(1) # pick the highest proxy reward
row.append(f"{n}:{t[np.arange(20_000), pick].mean():.2f}")
print(f"{name:5s} true reward of the pick " + " ".join(row))
Output (NumPy, finishes in a few seconds):
inter-labeler agreement 0.669 -> oracle accuracy 0.791
inter-labeler agreement 0.730 -> oracle accuracy 0.839
inter-labeler agreement 0.770 -> oracle accuracy 0.867
objective: pi* -0.6197, best of 200k random -0.6526
best-of- 2: KL 0.1931 log n-(n-1)/n 0.1931
best-of- 16: KL 1.8351 log n-(n-1)/n 1.8351
best-of- 64: KL 3.1745 log n-(n-1)/n 3.1745
best-of-256: KL 4.5491 log n-(n-1)/n 4.5491
KL 14.0: best-of-n with n = 3.27e+06
KL 18.0: best-of-n with n = 1.78e+08
gauss true reward of the pick 1:-0.01 4:0.73 16:1.24 64:1.67 256:2.00 1024:2.30
heavy true reward of the pick 1:-0.01 4:0.50 16:0.55 64:0.27 256:0.10 1024:0.03
How to read these numbers:
- “Close to labeler agreement” is not “close to the ceiling”. The paper says the 6.7B reward model agrees with labelers on CNN/DM (66.5%) almost as often as labelers agree with each other (66.9%). Under the simplifying assumption that every pair has the same preference probability, an agreement of 66.9% implies that a perfect reward model would agree with a single labeler about 79% of the time. Real preference probabilities vary by example, so 79% is only an order-of-magnitude estimate, but it shows that agreement between labelers compares two noisy labels and is not the reward model’s ceiling.
- The optimum of the KL-regularized objective is an exponential tilt. The closed-form reaches an objective of −0.6197, above the best of 200k random policies (−0.6526). This form is later the starting point of DPO.
- The closed form matches the exact value digit for digit. The KL of best-of- agrees with to four decimals, 1.84 at and 4.55 at . In the appendix table of the paper the PPO policies have a KL to the supervised model of 18.0 (1.3B) and 14.0 (6.7B), which by this formula is roughly picking the best of and samples. A PPO policy is not best-of-, so this conversion is my own estimate, used only for a sense of scale.
- With heavy-tailed error the true reward rises and then falls. With Gaussian error the true reward keeps growing with . With heavy-tailed error it peaks at 0.55 for and drops to 0.03 at , while the proxy reward keeps rising. This is a toy and the mechanism differs from the paper’s neural reward models, but the shape of “more optimization pressure, larger gap between proxy and true goal” matches Figure 5 of the paper.
Limitations and what to keep in mind
- One task. The conclusions rest on English Reddit summarization. Dialogue, code and reasoning are not tested, and InstructGPT is what extended the recipe to instruction following.
- Human preferences are biased. Labelers prefer longer, more complete summaries. The paper itself flags length as a confounder and the advantage shrinks after controlling for it.
- The reward model is a proxy. The over-optimization result says optimization has to be constrained with a KL penalty, early stopping or a better reward model.
- It is expensive. It needs continuing human labeling, PPO training of large models and several models at once (policy, value, reward and reference), which is the motivation for reward-model-free methods such as DPO.
- Evaluation depends on the same labelers. The paper controls quality with researcher-labeler agreement, but human evaluation is noisy, and the paper says the 6.7B reward model is only beginning to approach a single human’s accuracy.
What to take from this paper
- A three-step recipe. Collect comparisons, train a reward model, run PPO with a KL penalty, a recipe that has been reused many times since.
- Comparisons are easier to label than scores. The paper chose pairwise comparisons over Likert ratings.
- The KL term is a seat belt. It preserves exploration and keeps the policy in the distribution the reward model has seen.
- Optimizing a reward model has a limit. True quality can drop after over-optimization, a problem reward modeling cannot escape.
- Watch for confounders. Surface features such as length inflate preference rates and must be controlled in evaluation.
Further reading
- Paper: Learning to summarize from human feedback
- Follow-ups: InstructGPT breakdown, DPO breakdown
- Related Wiki on this site: Preference optimization, Reasoning RL
- Glossary: RLHF, Reward model, PPO
FAQ
- How is the reward model in RLHF trained?
- It starts from the supervised fine-tuned model and adds a randomly initialized linear head that outputs a scalar reward. Each example is a post with two summaries and a human label for the better one. The loss is -log σ(r(x, better) - r(x, worse)), which pushes the better summary's reward above the worse one's. After training the rewards are shifted so the dataset's reference summaries score 0 on average.
- Why add a KL penalty when optimizing the policy?
- The paper gives two reasons. It acts as an entropy bonus that encourages exploration and keeps the policy from collapsing to a single mode, and it keeps the policy from producing text too different from what the reward model saw in training. The reward is R = r(x, y) - β log[π_RL(y|x) / π_SFT(y|x)], and the main runs use β=0.05.
- What is over-optimization of a reward model?
- The paper finds that the harder the reward model is optimized (the larger the KL from the supervised model), the more true human preference first rises and then falls, until the reward model is even anti-correlated with human preference. It also happens when optimizing ROUGE. The reward model is only a proxy for human preference and cannot be optimized without limit.
- Are human-feedback models really better than the human-written reference summaries?
- In the paper's evaluation both human-feedback models are judged better than the dataset's reference summaries. The models learned to write longer summaries, though, and controlling for length lowers the preference rate by about 5 points, with the 6.7B model still preferred about 65% of the time. This is a result on one English task, Reddit TL;DR.