# Chapter 7 · Reward models: turning preferences into a number

Author: Ishwar Jangid
Canonical URL: https://ishwarj.com/books/how-models-are-trained/07-reward-models/
Updated: 2026-10-11
Source: https://github.com/ishwar6/ishwar-books/blob/main/content/books/how-models-are-trained/part3-learning-from-feedback/07-reward-models.md


> **Goal:** by the end of this chapter you can explain why RLHF needs a learned reward, derive the Bradley-Terry model and the reward model loss from scratch and compute them by hand, describe exactly how a reward model is built from a language model, train one yourself on real preference data, measure how good it is (accuracy, calibration, length bias), watch it being over-optimised, and name the main defences. You will also have a trained reward model on disk, which Chapter 8 uses to train a policy with PPO.

---

## 7.1 Why learn a reward?

[Chapter 6](https://ishwarj.com/books/how-models-are-trained/06-reinforcement-learning-basics) gave us the machinery of reinforcement learning for text. A policy (the language model) writes a response, the response gets a **reward**, and the policy gradient nudges the model so that high-reward responses become more likely. Chapter 6 used rewards that a few lines of code could compute: does the answer contain a number, what does a sentiment classifier say. For the thing we actually care about, "is this a good answer to this person's question?", there is no such rule.

The obvious fix is to ask people. That does not scale. A single PPO run on a small model samples hundreds of thousands of responses; InstructGPT's PPO dataset alone had 31,000 prompts, each answered many times during training. Nobody can read and score all of that, and even if they could, the policy would have to wait for them at every step.

So RLHF splits the job in two:

1. People judge a modest number of responses, once. Typically tens of thousands of comparisons, sometimes a million.
2. A model learns to predict those judgements. After that, it can score any number of new responses in milliseconds.

That second model is the **reward model**.

> [!DEFINITION] Reward model (RM)
> A neural network that reads a prompt and a response and outputs a single number, the **reward**, which should be higher for responses people prefer. It is trained on human (or AI) preference judgements and then used in place of a person to score new responses.

<figure class="fig"><svg viewBox="0 0 800 270" role="img" aria-label="The RLHF loop: the SFT model writes answers, people compare pairs, a reward model learns a score from the pairs, and an optimiser uses that score."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">Where the reward model sits in RLHF</text><rect class="box-1" x="20.0" y="46.0" width="170.0" height="84.0" rx="10"/><text class="t-note" x="105.0" y="68.0" text-anchor="middle">SFT model</text><text class="t-tick" x="105.0" y="87.0" text-anchor="middle">writes several</text><text class="t-tick" x="105.0" y="104.0" text-anchor="middle">answers per prompt</text><line class="edge" x1="192.0" y1="88.0" x2="216.0" y2="88.0" marker-end="url(#ah)"/><rect class="box-2" x="218.0" y="46.0" width="170.0" height="84.0" rx="10"/><text class="t-note" x="303.0" y="68.0" text-anchor="middle">people compare</text><text class="t-tick" x="303.0" y="87.0" text-anchor="middle">"A is better</text><text class="t-tick" x="303.0" y="104.0" text-anchor="middle">than B"</text><line class="edge" x1="390.0" y1="88.0" x2="414.0" y2="88.0" marker-end="url(#ah)"/><rect class="box-on" x="416.0" y="46.0" width="170.0" height="84.0" rx="10"/><text class="t-note" x="501.0" y="68.0" text-anchor="middle">reward model</text><text class="t-tick" x="501.0" y="87.0" text-anchor="middle">learns a score</text><text class="t-tick" x="501.0" y="104.0" text-anchor="middle">r(x, y) from pairs</text><line class="edge" x1="588.0" y1="88.0" x2="612.0" y2="88.0" marker-end="url(#ah)"/><rect class="box-3" x="614.0" y="46.0" width="170.0" height="84.0" rx="10"/><text class="t-note" x="699.0" y="68.0" text-anchor="middle">optimise</text><text class="t-tick" x="699.0" y="87.0" text-anchor="middle">RL (Chapter 8) or</text><text class="t-tick" x="699.0" y="104.0" text-anchor="middle">best-of-n</text><line class="edge-dim" x1="105.0" y1="132.0" x2="105.0" y2="168.0"/><line class="edge-dim" x1="105.0" y1="168.0" x2="698.0" y2="168.0"/><line class="edge-dim" x1="698.0" y1="168.0" x2="698.0" y2="132.0"/><text class="t-muted" x="400.0" y="186.0" text-anchor="middle">the optimised model writes new answers; the loop can repeat with fresh comparisons</text><rect class="box-ghost" x="216.0" y="206.0" width="368.0" height="52.0" rx="8"/><text class="t-tick" x="400.0" y="228.0" text-anchor="middle">People label a few thousand pairs once.</text><text class="t-tick" x="400.0" y="246.0" text-anchor="middle">The reward model then scores millions of answers for free.</text></svg><figcaption>The reward model's place in RLHF. People label a few thousand comparisons once; the reward model generalises from them and scores everything the optimiser produces. Chapter 8 does the optimisation with PPO; best-of-n, used later in this chapter, is the simplest optimiser.</figcaption></figure>

[Chapter 2](https://ishwarj.com/books/how-models-are-trained/02-how-it-started) told the story of how this idea arrived: Christiano et al. (2017) taught a simulated robot to backflip from 900 bits of human feedback, Ziegler et al. (2019) and Stiennon et al. (2020) moved it to text, and InstructGPT (Ouyang et al., 2022) made it the standard recipe. [Chapter 3](https://ishwarj.com/books/how-models-are-trained/03-how-we-measure-a-model) showed how reward models are evaluated (RewardBench) and gave a first glimpse of reward hacking. This chapter opens the box. It answers four questions:

- **What exactly is learned?** A model of *how people choose*, the Bradley-Terry model, which turns choices into scores (Sections 7.2 to 7.4).
- **What does the network look like?** A language model with its output layer replaced by a single number (Section 7.5).
- **How well does it work?** We train one and measure it (Sections 7.6 to 7.9).
- **What goes wrong when you optimise against it?** Overoptimisation, and what people do about it (Sections 7.10 to 7.12).

A warning before we start. A reward model is a *proxy*. It is trained to agree with people on the kind of responses it saw during training. The policy we optimise will produce new kinds of responses, and it will search, hard, for the ones the reward model likes most. Everything in this chapter is about how good that proxy is, and how to keep the optimiser from exploiting where it is wrong.

## 7.2 What people are asked: ratings or comparisons

There are two natural ways to collect human judgements of a response.

- **Ratings** (also called absolute or Likert scores): "How good is this answer, from 1 to 7?"
- **Comparisons** (pairwise preferences): "Here are two answers to the same question. Which is better?"

Almost every RLHF system trains its reward model on comparisons. Christiano et al. (2017) gave their reason in one sentence: "We found comparisons to be easier for humans to provide in some domains, while being equally useful for learning human preferences." Stiennon et al. (2020) asked labelers to compare two summaries; InstructGPT asked them to rank 4 to 9 answers; Llama 2 (Touvron et al., 2023) asked for a choice between two answers plus how strongly they preferred it ("significantly better", "better", "slightly better", "negligibly better or unsure").

Why would comparisons be better? Ratings carry *more* information per judgement: a rating of 6 against a rating of 3 says not only which is better but by how much. The problem is that each person uses the scale differently, and even one person's scale wanders. A strict rater's 5 is a lenient rater's 7. After reading three excellent answers, a decent one feels like a 4; after three bad ones, the same answer feels like a 6. A comparison is made with both answers side by side, at the same moment, by the same person, so whatever offset that person has at that moment cancels out.

That argument is easy to state and easy to over-sell, so let us test it with a small simulation. `ch7_bt.py` invents 200 answers with a hidden "true quality" and 20 raters. Each rater has a personal offset (harsh or generous) and a personal scale (uses a narrow or a wide range). Each rater sees 60 answers and either rates each one on a 1 to 10 scale (1,200 ratings in total) or compares them in 30 side-by-side pairs (600 comparisons in total). From the ratings we estimate quality by averaging; from the comparisons we fit a Bradley-Terry model (Section 7.3). Then we ask how well each estimate recovers the true order, measured by the rank correlation (1.0 means a perfect order). We run it three times: with raters whose offset is fixed, and with raters whose offset *drifts* from one answer to the next (a random walk with step 0.3 or 0.6), which is a simple model of the context effects just described.

```text
200 answers, 20 raters (own offset and scale), each sees 60 answers: 1200 ratings or 600 comparisons; 50 repeats
  drift 0.0: rank correlation with the truth | mean rating 0.898 (sd 0.028) | Bradley-Terry 0.768 (sd 0.036) | comparisons better in 0/50
  drift 0.3: rank correlation with the truth | mean rating 0.777 (sd 0.059) | Bradley-Terry 0.763 (sd 0.041) | comparisons better in 18/50
  drift 0.6: rank correlation with the truth | mean rating 0.620 (sd 0.064) | Bradley-Terry 0.760 (sd 0.045) | comparisons better in 50/50
```

<figure class="fig"><svg viewBox="0 0 800 332" role="img" aria-label="Grouped bars: with stable raters, averaging ratings recovers the true order better; as raters drift, ratings get worse while comparisons stay at about 0.76."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">Ratings or comparisons? 200 answers, 20 simulated raters, 50 repeats (ch7_bt.py)</text><line class="grid" x1="90" y1="266.0" x2="690" y2="266.0"/><text class="t-tick" x="82.0" y="270.0" text-anchor="end">0.5</text><line class="grid" x1="90" y1="226.0" x2="690" y2="226.0"/><text class="t-tick" x="82.0" y="230.0" text-anchor="end">0.6</text><line class="grid" x1="90" y1="186.0" x2="690" y2="186.0"/><text class="t-tick" x="82.0" y="190.0" text-anchor="end">0.7</text><line class="grid" x1="90" y1="146.0" x2="690" y2="146.0"/><text class="t-tick" x="82.0" y="150.0" text-anchor="end">0.8</text><line class="grid" x1="90" y1="106.0" x2="690" y2="106.0"/><text class="t-tick" x="82.0" y="110.0" text-anchor="end">0.9</text><line class="grid" x1="90" y1="66.0" x2="690" y2="66.0"/><text class="t-tick" x="82.0" y="70.0" text-anchor="end">1.0</text><text class="t-muted" x="30.0" y="54.0" text-anchor="start">rank correlation with the true quality</text><g class="mark"><title>mean rating: 0.898</title><rect class="s1" x="132" y="106.8" width="54" height="159.2" rx="3"/></g><text class="t-val" x="159.0" y="100.8" text-anchor="middle">0.90</text><g class="mark"><title>Bradley-Terry: 0.768</title><rect class="s2" x="194" y="158.7" width="54" height="107.3" rx="3"/></g><text class="t-val" x="221.0" y="152.7" text-anchor="middle">0.77</text><text class="t-tick" x="188.0" y="286.0" text-anchor="middle">stable raters (drift 0.0)</text><g class="mark"><title>mean rating: 0.777</title><rect class="s1" x="332" y="155.3" width="54" height="110.7" rx="3"/></g><text class="t-val" x="359.0" y="149.3" text-anchor="middle">0.78</text><g class="mark"><title>Bradley-Terry: 0.763</title><rect class="s2" x="394" y="160.8" width="54" height="105.2" rx="3"/></g><text class="t-val" x="421.0" y="154.8" text-anchor="middle">0.76</text><text class="t-tick" x="388.0" y="286.0" text-anchor="middle">some drift (drift 0.3)</text><g class="mark"><title>mean rating: 0.620</title><rect class="s1" x="532" y="217.8" width="54" height="48.2" rx="3"/></g><text class="t-val" x="559.0" y="211.8" text-anchor="middle">0.62</text><g class="mark"><title>Bradley-Terry: 0.760</title><rect class="s2" x="594" y="161.8" width="54" height="104.2" rx="3"/></g><text class="t-val" x="621.0" y="155.8" text-anchor="middle">0.76</text><text class="t-tick" x="588.0" y="286.0" text-anchor="middle">strong drift (drift 0.6)</text><line class="axis" x1="90" y1="266" x2="690" y2="266"/><rect class="s1" x="240" y="307" width="12" height="12" rx="2"/><text class="t-tick" x="268.0" y="317.0" text-anchor="start">mean of 1,200 ratings (1 to 10)</text><rect class="s2" x="497.0" y="307" width="12" height="12" rx="2"/><text class="t-tick" x="525.0" y="317.0" text-anchor="start">Bradley-Terry on 600 comparisons</text></svg><figcaption>How well each kind of label recovers the true order of 200 answers. With raters whose personal scale is stable, averaging ratings wins clearly (0.90 against 0.77): ratings carry more information. As the raters' scale drifts, ratings degrade fast, while comparisons are untouched, because a drift that affects both answers of a pair cancels.</figcaption></figure>

The result is more interesting than "comparisons are better":

- **With stable raters, ratings win.** Each rating says how good, not just which is better, and averaging two ratings per rater removes their offset anyway. Comparisons throw that magnitude away.
- **With drifting raters, comparisons win.** The Bradley-Terry estimate is the same 0.76 in all three settings: drift that hits both answers of a pair equally does not change which one looks better.

Real human judgement drifts, and real labeling teams are made of many people with different standards, so in practice comparisons are the safer choice. Many teams also collect a strength-of-preference grade or a rating *alongside* the comparison (Llama 2 does; InstructGPT also collected 1 to 7 quality scores as metadata), which recovers some of the lost magnitude. We will use exactly that in Section 7.11.

> [!NOTE]
> Comparisons have a second, practical advantage: agreement between labelers is easy to measure (do two people pick the same answer?). Stiennon et al. report that on their validation comparisons labelers agreed with each other 66.9% of the time, and that their 6.7B reward model agreed with the labelers 66.5% of the time. Even people do not agree perfectly, and that sets a ceiling on how accurate any reward model can look.

## 7.3 The Bradley-Terry model, derived

We have comparisons: for prompt $$x$$, answer $$y_w$$ ("winner") was preferred to $$y_l$$ ("loser"). We want a function $$r(x, y)$$ that gives one number per answer. We need a bridge between the two: a statement of the form "if the scores are such and such, then a person picks $$y_w$$ with this probability". That bridge is a **model of the judge**.

Chapter 2 used the Bradley-Terry formula; Chapter 3 used it to rank chatbots. Here we derive it, because the derivation tells you exactly what a reward model assumes about people.

### A noisy judge

Imagine that each answer has a true quality $$r$$ and that, when a person looks at two answers, they perceive each quality with some noise: they see $$r_w + \epsilon_w$$ and $$r_l + \epsilon_l$$, where $$\epsilon_w$$ and $$\epsilon_l$$ are random, independent, and different every time. The person picks whichever looks better. Then

$$
P(y_w \succ y_l) = P(r_w + \epsilon_w > r_l + \epsilon_l) = P(\epsilon_l - \epsilon_w < r_w - r_l)
$$

where:

- $$y_w \succ y_l$$ (read "$$y_w$$ is preferred to $$y_l$$") is the event that the person picks $$y_w$$;
- $$r_w$$ and $$r_l$$ are the true qualities (rewards) of the two answers;
- $$\epsilon_w$$ and $$\epsilon_l$$ are the person's perception noise for each answer.

The right-hand side depends on the qualities only through the gap $$r_w - r_l$$. The *shape* of the curve depends on the noise. Two classic choices:

- **Normal noise** gives the probit curve: this is **Thurstone's model** (1927), from psychology, built to explain judgements like "which of these two weights is heavier?".
- **Gumbel noise** (the distribution of the maximum of many random variables) has a neat property: the difference of two independent Gumbel variables follows the logistic distribution, whose cumulative curve is exactly the sigmoid. That gives

$$
P(y_w \succ y_l) = \sigma(r_w - r_l) = \frac{1}{1 + e^{-(r_w - r_l)}}
$$

where:

- $$\sigma$$ is the sigmoid function, $$\sigma(z) = 1/(1 + e^{-z})$$;
- $$e \approx 2.718$$.

This is the **Bradley-Terry model**. Ralph Bradley and Milton Terry published it in 1952 in *Biometrika* for the analysis of "paired comparisons"; they wrote it as $$P(i \succ j) = \pi_i / (\pi_i + \pi_j)$$ with a positive "worth" $$\pi_i$$ for each item. Ernst Zermelo had found the same model in 1929 to rank chess players from incomplete tournaments. Set $$\pi_i = e^{r_i}$$ and divide top and bottom by $$e^{r_i}$$ and you get the sigmoid form above. The probit and logistic curves are nearly identical in shape; the logistic one is used because it is simpler to compute and its loss is the familiar cross-entropy.

> [!DEFINITION] Bradley-Terry model
> A model of pairwise choices: each item has a score $$r$$, and the probability that item $$i$$ beats item $$j$$ is $$\sigma(r_i - r_j)$$. Only differences of scores matter. In reward modelling the items are responses to the same prompt and the scores come from the reward model.

### What the reward gap means

Turn the formula around. If $$p = \sigma(r_w - r_l)$$, then

$$
r_w - r_l = \log \frac{p}{1 - p}
$$

where:

- $$p$$ is the probability that $$y_w$$ is preferred;
- $$\frac{p}{1-p}$$ is the **odds** of that preference (3 means "three times as likely to win as to lose");
- $$\log$$ is the natural logarithm.

So **a reward gap is a log-odds**. This is the sentence InstructGPT uses to describe Stiennon et al.'s loss: "the difference in rewards represents the log odds that one response will be preferred to the other by a human labeler." A gap of 0 means a coin flip; a gap of 1 means odds of $$e^1 = 2.72$$ to 1, a 73% chance; a gap of 2 means 88%; a gap of 4 means 98%.

**Worked example.** Our reward model gives the chosen answer 1.3 and the rejected one 0.4. The gap is 0.9, so the predicted chance that a person picks the chosen answer is $$\sigma(0.9) = 1/(1 + e^{-0.9}) = 1/(1 + 0.4066) = 0.7109$$. The odds are $$0.7109 / 0.2891 = 2.46$$, and $$\log 2.46 = 0.9$$: back to the gap.

### The Elo link

Chapter 3 met the same model as Elo ratings: a chess player with rating $$R_A$$ beats one with $$R_B$$ with probability $$1 / (1 + 10^{-(R_A - R_B)/400})$$. Since $$10^{z} = e^{z \ln 10}$$, this is $$\sigma\big((R_A - R_B) \cdot \ln 10 / 400\big)$$, the Bradley-Terry model with the scores multiplied by a constant. One unit of reward is worth $$400 / \ln 10 = 173.7$$ Elo points. Our gap of 0.9 would be a 156-point Elo gap. Going the other way, Chapter 3's example of a 100-point gap is a reward gap of $$100 / 173.7 = 0.576$$, and $$\sigma(0.576) = 0.640$$: the 64% Chapter 3 printed.

```text
Elo: P = 1 / (1 + 10^(-(R_A - R_B) / 400)) = sigmoid((R_A - R_B) * ln(10) / 400)
so a reward gap of 1 equals 173.7 Elo points; our gap of 0.9 = 156 Elo points; 100 Elo points = gap 0.576 -> P 0.640
```

A reward model is therefore an Elo system for *answers*, with one important difference: Chatbot Arena fits one free number per model, while a reward model is a *function*. It must give a sensible score to answers it has never seen, from their text alone. That is what makes it useful, and what makes it fallible.

### What the model assumes

Writing the assumptions down helps later, when we see where reward models break:

1. **One number per answer.** All the things people care about (correctness, helpfulness, tone, safety, length) are collapsed into a single score. If two labelers weigh them differently, the model can only learn an average.
2. **Independence from the alternative.** How good $$y_w$$ is does not depend on what it is compared with.
3. **Transitivity.** If A usually beats B and B usually beats C, A must usually beat C. Real human preferences are not always transitive.
4. **Noise of a fixed shape.** Every comparison is equally noisy given the gap. In reality some labelers are careless and some pairs are genuinely ambiguous.

None of these is exactly true. All of them are close enough to be useful.

## 7.4 The reward model loss

Now make the score a neural network with parameters $$\theta$$: $$r_\theta(x, y)$$. We have a dataset $$D$$ of comparisons $$(x, y_w, y_l)$$. Training means choosing $$\theta$$ so that the observed choices are as probable as possible under the Bradley-Terry model: **maximum likelihood**. The likelihood of the whole dataset is the product of $$\sigma(r_\theta(x, y_w) - r_\theta(x, y_l))$$ over all comparisons; taking minus the log turns the product into a sum, and dividing by the number of comparisons gives an average:

$$
\mathcal{L}(\theta) = -\,\mathbb{E}_{(x, y_w, y_l) \sim D}\Big[\log \sigma\big(r_\theta(x, y_w) - r_\theta(x, y_l)\big)\Big]
$$

where:

- $$\mathcal{L}(\theta)$$ is the loss, a single number to minimise;
- $$\theta$$ are the reward model's parameters (for us, the LoRA weights and the score head);
- $$\mathbb{E}_{(x, y_w, y_l) \sim D}$$ means "the average over comparisons from the dataset $$D$$";
- $$x$$ is the prompt, $$y_w$$ the preferred ("chosen") response, $$y_l$$ the other ("rejected") one;
- $$r_\theta(x, y)$$ is the reward model's score for response $$y$$ to prompt $$x$$;
- $$\sigma$$ is the sigmoid and $$\log$$ the natural logarithm.

This is the loss of Stiennon et al. (2020), InstructGPT and Llama 2, written in nearly identical notation in all three papers. It is just binary cross-entropy where the "logit" is the reward gap and the label is always "the first one won".

> [!PAPER] Stiennon et al. (2020), Learning to summarize from human feedback · Section 3.4 · page 6
> [![The reward model paragraph of Stiennon et al.: start from a supervised baseline, add a randomly initialized linear head that outputs a scalar value, train to predict which summary is better with loss minus the expectation of log sigma of the reward difference, and at the end normalize the reward model outputs so the reference summaries achieve a mean score of 0](https://ishwarj.com/img/training/ch7-stiennon-rm.pngch7-stiennon-rm.png)](/img/training/ch7-stiennon-rm.png)
>
> **Context:** the methods section, right after the description of how human comparisons were collected.
>
> **What it says:** the reward model is the supervised (SFT) model plus "a randomly initialized linear head that outputs a scalar value", trained with the loss above. After training, the outputs are shifted "such that the reference summaries from our dataset achieve a mean score of 0."
>
> **Why it matters:** this paragraph is the whole recipe. The 2022 and 2023 papers change the data and the scale, not the method.

### Worked example: loss and gradient

Take the pair from before: $$r_\theta(x, y_w) = 1.3$$ and $$r_\theta(x, y_l) = 0.4$$.

1. The gap is $$1.3 - 0.4 = 0.9$$.
2. $$\sigma(0.9) = 0.7109$$.
3. The loss is $$-\log 0.7109 = 0.3412$$.

If the model had them the wrong way round (gap $$-0.9$$), the loss would be $$-\log \sigma(-0.9) = -\log 0.2891 = 1.2412$$, almost four times bigger.

How does training change the rewards? Differentiate. Write $$\Delta = r_w - r_l$$ for the gap. Because $$\frac{d}{d\Delta}\log\sigma(\Delta) = 1 - \sigma(\Delta)$$,

$$
\frac{\partial \mathcal{L}}{\partial r_w} = -\big(1 - \sigma(\Delta)\big), \qquad \frac{\partial \mathcal{L}}{\partial r_l} = +\big(1 - \sigma(\Delta)\big)
$$

where:

- $$\Delta = r_\theta(x, y_w) - r_\theta(x, y_l)$$ is the reward gap for one pair;
- $$1 - \sigma(\Delta)$$ is the probability the model currently gives to the *wrong* outcome.

Gradient descent moves each reward against its gradient: the chosen reward goes **up**, the rejected reward goes **down**, both by an amount proportional to $$1 - \sigma(\Delta)$$. For our pair that is $$1 - 0.7109 = 0.2891$$. A pair the model already gets right by a wide margin (gap 4, $$1 - \sigma = 0.018$$) barely moves anything; a pair it gets badly wrong (gap $$-2$$, $$0.881$$) gets almost the full push. The loss focuses the training on the mistakes.

```python
# simplified from ch7_bt.py
t = torch.tensor([1.3, 0.4], requires_grad=True)     # r(chosen), r(rejected)
loss = -F.logsigmoid(t[0] - t[1])                     # the reward model loss for one pair
loss.backward()                                       # autograd computes the two derivatives
```

- `F.logsigmoid` computes $$\log\sigma$$ in one numerically safe step (computing `sigmoid` and then `log` separately overflows for large negative gaps).
- `backward()` fills `t.grad` with $$\partial\mathcal{L}/\partial r_w$$ and $$\partial\mathcal{L}/\partial r_l$$.

```text
r(chosen) = 1.3, r(rejected) = 0.4, gap = 0.9
P(chosen beats rejected) = sigmoid(0.9) = 1 / (1 + e^-0.9) = 1 / (1 + 0.4066) = 0.7109
loss = -log(0.7109) = 0.3412
if the model had them the wrong way round (gap -0.9): P = 0.2891, loss = 1.2412
autograd: loss 0.3412, d loss / d r(chosen) = -0.2891, d loss / d r(rejected) = 0.2891
check: -(1 - P) = -0.2891
  gap -2: P 0.119  loss 2.127  gradient on r(chosen) -0.881
  gap -1: P 0.269  loss 1.313  gradient on r(chosen) -0.731
  gap +0: P 0.500  loss 0.693  gradient on r(chosen) -0.500
  gap +1: P 0.731  loss 0.313  gradient on r(chosen) -0.269
  gap +2: P 0.881  loss 0.127  gradient on r(chosen) -0.119
  gap +4: P 0.982  loss 0.018  gradient on r(chosen) -0.018
```

<figure class="fig"><svg viewBox="0 0 800 178" role="img" aria-label="Four steps: score both answers, take the gap, turn it into a probability with the sigmoid, and take minus the log."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">From two rewards to a loss, with the numbers from ch7_bt.py</text><rect class="box-1" x="20.0" y="46.0" width="178.0" height="88.0" rx="10"/><text class="t-note" x="109.0" y="68.0" text-anchor="middle">1. score each answer</text><text class="t-tick" x="109.0" y="87.0" text-anchor="middle">r(x, chosen) = 1.3</text><text class="t-tick" x="109.0" y="104.0" text-anchor="middle">r(x, rejected) = 0.4</text><line class="edge" x1="200.0" y1="90.0" x2="216.0" y2="90.0" marker-end="url(#ah)"/><rect class="box-2" x="216.0" y="46.0" width="178.0" height="88.0" rx="10"/><text class="t-note" x="305.0" y="68.0" text-anchor="middle">2. take the gap</text><text class="t-tick" x="305.0" y="87.0" text-anchor="middle">1.3 - 0.4 = 0.9</text><text class="t-tick" x="305.0" y="104.0" text-anchor="middle">only the gap matters</text><line class="edge" x1="396.0" y1="90.0" x2="412.0" y2="90.0" marker-end="url(#ah)"/><rect class="box-3" x="412.0" y="46.0" width="178.0" height="88.0" rx="10"/><text class="t-note" x="501.0" y="68.0" text-anchor="middle">3. squash with sigmoid</text><text class="t-tick" x="501.0" y="87.0" text-anchor="middle">sigmoid(0.9) = 0.711</text><text class="t-tick" x="501.0" y="104.0" text-anchor="middle">P(chosen wins)</text><line class="edge" x1="592.0" y1="90.0" x2="608.0" y2="90.0" marker-end="url(#ah)"/><rect class="box-on" x="608.0" y="46.0" width="178.0" height="88.0" rx="10"/><text class="t-note" x="697.0" y="68.0" text-anchor="middle">4. loss = -log P</text><text class="t-tick" x="697.0" y="87.0" text-anchor="middle">-log 0.711 = 0.341</text><text class="t-tick" x="697.0" y="104.0" text-anchor="middle">wrong way round: 1.241</text><text class="t-muted" x="400.0" y="162.0" text-anchor="middle">The gradient pushes r(chosen) up and r(rejected) down by the same amount: 1 - P = 0.289.</text></svg><figcaption>The reward model loss in four steps, for one pair. Only the gap between the two rewards enters; the sigmoid turns it into a probability; the loss is minus its log.</figcaption></figure>

Note the value at gap 0: the loss is $$\log 2 = 0.693$$. A reward model that has learned nothing (gives every answer the same score) has exactly this loss. Every training log in this chapter should be read against 0.693.

<figure class="fig"><svg viewBox="0 0 900 330" role="img" aria-label="Line chart over the reward gap from -4 to 4: the plain loss falls from 4 to near 0; with 10% random labels the loss is capped near 3 for wrong orderings; the gradient shrinks as the gap grows."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">The reward model loss as a function of the reward gap</text><line class="grid" x1="70" y1="286.0" x2="610" y2="286.0"/><text class="t-tick" x="62.0" y="290.0" text-anchor="end">0</text><line class="grid" x1="70" y1="231.2" x2="610" y2="231.2"/><text class="t-tick" x="62.0" y="235.2" text-anchor="end">1</text><line class="grid" x1="70" y1="176.5" x2="610" y2="176.5"/><text class="t-tick" x="62.0" y="180.5" text-anchor="end">2</text><line class="grid" x1="70" y1="121.7" x2="610" y2="121.7"/><text class="t-tick" x="62.0" y="125.7" text-anchor="end">3</text><line class="grid" x1="70" y1="67.0" x2="610" y2="67.0"/><text class="t-tick" x="62.0" y="71.0" text-anchor="end">4</text><text class="t-tick" x="70.0" y="304.0" text-anchor="middle">-4</text><text class="t-tick" x="205.0" y="304.0" text-anchor="middle">-2</text><text class="t-tick" x="340.0" y="304.0" text-anchor="middle">0</text><text class="t-tick" x="475.0" y="304.0" text-anchor="middle">+2</text><text class="t-tick" x="610.0" y="304.0" text-anchor="middle">+4</text><line class="axis" x1="70" y1="286" x2="610" y2="286"/><polyline class="l1" points="70.0,66.0 76.8,71.3 83.5,76.7 90.2,82.0 97.0,87.4 103.8,92.7 110.5,98.0 117.3,103.3 124.0,108.6 130.8,113.8 137.5,119.1 144.2,124.3 151.0,129.4 157.8,134.6 164.5,139.7 171.2,144.8 178.0,149.8 184.8,154.8 191.5,159.8 198.3,164.7 205.0,169.5 211.8,174.3 218.5,179.1 225.3,183.7 232.0,188.3 238.8,192.8 245.5,197.3 252.2,201.6 259.0,205.9 265.8,210.0 272.5,214.1 279.2,218.0 286.0,221.9 292.8,225.6 299.5,229.2 306.2,232.7 313.0,236.0 319.8,239.2 326.5,242.3 333.2,245.2 340.0,248.0 346.8,250.7 353.5,253.2 360.2,255.6 367.0,257.9 373.8,260.0 380.5,262.0 387.2,263.9 394.0,265.7 400.8,267.3 407.5,268.8 414.3,270.3 421.0,271.6 427.8,272.8 434.5,273.9 441.2,275.0 448.0,275.9 454.8,276.8 461.5,277.6 468.2,278.4 475.0,279.0 481.8,279.7 488.5,280.2 495.3,280.8 502.0,281.2 508.8,281.7 515.5,282.1 522.2,282.4 529.0,282.8 535.8,283.1 542.5,283.3 549.2,283.6 556.0,283.8 562.8,284.0 569.5,284.2 576.2,284.4 583.0,284.5 589.8,284.7 596.5,284.8 603.2,284.9 610.0,285.0"/><polyline class="l2" points="70.0,137.3 76.8,138.7 83.5,140.1 90.2,141.7 97.0,143.4 103.8,145.2 110.5,147.0 117.3,149.0 124.0,151.2 130.8,153.4 137.5,155.7 144.2,158.2 151.0,160.8 157.8,163.4 164.5,166.2 171.2,169.1 178.0,172.1 184.8,175.1 191.5,178.2 198.3,181.4 205.0,184.7 211.8,188.0 218.5,191.4 225.3,194.8 232.0,198.2 238.8,201.6 245.5,205.0 252.2,208.5 259.0,211.9 265.8,215.3 272.5,218.6 279.2,221.9 286.0,225.1 292.8,228.3 299.5,231.4 306.2,234.4 313.0,237.3 319.8,240.2 326.5,242.9 333.2,245.5 340.0,248.0 346.8,250.5 353.5,252.7 360.2,254.9 367.0,257.0 373.8,259.0 380.5,260.8 387.2,262.5 394.0,264.1 400.8,265.7 407.5,267.1 414.3,268.4 421.0,269.6 427.8,270.8 434.5,271.8 441.2,272.8 448.0,273.7 454.8,274.5 461.5,275.3 468.2,276.0 475.0,276.6 481.8,277.2 488.5,277.8 495.3,278.2 502.0,278.7 508.8,279.1 515.5,279.5 522.2,279.8 529.0,280.1 535.8,280.4 542.5,280.7 549.2,280.9 556.0,281.1 562.8,281.3 569.5,281.5 576.2,281.6 583.0,281.8 589.8,281.9 596.5,282.0 603.2,282.2 610.0,282.2"/><polyline class="l3" points="70.0,232.2 76.8,232.3 83.5,232.4 90.2,232.6 97.0,232.7 103.8,232.8 110.5,233.0 117.3,233.2 124.0,233.4 130.8,233.6 137.5,233.8 144.2,234.1 151.0,234.4 157.8,234.7 164.5,235.0 171.2,235.4 178.0,235.8 184.8,236.2 191.5,236.7 198.3,237.2 205.0,237.8 211.8,238.4 218.5,239.0 225.3,239.7 232.0,240.4 238.8,241.2 245.5,242.1 252.2,243.0 259.0,243.9 265.8,244.9 272.5,246.0 279.2,247.1 286.0,248.2 292.8,249.4 299.5,250.6 306.2,251.9 313.0,253.2 319.8,254.5 326.5,255.9 333.2,257.3 340.0,258.6 346.8,260.0 353.5,261.3 360.2,262.7 367.0,264.0 373.8,265.3 380.5,266.6 387.2,267.8 394.0,269.0 400.8,270.2 407.5,271.3 414.3,272.3 421.0,273.3 427.8,274.3 434.5,275.2 441.2,276.0 448.0,276.8 454.8,277.5 461.5,278.2 468.2,278.9 475.0,279.5 481.8,280.0 488.5,280.5 495.3,281.0 502.0,281.4 508.8,281.8 515.5,282.2 522.2,282.6 529.0,282.9 535.8,283.1 542.5,283.4 549.2,283.6 556.0,283.9 562.8,284.1 569.5,284.2 576.2,284.4 583.0,284.5 589.8,284.7 596.5,284.8 603.2,284.9 610.0,285.0"/><text class="t-muted" x="340.0" y="324.0" text-anchor="middle">reward gap r(chosen) - r(rejected)</text><line class="l1" x1="650" y1="80" x2="672" y2="80"/><text class="t-tick" x="678.0" y="84.0" text-anchor="start">loss, plain</text><line class="l2" x1="650" y1="102" x2="672" y2="102"/><text class="t-tick" x="678.0" y="106.0" text-anchor="start">loss, 10% random labels</text><line class="l3" x1="650" y1="124" x2="672" y2="124"/><text class="t-tick" x="678.0" y="128.0" text-anchor="start">size of the gradient on r(chosen)</text><circle class="s1 ring" cx="400.8" cy="267.3" r="5"/><text class="t-tick" x="408.8" y="259.3" text-anchor="start">gap 0.9: loss 0.341</text><text class="t-muted" x="76.8" y="64.2" text-anchor="start">wrong order: big loss</text><text class="t-muted" x="448.0" y="220.3" text-anchor="start">right order: loss goes to 0</text></svg><figcaption>Loss (blue) and the size of the gradient on the chosen reward (green) against the reward gap. The loss never reaches zero, so a reward model trained too long keeps pushing gaps apart. The orange curve is the label-noise version from Christiano et al. (2017), discussed below: it caps the loss at about 3 for pairs the model is confident are mislabelled.</figcaption></figure>

### Shifting every reward changes nothing

Because only gaps appear, adding the same constant $$c$$ to every reward leaves the loss unchanged:

```text
  shift   +0.0: rewards (1.3, 0.4) -> loss 0.3412
  shift  +10.0: rewards (11.3, 10.4) -> loss 0.3412
  shift   -7.5: rewards (-6.2, -7.1) -> loss 0.3412
```

The absolute level of a reward model's output is therefore arbitrary: training cannot fix it. That matters as soon as the reward is *used*. In PPO ([Chapter 8](https://ishwarj.com/books/how-models-are-trained/08-rlhf-with-ppo)) the reward is added to a KL penalty, so its level and scale interact with other terms. That is why every paper normalises the reward model after training: Christiano et al. normalised rewards "to have zero mean and constant standard deviation"; Stiennon et al. shifted them so reference summaries score 0; InstructGPT did the same with labeler demonstrations:

> [!PAPER] Ouyang et al. (2022), InstructGPT · Section 3.5 · page 9
> [![InstructGPT: since the RM loss is invariant to shifts in reward, we normalize the reward model using a bias so that the labeler demonstrations achieve a mean score of 0 before doing RL](https://ishwarj.com/img/training/ch7-instructgpt-bias.pngnstructgpt-bias.png)](/img/training/ch7-instructgpt-bias.png)
>
> **Context:** the last sentence of the reward modelling paragraph.
>
> **What it says:** "since the RM loss is invariant to shifts in reward, we normalize the reward model using a bias so that the labeler demonstrations achieve a mean score of 0 before doing RL."
>
> **Why it matters:** a fixed bias added to the output changes nothing about which answer is preferred, but it sets the zero point the RL algorithm sees.

### Rankings: K answers, K(K-1)/2 pairs

InstructGPT made labeling cheaper by showing each labeler 4 to 9 answers at once and asking for a full ranking. A ranking of $$K$$ answers implies a comparison for every pair, $$\binom{K}{2} = K(K-1)/2$$ of them: 6 for $$K = 4$$, 36 for $$K = 9$$.

> [!PAPER] Ouyang et al. (2022), InstructGPT · Section 3.5 · page 8
> [![InstructGPT reward modeling paragraph: only 6B reward models are used; labelers rank between K equals 4 and K equals 9 responses, which produces K choose 2 comparisons; shuffling them into one dataset caused overfitting in a single pass, so all comparisons from a prompt are a single batch element; then equation 1, the loss with a 1 over K choose 2 factor](https://ishwarj.com/img/training/ch7-instructgpt-rm.png-instructgpt-rm.png)](/img/training/ch7-instructgpt-rm.png)
>
> **Context:** the reward modelling subsection of the methods.
>
> **What it says:** reward models are 6B parameters ("175B RM training could be unstable"); labelers rank 4 to 9 responses; if the $$\binom{K}{2}$$ comparisons from one ranking are shuffled into the dataset as independent examples, "a single pass over the dataset caused the reward model to overfit", so all comparisons from one prompt go into one batch element, with the loss averaged over them (the $$1/\binom{K}{2}$$ in equation 1).
>
> **Why it matters:** comparisons from the same ranking share answers, so they are not independent. Seeing the same answer in many separate steps lets the model memorise it. Grouping also saves compute: each of the $$K$$ answers is scored once, not once per pair.

**Worked example.** A labeler ranks four answers A > B > C > D. The model currently scores them 2.1, 1.2, 0.9 and -0.5. The six pairs and their losses (from `ch7_bt.py`):

```text
  A > B: gap +0.9, loss 0.3412
  A > C: gap +1.2, loss 0.2633
  A > D: gap +2.6, loss 0.0716
  B > C: gap +0.3, loss 0.5544
  B > D: gap +1.7, loss 0.1678
  C > D: gap +1.4, loss 0.2204
  mean over the 6 pairs (the 1/C(K,2) in InstructGPT's equation): 0.2698
```

<figure class="fig"><svg viewBox="0 0 800 222" role="img" aria-label="Four answers with rewards 2.1, 1.2, 0.9 and -0.5; the six pairs, their gaps and losses; the smallest gap (B over C) has the largest loss."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">A labeler ranks four answers: A &gt; B &gt; C &gt; D. That is 6 comparisons.</text><rect class="box-3" x="20.0" y="46.0" width="64.0" height="50.0" rx="8"/><text class="t-note" x="52.0" y="68.0" text-anchor="middle">A</text><text class="t-tick" x="52.0" y="86.0" text-anchor="middle">r = 2.1</text><rect class="box-1" x="94.0" y="46.0" width="64.0" height="50.0" rx="8"/><text class="t-note" x="126.0" y="68.0" text-anchor="middle">B</text><text class="t-tick" x="126.0" y="86.0" text-anchor="middle">r = 1.2</text><rect class="box-2" x="168.0" y="46.0" width="64.0" height="50.0" rx="8"/><text class="t-note" x="200.0" y="68.0" text-anchor="middle">C</text><text class="t-tick" x="200.0" y="86.0" text-anchor="middle">r = 0.9</text><rect class="box-4" x="242.0" y="46.0" width="64.0" height="50.0" rx="8"/><text class="t-note" x="274.0" y="68.0" text-anchor="middle">D</text><text class="t-tick" x="274.0" y="86.0" text-anchor="middle">r = -0.5</text><text class="t-muted" x="20.0" y="118.0" text-anchor="start">the model's current rewards</text><text class="t-tick t-strong" x="360.0" y="61.0" text-anchor="start">A &gt; B</text><text class="t-tick" x="420.0" y="61.0" text-anchor="start">gap +0.9</text><rect class="s1" x="500" y="49" width="113.7" height="16" rx="3"/><text class="t-val" x="619.7" y="61.0" text-anchor="start">loss 0.341</text><text class="t-tick t-strong" x="360.0" y="85.0" text-anchor="start">A &gt; C</text><text class="t-tick" x="420.0" y="85.0" text-anchor="start">gap +1.2</text><rect class="s1" x="500" y="73" width="87.8" height="16" rx="3"/><text class="t-val" x="593.8" y="85.0" text-anchor="start">loss 0.263</text><text class="t-tick t-strong" x="360.0" y="109.0" text-anchor="start">A &gt; D</text><text class="t-tick" x="420.0" y="109.0" text-anchor="start">gap +2.6</text><rect class="s1" x="500" y="97" width="23.9" height="16" rx="3"/><text class="t-val" x="529.9" y="109.0" text-anchor="start">loss 0.072</text><text class="t-tick t-strong" x="360.0" y="133.0" text-anchor="start">B &gt; C</text><text class="t-tick" x="420.0" y="133.0" text-anchor="start">gap +0.3</text><rect class="s1" x="500" y="121" width="184.8" height="16" rx="3"/><text class="t-val" x="690.8" y="133.0" text-anchor="start">loss 0.554</text><text class="t-tick t-strong" x="360.0" y="157.0" text-anchor="start">B &gt; D</text><text class="t-tick" x="420.0" y="157.0" text-anchor="start">gap +1.7</text><rect class="s1" x="500" y="145" width="55.9" height="16" rx="3"/><text class="t-val" x="561.9" y="157.0" text-anchor="start">loss 0.168</text><text class="t-tick t-strong" x="360.0" y="181.0" text-anchor="start">C &gt; D</text><text class="t-tick" x="420.0" y="181.0" text-anchor="start">gap +1.4</text><rect class="s1" x="500" y="169" width="73.5" height="16" rx="3"/><text class="t-val" x="579.5" y="181.0" text-anchor="start">loss 0.220</text><text class="t-muted" x="360.0" y="208.0" text-anchor="start">mean over the 6 pairs = 0.2698: one batch element, one forward pass per answer</text></svg><figcaption>One ranking of four answers gives six pairs. The model orders all six correctly, but B and C are close (gap 0.3), so that pair contributes the largest loss and the largest gradient.</figcaption></figure>

(There is a more principled model for whole rankings, the Plackett-Luce model, which picks the best answer first, then the best of the rest, and so on. With $$K = 2$$ it reduces to Bradley-Terry. InstructGPT's sum over pairs is simpler and works well.)

### Noisy labels

People make mistakes. In the UltraFeedback data we will use, the labels come from GPT-4 and are noisier still. The plain loss treats every label as certain: if the model is confident (gap 10) that a label is wrong, the loss for that one pair is 10, and its gradient is nearly the maximum. A few mislabelled pairs can then dominate training.

Christiano et al. (2017) fixed this with a simple change to the judge model:

> [!PAPER] Christiano et al. (2017), Deep reinforcement learning from human preferences · Section 2.2.3 · page 5
> [![Three modifications from Christiano et al.: fit an ensemble of predictors on bootstrap samples, normalise each and average them; hold out a fraction 1 over e of the data for validation with l2 regularisation; and assume a 10% chance that the human responds uniformly at random, because human raters have a constant probability of error](https://ishwarj.com/img/training/ch7-christiano-mods.pngchristiano-mods.png)](/img/training/ch7-christiano-mods.png)
>
> **Context:** the list of modifications to the basic reward fitting, right after the Bradley-Terry equation.
>
> **What it says:** three tricks. An **ensemble** of predictors, each trained on a bootstrap sample of the comparisons, "independently normalizing each of these predictors and then averaging the results"; a validation set and regularisation; and "a 10% chance that the human responds uniformly at random."
>
> **Why it matters:** ensembles and label-noise models came back years later as defences against reward hacking (Section 7.11).

With a 10% chance of a random answer, the probability of the observed choice becomes

$$
P(y_w \succ y_l) = 0.1 \cdot 0.5 + 0.9 \cdot \sigma(r_w - r_l)
$$

where:

- $$0.1$$ is the chance that the person answered at random;
- $$0.5$$ is the probability of either choice when answering at random;
- $$0.9 \cdot \sigma(r_w - r_l)$$ is the Bradley-Terry probability for the other 90% of judgements.

This probability can never go below 0.05 or above 0.95, so the loss of a pair can never exceed $$-\log 0.05 = 3.0$$:

```text
  gap  1: plain P 0.73106, loss if the label is flipped   1.31 | noisy P 0.7080, loss if flipped 1.23
  gap  3: plain P 0.95257, loss if the label is flipped   3.05 | noisy P 0.9073, loss if flipped 2.38
  gap  6: plain P 0.99753, loss if the label is flipped   6.00 | noisy P 0.9478, loss if flipped 2.95
  gap 10: plain P 0.99995, loss if the label is flipped  10.00 | noisy P 0.9500, loss if flipped 2.99
  the flipped-label loss can never exceed -log(0.05) = 3.00
```

Modern reward models usually skip this and rely on one epoch of training (so no pair is seen twice) and on cleaner data. But the idea is worth knowing: the loss is a statement about how reliable you think your labels are.

## 7.5 Inside a reward model

What network computes $$r_\theta(x, y)$$? It has to read a prompt and a long response and understand both well enough to judge quality. The thing that understands text best is a pretrained language model, so every modern reward model starts from one.

Recall from [Chapter 4](https://ishwarj.com/books/how-models-are-trained/04-pretraining) that a language model is a stack of Transformer layers that turns each token into a hidden vector (896 numbers for Qwen2.5-0.5B), followed by an **output head**, a linear layer that maps each hidden vector to 151,936 scores, one per vocabulary token. A reward model keeps the stack and throws away the output head. In its place goes a **score head**, a linear layer from 896 numbers to 1.

<figure class="fig"><svg viewBox="0 0 800 260" role="img" aria-label="The chat goes into the transformer; the hidden state at the final <|im_end|> token goes through a 896-by-1 linear layer that outputs the reward."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">A reward model is a language model with its last layer swapped for one number</text><rect class="box" x="20.0" y="196.0" width="96.4" height="26.0" rx="5"/><text class="t-tick" x="68.2" y="213.0" text-anchor="middle">&lt;|im_start|&gt;</text><rect class="box" x="120.4" y="196.0" width="38.8" height="26.0" rx="5"/><text class="t-tick" x="139.8" y="213.0" text-anchor="middle">user</text><rect class="box" x="163.2" y="196.0" width="34.0" height="26.0" rx="5"/><text class="t-tick" x="180.2" y="213.0" text-anchor="middle">...</text><rect class="box" x="201.2" y="196.0" width="82.0" height="26.0" rx="5"/><text class="t-tick" x="242.2" y="213.0" text-anchor="middle">&lt;|im_end|&gt;</text><rect class="box" x="287.2" y="196.0" width="96.4" height="26.0" rx="5"/><text class="t-tick" x="335.4" y="213.0" text-anchor="middle">&lt;|im_start|&gt;</text><rect class="box" x="387.6" y="196.0" width="74.8" height="26.0" rx="5"/><text class="t-tick" x="425.0" y="213.0" text-anchor="middle">assistant</text><rect class="box" x="466.4" y="196.0" width="34.0" height="26.0" rx="5"/><text class="t-tick" x="483.4" y="213.0" text-anchor="middle">The</text><rect class="box" x="504.4" y="196.0" width="38.8" height="26.0" rx="5"/><text class="t-tick" x="523.8" y="213.0" text-anchor="middle">word</text><rect class="box" x="547.2" y="196.0" width="46.0" height="26.0" rx="5"/><text class="t-tick" x="570.2" y="213.0" text-anchor="middle">"red"</text><rect class="box" x="597.2" y="196.0" width="34.0" height="26.0" rx="5"/><text class="t-tick" x="614.2" y="213.0" text-anchor="middle">...</text><rect class="box-on" x="635.2" y="196.0" width="82.0" height="26.0" rx="5"/><text class="t-tick" x="676.2" y="213.0" text-anchor="middle">&lt;|im_end|&gt;</text><rect class="box-1" x="20.0" y="120.0" width="697.2" height="52.0" rx="10"/><text class="t-note" x="368.6" y="142.0" text-anchor="middle">Qwen2.5-0.5B-Instruct transformer, 24 layers (frozen, plus LoRA adapters)</text><text class="t-tick" x="368.6" y="160.0" text-anchor="middle">every token gets a 896-number hidden state; causal attention, so the last one has seen everything</text><line class="edge-on" x1="676.2" y1="194.0" x2="676.2" y2="174.0"/><rect class="box-3" x="616.2" y="62.0" width="120.0" height="40.0" rx="8"/><text class="t-note" x="676.2" y="80.0" text-anchor="middle">score head</text><text class="t-tick" x="676.2" y="96.0" text-anchor="middle">896 x 1, no bias</text><line class="edge-on" x1="676.2" y1="118.0" x2="676.2" y2="104.0"/><rect class="box-on" x="630.2" y="14.0" width="92.0" height="34.0" rx="8"/><text class="t-note" x="676.2" y="36.0" text-anchor="middle">r = 4.20</text><line class="edge-on" x1="676.2" y1="60.0" x2="676.2" y2="50.0"/><text class="t-muted" x="20.0" y="66.0" text-anchor="start">The language model head (896 x 151,936) is gone.</text><text class="t-muted" x="20.0" y="83.0" text-anchor="start">In its place: one weight per hidden unit.</text><text class="t-muted" x="20.0" y="100.0" text-anchor="start">Hidden states of the other tokens are ignored.</text><text class="t-muted" x="20.0" y="246.0" text-anchor="start">The reward is read at the token that closes the reply, so it can depend on the whole prompt and the whole answer.</text></svg><figcaption>A reward model built from Qwen2.5-0.5B-Instruct. The whole chat is fed in; the hidden state at the last token (the <|im_end|> that closes the reply) goes through a 896-by-1 linear layer. That one number is the reward. In our model the transformer is frozen and adapted with LoRA; the head is trained in full.</figcaption></figure>

Three details matter.

**Which token.** The Transformer produces a hidden state for every token, but we need one number for the whole response. Because attention is causal, the hidden state at the *last* token is the only one that has seen the entire prompt and response, so the score is read there. Our chats end with the `<|im_end|>` token that closes the assistant's turn. When several chats of different lengths are padded into one batch, the code must find each chat's last real token, not the last padding token; in Hugging Face's `AutoModelForSequenceClassification` this is done by searching for the last token that is not the pad token, which is why we set `pad_token_id` explicitly.

**Which starting model.** Stiennon et al. and InstructGPT start from the SFT model. Llama 2 starts from the chat model itself:

> [!PAPER] Touvron et al. (2023), Llama 2 · Section 3.2.2 · page 10
> [![Llama 2: we train two separate reward models, one optimized for helpfulness and another for safety; we initialize our reward models from pretrained chat model checkpoints, as it ensures that both models benefit from knowledge acquired in pretraining; in short, the reward model knows what the chat model knows](https://ishwarj.com/img/training/ch7-llama2-init.pngch7-llama2-init.png)](/img/training/ch7-llama2-init.png)
>
> **Context:** the reward modelling section of the Llama 2 paper.
>
> **What it says:** two reward models (helpfulness and safety), both initialised "from pretrained chat model checkpoints"; "the reward model 'knows' what the chat model knows."
>
> **Why it matters:** the reward model must judge the policy's own outputs. If it starts from the same knowledge, it is less likely to be fooled by confident claims it cannot check. We do the same: our reward model starts from Qwen2.5-0.5B-Instruct, the model Chapter 8 will train.

**How big.** InstructGPT used 6B reward models to train a 175B policy; Llama 2 used reward models the same size as the policy (7B to 70B). Stiennon et al. found that reward model accuracy improves steadily with both data and size:

> [!PAPER] Stiennon et al. (2020) · Figure 6 · page 8
> [![Reward model validation accuracy against the amount of training data (8k to 64k comparisons) for model sizes from 1.3B to 12.9B parameters; accuracy rises with both; the 6.7B model trained on all data approaches the accuracy of a single human](https://ishwarj.com/img/training/ch7-stiennon-fig6.png7-stiennon-fig6.png)](/img/training/ch7-stiennon-fig6.png)
>
> **Context:** the analysis of the reward model.
>
> **What it says:** "Doubling amount of training data leads to a ~1.1% increase in reward model validation accuracy, whereas doubling the model size leads to a ~1.8% increase." The best model approaches the agreement rate of a single human with the others.
>
> **Why it matters:** with only 0.5B parameters and 3,200 comparisons, our reward model sits at the far bottom left of this chart. We should expect modest accuracy, and we will get it.

> [!NOTE]
> A reward model is a **sequence classifier** in the Hugging Face sense: the same class that classifies sentiment, with one output instead of two. The difference is only in the loss: a sentiment classifier is trained against fixed labels, a reward model against comparisons. That is why `AutoModelForSequenceClassification(num_labels=1)` is all the code needs.

## 7.6 The data: UltraFeedback

For a real reward model we need real preference data. Two public datasets are widely used:

- **Anthropic HH-RLHF** (Bai et al., 2022): about 160,000 human comparisons of chat assistant replies, collected for helpfulness and harmlessness. The comparisons are human, but most replies are short and many conversations are multi-turn.
- **UltraFeedback** (Cui et al., 2023): about 64,000 prompts, each answered by 4 different models (from LLaMA-2 and Falcon to GPT-4), and each answer rated by GPT-4 for instruction following, truthfulness, honesty and helpfulness, plus an overall score from 1 to 10. The team behind Zephyr (Tunstall et al., 2023) turned it into pairs: the answer with the highest overall score is "chosen", one of the other three, picked at random, is "rejected". That version, **UltraFeedback binarized**, is a standard benchmark dataset for reward models and DPO.

We use UltraFeedback binarized, for three reasons: it is single-turn and varied, the answers come from many different models (so the reward model sees a range of quality), and it keeps both ratings, which we need for the margin loss in Section 7.11. Its labels come from GPT-4, not from people, so strictly this is RLAIF (RL from AI feedback, Chapter 2): our reward model learns to imitate GPT-4's judgement. The method is identical.

`ch7_data.py` loads it and keeps pairs that fit our budget:

```text
UltraFeedback binarized train_prefs: 61,135 rows; ties (same rating) 12.1%
train: 4000 pairs | rating gap mean 2.21, median 1.50 | response tokens chosen 155, rejected 136 | chosen is longer in 53.1%
test: 600 pairs | rating gap mean 2.19, median 1.50 | response tokens chosen 155, rejected 139 | chosen is longer in 53.3%
```

- We drop **ties**: 12.1% of rows have the same rating for both answers, so there is no preference to learn.
- We keep pairs whose whole chat fits in **512 tokens**, to keep training fast. This drops the longest answers, so our answers are shorter than in the full dataset.
- The **rating gap** (chosen rating minus rejected rating) has a median of 1.5 points out of 10: many pairs are close calls.
- The chosen answer is longer in 53% of pairs, and on average 19 tokens longer. Hold on to that number.

The test set is 600 pairs from UltraFeedback's own test split, never used in training. Here is one of them:

<figure class="fig"><svg viewBox="0 0 800 234" role="img" aria-label="A preference pair: the prompt asks to fill a blank; the chosen answer suggests red (rating 7), the rejected answer asks a question back (rating 3)."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">One UltraFeedback pair (test set), rated by GPT-4 on a 1 to 10 scale</text><rect class="box-ghost" x="20.0" y="40.0" width="760.0" height="34.0" rx="8"/><text class="t-tick" x="32.0" y="62.0" text-anchor="start">prompt: Complete the sentence by providing an appropriate word. She was wearing a ____ dress.</text><rect class="box-3" x="20.0" y="86.0" width="372.0" height="112.0" rx="8"/><text class="t-note" x="32.0" y="106.0" text-anchor="start">chosen: rating 7.0</text><text class="t-tick" x="32.0" y="128.0" text-anchor="start">The word "red" would be an appropriate word</text><text class="t-tick" x="32.0" y="145.0" text-anchor="start">to fill in the blank in the sentence</text><text class="t-tick" x="32.0" y="162.0" text-anchor="start">"She was wearing a [___] dress."</text><rect class="box-4" x="408.0" y="86.0" width="372.0" height="112.0" rx="8"/><text class="t-note" x="420.0" y="106.0" text-anchor="start">rejected: rating 3.0</text><text class="t-tick" x="420.0" y="128.0" text-anchor="start">Is the dress navy blue, black, or any other color?</text><text class="t-val" x="32.0" y="186.0" text-anchor="start">our reward model: +4.20</text><text class="t-val" x="420.0" y="186.0" text-anchor="start">our reward model: +2.19</text><text class="t-muted" x="400.0" y="220.0" text-anchor="middle">The reward model never sees the ratings. It only learns that the left answer should score higher.</text></svg><figcaption>One pair from the test set. The reward model sees only the two chats and must learn that the left one should score higher; the ratings themselves are used only for the margin loss and for analysis.</figcaption></figure>

And this is exactly what the reward model reads for the chosen answer, the whole chat in Qwen's template:

```text
'<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n<|im_start|>user\nComplete the sentence by providing an appropriate word. She was wearing a ____ dress.<|im_end|>\n<|im_start|>assistant\nThe word "red" would be an appropriate word to fill in the blank in the sentence "She was wearing a [___] dress."<|im_end|>'
... 74 tokens; last token id 151645 = <|im_end|>
```

The system line is added by Qwen's chat template when no system message is given. We drop the final newline that the template would add after `<|im_end|>`, so the last token, where the reward is read, is the one that closes the reply.

## 7.7 Hands-on: training a reward model

Everything is in place: a backbone, a head, a loss and data. `ch7_train.py` trains the reward model; `ch7_common.py` holds the pieces it shares with the other scripts. We go through them block by block.

### Building the model

```python
# simplified from ch7_common.py
BACKBONE = 'Qwen/Qwen2.5-0.5B-Instruct'

def build_rm(r=16, alpha=32, dropout=0.05):
    m = AutoModelForSequenceClassification.from_pretrained(BACKBONE, num_labels=1)
    m.config.pad_token_id = tok.pad_token_id          # <|endoftext|>: how the model finds each chat's last token
    cfg = LoraConfig(r=r, lora_alpha=alpha, lora_dropout=dropout, task_type='SEQ_CLS',
                     target_modules=['q_proj', 'k_proj', 'v_proj', 'o_proj', 'gate_proj', 'up_proj', 'down_proj'],
                     modules_to_save=['score'])        # the new head is trained in full
    return get_peft_model(m, cfg)
```

- `AutoModelForSequenceClassification(..., num_labels=1)` loads the pretrained transformer and adds the score head, a fresh $$896 \times 1$$ linear layer. The loading report says so: `score.weight | MISSING ... newly initialized`. The language model head is not loaded at all.
- `pad_token_id` is set so that, in a padded batch, the model reads the reward at each chat's last real token.
- The `LoraConfig` is the one from [Chapter 5](https://ishwarj.com/books/how-models-are-trained/05-supervised-fine-tuning): rank 16 adapters on all seven linear layers of each of the 24 Transformer blocks. `modules_to_save=['score']` tells LoRA to train the head itself rather than adapt it; it is new, so there is nothing to keep frozen.

The parameter count is a good check that we understand the model:

```text
trainable parameters 8,799,104 of 502,832,768 (1.75%)
```

Per block, a rank-16 adapter on a layer of shape $$d_{in} \times d_{out}$$ adds $$16 \cdot (d_{in} + d_{out})$$ numbers. The query and output projections are $$896 \times 896$$ (28,672 each), key and value are $$896 \times 128$$ (16,384 each, Qwen shares keys and values across heads), and the three MLP layers connect 896 and 4,864 (92,160 each). That is 366,592 per block, $$\times 24 = 8{,}798{,}208$$, plus 896 for the head: 8,799,104.

### One training step

```python
# simplified from ch7_train.py
for s in range(steps):                                        # 400 steps of 8 pairs = 3,200 pairs, one epoch
    batch = [train[i] for i in order[s * 8:(s + 1) * 8]]
    for k in (0, 4):                                          # two micro-batches of 4 pairs
        mb = batch[k:k + 4]
        ids, att = pad([p['ids_c'] for p in mb] + [p['ids_r'] for p in mb])   # 4 chosen + 4 rejected chats
        with torch.autocast('mps', dtype=torch.bfloat16):
            r = model(input_ids=ids, attention_mask=att).logits[:, 0].float()  # 8 rewards
        rc, rr = r[:4], r[4:]
        loss = -F.logsigmoid(rc - rr).mean()                  # the Bradley-Terry loss
        (loss / 2).backward()                                 # accumulate gradients over the 2 micro-batches
    torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0)
    opt.step(); sched.step(); opt.zero_grad()
```

- Each step uses 8 pairs. They are split into two micro-batches of 4 pairs so that memory stays small; the gradients of the two are added up before the update (gradient accumulation, Chapter 4).
- `pad` puts the 4 chosen and the 4 rejected chats into one padded tensor of 8 rows, so one forward pass scores all of them. Lengths are rounded up to a multiple of 64 tokens: the GPU backend (all runs in this chapter are on an Apple M5 Pro, 64 GB) compiles its kernels once per tensor shape, and fewer distinct shapes means less waiting (the same trick as in Chapter 5).
- `logits[:, 0]` is the score head's output at each chat's last token: one reward per chat. The first 4 are the chosen answers, the last 4 the rejected ones, in the same order, so `rc - rr` gives the 4 gaps.
- `torch.autocast(..., bfloat16)` runs the matrix multiplications in 16-bit (Chapter 4, Section 4.10). It made steps about 30% faster in a quick test (2.5 against 3.5 seconds per step); the loss is computed in 32-bit.
- AdamW with learning rate $$3 \times 10^{-4}$$, a short linear warm-up (5% of the steps) then linear decay to zero, and gradient clipping at 1.0. (Why 3e-4 and not the more usual 1e-4 is explained below the run.)
- **One epoch.** Every paper we have quoted trains reward models for a single pass over the data: InstructGPT saw overfitting otherwise, and Llama 2 says "training longer can lead to over-fitting." We do the same.

Every 100 steps the script scores all 600 test pairs and records the accuracy: the share of pairs where the chosen answer gets the higher reward.

### The run

[![Terminal output of ch7_train.py: 3,200 training pairs and 600 test pairs; 8,799,104 trainable parameters of 502,832,768; test accuracy 0.465 before training, then 0.652, 0.682, 0.688 and 0.695 at steps 100 to 400, with test loss falling from 0.787 to 0.571; adapter saved to results/ch7_rm](https://ishwarj.com/img/training/ch7-train-run.pngg/ch7-train-run.png)](/img/training/ch7-train-run.png)

```text
step    0 | test acc 0.465 test loss 0.7873 (before training)
step  100 | train loss 0.7178 train acc 0.588 | test acc 0.652 test loss 0.6363 | 1062s
step  200 | train loss 0.6384 train acc 0.634 | test acc 0.682 test loss 0.5984 | 1679s
step  300 | train loss 0.5829 train acc 0.715 | test acc 0.688 test loss 0.5824 | 1981s
step  400 | train loss 0.5419 train acc 0.713 | test acc 0.695 test loss 0.5709 | 2278s
saved adapter to results/ch7_rm; total time 2279s
```

<figure class="fig"><svg viewBox="0 0 820 310" role="img" aria-label="Left: training and test loss of the main run fall from about 0.79 to below 0.6. Right: held-out accuracy of the main run and of the same run with a three times smaller learning rate."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">Training the reward model: 3,200 pairs, one epoch, 400 steps of 8 pairs (ch7_train.py)</text><line class="grid" x1="70" y1="260.0" x2="320" y2="260.0"/><text class="t-tick" x="62.0" y="264.0" text-anchor="end">0.5</text><line class="grid" x1="70" y1="193.3" x2="320" y2="193.3"/><text class="t-tick" x="62.0" y="197.3" text-anchor="end">0.6</text><line class="grid" x1="70" y1="126.7" x2="320" y2="126.7"/><text class="t-tick" x="62.0" y="130.7" text-anchor="end">0.7</text><line class="grid" x1="70" y1="60.0" x2="320" y2="60.0"/><text class="t-tick" x="62.0" y="64.0" text-anchor="end">0.8</text><text class="t-tick" x="70.0" y="278.0" text-anchor="middle">0</text><text class="t-tick" x="195.0" y="278.0" text-anchor="middle">200</text><text class="t-tick" x="320.0" y="278.0" text-anchor="middle">400</text><line class="axis" x1="70" y1="260" x2="320" y2="260"/><polyline class="l1" points="132.5,114.8 195.0,167.7 257.5,204.7 320.0,232.1"/><g class="mark"><title>train loss: 100, 0.7</title><circle class="s1 ring" cx="132.5" cy="114.8" r="4"/></g><g class="mark"><title>train loss: 200, 0.6</title><circle class="s1 ring" cx="195.0" cy="167.7" r="4"/></g><g class="mark"><title>train loss: 300, 0.6</title><circle class="s1 ring" cx="257.5" cy="204.7" r="4"/></g><g class="mark"><title>train loss: 400, 0.5</title><circle class="s1 ring" cx="320.0" cy="232.1" r="4"/></g><polyline class="l2" points="70.0,68.5 132.5,169.1 195.0,194.4 257.5,205.0 320.0,212.7"/><g class="mark"><title>test loss: 0, 0.8</title><circle class="s2 ring" cx="70.0" cy="68.5" r="4"/></g><g class="mark"><title>test loss: 100, 0.6</title><circle class="s2 ring" cx="132.5" cy="169.1" r="4"/></g><g class="mark"><title>test loss: 200, 0.6</title><circle class="s2 ring" cx="195.0" cy="194.4" r="4"/></g><g class="mark"><title>test loss: 300, 0.6</title><circle class="s2 ring" cx="257.5" cy="205.0" r="4"/></g><g class="mark"><title>test loss: 400, 0.6</title><circle class="s2 ring" cx="320.0" cy="212.7" r="4"/></g><rect class="s2" x="332.0" y="207.7" width="10" height="10" rx="2"/><text class="t-tick" x="347.0" y="216.7" text-anchor="start">test loss</text><rect class="s1" x="332.0" y="227.1" width="10" height="10" rx="2"/><text class="t-tick" x="347.0" y="236.1" text-anchor="start">train loss</text><text class="t-muted" x="195.0" y="298.0" text-anchor="middle">optimizer step</text><text class="t-muted" x="62.0" y="44.0" text-anchor="start">loss (chance = 0.693)</text><line class="grid" x1="450" y1="260.0" x2="670" y2="260.0"/><text class="t-tick" x="442.0" y="264.0" text-anchor="end">40%</text><line class="grid" x1="450" y1="210.0" x2="670" y2="210.0"/><text class="t-tick" x="442.0" y="214.0" text-anchor="end">50%</text><line class="grid" x1="450" y1="160.0" x2="670" y2="160.0"/><text class="t-tick" x="442.0" y="164.0" text-anchor="end">60%</text><line class="grid" x1="450" y1="110.0" x2="670" y2="110.0"/><text class="t-tick" x="442.0" y="114.0" text-anchor="end">70%</text><line class="grid" x1="450" y1="60.0" x2="670" y2="60.0"/><text class="t-tick" x="442.0" y="64.0" text-anchor="end">80%</text><text class="t-tick" x="450.0" y="278.0" text-anchor="middle">0</text><text class="t-tick" x="560.0" y="278.0" text-anchor="middle">200</text><text class="t-tick" x="670.0" y="278.0" text-anchor="middle">400</text><line class="axis" x1="450" y1="260" x2="670" y2="260"/><polyline class="l3" points="450.0,227.5 505.0,134.2 560.0,119.2 615.0,115.8 670.0,112.5"/><g class="mark"><title>lr 3e-4 (main): 0, 46%</title><circle class="s3 ring" cx="450.0" cy="227.5" r="4"/></g><g class="mark"><title>lr 3e-4 (main): 100, 65%</title><circle class="s3 ring" cx="505.0" cy="134.2" r="4"/></g><g class="mark"><title>lr 3e-4 (main): 200, 68%</title><circle class="s3 ring" cx="560.0" cy="119.2" r="4"/></g><g class="mark"><title>lr 3e-4 (main): 300, 69%</title><circle class="s3 ring" cx="615.0" cy="115.8" r="4"/></g><g class="mark"><title>lr 3e-4 (main): 400, 70%</title><circle class="s3 ring" cx="670.0" cy="112.5" r="4"/></g><polyline class="l4" points="450.0,227.5 505.0,195.8 560.0,155.0 615.0,146.7 670.0,146.7"/><g class="mark"><title>lr 1e-4: 0, 46%</title><circle class="s4 ring" cx="450.0" cy="227.5" r="4"/></g><g class="mark"><title>lr 1e-4: 100, 53%</title><circle class="s4 ring" cx="505.0" cy="195.8" r="4"/></g><g class="mark"><title>lr 1e-4: 200, 61%</title><circle class="s4 ring" cx="560.0" cy="155.0" r="4"/></g><g class="mark"><title>lr 1e-4: 300, 63%</title><circle class="s4 ring" cx="615.0" cy="146.7" r="4"/></g><g class="mark"><title>lr 1e-4: 400, 63%</title><circle class="s4 ring" cx="670.0" cy="146.7" r="4"/></g><rect class="s3" x="682.0" y="107.5" width="10" height="10" rx="2"/><text class="t-tick" x="697.0" y="116.5" text-anchor="start">lr 3e-4 (main)</text><rect class="s4" x="682.0" y="141.7" width="10" height="10" rx="2"/><text class="t-tick" x="697.0" y="150.7" text-anchor="start">lr 1e-4</text><text class="t-muted" x="560.0" y="298.0" text-anchor="middle">optimizer step</text><text class="t-muted" x="442.0" y="44.0" text-anchor="start">held-out accuracy (600 pairs)</text><text class="t-tick" x="456.0" y="245.5" text-anchor="start">46.5% before training</text></svg><figcaption>Training the reward model. Left: training loss (averaged over each block of 100 steps) and test loss; both start above 0.693, the loss of a model that knows nothing, and end below 0.6. Right: accuracy on the 600 held-out pairs, for the main run (learning rate 3e-4) and for our first attempt with a three times smaller learning rate, which stalls at 62.7%.</figcaption></figure>

How to read it:

- **Before training the accuracy is 46.5%, not 50%.** The new score head starts with random weights, so the untrained model already gives each answer an arbitrary score, by chance slightly anti-correlated with quality on this test set. Its loss, 0.787, is *above* 0.693 for the same reason: random scores are confidently wrong about half the time.
- **Accuracy ends at 69.5%** and rises only slowly after step 200. For a sense of scale (different data, so not a like-for-like comparison): Stiennon et al.'s 1.3B reward model agreed with labelers 62.4% of the time on summaries, and Llama 2's helpfulness reward model averages 63.2% on Meta's own test set.
- **The test loss ends at 0.571.** On the loss curve of Section 7.4, that means typical gaps are small: the model is rarely very confident. That is reasonable, since many pairs are close calls.
- **Little overfitting.** Training accuracy over the last 100 steps (71.3%) is close to test accuracy, as expected after one epoch.

**The learning rate mattered more than anything else we tried.** Our first run used $$10^{-4}$$, a common LoRA value. It is the lower curve in the figure: 52.8% after 100 steps and 62.7% at the end, with the same data, the same seed and the same schedule. Tripling the learning rate gave 69.5%. The plain Bradley-Terry loss gives small gradients once gaps open up (Section 7.4), so a reward model can under-train quietly; always compare a couple of learning rates on held-out pairs. Section 7.11 shows that this also changes how a margin loss looks.

The run took 38 minutes on the M5 Pro, including five passes over the test set. The adapter it saves, `results/ch7_rm/`, is 34 MB.

## 7.8 How good is it? Accuracy, calibration and scores

`ch7_eval.py` loads the saved reward model (and the other reward models we trained, which Section 7.11 uses), scores all 600 test pairs, and looks at the results from several angles.

### Accuracy, with an honest error bar

```text
main RM: accuracy 0.695 (95% bootstrap interval 0.657 to 0.732); mean loss 0.5709
```

With only 600 test pairs, 69.5% is uncertain by about 4 points either way. The interval comes from the bootstrap of Chapter 3, Section 3.6: resample the 600 pairs with replacement 2,000 times, recompute the accuracy each time, and keep the middle 95% of the results. Keep this in mind whenever two reward models in this chapter differ by a few points: on this test set, differences under about 4 points are within the noise.

### Accuracy depends on how different the two answers are

An average accuracy hides a lot. UltraFeedback keeps both GPT-4 ratings, so we can split the test pairs by the rating gap, exactly as Llama 2 split its test set by the labelers' strength of preference. We use four buckets with Llama 2's names: a rating gap below 1 is "negligibly better", 1 to 2 "slightly better", 2 to 4 "better" and 4 or more "significantly better".

```text
by rating gap (chosen rating minus rejected rating):
  negligibly better     n=142  main 0.549  lr1 0.514  margin 0.556  seed1 0.542  seed2 0.563  small 0.585
  slightly better       n=192  main 0.672  lr1 0.615  margin 0.703  seed1 0.677  seed2 0.630  small 0.625
  better                n=136  main 0.779  lr1 0.654  margin 0.750  seed1 0.735  seed2 0.684  small 0.662
  significantly better  n=130  main 0.800  lr1 0.738  margin 0.785  seed1 0.777  seed2 0.731  small 0.754
  gold RM by rating gap: negligibly better 0.613, slightly better 0.760, better 0.838, significantly better 0.931
```

<figure class="fig"><svg viewBox="0 0 800 342" role="img" aria-label="Grouped bars of accuracy for four rating-gap buckets: all reward models are near chance when the ratings are close and much better when one answer is clearly better."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">Held-out accuracy by how far apart the two GPT-4 ratings are (600 test pairs)</text><line class="grid" x1="80" y1="264.0" x2="720" y2="264.0"/><text class="t-tick" x="72.0" y="268.0" text-anchor="end">30%</text><line class="grid" x1="80" y1="204.0" x2="720" y2="204.0"/><text class="t-tick" x="72.0" y="208.0" text-anchor="end">50%</text><line class="grid" x1="80" y1="144.0" x2="720" y2="144.0"/><text class="t-tick" x="72.0" y="148.0" text-anchor="end">70%</text><line class="grid" x1="80" y1="84.0" x2="720" y2="84.0"/><text class="t-tick" x="72.0" y="88.0" text-anchor="end">90%</text><line class="grid" x1="80" y1="54.0" x2="720" y2="54.0"/><text class="t-tick" x="72.0" y="58.0" text-anchor="end">100%</text><line class="edge-dim" x1="80" y1="204.0" x2="720" y2="204.0"/><g class="mark"><title>plain, lr 1e-4, negligibly better: 0.514</title><rect class="s4" x="92" y="199.8" width="30" height="64.2" rx="3"/></g><text class="t-val" x="107.0" y="194.8" text-anchor="middle">51</text><g class="mark"><title>margin, lr 1e-4, negligibly better: 0.556</title><rect class="s2" x="126" y="187.1" width="30" height="76.9" rx="3"/></g><text class="t-val" x="141.0" y="182.1" text-anchor="middle">56</text><g class="mark"><title>plain, lr 3e-4 (main), negligibly better: 0.549</title><rect class="s1" x="160" y="189.2" width="30" height="74.8" rx="3"/></g><text class="t-val" x="175.0" y="184.2" text-anchor="middle">55</text><g class="mark"><title>gold RM (Skywork V2), negligibly better: 0.613</title><rect class="s3" x="194" y="170.2" width="30" height="93.8" rx="3"/></g><text class="t-val" x="209.0" y="165.2" text-anchor="middle">61</text><text class="t-tick" x="160.0" y="282.0" text-anchor="middle">negligibly better</text><text class="t-muted" x="160.0" y="298.0" text-anchor="middle">n = 142</text><g class="mark"><title>plain, lr 1e-4, slightly better: 0.615</title><rect class="s4" x="252" y="169.6" width="30" height="94.4" rx="3"/></g><text class="t-val" x="267.0" y="164.6" text-anchor="middle">61</text><g class="mark"><title>margin, lr 1e-4, slightly better: 0.703</title><rect class="s2" x="286" y="143.1" width="30" height="120.9" rx="3"/></g><text class="t-val" x="301.0" y="138.1" text-anchor="middle">70</text><g class="mark"><title>plain, lr 3e-4 (main), slightly better: 0.672</title><rect class="s1" x="320" y="152.4" width="30" height="111.6" rx="3"/></g><text class="t-val" x="335.0" y="147.4" text-anchor="middle">67</text><g class="mark"><title>gold RM (Skywork V2), slightly better: 0.760</title><rect class="s3" x="354" y="125.9" width="30" height="138.1" rx="3"/></g><text class="t-val" x="369.0" y="120.9" text-anchor="middle">76</text><text class="t-tick" x="320.0" y="282.0" text-anchor="middle">slightly better</text><text class="t-muted" x="320.0" y="298.0" text-anchor="middle">n = 192</text><g class="mark"><title>plain, lr 1e-4, better: 0.654</title><rect class="s4" x="412" y="157.7" width="30" height="106.3" rx="3"/></g><text class="t-val" x="427.0" y="152.7" text-anchor="middle">65</text><g class="mark"><title>margin, lr 1e-4, better: 0.750</title><rect class="s2" x="446" y="129.0" width="30" height="135.0" rx="3"/></g><text class="t-val" x="461.0" y="124.0" text-anchor="middle">75</text><g class="mark"><title>plain, lr 3e-4 (main), better: 0.779</title><rect class="s1" x="480" y="120.2" width="30" height="143.8" rx="3"/></g><text class="t-val" x="495.0" y="115.2" text-anchor="middle">78</text><g class="mark"><title>gold RM (Skywork V2), better: 0.838</title><rect class="s3" x="514" y="102.5" width="30" height="161.5" rx="3"/></g><text class="t-val" x="529.0" y="97.5" text-anchor="middle">84</text><text class="t-tick" x="480.0" y="282.0" text-anchor="middle">better</text><text class="t-muted" x="480.0" y="298.0" text-anchor="middle">n = 136</text><g class="mark"><title>plain, lr 1e-4, significantly better: 0.738</title><rect class="s4" x="572" y="132.5" width="30" height="131.5" rx="3"/></g><text class="t-val" x="587.0" y="127.5" text-anchor="middle">74</text><g class="mark"><title>margin, lr 1e-4, significantly better: 0.785</title><rect class="s2" x="606" y="118.6" width="30" height="145.4" rx="3"/></g><text class="t-val" x="621.0" y="113.6" text-anchor="middle">78</text><g class="mark"><title>plain, lr 3e-4 (main), significantly better: 0.800</title><rect class="s1" x="640" y="114.0" width="30" height="150.0" rx="3"/></g><text class="t-val" x="655.0" y="109.0" text-anchor="middle">80</text><g class="mark"><title>gold RM (Skywork V2), significantly better: 0.931</title><rect class="s3" x="674" y="74.8" width="30" height="189.2" rx="3"/></g><text class="t-val" x="689.0" y="69.8" text-anchor="middle">93</text><text class="t-tick" x="640.0" y="282.0" text-anchor="middle">significantly better</text><text class="t-muted" x="640.0" y="298.0" text-anchor="middle">n = 130</text><line class="axis" x1="80" y1="264" x2="720" y2="264"/><rect class="s4" x="40" y="317" width="12" height="12" rx="2"/><text class="t-tick" x="68.0" y="327.0" text-anchor="start">plain, lr 1e-4</text><rect class="s2" x="178.0" y="317" width="12" height="12" rx="2"/><text class="t-tick" x="206.0" y="327.0" text-anchor="start">margin, lr 1e-4</text><rect class="s1" x="323.0" y="317" width="12" height="12" rx="2"/><text class="t-tick" x="351.0" y="327.0" text-anchor="start">plain, lr 3e-4 (main)</text><rect class="s3" x="510.0" y="317" width="12" height="12" rx="2"/><text class="t-tick" x="538.0" y="327.0" text-anchor="start">gold RM (Skywork V2)</text></svg><figcaption>Accuracy by rating gap. Every reward model, including the much stronger gold model, is close to a coin flip when GPT-4 rated the two answers almost the same, and far better when one answer is clearly better. Llama 2's Table 8 shows the same pattern with human labels.</figcaption></figure>

Our main model is right 80% of the time on clear cases and 55% on near-ties. The near-ties are not a failure of the reward model so much as a property of the data: if GPT-4's ratings differ by half a point, a different rater might well have ranked them the other way. Even the gold model, Skywork-Reward-V2 (a 2025 reward model of similar size, 0.6B parameters, but trained on far more and far cleaner preference data), manages only 61% there. Compare Llama 2's own numbers in Section 7.11: 80.7% on significantly better pairs, 54.7% on negligibly better ones. The shape is the same.

### Calibration: does 80% mean 80%?

The Bradley-Terry model makes a promise: when the reward gap is $$\Delta$$, the chosen answer should win with probability $$\sigma(\Delta)$$. A reward model that keeps this promise is **calibrated**. Calibration matters later: PPO treats reward differences as meaningful sizes, not just orderings.

> [!DEFINITION] Calibration
> A model is calibrated if its stated probabilities match observed frequencies: of all the pairs where it says "80% sure", about 80% should be right.

To check, take each test pair's predicted probability $$p = \sigma(r_w - r_l)$$. The model's *confidence* in its own prediction is $$\max(p, 1 - p)$$ (it predicts whichever answer it thinks is likelier). Put the pairs into bins by confidence and compare, in each bin, the average confidence with the share of pairs the model got right:

```text
  confidence 0.5 to 0.6: n=147  mean confidence 0.550  accuracy 0.483
  confidence 0.6 to 0.7: n=121  mean confidence 0.650  accuracy 0.620
  confidence 0.7 to 0.8: n= 98  mean confidence 0.750  accuracy 0.755
  confidence 0.8 to 0.9: n=108  mean confidence 0.851  accuracy 0.806
  confidence 0.9 to 1.0: n=126  mean confidence 0.955  accuracy 0.873
expected calibration error (ECE) 0.049
```

<figure class="fig"><svg viewBox="0 0 800 356" role="img" aria-label="Reliability diagram: the reward model confidence on each pair against how often it is right, in five bins, with a table of the values."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">Calibration: predicted confidence against actual accuracy (ECE 0.049)</text><text class="t-tick" x="90.0" y="322.0" text-anchor="middle">0.5</text><text class="t-tick" x="138.0" y="322.0" text-anchor="middle">0.6</text><text class="t-tick" x="186.0" y="322.0" text-anchor="middle">0.7</text><text class="t-tick" x="234.0" y="322.0" text-anchor="middle">0.8</text><text class="t-tick" x="282.0" y="322.0" text-anchor="middle">0.9</text><text class="t-tick" x="330.0" y="322.0" text-anchor="middle">1.0</text><line class="grid" x1="90" y1="304.0" x2="330" y2="304.0"/><text class="t-tick" x="82.0" y="308.0" text-anchor="end">0.3</text><line class="grid" x1="90" y1="235.4" x2="330" y2="235.4"/><text class="t-tick" x="82.0" y="239.4" text-anchor="end">0.5</text><line class="grid" x1="90" y1="166.9" x2="330" y2="166.9"/><text class="t-tick" x="82.0" y="170.9" text-anchor="end">0.7</text><line class="grid" x1="90" y1="98.3" x2="330" y2="98.3"/><text class="t-tick" x="82.0" y="102.3" text-anchor="end">0.9</text><line class="edge-dim" x1="90.0" y1="235.4" x2="330.0" y2="64.0"/><text class="t-muted" x="296.4" y="66.9" text-anchor="end">perfect</text><polyline class="l1" points="114.2,241.3 161.8,194.3 210.2,148.0 258.4,130.7 308.6,107.5"/><g class="mark"><title>confidence 0.55, accuracy 0.48, n=147</title><circle class="s1 ring" cx="114.2" cy="241.3" r="6.0"/></g><g class="mark"><title>confidence 0.65, accuracy 0.62, n=121</title><circle class="s1 ring" cx="161.8" cy="194.3" r="5.7"/></g><g class="mark"><title>confidence 0.75, accuracy 0.76, n=98</title><circle class="s1 ring" cx="210.2" cy="148.0" r="5.4"/></g><g class="mark"><title>confidence 0.85, accuracy 0.81, n=108</title><circle class="s1 ring" cx="258.4" cy="130.7" r="5.5"/></g><g class="mark"><title>confidence 0.96, accuracy 0.87, n=126</title><circle class="s1 ring" cx="308.6" cy="107.5" r="5.7"/></g><text class="t-muted" x="210.0" y="342.0" text-anchor="middle">mean confidence in the bin, max(P, 1 - P)</text><text class="t-muted" x="30.0" y="52.0" text-anchor="start">accuracy in the bin</text><text class="t-tick t-strong" x="400.0" y="74.0" text-anchor="start">bin</text><text class="t-tick t-strong" x="520.0" y="74.0" text-anchor="end">pairs</text><text class="t-tick t-strong" x="620.0" y="74.0" text-anchor="end">confidence</text><text class="t-tick t-strong" x="710.0" y="74.0" text-anchor="end">accuracy</text><text class="t-tick" x="400.0" y="98.0" text-anchor="start">0.5 to 0.6</text><text class="t-tick" x="520.0" y="98.0" text-anchor="end">147</text><text class="t-tick" x="620.0" y="98.0" text-anchor="end">0.550</text><text class="t-tick" x="710.0" y="98.0" text-anchor="end">0.483</text><text class="t-tick" x="400.0" y="120.0" text-anchor="start">0.6 to 0.7</text><text class="t-tick" x="520.0" y="120.0" text-anchor="end">121</text><text class="t-tick" x="620.0" y="120.0" text-anchor="end">0.650</text><text class="t-tick" x="710.0" y="120.0" text-anchor="end">0.620</text><text class="t-tick" x="400.0" y="142.0" text-anchor="start">0.7 to 0.8</text><text class="t-tick" x="520.0" y="142.0" text-anchor="end">98</text><text class="t-tick" x="620.0" y="142.0" text-anchor="end">0.750</text><text class="t-tick" x="710.0" y="142.0" text-anchor="end">0.755</text><text class="t-tick" x="400.0" y="164.0" text-anchor="start">0.8 to 0.9</text><text class="t-tick" x="520.0" y="164.0" text-anchor="end">108</text><text class="t-tick" x="620.0" y="164.0" text-anchor="end">0.851</text><text class="t-tick" x="710.0" y="164.0" text-anchor="end">0.806</text><text class="t-tick" x="400.0" y="186.0" text-anchor="start">0.9 to 1.0</text><text class="t-tick" x="520.0" y="186.0" text-anchor="end">126</text><text class="t-tick" x="620.0" y="186.0" text-anchor="end">0.955</text><text class="t-tick" x="710.0" y="186.0" text-anchor="end">0.873</text><text class="t-muted" x="400.0" y="228.0" text-anchor="start">Dot size: number of pairs in the bin.</text><text class="t-muted" x="400.0" y="245.0" text-anchor="start">Points below the diagonal: overconfident;</text><text class="t-muted" x="400.0" y="262.0" text-anchor="start">above: underconfident.</text></svg><figcaption>Reliability diagram for our reward model. Each dot is a bin of test pairs; a perfectly calibrated model would lie on the diagonal. Ours is close in the middle and somewhat overconfident at the top: when it is 95% sure, it is right 87% of the time.</figcaption></figure>

The summary number is the **expected calibration error**:

$$
\text{ECE} = \sum_{b=1}^{B} \frac{n_b}{N}\,\big|\text{acc}_b - \text{conf}_b\big|
$$

where:

- $$B$$ is the number of bins (5 here) and $$b$$ indexes them;
- $$n_b$$ is the number of pairs in bin $$b$$ and $$N = 600$$ the total;
- $$\text{acc}_b$$ is the share of pairs in the bin that the model got right;
- $$\text{conf}_b$$ is the model's average confidence in that bin.

**Worked example** with the table's values: $$\frac{147}{600}\cdot 0.067 + \frac{121}{600}\cdot 0.030 + \frac{98}{600}\cdot 0.005 + \frac{108}{600}\cdot 0.045 + \frac{126}{600}\cdot 0.082 = 0.0164 + 0.0061 + 0.0008 + 0.0081 + 0.0172 = 0.0486$$, which is the 0.049 the script prints.

An ECE of 0.049 is good for a model trained for one epoch on noisy labels. The pattern, overconfidence on the pairs it is surest about, is common: the most confident predictions include pairs where the label itself is wrong, which no reward model can get right. (This is the situation Christiano et al.'s 10% label-noise term was designed for.)

### What the scores look like

```text
chosen   mean +5.317 sd 1.496 | rejected mean +4.427 sd 1.754 | gap mean +0.891 sd 1.668
```

<figure class="fig"><svg viewBox="0 0 800 316" role="img" aria-label="Two overlapping histograms of rewards: chosen answers are shifted to the right of rejected ones, but the two distributions overlap heavily."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">Rewards of the 600 chosen and 600 rejected test answers (our reward model)</text><polyline class="l1" points="60.0,250.0 60.0,250.0 82.0,250.0 82.0,247.1 104.0,247.1 104.0,250.0 126.0,250.0 126.0,244.2 148.0,244.2 148.0,250.0 170.0,250.0 170.0,250.0 192.0,250.0 192.0,247.1 214.0,247.1 214.0,229.7 236.0,229.7 236.0,223.9 258.0,223.9 258.0,223.9 280.0,223.9 280.0,221.0 302.0,221.0 302.0,223.9 324.0,223.9 324.0,194.9 346.0,194.9 346.0,186.2 368.0,186.2 368.0,212.3 390.0,212.3 390.0,154.3 412.0,154.3 412.0,157.2 434.0,157.2 434.0,102.2 456.0,102.2 456.0,64.5 478.0,64.5 478.0,119.6 500.0,119.6 500.0,93.5 522.0,93.5 522.0,110.9 544.0,110.9 544.0,50.0 566.0,50.0 566.0,125.4 588.0,125.4 588.0,189.1 610.0,189.1 610.0,186.2 632.0,186.2 632.0,218.1 654.0,218.1 654.0,241.3 676.0,241.3 676.0,244.2 698.0,244.2 698.0,250.0 720.0,250.0 720.0,250.0"/><polyline class="l2" points="60.0,250.0 60.0,244.2 82.0,244.2 82.0,244.2 104.0,244.2 104.0,244.2 126.0,244.2 126.0,232.6 148.0,232.6 148.0,226.8 170.0,226.8 170.0,226.8 192.0,226.8 192.0,221.0 214.0,221.0 214.0,221.0 236.0,221.0 236.0,197.8 258.0,197.8 258.0,200.7 280.0,200.7 280.0,189.1 302.0,189.1 302.0,180.4 324.0,180.4 324.0,165.9 346.0,165.9 346.0,177.5 368.0,177.5 368.0,174.6 390.0,174.6 390.0,139.9 412.0,139.9 412.0,108.0 434.0,108.0 434.0,128.3 456.0,128.3 456.0,93.5 478.0,93.5 478.0,79.0 500.0,79.0 500.0,160.1 522.0,160.1 522.0,131.2 544.0,131.2 544.0,154.3 566.0,154.3 566.0,177.5 588.0,177.5 588.0,221.0 610.0,221.0 610.0,229.7 632.0,229.7 632.0,244.2 654.0,244.2 654.0,247.1 676.0,247.1 676.0,250.0 698.0,250.0 698.0,250.0 720.0,250.0 720.0,250.0"/><line class="axis" x1="60" y1="250" x2="720" y2="250"/><text class="t-tick" x="60.0" y="266.0" text-anchor="middle">-1</text><text class="t-tick" x="192.0" y="266.0" text-anchor="middle">1</text><text class="t-tick" x="324.0" y="266.0" text-anchor="middle">3</text><text class="t-tick" x="456.0" y="266.0" text-anchor="middle">5</text><text class="t-tick" x="588.0" y="266.0" text-anchor="middle">7</text><text class="t-tick" x="720.0" y="266.0" text-anchor="middle">9</text><text class="t-muted" x="390.0" y="284.0" text-anchor="middle">reward</text><line class="l1" stroke-dasharray="6 4" x1="476.9" y1="50" x2="476.9" y2="250"/><line class="l2" stroke-dasharray="6 4" x1="418.2" y1="50" x2="418.2" y2="250"/><line class="l1" x1="80" y1="297" x2="102" y2="297"/><text class="t-tick" x="108.0" y="301.0" text-anchor="start">chosen (mean +5.32)</text><line class="l2" x1="253.0" y1="297" x2="275.0" y2="297"/><text class="t-tick" x="281.0" y="301.0" text-anchor="start">rejected (mean +4.43)</text><line class="edge-dim" x1="440.0" y1="297" x2="462.0" y2="297" stroke-dasharray="6 4"/><text class="t-tick" x="468.0" y="301.0" text-anchor="start">dashed: means</text></svg><figcaption>The rewards our model gives to the 600 chosen and 600 rejected test answers. The chosen answers are shifted right by 0.89 on average, but the two distributions overlap heavily: a reward of 5 says little on its own. Only comparisons between answers to the same prompt are meaningful.</figcaption></figure>

Two things to notice. First, all rewards sit around +5, a level nobody chose: the loss never fixes it (Section 7.4), so it is wherever the random head and training happened to leave it. Second, the overlap. A good answer to a hard prompt can score lower than a bad answer to an easy one. A reward model ranks answers *to the same prompt*; comparing raw rewards across prompts mixes in how "rewardable" each prompt is. PPO's baseline and advantage (Chapter 6) remove exactly this per-prompt level, which is one reason they matter so much for RLHF.

For the example pair from Section 7.6, the model gives the chosen answer 4.20 and the rejected one 2.19: a gap of 2.01, so it is $$\sigma(2.01) = 88\%$$ sure the right answer won. It is.

## 7.9 What else did it learn? Length and other shortcuts

A reward model learns whatever separates chosen from rejected answers in its training data. If chosen answers tend to be longer, length itself becomes a signal, whether or not people actually want longer answers. This is the most studied shortcut in reward modelling:

> [!PAPER] Singhal et al. (2023), A Long Way to Go: Investigating Length Correlations in RLHF · Figure 1 · page 1
> [![Left: a heatmap of SFT output length against reward model score for WebGPT, showing that reward scores are strongly correlated with length. Right: an example where RLHF makes an answer much longer than the SFT answer](https://ishwarj.com/img/training/ch7-singhal-fig1.pngh7-singhal-fig1.png)](/img/training/ch7-singhal-fig1.png)
>
> **Context:** the first figure of the paper.
>
> **What it says:** for the WebGPT reward model, "reward scores are strongly correlated with length", and "RLHF with these consistently leads to longer outputs."
>
> **Why it matters:** the paper goes on to show that, on several datasets, much of the improvement credited to RLHF could be matched by optimising for length alone. If the reward model pays for length, PPO will deliver length.

Recall from Section 7.6 that in our training data the chosen answer is longer in 53% of pairs. How much of that did the reward model absorb?

```text
over all 1,200 test answers: corr(reward, length) Pearson 0.217 Spearman 0.147
                             corr(GPT-4 rating, length) Pearson 0.175 Spearman 0.124
within pairs: corr(reward gap, length gap) 0.205; corr(rating gap, length gap) 0.019
accuracy when the chosen answer is longer 0.762 (n=320), shorter 0.615 (n=273)
```

<figure class="fig"><svg viewBox="0 0 800 330" role="img" aria-label="Scatter plot of reward against answer length with binned means, and a table of correlations and of accuracy split by whether the chosen answer is longer."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">Reward against answer length, 1,200 test answers (Spearman 0.15)</text><line class="grid" x1="70" y1="280.0" x2="490" y2="280.0"/><text class="t-tick" x="62.0" y="284.0" text-anchor="end">-1</text><line class="grid" x1="70" y1="234.0" x2="490" y2="234.0"/><text class="t-tick" x="62.0" y="238.0" text-anchor="end">1</text><line class="grid" x1="70" y1="188.0" x2="490" y2="188.0"/><text class="t-tick" x="62.0" y="192.0" text-anchor="end">3</text><line class="grid" x1="70" y1="142.0" x2="490" y2="142.0"/><text class="t-tick" x="62.0" y="146.0" text-anchor="end">5</text><line class="grid" x1="70" y1="96.0" x2="490" y2="96.0"/><text class="t-tick" x="62.0" y="100.0" text-anchor="end">7</text><line class="grid" x1="70" y1="50.0" x2="490" y2="50.0"/><text class="t-tick" x="62.0" y="54.0" text-anchor="end">9</text><text class="t-tick" x="70.0" y="296.0" text-anchor="middle">0</text><text class="t-tick" x="175.0" y="296.0" text-anchor="middle">128</text><text class="t-tick" x="280.0" y="296.0" text-anchor="middle">256</text><text class="t-tick" x="385.0" y="296.0" text-anchor="middle">384</text><text class="t-tick" x="490.0" y="296.0" text-anchor="middle">512</text><circle class="s1" cx="103.6" cy="119.1" r="2" opacity="0.45"/><circle class="s1" cx="111.8" cy="149.0" r="2" opacity="0.45"/><circle class="s1" cx="426.0" cy="95.7" r="2" opacity="0.45"/><circle class="s1" cx="98.7" cy="152.3" r="2" opacity="0.45"/><circle class="s1" cx="135.6" cy="117.2" r="2" opacity="0.45"/><circle class="s1" cx="91.3" cy="101.1" r="2" opacity="0.45"/><circle class="s1" cx="86.4" cy="105.3" r="2" opacity="0.45"/><circle class="s1" cx="188.1" cy="135.5" r="2" opacity="0.45"/><circle class="s1" cx="422.7" cy="124.0" r="2" opacity="0.45"/><circle class="s1" cx="72.5" cy="143.1" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="144.8" r="2" opacity="0.45"/><circle class="s1" cx="136.4" cy="118.8" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="152.1" r="2" opacity="0.45"/><circle class="s1" cx="228.3" cy="139.6" r="2" opacity="0.45"/><circle class="s1" cx="449.0" cy="83.6" r="2" opacity="0.45"/><circle class="s1" cx="110.2" cy="152.2" r="2" opacity="0.45"/><circle class="s1" cx="129.1" cy="107.3" r="2" opacity="0.45"/><circle class="s1" cx="88.0" cy="134.7" r="2" opacity="0.45"/><circle class="s1" cx="316.1" cy="159.7" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="216.9" r="2" opacity="0.45"/><circle class="s1" cx="75.7" cy="106.4" r="2" opacity="0.45"/><circle class="s1" cx="120.0" cy="104.4" r="2" opacity="0.45"/><circle class="s1" cx="129.1" cy="140.1" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="175.7" r="2" opacity="0.45"/><circle class="s1" cx="199.6" cy="205.7" r="2" opacity="0.45"/><circle class="s1" cx="164.3" cy="135.0" r="2" opacity="0.45"/><circle class="s1" cx="130.7" cy="150.8" r="2" opacity="0.45"/><circle class="s1" cx="152.0" cy="104.6" r="2" opacity="0.45"/><circle class="s1" cx="179.9" cy="123.2" r="2" opacity="0.45"/><circle class="s1" cx="272.6" cy="184.9" r="2" opacity="0.45"/><circle class="s1" cx="406.3" cy="105.1" r="2" opacity="0.45"/><circle class="s1" cx="295.6" cy="114.9" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="120.7" r="2" opacity="0.45"/><circle class="s1" cx="147.1" cy="175.9" r="2" opacity="0.45"/><circle class="s1" cx="274.3" cy="158.8" r="2" opacity="0.45"/><circle class="s1" cx="282.5" cy="157.3" r="2" opacity="0.45"/><circle class="s1" cx="93.0" cy="84.6" r="2" opacity="0.45"/><circle class="s1" cx="274.3" cy="185.8" r="2" opacity="0.45"/><circle class="s1" cx="162.7" cy="146.8" r="2" opacity="0.45"/><circle class="s1" cx="130.7" cy="148.5" r="2" opacity="0.45"/><circle class="s1" cx="338.2" cy="136.0" r="2" opacity="0.45"/><circle class="s1" cx="93.0" cy="83.8" r="2" opacity="0.45"/><circle class="s1" cx="254.6" cy="144.4" r="2" opacity="0.45"/><circle class="s1" cx="126.6" cy="135.2" r="2" opacity="0.45"/><circle class="s1" cx="157.8" cy="131.3" r="2" opacity="0.45"/><circle class="s1" cx="94.6" cy="107.6" r="2" opacity="0.45"/><circle class="s1" cx="166.8" cy="142.9" r="2" opacity="0.45"/><circle class="s1" cx="115.9" cy="83.8" r="2" opacity="0.45"/><circle class="s1" cx="177.5" cy="113.7" r="2" opacity="0.45"/><circle class="s1" cx="80.7" cy="178.8" r="2" opacity="0.45"/><circle class="s1" cx="74.1" cy="171.8" r="2" opacity="0.45"/><circle class="s1" cx="106.1" cy="158.2" r="2" opacity="0.45"/><circle class="s1" cx="129.9" cy="112.3" r="2" opacity="0.45"/><circle class="s1" cx="338.2" cy="144.6" r="2" opacity="0.45"/><circle class="s1" cx="159.4" cy="189.5" r="2" opacity="0.45"/><circle class="s1" cx="81.5" cy="216.2" r="2" opacity="0.45"/><circle class="s1" cx="129.9" cy="107.5" r="2" opacity="0.45"/><circle class="s1" cx="106.1" cy="103.8" r="2" opacity="0.45"/><circle class="s1" cx="260.3" cy="145.9" r="2" opacity="0.45"/><circle class="s1" cx="325.9" cy="118.0" r="2" opacity="0.45"/><circle class="s1" cx="137.3" cy="117.9" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="81.7" r="2" opacity="0.45"/><circle class="s1" cx="313.6" cy="159.8" r="2" opacity="0.45"/><circle class="s1" cx="194.7" cy="157.5" r="2" opacity="0.45"/><circle class="s1" cx="93.8" cy="203.3" r="2" opacity="0.45"/><circle class="s1" cx="140.5" cy="141.4" r="2" opacity="0.45"/><circle class="s1" cx="111.0" cy="105.2" r="2" opacity="0.45"/><circle class="s1" cx="172.5" cy="155.7" r="2" opacity="0.45"/><circle class="s1" cx="277.5" cy="127.5" r="2" opacity="0.45"/><circle class="s1" cx="126.6" cy="123.7" r="2" opacity="0.45"/><circle class="s1" cx="118.4" cy="140.3" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="76.4" r="2" opacity="0.45"/><circle class="s1" cx="176.6" cy="124.8" r="2" opacity="0.45"/><circle class="s1" cx="412.1" cy="102.4" r="2" opacity="0.45"/><circle class="s1" cx="232.4" cy="196.9" r="2" opacity="0.45"/><circle class="s1" cx="102.0" cy="107.1" r="2" opacity="0.45"/><circle class="s1" cx="141.4" cy="131.4" r="2" opacity="0.45"/><circle class="s1" cx="261.1" cy="136.2" r="2" opacity="0.45"/><circle class="s1" cx="453.1" cy="91.4" r="2" opacity="0.45"/><circle class="s1" cx="134.8" cy="118.5" r="2" opacity="0.45"/><circle class="s1" cx="98.7" cy="97.1" r="2" opacity="0.45"/><circle class="s1" cx="269.3" cy="153.0" r="2" opacity="0.45"/><circle class="s1" cx="447.3" cy="64.7" r="2" opacity="0.45"/><circle class="s1" cx="209.5" cy="154.0" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="158.9" r="2" opacity="0.45"/><circle class="s1" cx="193.0" cy="212.0" r="2" opacity="0.45"/><circle class="s1" cx="112.7" cy="148.1" r="2" opacity="0.45"/><circle class="s1" cx="427.7" cy="128.7" r="2" opacity="0.45"/><circle class="s1" cx="84.8" cy="128.7" r="2" opacity="0.45"/><circle class="s1" cx="90.5" cy="146.3" r="2" opacity="0.45"/><circle class="s1" cx="144.6" cy="86.1" r="2" opacity="0.45"/><circle class="s1" cx="120.9" cy="152.2" r="2" opacity="0.45"/><circle class="s1" cx="326.8" cy="158.9" r="2" opacity="0.45"/><circle class="s1" cx="84.8" cy="140.9" r="2" opacity="0.45"/><circle class="s1" cx="205.4" cy="177.2" r="2" opacity="0.45"/><circle class="s1" cx="113.5" cy="227.4" r="2" opacity="0.45"/><circle class="s1" cx="398.1" cy="105.2" r="2" opacity="0.45"/><circle class="s1" cx="410.4" cy="76.8" r="2" opacity="0.45"/><circle class="s1" cx="103.6" cy="123.1" r="2" opacity="0.45"/><circle class="s1" cx="417.0" cy="118.9" r="2" opacity="0.45"/><circle class="s1" cx="122.5" cy="189.8" r="2" opacity="0.45"/><circle class="s1" cx="102.8" cy="134.0" r="2" opacity="0.45"/><circle class="s1" cx="93.0" cy="145.1" r="2" opacity="0.45"/><circle class="s1" cx="115.9" cy="144.4" r="2" opacity="0.45"/><circle class="s1" cx="303.0" cy="163.2" r="2" opacity="0.45"/><circle class="s1" cx="334.1" cy="125.3" r="2" opacity="0.45"/><circle class="s1" cx="271.8" cy="107.5" r="2" opacity="0.45"/><circle class="s1" cx="342.3" cy="116.7" r="2" opacity="0.45"/><circle class="s1" cx="82.3" cy="112.8" r="2" opacity="0.45"/><circle class="s1" cx="346.4" cy="121.4" r="2" opacity="0.45"/><circle class="s1" cx="127.4" cy="92.5" r="2" opacity="0.45"/><circle class="s1" cx="127.4" cy="124.6" r="2" opacity="0.45"/><circle class="s1" cx="269.3" cy="111.6" r="2" opacity="0.45"/><circle class="s1" cx="185.7" cy="163.7" r="2" opacity="0.45"/><circle class="s1" cx="172.5" cy="122.7" r="2" opacity="0.45"/><circle class="s1" cx="308.7" cy="136.1" r="2" opacity="0.45"/><circle class="s1" cx="405.5" cy="114.1" r="2" opacity="0.45"/><circle class="s1" cx="129.1" cy="107.2" r="2" opacity="0.45"/><circle class="s1" cx="380.9" cy="98.7" r="2" opacity="0.45"/><circle class="s1" cx="170.9" cy="135.2" r="2" opacity="0.45"/><circle class="s1" cx="79.8" cy="185.2" r="2" opacity="0.45"/><circle class="s1" cx="446.5" cy="128.4" r="2" opacity="0.45"/><circle class="s1" cx="91.3" cy="99.4" r="2" opacity="0.45"/><circle class="s1" cx="375.2" cy="140.7" r="2" opacity="0.45"/><circle class="s1" cx="92.1" cy="169.1" r="2" opacity="0.45"/><circle class="s1" cx="130.7" cy="107.7" r="2" opacity="0.45"/><circle class="s1" cx="121.7" cy="117.3" r="2" opacity="0.45"/><circle class="s1" cx="193.0" cy="145.9" r="2" opacity="0.45"/><circle class="s1" cx="417.0" cy="137.6" r="2" opacity="0.45"/><circle class="s1" cx="126.6" cy="193.4" r="2" opacity="0.45"/><circle class="s1" cx="312.0" cy="142.7" r="2" opacity="0.45"/><circle class="s1" cx="124.1" cy="122.5" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="83.4" r="2" opacity="0.45"/><circle class="s1" cx="96.2" cy="86.6" r="2" opacity="0.45"/><circle class="s1" cx="179.1" cy="140.2" r="2" opacity="0.45"/><circle class="s1" cx="125.8" cy="200.2" r="2" opacity="0.45"/><circle class="s1" cx="120.0" cy="205.2" r="2" opacity="0.45"/><circle class="s1" cx="184.8" cy="151.7" r="2" opacity="0.45"/><circle class="s1" cx="342.3" cy="104.6" r="2" opacity="0.45"/><circle class="s1" cx="76.6" cy="162.3" r="2" opacity="0.45"/><circle class="s1" cx="359.6" cy="134.4" r="2" opacity="0.45"/><circle class="s1" cx="185.7" cy="100.6" r="2" opacity="0.45"/><circle class="s1" cx="264.4" cy="134.4" r="2" opacity="0.45"/><circle class="s1" cx="76.6" cy="132.6" r="2" opacity="0.45"/><circle class="s1" cx="141.4" cy="191.4" r="2" opacity="0.45"/><circle class="s1" cx="264.4" cy="124.4" r="2" opacity="0.45"/><circle class="s1" cx="88.9" cy="106.5" r="2" opacity="0.45"/><circle class="s1" cx="394.0" cy="74.8" r="2" opacity="0.45"/><circle class="s1" cx="171.7" cy="174.4" r="2" opacity="0.45"/><circle class="s1" cx="120.9" cy="132.5" r="2" opacity="0.45"/><circle class="s1" cx="96.2" cy="90.9" r="2" opacity="0.45"/><circle class="s1" cx="365.3" cy="86.6" r="2" opacity="0.45"/><circle class="s1" cx="373.5" cy="155.6" r="2" opacity="0.45"/><circle class="s1" cx="202.9" cy="118.3" r="2" opacity="0.45"/><circle class="s1" cx="174.2" cy="194.6" r="2" opacity="0.45"/><circle class="s1" cx="209.5" cy="138.4" r="2" opacity="0.45"/><circle class="s1" cx="93.8" cy="128.2" r="2" opacity="0.45"/><circle class="s1" cx="330.0" cy="99.2" r="2" opacity="0.45"/><circle class="s1" cx="381.7" cy="143.2" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="144.2" r="2" opacity="0.45"/><circle class="s1" cx="269.3" cy="164.1" r="2" opacity="0.45"/><circle class="s1" cx="127.4" cy="144.9" r="2" opacity="0.45"/><circle class="s1" cx="417.0" cy="143.9" r="2" opacity="0.45"/><circle class="s1" cx="335.0" cy="97.5" r="2" opacity="0.45"/><circle class="s1" cx="215.2" cy="128.7" r="2" opacity="0.45"/><circle class="s1" cx="83.1" cy="121.6" r="2" opacity="0.45"/><circle class="s1" cx="180.7" cy="93.0" r="2" opacity="0.45"/><circle class="s1" cx="128.2" cy="110.8" r="2" opacity="0.45"/><circle class="s1" cx="83.1" cy="121.6" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="105.5" r="2" opacity="0.45"/><circle class="s1" cx="140.5" cy="128.2" r="2" opacity="0.45"/><circle class="s1" cx="120.9" cy="124.6" r="2" opacity="0.45"/><circle class="s1" cx="95.4" cy="94.5" r="2" opacity="0.45"/><circle class="s1" cx="324.3" cy="101.6" r="2" opacity="0.45"/><circle class="s1" cx="79.0" cy="77.2" r="2" opacity="0.45"/><circle class="s1" cx="185.7" cy="96.1" r="2" opacity="0.45"/><circle class="s1" cx="147.1" cy="113.5" r="2" opacity="0.45"/><circle class="s1" cx="155.3" cy="163.0" r="2" opacity="0.45"/><circle class="s1" cx="81.5" cy="187.4" r="2" opacity="0.45"/><circle class="s1" cx="137.3" cy="110.9" r="2" opacity="0.45"/><circle class="s1" cx="72.5" cy="141.1" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="110.2" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="106.6" r="2" opacity="0.45"/><circle class="s1" cx="287.4" cy="119.2" r="2" opacity="0.45"/><circle class="s1" cx="146.3" cy="183.5" r="2" opacity="0.45"/><circle class="s1" cx="262.8" cy="105.0" r="2" opacity="0.45"/><circle class="s1" cx="78.2" cy="105.0" r="2" opacity="0.45"/><circle class="s1" cx="394.0" cy="115.1" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="158.0" r="2" opacity="0.45"/><circle class="s1" cx="327.6" cy="97.8" r="2" opacity="0.45"/><circle class="s1" cx="118.4" cy="144.9" r="2" opacity="0.45"/><circle class="s1" cx="333.3" cy="141.3" r="2" opacity="0.45"/><circle class="s1" cx="121.7" cy="109.0" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="71.2" r="2" opacity="0.45"/><circle class="s1" cx="84.8" cy="117.3" r="2" opacity="0.45"/><circle class="s1" cx="140.5" cy="95.3" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="97.1" r="2" opacity="0.45"/><circle class="s1" cx="315.3" cy="97.3" r="2" opacity="0.45"/><circle class="s1" cx="125.0" cy="141.7" r="2" opacity="0.45"/><circle class="s1" cx="204.5" cy="150.3" r="2" opacity="0.45"/><circle class="s1" cx="326.8" cy="110.1" r="2" opacity="0.45"/><circle class="s1" cx="147.9" cy="96.5" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="115.7" r="2" opacity="0.45"/><circle class="s1" cx="271.8" cy="104.7" r="2" opacity="0.45"/><circle class="s1" cx="225.0" cy="182.7" r="2" opacity="0.45"/><circle class="s1" cx="104.5" cy="210.9" r="2" opacity="0.45"/><circle class="s1" cx="156.1" cy="225.8" r="2" opacity="0.45"/><circle class="s1" cx="106.1" cy="129.9" r="2" opacity="0.45"/><circle class="s1" cx="451.4" cy="128.2" r="2" opacity="0.45"/><circle class="s1" cx="115.9" cy="195.7" r="2" opacity="0.45"/><circle class="s1" cx="140.5" cy="135.4" r="2" opacity="0.45"/><circle class="s1" cx="74.1" cy="102.9" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="62.8" r="2" opacity="0.45"/><circle class="s1" cx="115.9" cy="122.4" r="2" opacity="0.45"/><circle class="s1" cx="106.9" cy="187.1" r="2" opacity="0.45"/><circle class="s1" cx="387.5" cy="104.9" r="2" opacity="0.45"/><circle class="s1" cx="226.7" cy="177.3" r="2" opacity="0.45"/><circle class="s1" cx="101.2" cy="109.7" r="2" opacity="0.45"/><circle class="s1" cx="78.2" cy="121.9" r="2" opacity="0.45"/><circle class="s1" cx="135.6" cy="137.9" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="137.6" r="2" opacity="0.45"/><circle class="s1" cx="79.8" cy="95.9" r="2" opacity="0.45"/><circle class="s1" cx="284.9" cy="102.6" r="2" opacity="0.45"/><circle class="s1" cx="346.4" cy="137.8" r="2" opacity="0.45"/><circle class="s1" cx="97.9" cy="147.1" r="2" opacity="0.45"/><circle class="s1" cx="109.4" cy="220.7" r="2" opacity="0.45"/><circle class="s1" cx="449.0" cy="128.7" r="2" opacity="0.45"/><circle class="s1" cx="392.4" cy="104.2" r="2" opacity="0.45"/><circle class="s1" cx="366.1" cy="104.8" r="2" opacity="0.45"/><circle class="s1" cx="261.1" cy="122.8" r="2" opacity="0.45"/><circle class="s1" cx="114.3" cy="213.8" r="2" opacity="0.45"/><circle class="s1" cx="90.5" cy="161.3" r="2" opacity="0.45"/><circle class="s1" cx="232.4" cy="210.1" r="2" opacity="0.45"/><circle class="s1" cx="101.2" cy="79.9" r="2" opacity="0.45"/><circle class="s1" cx="198.0" cy="121.6" r="2" opacity="0.45"/><circle class="s1" cx="274.3" cy="105.0" r="2" opacity="0.45"/><circle class="s1" cx="119.2" cy="94.9" r="2" opacity="0.45"/><circle class="s1" cx="377.6" cy="106.2" r="2" opacity="0.45"/><circle class="s1" cx="79.8" cy="162.9" r="2" opacity="0.45"/><circle class="s1" cx="166.0" cy="154.0" r="2" opacity="0.45"/><circle class="s1" cx="371.1" cy="113.9" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="117.6" r="2" opacity="0.45"/><circle class="s1" cx="258.7" cy="149.0" r="2" opacity="0.45"/><circle class="s1" cx="132.3" cy="195.6" r="2" opacity="0.45"/><circle class="s1" cx="197.1" cy="140.3" r="2" opacity="0.45"/><circle class="s1" cx="99.5" cy="119.6" r="2" opacity="0.45"/><circle class="s1" cx="102.0" cy="132.0" r="2" opacity="0.45"/><circle class="s1" cx="119.2" cy="123.0" r="2" opacity="0.45"/><circle class="s1" cx="377.6" cy="119.0" r="2" opacity="0.45"/><circle class="s1" cx="380.9" cy="97.1" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="96.0" r="2" opacity="0.45"/><circle class="s1" cx="318.6" cy="154.5" r="2" opacity="0.45"/><circle class="s1" cx="311.2" cy="75.5" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="110.1" r="2" opacity="0.45"/><circle class="s1" cx="269.3" cy="123.3" r="2" opacity="0.45"/><circle class="s1" cx="394.0" cy="109.7" r="2" opacity="0.45"/><circle class="s1" cx="202.9" cy="134.0" r="2" opacity="0.45"/><circle class="s1" cx="411.2" cy="106.9" r="2" opacity="0.45"/><circle class="s1" cx="143.8" cy="97.7" r="2" opacity="0.45"/><circle class="s1" cx="385.0" cy="101.7" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="153.3" r="2" opacity="0.45"/><circle class="s1" cx="167.6" cy="136.4" r="2" opacity="0.45"/><circle class="s1" cx="219.3" cy="110.0" r="2" opacity="0.45"/><circle class="s1" cx="432.6" cy="76.2" r="2" opacity="0.45"/><circle class="s1" cx="408.8" cy="150.1" r="2" opacity="0.45"/><circle class="s1" cx="76.6" cy="130.3" r="2" opacity="0.45"/><circle class="s1" cx="116.8" cy="127.4" r="2" opacity="0.45"/><circle class="s1" cx="134.8" cy="141.1" r="2" opacity="0.45"/><circle class="s1" cx="83.9" cy="112.6" r="2" opacity="0.45"/><circle class="s1" cx="391.6" cy="95.6" r="2" opacity="0.45"/><circle class="s1" cx="118.4" cy="143.5" r="2" opacity="0.45"/><circle class="s1" cx="282.5" cy="107.6" r="2" opacity="0.45"/><circle class="s1" cx="88.9" cy="165.4" r="2" opacity="0.45"/><circle class="s1" cx="157.8" cy="128.9" r="2" opacity="0.45"/><circle class="s1" cx="224.2" cy="133.3" r="2" opacity="0.45"/><circle class="s1" cx="80.7" cy="135.7" r="2" opacity="0.45"/><circle class="s1" cx="392.4" cy="119.3" r="2" opacity="0.45"/><circle class="s1" cx="117.6" cy="131.9" r="2" opacity="0.45"/><circle class="s1" cx="230.8" cy="179.9" r="2" opacity="0.45"/><circle class="s1" cx="192.2" cy="197.4" r="2" opacity="0.45"/><circle class="s1" cx="73.3" cy="128.2" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="103.8" r="2" opacity="0.45"/><circle class="s1" cx="278.4" cy="141.2" r="2" opacity="0.45"/><circle class="s1" cx="436.7" cy="87.0" r="2" opacity="0.45"/><circle class="s1" cx="180.7" cy="120.4" r="2" opacity="0.45"/><circle class="s1" cx="188.9" cy="87.3" r="2" opacity="0.45"/><circle class="s1" cx="332.5" cy="109.6" r="2" opacity="0.45"/><circle class="s1" cx="72.5" cy="119.9" r="2" opacity="0.45"/><circle class="s1" cx="80.7" cy="98.4" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="99.8" r="2" opacity="0.45"/><circle class="s1" cx="136.4" cy="121.8" r="2" opacity="0.45"/><circle class="s1" cx="94.6" cy="111.6" r="2" opacity="0.45"/><circle class="s1" cx="157.8" cy="175.2" r="2" opacity="0.45"/><circle class="s1" cx="91.3" cy="101.7" r="2" opacity="0.45"/><circle class="s1" cx="396.5" cy="94.4" r="2" opacity="0.45"/><circle class="s1" cx="126.6" cy="122.5" r="2" opacity="0.45"/><circle class="s1" cx="74.1" cy="113.7" r="2" opacity="0.45"/><circle class="s1" cx="139.7" cy="225.7" r="2" opacity="0.45"/><circle class="s1" cx="339.1" cy="215.1" r="2" opacity="0.45"/><circle class="s1" cx="94.6" cy="218.4" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="165.4" r="2" opacity="0.45"/><circle class="s1" cx="157.8" cy="159.4" r="2" opacity="0.45"/><circle class="s1" cx="110.2" cy="173.0" r="2" opacity="0.45"/><circle class="s1" cx="150.4" cy="122.0" r="2" opacity="0.45"/><circle class="s1" cx="80.7" cy="123.5" r="2" opacity="0.45"/><circle class="s1" cx="93.0" cy="84.4" r="2" opacity="0.45"/><circle class="s1" cx="120.9" cy="135.3" r="2" opacity="0.45"/><circle class="s1" cx="149.6" cy="138.8" r="2" opacity="0.45"/><circle class="s1" cx="240.6" cy="163.1" r="2" opacity="0.45"/><circle class="s1" cx="89.7" cy="100.1" r="2" opacity="0.45"/><circle class="s1" cx="378.4" cy="119.7" r="2" opacity="0.45"/><circle class="s1" cx="178.3" cy="138.4" r="2" opacity="0.45"/><circle class="s1" cx="261.1" cy="143.8" r="2" opacity="0.45"/><circle class="s1" cx="335.0" cy="126.6" r="2" opacity="0.45"/><circle class="s1" cx="445.7" cy="110.5" r="2" opacity="0.45"/><circle class="s1" cx="189.8" cy="148.1" r="2" opacity="0.45"/><circle class="s1" cx="89.7" cy="105.8" r="2" opacity="0.45"/><circle class="s1" cx="378.4" cy="157.9" r="2" opacity="0.45"/><circle class="s1" cx="390.7" cy="104.2" r="2" opacity="0.45"/><circle class="s1" cx="74.1" cy="141.1" r="2" opacity="0.45"/><circle class="s1" cx="106.9" cy="218.2" r="2" opacity="0.45"/><circle class="s1" cx="211.1" cy="177.6" r="2" opacity="0.45"/><circle class="s1" cx="429.3" cy="86.1" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="133.0" r="2" opacity="0.45"/><circle class="s1" cx="373.5" cy="96.6" r="2" opacity="0.45"/><circle class="s1" cx="119.2" cy="183.7" r="2" opacity="0.45"/><circle class="s1" cx="141.4" cy="210.0" r="2" opacity="0.45"/><circle class="s1" cx="110.2" cy="88.2" r="2" opacity="0.45"/><circle class="s1" cx="200.4" cy="162.4" r="2" opacity="0.45"/><circle class="s1" cx="346.4" cy="102.9" r="2" opacity="0.45"/><circle class="s1" cx="323.5" cy="127.6" r="2" opacity="0.45"/><circle class="s1" cx="80.7" cy="140.9" r="2" opacity="0.45"/><circle class="s1" cx="209.5" cy="142.7" r="2" opacity="0.45"/><circle class="s1" cx="386.6" cy="134.0" r="2" opacity="0.45"/><circle class="s1" cx="88.9" cy="137.3" r="2" opacity="0.45"/><circle class="s1" cx="252.1" cy="101.9" r="2" opacity="0.45"/><circle class="s1" cx="166.0" cy="116.2" r="2" opacity="0.45"/><circle class="s1" cx="186.5" cy="110.3" r="2" opacity="0.45"/><circle class="s1" cx="82.3" cy="136.8" r="2" opacity="0.45"/><circle class="s1" cx="355.5" cy="112.3" r="2" opacity="0.45"/><circle class="s1" cx="102.8" cy="194.0" r="2" opacity="0.45"/><circle class="s1" cx="205.4" cy="134.8" r="2" opacity="0.45"/><circle class="s1" cx="431.8" cy="80.6" r="2" opacity="0.45"/><circle class="s1" cx="405.5" cy="134.2" r="2" opacity="0.45"/><circle class="s1" cx="125.0" cy="184.5" r="2" opacity="0.45"/><circle class="s1" cx="205.4" cy="207.5" r="2" opacity="0.45"/><circle class="s1" cx="86.4" cy="150.3" r="2" opacity="0.45"/><circle class="s1" cx="199.6" cy="164.5" r="2" opacity="0.45"/><circle class="s1" cx="82.3" cy="117.9" r="2" opacity="0.45"/><circle class="s1" cx="80.7" cy="149.5" r="2" opacity="0.45"/><circle class="s1" cx="88.9" cy="136.2" r="2" opacity="0.45"/><circle class="s1" cx="115.9" cy="203.0" r="2" opacity="0.45"/><circle class="s1" cx="88.0" cy="153.2" r="2" opacity="0.45"/><circle class="s1" cx="86.4" cy="144.1" r="2" opacity="0.45"/><circle class="s1" cx="93.0" cy="83.9" r="2" opacity="0.45"/><circle class="s1" cx="343.2" cy="117.0" r="2" opacity="0.45"/><circle class="s1" cx="403.9" cy="75.4" r="2" opacity="0.45"/><circle class="s1" cx="312.0" cy="131.6" r="2" opacity="0.45"/><circle class="s1" cx="83.1" cy="104.2" r="2" opacity="0.45"/><circle class="s1" cx="153.7" cy="100.1" r="2" opacity="0.45"/><circle class="s1" cx="223.4" cy="169.6" r="2" opacity="0.45"/><circle class="s1" cx="74.1" cy="174.8" r="2" opacity="0.45"/><circle class="s1" cx="374.3" cy="124.1" r="2" opacity="0.45"/><circle class="s1" cx="213.6" cy="160.2" r="2" opacity="0.45"/><circle class="s1" cx="278.4" cy="132.2" r="2" opacity="0.45"/><circle class="s1" cx="78.2" cy="88.4" r="2" opacity="0.45"/><circle class="s1" cx="153.7" cy="180.6" r="2" opacity="0.45"/><circle class="s1" cx="138.9" cy="173.1" r="2" opacity="0.45"/><circle class="s1" cx="193.9" cy="183.0" r="2" opacity="0.45"/><circle class="s1" cx="282.5" cy="134.7" r="2" opacity="0.45"/><circle class="s1" cx="182.4" cy="91.1" r="2" opacity="0.45"/><circle class="s1" cx="184.0" cy="143.2" r="2" opacity="0.45"/><circle class="s1" cx="438.3" cy="99.4" r="2" opacity="0.45"/><circle class="s1" cx="148.8" cy="144.8" r="2" opacity="0.45"/><circle class="s1" cx="246.4" cy="114.8" r="2" opacity="0.45"/><circle class="s1" cx="174.2" cy="104.6" r="2" opacity="0.45"/><circle class="s1" cx="90.5" cy="163.5" r="2" opacity="0.45"/><circle class="s1" cx="158.6" cy="176.3" r="2" opacity="0.45"/><circle class="s1" cx="79.8" cy="210.2" r="2" opacity="0.45"/><circle class="s1" cx="282.5" cy="184.5" r="2" opacity="0.45"/><circle class="s1" cx="309.5" cy="139.2" r="2" opacity="0.45"/><circle class="s1" cx="166.0" cy="149.7" r="2" opacity="0.45"/><circle class="s1" cx="171.7" cy="147.7" r="2" opacity="0.45"/><circle class="s1" cx="289.8" cy="108.1" r="2" opacity="0.45"/><circle class="s1" cx="80.7" cy="154.2" r="2" opacity="0.45"/><circle class="s1" cx="205.4" cy="110.2" r="2" opacity="0.45"/><circle class="s1" cx="258.7" cy="148.4" r="2" opacity="0.45"/><circle class="s1" cx="211.9" cy="96.8" r="2" opacity="0.45"/><circle class="s1" cx="223.4" cy="116.1" r="2" opacity="0.45"/><circle class="s1" cx="436.7" cy="115.1" r="2" opacity="0.45"/><circle class="s1" cx="327.6" cy="109.9" r="2" opacity="0.45"/><circle class="s1" cx="89.7" cy="216.7" r="2" opacity="0.45"/><circle class="s1" cx="179.9" cy="183.3" r="2" opacity="0.45"/><circle class="s1" cx="88.0" cy="173.8" r="2" opacity="0.45"/><circle class="s1" cx="120.9" cy="141.8" r="2" opacity="0.45"/><circle class="s1" cx="411.2" cy="142.7" r="2" opacity="0.45"/><circle class="s1" cx="243.9" cy="108.4" r="2" opacity="0.45"/><circle class="s1" cx="253.8" cy="171.0" r="2" opacity="0.45"/><circle class="s1" cx="166.0" cy="136.9" r="2" opacity="0.45"/><circle class="s1" cx="321.0" cy="124.5" r="2" opacity="0.45"/><circle class="s1" cx="140.5" cy="97.3" r="2" opacity="0.45"/><circle class="s1" cx="93.8" cy="146.1" r="2" opacity="0.45"/><circle class="s1" cx="293.1" cy="121.4" r="2" opacity="0.45"/><circle class="s1" cx="120.9" cy="106.4" r="2" opacity="0.45"/><circle class="s1" cx="303.8" cy="113.6" r="2" opacity="0.45"/><circle class="s1" cx="101.2" cy="215.2" r="2" opacity="0.45"/><circle class="s1" cx="160.2" cy="141.2" r="2" opacity="0.45"/><circle class="s1" cx="426.8" cy="134.5" r="2" opacity="0.45"/><circle class="s1" cx="141.4" cy="166.8" r="2" opacity="0.45"/><circle class="s1" cx="410.4" cy="70.9" r="2" opacity="0.45"/><circle class="s1" cx="97.9" cy="106.2" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="78.7" r="2" opacity="0.45"/><circle class="s1" cx="230.0" cy="129.4" r="2" opacity="0.45"/><circle class="s1" cx="380.9" cy="127.5" r="2" opacity="0.45"/><circle class="s1" cx="198.8" cy="125.4" r="2" opacity="0.45"/><circle class="s1" cx="402.2" cy="87.1" r="2" opacity="0.45"/><circle class="s1" cx="268.5" cy="129.0" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="108.5" r="2" opacity="0.45"/><circle class="s1" cx="97.9" cy="172.9" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="120.6" r="2" opacity="0.45"/><circle class="s1" cx="218.5" cy="93.6" r="2" opacity="0.45"/><circle class="s1" cx="79.0" cy="121.5" r="2" opacity="0.45"/><circle class="s1" cx="237.3" cy="164.4" r="2" opacity="0.45"/><circle class="s1" cx="399.8" cy="120.5" r="2" opacity="0.45"/><circle class="s1" cx="173.4" cy="185.7" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="116.3" r="2" opacity="0.45"/><circle class="s1" cx="364.5" cy="114.3" r="2" opacity="0.45"/><circle class="s1" cx="81.5" cy="143.0" r="2" opacity="0.45"/><circle class="s1" cx="358.8" cy="168.4" r="2" opacity="0.45"/><circle class="s1" cx="105.3" cy="175.7" r="2" opacity="0.45"/><circle class="s1" cx="124.1" cy="135.2" r="2" opacity="0.45"/><circle class="s1" cx="400.6" cy="103.1" r="2" opacity="0.45"/><circle class="s1" cx="211.9" cy="219.1" r="2" opacity="0.45"/><circle class="s1" cx="93.8" cy="105.8" r="2" opacity="0.45"/><circle class="s1" cx="89.7" cy="97.4" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="87.6" r="2" opacity="0.45"/><circle class="s1" cx="83.1" cy="123.7" r="2" opacity="0.45"/><circle class="s1" cx="366.1" cy="168.3" r="2" opacity="0.45"/><circle class="s1" cx="240.6" cy="165.7" r="2" opacity="0.45"/><circle class="s1" cx="74.9" cy="145.0" r="2" opacity="0.45"/><circle class="s1" cx="143.8" cy="160.7" r="2" opacity="0.45"/><circle class="s1" cx="430.1" cy="144.7" r="2" opacity="0.45"/><circle class="s1" cx="223.4" cy="161.3" r="2" opacity="0.45"/><circle class="s1" cx="120.0" cy="104.1" r="2" opacity="0.45"/><circle class="s1" cx="297.2" cy="106.5" r="2" opacity="0.45"/><circle class="s1" cx="384.2" cy="119.5" r="2" opacity="0.45"/><circle class="s1" cx="317.7" cy="109.6" r="2" opacity="0.45"/><circle class="s1" cx="428.5" cy="131.7" r="2" opacity="0.45"/><circle class="s1" cx="235.7" cy="160.6" r="2" opacity="0.45"/><circle class="s1" cx="130.7" cy="131.3" r="2" opacity="0.45"/><circle class="s1" cx="234.1" cy="143.6" r="2" opacity="0.45"/><circle class="s1" cx="266.1" cy="154.7" r="2" opacity="0.45"/><circle class="s1" cx="79.0" cy="83.4" r="2" opacity="0.45"/><circle class="s1" cx="437.5" cy="152.3" r="2" opacity="0.45"/><circle class="s1" cx="376.0" cy="98.4" r="2" opacity="0.45"/><circle class="s1" cx="126.6" cy="136.4" r="2" opacity="0.45"/><circle class="s1" cx="180.7" cy="141.9" r="2" opacity="0.45"/><circle class="s1" cx="385.0" cy="182.1" r="2" opacity="0.45"/><circle class="s1" cx="376.8" cy="136.5" r="2" opacity="0.45"/><circle class="s1" cx="157.0" cy="109.9" r="2" opacity="0.45"/><circle class="s1" cx="257.0" cy="142.8" r="2" opacity="0.45"/><circle class="s1" cx="73.3" cy="147.2" r="2" opacity="0.45"/><circle class="s1" cx="210.3" cy="102.1" r="2" opacity="0.45"/><circle class="s1" cx="266.9" cy="125.1" r="2" opacity="0.45"/><circle class="s1" cx="102.8" cy="126.1" r="2" opacity="0.45"/><circle class="s1" cx="311.2" cy="135.2" r="2" opacity="0.45"/><circle class="s1" cx="212.7" cy="254.0" r="2" opacity="0.45"/><circle class="s1" cx="132.3" cy="129.8" r="2" opacity="0.45"/><circle class="s1" cx="177.5" cy="165.3" r="2" opacity="0.45"/><circle class="s1" cx="417.8" cy="82.2" r="2" opacity="0.45"/><circle class="s1" cx="143.8" cy="183.3" r="2" opacity="0.45"/><circle class="s1" cx="161.9" cy="105.1" r="2" opacity="0.45"/><circle class="s1" cx="81.5" cy="140.6" r="2" opacity="0.45"/><circle class="s1" cx="83.9" cy="108.5" r="2" opacity="0.45"/><circle class="s1" cx="316.1" cy="126.7" r="2" opacity="0.45"/><circle class="s1" cx="78.2" cy="150.3" r="2" opacity="0.45"/><circle class="s1" cx="218.5" cy="142.4" r="2" opacity="0.45"/><circle class="s1" cx="90.5" cy="121.2" r="2" opacity="0.45"/><circle class="s1" cx="309.5" cy="113.6" r="2" opacity="0.45"/><circle class="s1" cx="120.0" cy="204.9" r="2" opacity="0.45"/><circle class="s1" cx="240.6" cy="145.1" r="2" opacity="0.45"/><circle class="s1" cx="122.5" cy="253.8" r="2" opacity="0.45"/><circle class="s1" cx="103.6" cy="201.1" r="2" opacity="0.45"/><circle class="s1" cx="114.3" cy="179.2" r="2" opacity="0.45"/><circle class="s1" cx="140.5" cy="113.9" r="2" opacity="0.45"/><circle class="s1" cx="140.5" cy="159.4" r="2" opacity="0.45"/><circle class="s1" cx="268.5" cy="112.2" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="153.8" r="2" opacity="0.45"/><circle class="s1" cx="105.3" cy="270.9" r="2" opacity="0.45"/><circle class="s1" cx="126.6" cy="140.5" r="2" opacity="0.45"/><circle class="s1" cx="273.4" cy="198.4" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="84.5" r="2" opacity="0.45"/><circle class="s1" cx="392.4" cy="105.9" r="2" opacity="0.45"/><circle class="s1" cx="259.5" cy="164.4" r="2" opacity="0.45"/><circle class="s1" cx="339.1" cy="135.9" r="2" opacity="0.45"/><circle class="s1" cx="238.2" cy="93.7" r="2" opacity="0.45"/><circle class="s1" cx="401.4" cy="96.2" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="116.7" r="2" opacity="0.45"/><circle class="s1" cx="79.8" cy="152.0" r="2" opacity="0.45"/><circle class="s1" cx="121.7" cy="195.6" r="2" opacity="0.45"/><circle class="s1" cx="388.3" cy="119.3" r="2" opacity="0.45"/><circle class="s1" cx="72.5" cy="117.1" r="2" opacity="0.45"/><circle class="s1" cx="140.5" cy="119.4" r="2" opacity="0.45"/><circle class="s1" cx="87.2" cy="224.8" r="2" opacity="0.45"/><circle class="s1" cx="453.9" cy="107.8" r="2" opacity="0.45"/><circle class="s1" cx="288.2" cy="142.5" r="2" opacity="0.45"/><circle class="s1" cx="356.3" cy="153.9" r="2" opacity="0.45"/><circle class="s1" cx="312.0" cy="127.6" r="2" opacity="0.45"/><circle class="s1" cx="186.5" cy="136.7" r="2" opacity="0.45"/><circle class="s1" cx="156.1" cy="139.9" r="2" opacity="0.45"/><circle class="s1" cx="81.5" cy="102.9" r="2" opacity="0.45"/><circle class="s1" cx="126.6" cy="175.6" r="2" opacity="0.45"/><circle class="s1" cx="220.9" cy="138.4" r="2" opacity="0.45"/><circle class="s1" cx="134.8" cy="198.3" r="2" opacity="0.45"/><circle class="s1" cx="134.0" cy="175.2" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="148.6" r="2" opacity="0.45"/><circle class="s1" cx="195.5" cy="145.1" r="2" opacity="0.45"/><circle class="s1" cx="139.7" cy="132.1" r="2" opacity="0.45"/><circle class="s1" cx="78.2" cy="153.0" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="114.2" r="2" opacity="0.45"/><circle class="s1" cx="72.5" cy="107.5" r="2" opacity="0.45"/><circle class="s1" cx="196.3" cy="177.5" r="2" opacity="0.45"/><circle class="s1" cx="92.1" cy="84.8" r="2" opacity="0.45"/><circle class="s1" cx="195.5" cy="207.5" r="2" opacity="0.45"/><circle class="s1" cx="394.0" cy="128.1" r="2" opacity="0.45"/><circle class="s1" cx="93.0" cy="96.8" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="141.5" r="2" opacity="0.45"/><circle class="s1" cx="227.5" cy="125.8" r="2" opacity="0.45"/><circle class="s1" cx="136.4" cy="90.7" r="2" opacity="0.45"/><circle class="s1" cx="334.1" cy="163.3" r="2" opacity="0.45"/><circle class="s1" cx="131.5" cy="182.3" r="2" opacity="0.45"/><circle class="s1" cx="295.6" cy="194.4" r="2" opacity="0.45"/><circle class="s1" cx="342.3" cy="107.0" r="2" opacity="0.45"/><circle class="s1" cx="128.2" cy="130.7" r="2" opacity="0.45"/><circle class="s1" cx="398.1" cy="199.9" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="116.0" r="2" opacity="0.45"/><circle class="s1" cx="339.1" cy="87.2" r="2" opacity="0.45"/><circle class="s1" cx="255.4" cy="151.4" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="151.9" r="2" opacity="0.45"/><circle class="s1" cx="186.5" cy="167.0" r="2" opacity="0.45"/><circle class="s1" cx="93.0" cy="97.1" r="2" opacity="0.45"/><circle class="s1" cx="157.0" cy="178.2" r="2" opacity="0.45"/><circle class="s1" cx="84.8" cy="98.0" r="2" opacity="0.45"/><circle class="s1" cx="121.7" cy="136.0" r="2" opacity="0.45"/><circle class="s1" cx="93.0" cy="160.3" r="2" opacity="0.45"/><circle class="s1" cx="154.5" cy="122.2" r="2" opacity="0.45"/><circle class="s1" cx="426.0" cy="131.7" r="2" opacity="0.45"/><circle class="s1" cx="156.1" cy="130.8" r="2" opacity="0.45"/><circle class="s1" cx="98.7" cy="134.8" r="2" opacity="0.45"/><circle class="s1" cx="147.1" cy="125.8" r="2" opacity="0.45"/><circle class="s1" cx="92.1" cy="153.1" r="2" opacity="0.45"/><circle class="s1" cx="430.1" cy="93.0" r="2" opacity="0.45"/><circle class="s1" cx="384.2" cy="102.5" r="2" opacity="0.45"/><circle class="s1" cx="404.7" cy="108.5" r="2" opacity="0.45"/><circle class="s1" cx="224.2" cy="140.0" r="2" opacity="0.45"/><circle class="s1" cx="319.4" cy="132.6" r="2" opacity="0.45"/><circle class="s1" cx="390.7" cy="94.2" r="2" opacity="0.45"/><circle class="s1" cx="190.6" cy="143.6" r="2" opacity="0.45"/><circle class="s1" cx="88.9" cy="183.6" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="140.9" r="2" opacity="0.45"/><circle class="s1" cx="399.8" cy="109.0" r="2" opacity="0.45"/><circle class="s1" cx="304.6" cy="93.6" r="2" opacity="0.45"/><circle class="s1" cx="149.6" cy="99.6" r="2" opacity="0.45"/><circle class="s1" cx="155.3" cy="143.4" r="2" opacity="0.45"/><circle class="s1" cx="219.3" cy="139.5" r="2" opacity="0.45"/><circle class="s1" cx="239.8" cy="158.2" r="2" opacity="0.45"/><circle class="s1" cx="182.4" cy="146.3" r="2" opacity="0.45"/><circle class="s1" cx="118.4" cy="219.0" r="2" opacity="0.45"/><circle class="s1" cx="110.2" cy="138.0" r="2" opacity="0.45"/><circle class="s1" cx="280.8" cy="128.7" r="2" opacity="0.45"/><circle class="s1" cx="189.8" cy="102.3" r="2" opacity="0.45"/><circle class="s1" cx="102.0" cy="113.5" r="2" opacity="0.45"/><circle class="s1" cx="72.5" cy="113.1" r="2" opacity="0.45"/><circle class="s1" cx="140.5" cy="147.7" r="2" opacity="0.45"/><circle class="s1" cx="335.8" cy="125.2" r="2" opacity="0.45"/><circle class="s1" cx="229.1" cy="162.0" r="2" opacity="0.45"/><circle class="s1" cx="209.5" cy="130.6" r="2" opacity="0.45"/><circle class="s1" cx="266.9" cy="124.4" r="2" opacity="0.45"/><circle class="s1" cx="136.4" cy="117.0" r="2" opacity="0.45"/><circle class="s1" cx="107.7" cy="170.2" r="2" opacity="0.45"/><circle class="s1" cx="93.0" cy="116.2" r="2" opacity="0.45"/><circle class="s1" cx="138.9" cy="106.3" r="2" opacity="0.45"/><circle class="s1" cx="211.1" cy="115.8" r="2" opacity="0.45"/><circle class="s1" cx="200.4" cy="149.8" r="2" opacity="0.45"/><circle class="s1" cx="80.7" cy="94.8" r="2" opacity="0.45"/><circle class="s1" cx="275.9" cy="106.4" r="2" opacity="0.45"/><circle class="s1" cx="214.4" cy="102.1" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="78.1" r="2" opacity="0.45"/><circle class="s1" cx="301.3" cy="153.1" r="2" opacity="0.45"/><circle class="s1" cx="191.4" cy="176.6" r="2" opacity="0.45"/><circle class="s1" cx="242.3" cy="71.0" r="2" opacity="0.45"/><circle class="s1" cx="225.9" cy="152.3" r="2" opacity="0.45"/><circle class="s1" cx="279.2" cy="147.9" r="2" opacity="0.45"/><circle class="s1" cx="86.4" cy="181.0" r="2" opacity="0.45"/><circle class="s1" cx="216.0" cy="130.4" r="2" opacity="0.45"/><circle class="s1" cx="335.8" cy="114.2" r="2" opacity="0.45"/><circle class="s1" cx="152.0" cy="121.3" r="2" opacity="0.45"/><circle class="s1" cx="174.2" cy="147.9" r="2" opacity="0.45"/><circle class="s1" cx="93.8" cy="221.8" r="2" opacity="0.45"/><circle class="s1" cx="180.7" cy="110.9" r="2" opacity="0.45"/><circle class="s1" cx="138.9" cy="153.7" r="2" opacity="0.45"/><circle class="s1" cx="208.6" cy="216.9" r="2" opacity="0.45"/><circle class="s1" cx="103.6" cy="211.7" r="2" opacity="0.45"/><circle class="s1" cx="260.3" cy="225.8" r="2" opacity="0.45"/><circle class="s1" cx="80.7" cy="140.9" r="2" opacity="0.45"/><circle class="s1" cx="95.4" cy="97.4" r="2" opacity="0.45"/><circle class="s1" cx="102.0" cy="222.8" r="2" opacity="0.45"/><circle class="s1" cx="231.6" cy="129.6" r="2" opacity="0.45"/><circle class="s1" cx="260.3" cy="113.9" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="138.4" r="2" opacity="0.45"/><circle class="s1" cx="235.7" cy="207.3" r="2" opacity="0.45"/><circle class="s1" cx="193.0" cy="155.8" r="2" opacity="0.45"/><circle class="s1" cx="236.5" cy="229.3" r="2" opacity="0.45"/><circle class="s1" cx="74.9" cy="135.2" r="2" opacity="0.45"/><circle class="s1" cx="398.1" cy="111.2" r="2" opacity="0.45"/><circle class="s1" cx="120.9" cy="169.5" r="2" opacity="0.45"/><circle class="s1" cx="96.2" cy="216.3" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="137.4" r="2" opacity="0.45"/><circle class="s1" cx="161.1" cy="178.3" r="2" opacity="0.45"/><circle class="s1" cx="190.6" cy="262.2" r="2" opacity="0.45"/><circle class="s1" cx="196.3" cy="133.6" r="2" opacity="0.45"/><circle class="s1" cx="116.8" cy="108.7" r="2" opacity="0.45"/><circle class="s1" cx="303.0" cy="143.3" r="2" opacity="0.45"/><circle class="s1" cx="92.1" cy="174.9" r="2" opacity="0.45"/><circle class="s1" cx="95.4" cy="157.1" r="2" opacity="0.45"/><circle class="s1" cx="207.0" cy="130.8" r="2" opacity="0.45"/><circle class="s1" cx="220.9" cy="168.1" r="2" opacity="0.45"/><circle class="s1" cx="297.2" cy="93.9" r="2" opacity="0.45"/><circle class="s1" cx="90.5" cy="121.4" r="2" opacity="0.45"/><circle class="s1" cx="201.2" cy="140.3" r="2" opacity="0.45"/><circle class="s1" cx="433.4" cy="121.0" r="2" opacity="0.45"/><circle class="s1" cx="263.6" cy="152.2" r="2" opacity="0.45"/><circle class="s1" cx="143.8" cy="127.0" r="2" opacity="0.45"/><circle class="s1" cx="152.9" cy="148.8" r="2" opacity="0.45"/><circle class="s1" cx="247.2" cy="236.1" r="2" opacity="0.45"/><circle class="s1" cx="312.0" cy="129.0" r="2" opacity="0.45"/><circle class="s1" cx="143.8" cy="101.2" r="2" opacity="0.45"/><circle class="s1" cx="80.7" cy="253.9" r="2" opacity="0.45"/><circle class="s1" cx="161.1" cy="161.1" r="2" opacity="0.45"/><circle class="s1" cx="339.9" cy="150.1" r="2" opacity="0.45"/><circle class="s1" cx="219.3" cy="153.6" r="2" opacity="0.45"/><circle class="s1" cx="90.5" cy="84.7" r="2" opacity="0.45"/><circle class="s1" cx="110.2" cy="177.7" r="2" opacity="0.45"/><circle class="s1" cx="83.1" cy="170.7" r="2" opacity="0.45"/><circle class="s1" cx="204.5" cy="128.3" r="2" opacity="0.45"/><circle class="s1" cx="178.3" cy="189.5" r="2" opacity="0.45"/><circle class="s1" cx="321.0" cy="97.9" r="2" opacity="0.45"/><circle class="s1" cx="111.8" cy="122.8" r="2" opacity="0.45"/><circle class="s1" cx="282.5" cy="121.5" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="216.2" r="2" opacity="0.45"/><circle class="s1" cx="79.8" cy="101.1" r="2" opacity="0.45"/><circle class="s1" cx="133.2" cy="183.9" r="2" opacity="0.45"/><circle class="s1" cx="113.5" cy="134.1" r="2" opacity="0.45"/><circle class="s1" cx="297.2" cy="141.2" r="2" opacity="0.45"/><circle class="s1" cx="180.7" cy="155.9" r="2" opacity="0.45"/><circle class="s1" cx="72.5" cy="181.3" r="2" opacity="0.45"/><circle class="s1" cx="87.2" cy="150.7" r="2" opacity="0.45"/><circle class="s1" cx="145.5" cy="129.3" r="2" opacity="0.45"/><circle class="s1" cx="179.9" cy="242.8" r="2" opacity="0.45"/><circle class="s1" cx="269.3" cy="160.6" r="2" opacity="0.45"/><circle class="s1" cx="227.5" cy="117.1" r="2" opacity="0.45"/><circle class="s1" cx="161.1" cy="257.3" r="2" opacity="0.45"/><circle class="s1" cx="176.6" cy="224.1" r="2" opacity="0.45"/><circle class="s1" cx="302.1" cy="207.3" r="2" opacity="0.45"/><circle class="s1" cx="93.0" cy="201.6" r="2" opacity="0.45"/><circle class="s1" cx="232.4" cy="156.3" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="132.4" r="2" opacity="0.45"/><circle class="s1" cx="126.6" cy="168.8" r="2" opacity="0.45"/><circle class="s1" cx="113.5" cy="231.1" r="2" opacity="0.45"/><circle class="s1" cx="281.6" cy="248.4" r="2" opacity="0.45"/><circle class="s1" cx="161.9" cy="165.3" r="2" opacity="0.45"/><circle class="s1" cx="88.0" cy="180.6" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="118.3" r="2" opacity="0.45"/><circle class="s1" cx="435.9" cy="89.7" r="2" opacity="0.45"/><circle class="s1" cx="293.9" cy="202.9" r="2" opacity="0.45"/><circle class="s1" cx="106.1" cy="88.9" r="2" opacity="0.45"/><circle class="s1" cx="166.8" cy="114.1" r="2" opacity="0.45"/><circle class="s1" cx="162.7" cy="166.6" r="2" opacity="0.45"/><circle class="s1" cx="402.2" cy="103.0" r="2" opacity="0.45"/><circle class="s1" cx="79.0" cy="87.3" r="2" opacity="0.45"/><circle class="s1" cx="131.5" cy="220.7" r="2" opacity="0.45"/><circle class="s1" cx="360.4" cy="144.3" r="2" opacity="0.45"/><circle class="s1" cx="420.3" cy="114.1" r="2" opacity="0.45"/><circle class="s1" cx="179.9" cy="184.5" r="2" opacity="0.45"/><circle class="s1" cx="257.0" cy="188.6" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="246.0" r="2" opacity="0.45"/><circle class="s1" cx="138.1" cy="233.6" r="2" opacity="0.45"/><circle class="s1" cx="215.2" cy="173.1" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="135.3" r="2" opacity="0.45"/><circle class="s1" cx="123.3" cy="138.2" r="2" opacity="0.45"/><circle class="s1" cx="129.9" cy="85.9" r="2" opacity="0.45"/><circle class="s1" cx="215.2" cy="154.8" r="2" opacity="0.45"/><circle class="s1" cx="188.1" cy="188.1" r="2" opacity="0.45"/><circle class="s1" cx="130.7" cy="216.3" r="2" opacity="0.45"/><circle class="s1" cx="184.8" cy="177.9" r="2" opacity="0.45"/><circle class="s1" cx="106.1" cy="243.1" r="2" opacity="0.45"/><circle class="s1" cx="99.5" cy="153.1" r="2" opacity="0.45"/><circle class="s1" cx="335.8" cy="100.4" r="2" opacity="0.45"/><circle class="s1" cx="238.2" cy="164.3" r="2" opacity="0.45"/><circle class="s1" cx="330.9" cy="115.7" r="2" opacity="0.45"/><circle class="s1" cx="205.4" cy="137.4" r="2" opacity="0.45"/><circle class="s1" cx="121.7" cy="121.7" r="2" opacity="0.45"/><circle class="s1" cx="135.6" cy="115.6" r="2" opacity="0.45"/><circle class="s1" cx="108.6" cy="150.0" r="2" opacity="0.45"/><circle class="s1" cx="356.3" cy="180.2" r="2" opacity="0.45"/><circle class="s1" cx="433.4" cy="119.9" r="2" opacity="0.45"/><circle class="s1" cx="129.9" cy="127.9" r="2" opacity="0.45"/><circle class="s1" cx="276.7" cy="206.3" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="141.8" r="2" opacity="0.45"/><circle class="s1" cx="411.2" cy="111.8" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="200.7" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="129.3" r="2" opacity="0.45"/><circle class="s1" cx="144.6" cy="164.9" r="2" opacity="0.45"/><circle class="s1" cx="194.7" cy="145.7" r="2" opacity="0.45"/><circle class="s1" cx="129.1" cy="182.9" r="2" opacity="0.45"/><circle class="s1" cx="285.7" cy="163.1" r="2" opacity="0.45"/><circle class="s1" cx="374.3" cy="132.0" r="2" opacity="0.45"/><circle class="s1" cx="106.1" cy="191.2" r="2" opacity="0.45"/><circle class="s1" cx="339.9" cy="75.8" r="2" opacity="0.45"/><circle class="s1" cx="120.0" cy="177.3" r="2" opacity="0.45"/><circle class="s1" cx="123.3" cy="131.4" r="2" opacity="0.45"/><circle class="s1" cx="207.0" cy="158.3" r="2" opacity="0.45"/><circle class="s1" cx="207.8" cy="88.9" r="2" opacity="0.45"/><circle class="s1" cx="240.6" cy="149.7" r="2" opacity="0.45"/><circle class="s1" cx="216.0" cy="185.9" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="203.6" r="2" opacity="0.45"/><circle class="s1" cx="80.7" cy="172.7" r="2" opacity="0.45"/><circle class="s1" cx="219.3" cy="154.7" r="2" opacity="0.45"/><circle class="s1" cx="301.3" cy="145.3" r="2" opacity="0.45"/><circle class="s1" cx="109.4" cy="197.9" r="2" opacity="0.45"/><circle class="s1" cx="303.8" cy="192.7" r="2" opacity="0.45"/><circle class="s1" cx="294.8" cy="143.9" r="2" opacity="0.45"/><circle class="s1" cx="97.9" cy="101.9" r="2" opacity="0.45"/><circle class="s1" cx="93.8" cy="85.3" r="2" opacity="0.45"/><circle class="s1" cx="233.2" cy="131.7" r="2" opacity="0.45"/><circle class="s1" cx="162.7" cy="211.5" r="2" opacity="0.45"/><circle class="s1" cx="134.0" cy="184.4" r="2" opacity="0.45"/><circle class="s1" cx="83.1" cy="136.1" r="2" opacity="0.45"/><circle class="s1" cx="410.4" cy="107.0" r="2" opacity="0.45"/><circle class="s1" cx="83.1" cy="143.4" r="2" opacity="0.45"/><circle class="s1" cx="123.3" cy="188.0" r="2" opacity="0.45"/><circle class="s1" cx="152.0" cy="200.8" r="2" opacity="0.45"/><circle class="s1" cx="132.3" cy="160.5" r="2" opacity="0.45"/><circle class="s1" cx="79.0" cy="126.8" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="190.4" r="2" opacity="0.45"/><circle class="s1" cx="264.4" cy="144.9" r="2" opacity="0.45"/><circle class="s1" cx="99.5" cy="121.5" r="2" opacity="0.45"/><circle class="s1" cx="412.9" cy="79.7" r="2" opacity="0.45"/><circle class="s1" cx="385.8" cy="187.3" r="2" opacity="0.45"/><circle class="s1" cx="84.8" cy="117.7" r="2" opacity="0.45"/><circle class="s1" cx="133.2" cy="150.5" r="2" opacity="0.45"/><circle class="s1" cx="350.5" cy="126.9" r="2" opacity="0.45"/><circle class="s1" cx="129.9" cy="169.7" r="2" opacity="0.45"/><circle class="s1" cx="193.0" cy="141.8" r="2" opacity="0.45"/><circle class="s1" cx="146.3" cy="172.4" r="2" opacity="0.45"/><circle class="s1" cx="145.5" cy="154.3" r="2" opacity="0.45"/><circle class="s1" cx="92.1" cy="142.8" r="2" opacity="0.45"/><circle class="s1" cx="92.1" cy="145.0" r="2" opacity="0.45"/><circle class="s1" cx="369.4" cy="191.1" r="2" opacity="0.45"/><circle class="s1" cx="88.0" cy="118.2" r="2" opacity="0.45"/><circle class="s1" cx="338.2" cy="109.7" r="2" opacity="0.45"/><circle class="s1" cx="111.0" cy="136.9" r="2" opacity="0.45"/><circle class="s1" cx="148.8" cy="200.5" r="2" opacity="0.45"/><circle class="s1" cx="184.8" cy="122.4" r="2" opacity="0.45"/><circle class="s1" cx="321.0" cy="103.8" r="2" opacity="0.45"/><circle class="s1" cx="88.9" cy="160.0" r="2" opacity="0.45"/><circle class="s1" cx="143.8" cy="112.0" r="2" opacity="0.45"/><circle class="s1" cx="251.3" cy="142.8" r="2" opacity="0.45"/><circle class="s1" cx="83.9" cy="128.2" r="2" opacity="0.45"/><circle class="s1" cx="87.2" cy="96.4" r="2" opacity="0.45"/><circle class="s1" cx="175.0" cy="160.3" r="2" opacity="0.45"/><circle class="s1" cx="283.3" cy="210.2" r="2" opacity="0.45"/><circle class="s1" cx="94.6" cy="235.9" r="2" opacity="0.45"/><circle class="s1" cx="225.0" cy="155.7" r="2" opacity="0.45"/><circle class="s1" cx="89.7" cy="101.3" r="2" opacity="0.45"/><circle class="s1" cx="79.0" cy="184.6" r="2" opacity="0.45"/><circle class="s1" cx="324.3" cy="154.1" r="2" opacity="0.45"/><circle class="s1" cx="136.4" cy="159.3" r="2" opacity="0.45"/><circle class="s1" cx="74.9" cy="228.8" r="2" opacity="0.45"/><circle class="s1" cx="125.8" cy="190.9" r="2" opacity="0.45"/><circle class="s1" cx="114.3" cy="132.7" r="2" opacity="0.45"/><circle class="s1" cx="143.0" cy="147.2" r="2" opacity="0.45"/><circle class="s1" cx="81.5" cy="234.4" r="2" opacity="0.45"/><circle class="s1" cx="154.5" cy="121.6" r="2" opacity="0.45"/><circle class="s1" cx="96.2" cy="178.7" r="2" opacity="0.45"/><circle class="s1" cx="229.1" cy="134.7" r="2" opacity="0.45"/><circle class="s1" cx="72.5" cy="148.7" r="2" opacity="0.45"/><circle class="s1" cx="147.1" cy="157.2" r="2" opacity="0.45"/><circle class="s1" cx="139.7" cy="132.9" r="2" opacity="0.45"/><circle class="s1" cx="125.0" cy="138.6" r="2" opacity="0.45"/><circle class="s1" cx="108.6" cy="163.3" r="2" opacity="0.45"/><circle class="s1" cx="344.0" cy="137.3" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="114.6" r="2" opacity="0.45"/><circle class="s1" cx="175.0" cy="132.9" r="2" opacity="0.45"/><circle class="s1" cx="107.7" cy="176.7" r="2" opacity="0.45"/><circle class="s1" cx="125.8" cy="123.4" r="2" opacity="0.45"/><circle class="s1" cx="324.3" cy="131.8" r="2" opacity="0.45"/><circle class="s1" cx="162.7" cy="116.8" r="2" opacity="0.45"/><circle class="s1" cx="169.3" cy="145.8" r="2" opacity="0.45"/><circle class="s1" cx="244.7" cy="147.5" r="2" opacity="0.45"/><circle class="s1" cx="196.3" cy="197.9" r="2" opacity="0.45"/><circle class="s1" cx="125.0" cy="92.0" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="116.9" r="2" opacity="0.45"/><circle class="s1" cx="367.8" cy="102.7" r="2" opacity="0.45"/><circle class="s1" cx="125.8" cy="205.9" r="2" opacity="0.45"/><circle class="s1" cx="84.8" cy="207.5" r="2" opacity="0.45"/><circle class="s1" cx="201.2" cy="229.6" r="2" opacity="0.45"/><circle class="s1" cx="115.9" cy="137.1" r="2" opacity="0.45"/><circle class="s1" cx="266.9" cy="151.5" r="2" opacity="0.45"/><circle class="s1" cx="92.1" cy="218.7" r="2" opacity="0.45"/><circle class="s1" cx="206.2" cy="162.8" r="2" opacity="0.45"/><circle class="s1" cx="73.3" cy="109.6" r="2" opacity="0.45"/><circle class="s1" cx="154.5" cy="107.1" r="2" opacity="0.45"/><circle class="s1" cx="262.8" cy="155.5" r="2" opacity="0.45"/><circle class="s1" cx="93.0" cy="191.9" r="2" opacity="0.45"/><circle class="s1" cx="215.2" cy="167.2" r="2" opacity="0.45"/><circle class="s1" cx="86.4" cy="167.1" r="2" opacity="0.45"/><circle class="s1" cx="75.7" cy="107.7" r="2" opacity="0.45"/><circle class="s1" cx="138.1" cy="147.8" r="2" opacity="0.45"/><circle class="s1" cx="266.1" cy="167.0" r="2" opacity="0.45"/><circle class="s1" cx="202.9" cy="119.0" r="2" opacity="0.45"/><circle class="s1" cx="175.0" cy="167.1" r="2" opacity="0.45"/><circle class="s1" cx="357.9" cy="105.2" r="2" opacity="0.45"/><circle class="s1" cx="83.1" cy="116.1" r="2" opacity="0.45"/><circle class="s1" cx="173.4" cy="204.0" r="2" opacity="0.45"/><circle class="s1" cx="131.5" cy="274.1" r="2" opacity="0.45"/><circle class="s1" cx="341.5" cy="203.2" r="2" opacity="0.45"/><circle class="s1" cx="264.4" cy="184.9" r="2" opacity="0.45"/><circle class="s1" cx="164.3" cy="197.4" r="2" opacity="0.45"/><circle class="s1" cx="125.8" cy="189.0" r="2" opacity="0.45"/><circle class="s1" cx="193.9" cy="214.4" r="2" opacity="0.45"/><circle class="s1" cx="129.9" cy="157.9" r="2" opacity="0.45"/><circle class="s1" cx="398.1" cy="269.2" r="2" opacity="0.45"/><circle class="s1" cx="138.9" cy="160.0" r="2" opacity="0.45"/><circle class="s1" cx="216.0" cy="155.6" r="2" opacity="0.45"/><circle class="s1" cx="271.8" cy="110.8" r="2" opacity="0.45"/><circle class="s1" cx="79.0" cy="105.9" r="2" opacity="0.45"/><circle class="s1" cx="303.8" cy="119.8" r="2" opacity="0.45"/><circle class="s1" cx="271.0" cy="146.3" r="2" opacity="0.45"/><circle class="s1" cx="156.1" cy="169.9" r="2" opacity="0.45"/><circle class="s1" cx="318.6" cy="110.6" r="2" opacity="0.45"/><circle class="s1" cx="211.1" cy="166.6" r="2" opacity="0.45"/><circle class="s1" cx="251.3" cy="140.6" r="2" opacity="0.45"/><circle class="s1" cx="368.6" cy="109.8" r="2" opacity="0.45"/><circle class="s1" cx="147.1" cy="148.0" r="2" opacity="0.45"/><circle class="s1" cx="102.0" cy="153.6" r="2" opacity="0.45"/><circle class="s1" cx="102.8" cy="130.7" r="2" opacity="0.45"/><circle class="s1" cx="162.7" cy="149.1" r="2" opacity="0.45"/><circle class="s1" cx="325.1" cy="129.3" r="2" opacity="0.45"/><circle class="s1" cx="293.9" cy="102.3" r="2" opacity="0.45"/><circle class="s1" cx="151.2" cy="136.2" r="2" opacity="0.45"/><circle class="s1" cx="103.6" cy="272.6" r="2" opacity="0.45"/><circle class="s1" cx="231.6" cy="112.2" r="2" opacity="0.45"/><circle class="s1" cx="74.1" cy="143.4" r="2" opacity="0.45"/><circle class="s1" cx="241.4" cy="128.3" r="2" opacity="0.45"/><circle class="s1" cx="138.1" cy="176.4" r="2" opacity="0.45"/><circle class="s1" cx="167.6" cy="154.4" r="2" opacity="0.45"/><circle class="s1" cx="395.7" cy="103.1" r="2" opacity="0.45"/><circle class="s1" cx="289.0" cy="108.7" r="2" opacity="0.45"/><circle class="s1" cx="383.4" cy="109.2" r="2" opacity="0.45"/><circle class="s1" cx="86.4" cy="163.4" r="2" opacity="0.45"/><circle class="s1" cx="87.2" cy="155.6" r="2" opacity="0.45"/><circle class="s1" cx="243.9" cy="136.0" r="2" opacity="0.45"/><circle class="s1" cx="291.5" cy="147.3" r="2" opacity="0.45"/><circle class="s1" cx="296.4" cy="131.2" r="2" opacity="0.45"/><circle class="s1" cx="223.4" cy="96.7" r="2" opacity="0.45"/><circle class="s1" cx="187.3" cy="135.1" r="2" opacity="0.45"/><circle class="s1" cx="267.7" cy="156.0" r="2" opacity="0.45"/><circle class="s1" cx="83.9" cy="192.1" r="2" opacity="0.45"/><circle class="s1" cx="207.8" cy="135.5" r="2" opacity="0.45"/><circle class="s1" cx="153.7" cy="158.9" r="2" opacity="0.45"/><circle class="s1" cx="280.0" cy="118.0" r="2" opacity="0.45"/><circle class="s1" cx="133.2" cy="156.4" r="2" opacity="0.45"/><circle class="s1" cx="398.9" cy="114.1" r="2" opacity="0.45"/><circle class="s1" cx="184.0" cy="123.2" r="2" opacity="0.45"/><circle class="s1" cx="109.4" cy="137.3" r="2" opacity="0.45"/><circle class="s1" cx="380.1" cy="132.0" r="2" opacity="0.45"/><circle class="s1" cx="97.9" cy="140.4" r="2" opacity="0.45"/><circle class="s1" cx="290.7" cy="179.5" r="2" opacity="0.45"/><circle class="s1" cx="233.2" cy="192.7" r="2" opacity="0.45"/><circle class="s1" cx="82.3" cy="123.3" r="2" opacity="0.45"/><circle class="s1" cx="123.3" cy="110.6" r="2" opacity="0.45"/><circle class="s1" cx="78.2" cy="222.7" r="2" opacity="0.45"/><circle class="s1" cx="262.0" cy="152.4" r="2" opacity="0.45"/><circle class="s1" cx="200.4" cy="134.4" r="2" opacity="0.45"/><circle class="s1" cx="81.5" cy="180.9" r="2" opacity="0.45"/><circle class="s1" cx="138.9" cy="164.5" r="2" opacity="0.45"/><circle class="s1" cx="72.5" cy="113.5" r="2" opacity="0.45"/><circle class="s1" cx="171.7" cy="90.0" r="2" opacity="0.45"/><circle class="s1" cx="99.5" cy="117.6" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="161.3" r="2" opacity="0.45"/><circle class="s1" cx="93.0" cy="126.8" r="2" opacity="0.45"/><circle class="s1" cx="107.7" cy="188.2" r="2" opacity="0.45"/><circle class="s1" cx="271.0" cy="189.5" r="2" opacity="0.45"/><circle class="s1" cx="333.3" cy="103.9" r="2" opacity="0.45"/><circle class="s1" cx="144.6" cy="103.9" r="2" opacity="0.45"/><circle class="s1" cx="91.3" cy="124.0" r="2" opacity="0.45"/><circle class="s1" cx="316.1" cy="152.6" r="2" opacity="0.45"/><circle class="s1" cx="321.8" cy="145.0" r="2" opacity="0.45"/><circle class="s1" cx="73.3" cy="140.1" r="2" opacity="0.45"/><circle class="s1" cx="108.6" cy="139.5" r="2" opacity="0.45"/><circle class="s1" cx="212.7" cy="162.1" r="2" opacity="0.45"/><circle class="s1" cx="90.5" cy="184.4" r="2" opacity="0.45"/><circle class="s1" cx="218.5" cy="122.0" r="2" opacity="0.45"/><circle class="s1" cx="74.9" cy="147.6" r="2" opacity="0.45"/><circle class="s1" cx="120.0" cy="181.9" r="2" opacity="0.45"/><circle class="s1" cx="144.6" cy="175.4" r="2" opacity="0.45"/><circle class="s1" cx="74.1" cy="121.9" r="2" opacity="0.45"/><circle class="s1" cx="94.6" cy="194.1" r="2" opacity="0.45"/><circle class="s1" cx="75.7" cy="240.9" r="2" opacity="0.45"/><circle class="s1" cx="380.1" cy="108.1" r="2" opacity="0.45"/><circle class="s1" cx="244.7" cy="186.7" r="2" opacity="0.45"/><circle class="s1" cx="225.0" cy="156.9" r="2" opacity="0.45"/><circle class="s1" cx="75.7" cy="225.6" r="2" opacity="0.45"/><circle class="s1" cx="228.3" cy="172.3" r="2" opacity="0.45"/><circle class="s1" cx="91.3" cy="172.2" r="2" opacity="0.45"/><circle class="s1" cx="89.7" cy="98.2" r="2" opacity="0.45"/><circle class="s1" cx="311.2" cy="134.4" r="2" opacity="0.45"/><circle class="s1" cx="296.4" cy="96.3" r="2" opacity="0.45"/><circle class="s1" cx="131.5" cy="87.9" r="2" opacity="0.45"/><circle class="s1" cx="75.7" cy="249.6" r="2" opacity="0.45"/><circle class="s1" cx="90.5" cy="170.7" r="2" opacity="0.45"/><circle class="s1" cx="368.6" cy="114.7" r="2" opacity="0.45"/><circle class="s1" cx="118.4" cy="131.9" r="2" opacity="0.45"/><circle class="s1" cx="388.3" cy="144.8" r="2" opacity="0.45"/><circle class="s1" cx="241.4" cy="192.8" r="2" opacity="0.45"/><circle class="s1" cx="82.3" cy="246.3" r="2" opacity="0.45"/><circle class="s1" cx="79.8" cy="138.8" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="187.4" r="2" opacity="0.45"/><circle class="s1" cx="359.6" cy="147.0" r="2" opacity="0.45"/><circle class="s1" cx="394.0" cy="111.2" r="2" opacity="0.45"/><circle class="s1" cx="179.9" cy="158.2" r="2" opacity="0.45"/><circle class="s1" cx="97.9" cy="251.7" r="2" opacity="0.45"/><circle class="s1" cx="338.2" cy="113.1" r="2" opacity="0.45"/><circle class="s1" cx="246.4" cy="197.3" r="2" opacity="0.45"/><circle class="s1" cx="280.0" cy="130.3" r="2" opacity="0.45"/><circle class="s1" cx="161.9" cy="125.6" r="2" opacity="0.45"/><circle class="s1" cx="139.7" cy="134.1" r="2" opacity="0.45"/><circle class="s1" cx="76.6" cy="150.9" r="2" opacity="0.45"/><circle class="s1" cx="280.8" cy="115.5" r="2" opacity="0.45"/><circle class="s1" cx="170.1" cy="222.4" r="2" opacity="0.45"/><circle class="s1" cx="78.2" cy="187.2" r="2" opacity="0.45"/><circle class="s1" cx="166.8" cy="156.3" r="2" opacity="0.45"/><circle class="s1" cx="436.7" cy="87.0" r="2" opacity="0.45"/><circle class="s1" cx="148.8" cy="197.3" r="2" opacity="0.45"/><circle class="s1" cx="102.0" cy="143.3" r="2" opacity="0.45"/><circle class="s1" cx="84.8" cy="127.5" r="2" opacity="0.45"/><circle class="s1" cx="97.9" cy="133.4" r="2" opacity="0.45"/><circle class="s1" cx="82.3" cy="228.2" r="2" opacity="0.45"/><circle class="s1" cx="101.2" cy="184.7" r="2" opacity="0.45"/><circle class="s1" cx="76.6" cy="152.9" r="2" opacity="0.45"/><circle class="s1" cx="72.5" cy="201.0" r="2" opacity="0.45"/><circle class="s1" cx="88.9" cy="115.3" r="2" opacity="0.45"/><circle class="s1" cx="244.7" cy="127.2" r="2" opacity="0.45"/><circle class="s1" cx="72.5" cy="96.4" r="2" opacity="0.45"/><circle class="s1" cx="219.3" cy="174.2" r="2" opacity="0.45"/><circle class="s1" cx="316.9" cy="118.7" r="2" opacity="0.45"/><circle class="s1" cx="152.0" cy="134.2" r="2" opacity="0.45"/><circle class="s1" cx="76.6" cy="107.9" r="2" opacity="0.45"/><circle class="s1" cx="143.8" cy="91.8" r="2" opacity="0.45"/><circle class="s1" cx="419.5" cy="124.9" r="2" opacity="0.45"/><circle class="s1" cx="99.5" cy="212.7" r="2" opacity="0.45"/><circle class="s1" cx="240.6" cy="138.5" r="2" opacity="0.45"/><circle class="s1" cx="184.0" cy="174.8" r="2" opacity="0.45"/><circle class="s1" cx="129.1" cy="168.8" r="2" opacity="0.45"/><circle class="s1" cx="159.4" cy="97.2" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="183.5" r="2" opacity="0.45"/><circle class="s1" cx="395.7" cy="108.6" r="2" opacity="0.45"/><circle class="s1" cx="86.4" cy="178.3" r="2" opacity="0.45"/><circle class="s1" cx="120.9" cy="160.1" r="2" opacity="0.45"/><circle class="s1" cx="107.7" cy="105.8" r="2" opacity="0.45"/><circle class="s1" cx="100.4" cy="202.7" r="2" opacity="0.45"/><circle class="s1" cx="300.5" cy="133.4" r="2" opacity="0.45"/><circle class="s1" cx="216.0" cy="134.8" r="2" opacity="0.45"/><circle class="s1" cx="292.3" cy="140.3" r="2" opacity="0.45"/><circle class="s1" cx="193.9" cy="115.0" r="2" opacity="0.45"/><circle class="s1" cx="91.3" cy="139.4" r="2" opacity="0.45"/><circle class="s1" cx="336.6" cy="190.9" r="2" opacity="0.45"/><circle class="s1" cx="73.3" cy="217.2" r="2" opacity="0.45"/><circle class="s1" cx="218.5" cy="204.7" r="2" opacity="0.45"/><circle class="s1" cx="166.8" cy="153.9" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="155.1" r="2" opacity="0.45"/><circle class="s1" cx="161.9" cy="159.4" r="2" opacity="0.45"/><circle class="s1" cx="262.0" cy="114.2" r="2" opacity="0.45"/><circle class="s1" cx="106.9" cy="175.5" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="120.2" r="2" opacity="0.45"/><circle class="s1" cx="120.0" cy="160.3" r="2" opacity="0.45"/><circle class="s1" cx="110.2" cy="156.4" r="2" opacity="0.45"/><circle class="s1" cx="166.8" cy="142.1" r="2" opacity="0.45"/><circle class="s1" cx="312.0" cy="132.9" r="2" opacity="0.45"/><circle class="s1" cx="284.9" cy="137.3" r="2" opacity="0.45"/><circle class="s1" cx="108.6" cy="203.0" r="2" opacity="0.45"/><circle class="s1" cx="84.8" cy="187.8" r="2" opacity="0.45"/><circle class="s1" cx="73.3" cy="128.8" r="2" opacity="0.45"/><circle class="s1" cx="401.4" cy="147.7" r="2" opacity="0.45"/><circle class="s1" cx="178.3" cy="160.8" r="2" opacity="0.45"/><circle class="s1" cx="112.7" cy="137.8" r="2" opacity="0.45"/><circle class="s1" cx="119.2" cy="215.6" r="2" opacity="0.45"/><circle class="s1" cx="93.8" cy="163.5" r="2" opacity="0.45"/><circle class="s1" cx="148.8" cy="182.4" r="2" opacity="0.45"/><circle class="s1" cx="127.4" cy="144.9" r="2" opacity="0.45"/><circle class="s1" cx="96.2" cy="133.9" r="2" opacity="0.45"/><circle class="s1" cx="241.4" cy="182.4" r="2" opacity="0.45"/><circle class="s1" cx="185.7" cy="147.6" r="2" opacity="0.45"/><circle class="s1" cx="122.5" cy="186.5" r="2" opacity="0.45"/><circle class="s1" cx="93.8" cy="213.1" r="2" opacity="0.45"/><circle class="s1" cx="196.3" cy="115.5" r="2" opacity="0.45"/><circle class="s1" cx="212.7" cy="123.7" r="2" opacity="0.45"/><circle class="s1" cx="275.1" cy="116.7" r="2" opacity="0.45"/><circle class="s1" cx="397.3" cy="106.0" r="2" opacity="0.45"/><circle class="s1" cx="187.3" cy="126.7" r="2" opacity="0.45"/><circle class="s1" cx="98.7" cy="120.1" r="2" opacity="0.45"/><circle class="s1" cx="207.0" cy="121.7" r="2" opacity="0.45"/><circle class="s1" cx="359.6" cy="118.1" r="2" opacity="0.45"/><circle class="s1" cx="91.3" cy="217.7" r="2" opacity="0.45"/><circle class="s1" cx="159.4" cy="164.7" r="2" opacity="0.45"/><circle class="s1" cx="131.5" cy="128.6" r="2" opacity="0.45"/><circle class="s1" cx="138.1" cy="185.3" r="2" opacity="0.45"/><circle class="s1" cx="115.1" cy="130.9" r="2" opacity="0.45"/><circle class="s1" cx="129.9" cy="156.2" r="2" opacity="0.45"/><circle class="s1" cx="192.2" cy="113.3" r="2" opacity="0.45"/><circle class="s1" cx="79.8" cy="151.7" r="2" opacity="0.45"/><circle class="s1" cx="75.7" cy="129.0" r="2" opacity="0.45"/><circle class="s1" cx="131.5" cy="165.1" r="2" opacity="0.45"/><circle class="s1" cx="390.7" cy="116.2" r="2" opacity="0.45"/><circle class="s1" cx="127.4" cy="138.5" r="2" opacity="0.45"/><circle class="s1" cx="335.8" cy="159.0" r="2" opacity="0.45"/><circle class="s1" cx="81.5" cy="146.5" r="2" opacity="0.45"/><circle class="s1" cx="291.5" cy="168.4" r="2" opacity="0.45"/><circle class="s1" cx="378.4" cy="111.0" r="2" opacity="0.45"/><circle class="s1" cx="226.7" cy="128.2" r="2" opacity="0.45"/><circle class="s1" cx="380.1" cy="128.0" r="2" opacity="0.45"/><circle class="s1" cx="82.3" cy="240.4" r="2" opacity="0.45"/><circle class="s1" cx="113.5" cy="132.6" r="2" opacity="0.45"/><circle class="s1" cx="87.2" cy="99.9" r="2" opacity="0.45"/><circle class="s1" cx="74.9" cy="205.3" r="2" opacity="0.45"/><circle class="s1" cx="88.9" cy="105.0" r="2" opacity="0.45"/><circle class="s1" cx="398.9" cy="106.9" r="2" opacity="0.45"/><circle class="s1" cx="314.5" cy="139.7" r="2" opacity="0.45"/><circle class="s1" cx="102.0" cy="183.7" r="2" opacity="0.45"/><circle class="s1" cx="82.3" cy="160.9" r="2" opacity="0.45"/><circle class="s1" cx="248.0" cy="175.1" r="2" opacity="0.45"/><circle class="s1" cx="230.8" cy="177.3" r="2" opacity="0.45"/><circle class="s1" cx="344.8" cy="242.6" r="2" opacity="0.45"/><circle class="s1" cx="278.4" cy="189.9" r="2" opacity="0.45"/><circle class="s1" cx="210.3" cy="214.1" r="2" opacity="0.45"/><circle class="s1" cx="125.8" cy="214.6" r="2" opacity="0.45"/><circle class="s1" cx="385.8" cy="96.4" r="2" opacity="0.45"/><circle class="s1" cx="210.3" cy="159.8" r="2" opacity="0.45"/><circle class="s1" cx="182.4" cy="167.8" r="2" opacity="0.45"/><circle class="s1" cx="198.0" cy="141.8" r="2" opacity="0.45"/><circle class="s1" cx="406.3" cy="139.2" r="2" opacity="0.45"/><circle class="s1" cx="129.9" cy="99.9" r="2" opacity="0.45"/><circle class="s1" cx="207.8" cy="200.2" r="2" opacity="0.45"/><circle class="s1" cx="325.1" cy="118.5" r="2" opacity="0.45"/><circle class="s1" cx="175.8" cy="160.3" r="2" opacity="0.45"/><circle class="s1" cx="199.6" cy="137.1" r="2" opacity="0.45"/><circle class="s1" cx="325.9" cy="145.2" r="2" opacity="0.45"/><circle class="s1" cx="113.5" cy="248.6" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="148.0" r="2" opacity="0.45"/><circle class="s1" cx="239.8" cy="132.9" r="2" opacity="0.45"/><circle class="s1" cx="79.8" cy="161.7" r="2" opacity="0.45"/><circle class="s1" cx="387.5" cy="115.3" r="2" opacity="0.45"/><circle class="s1" cx="320.2" cy="172.9" r="2" opacity="0.45"/><circle class="s1" cx="198.8" cy="176.9" r="2" opacity="0.45"/><circle class="s1" cx="146.3" cy="188.5" r="2" opacity="0.45"/><circle class="s1" cx="117.6" cy="187.6" r="2" opacity="0.45"/><circle class="s1" cx="99.5" cy="116.7" r="2" opacity="0.45"/><circle class="s1" cx="197.1" cy="148.5" r="2" opacity="0.45"/><circle class="s1" cx="239.0" cy="149.2" r="2" opacity="0.45"/><circle class="s1" cx="175.0" cy="217.0" r="2" opacity="0.45"/><circle class="s1" cx="93.8" cy="72.7" r="2" opacity="0.45"/><circle class="s1" cx="108.6" cy="160.4" r="2" opacity="0.45"/><circle class="s1" cx="138.9" cy="198.9" r="2" opacity="0.45"/><circle class="s1" cx="321.8" cy="130.5" r="2" opacity="0.45"/><circle class="s1" cx="122.5" cy="232.8" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="119.4" r="2" opacity="0.45"/><circle class="s1" cx="93.8" cy="125.1" r="2" opacity="0.45"/><circle class="s1" cx="138.1" cy="127.2" r="2" opacity="0.45"/><circle class="s1" cx="130.7" cy="195.8" r="2" opacity="0.45"/><circle class="s1" cx="353.0" cy="139.3" r="2" opacity="0.45"/><circle class="s1" cx="229.1" cy="249.5" r="2" opacity="0.45"/><circle class="s1" cx="184.8" cy="203.4" r="2" opacity="0.45"/><circle class="s1" cx="119.2" cy="216.3" r="2" opacity="0.45"/><circle class="s1" cx="76.6" cy="148.5" r="2" opacity="0.45"/><circle class="s1" cx="97.9" cy="140.5" r="2" opacity="0.45"/><circle class="s1" cx="348.1" cy="99.0" r="2" opacity="0.45"/><circle class="s1" cx="79.0" cy="129.8" r="2" opacity="0.45"/><circle class="s1" cx="206.2" cy="268.0" r="2" opacity="0.45"/><circle class="s1" cx="94.6" cy="156.1" r="2" opacity="0.45"/><circle class="s1" cx="81.5" cy="236.9" r="2" opacity="0.45"/><circle class="s1" cx="120.0" cy="121.1" r="2" opacity="0.45"/><circle class="s1" cx="253.8" cy="151.4" r="2" opacity="0.45"/><circle class="s1" cx="79.0" cy="185.1" r="2" opacity="0.45"/><circle class="s1" cx="298.0" cy="180.1" r="2" opacity="0.45"/><circle class="s1" cx="149.6" cy="142.8" r="2" opacity="0.45"/><circle class="s1" cx="251.3" cy="153.9" r="2" opacity="0.45"/><circle class="s1" cx="159.4" cy="159.8" r="2" opacity="0.45"/><circle class="s1" cx="102.8" cy="188.2" r="2" opacity="0.45"/><circle class="s1" cx="72.5" cy="184.9" r="2" opacity="0.45"/><circle class="s1" cx="295.6" cy="118.3" r="2" opacity="0.45"/><circle class="s1" cx="71.6" cy="109.1" r="2" opacity="0.45"/><circle class="s1" cx="133.2" cy="154.6" r="2" opacity="0.45"/><circle class="s1" cx="86.4" cy="232.9" r="2" opacity="0.45"/><circle class="s1" cx="221.8" cy="215.1" r="2" opacity="0.45"/><circle class="s1" cx="110.2" cy="233.5" r="2" opacity="0.45"/><circle class="s1" cx="145.5" cy="139.2" r="2" opacity="0.45"/><circle class="s1" cx="186.5" cy="153.9" r="2" opacity="0.45"/><circle class="s1" cx="301.3" cy="139.7" r="2" opacity="0.45"/><circle class="s1" cx="281.6" cy="117.9" r="2" opacity="0.45"/><circle class="s1" cx="136.4" cy="134.1" r="2" opacity="0.45"/><circle class="s1" cx="102.0" cy="167.7" r="2" opacity="0.45"/><circle class="s1" cx="100.4" cy="180.1" r="2" opacity="0.45"/><circle class="s1" cx="262.8" cy="192.5" r="2" opacity="0.45"/><circle class="s1" cx="213.6" cy="137.5" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="146.2" r="2" opacity="0.45"/><circle class="s1" cx="104.5" cy="132.7" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="187.1" r="2" opacity="0.45"/><circle class="s1" cx="246.4" cy="203.9" r="2" opacity="0.45"/><circle class="s1" cx="129.1" cy="238.5" r="2" opacity="0.45"/><circle class="s1" cx="88.9" cy="95.6" r="2" opacity="0.45"/><circle class="s1" cx="134.0" cy="178.1" r="2" opacity="0.45"/><circle class="s1" cx="87.2" cy="97.5" r="2" opacity="0.45"/><circle class="s1" cx="346.4" cy="171.9" r="2" opacity="0.45"/><circle class="s1" cx="322.7" cy="160.9" r="2" opacity="0.45"/><circle class="s1" cx="204.5" cy="141.6" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="157.1" r="2" opacity="0.45"/><circle class="s1" cx="103.6" cy="144.6" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="163.1" r="2" opacity="0.45"/><circle class="s1" cx="223.4" cy="153.8" r="2" opacity="0.45"/><circle class="s1" cx="139.7" cy="209.2" r="2" opacity="0.45"/><circle class="s1" cx="143.8" cy="241.7" r="2" opacity="0.45"/><circle class="s1" cx="319.4" cy="148.4" r="2" opacity="0.45"/><circle class="s1" cx="102.8" cy="238.7" r="2" opacity="0.45"/><circle class="s1" cx="120.0" cy="202.6" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="128.4" r="2" opacity="0.45"/><circle class="s1" cx="240.6" cy="147.1" r="2" opacity="0.45"/><circle class="s1" cx="175.8" cy="99.8" r="2" opacity="0.45"/><circle class="s1" cx="139.7" cy="132.6" r="2" opacity="0.45"/><circle class="s1" cx="70.8" cy="197.4" r="2" opacity="0.45"/><circle class="s1" cx="95.4" cy="105.7" r="2" opacity="0.45"/><circle class="s1" cx="296.4" cy="164.9" r="2" opacity="0.45"/><circle class="s1" cx="102.0" cy="112.6" r="2" opacity="0.45"/><circle class="s1" cx="119.2" cy="152.5" r="2" opacity="0.45"/><circle class="s1" cx="80.7" cy="206.7" r="2" opacity="0.45"/><circle class="s1" cx="239.0" cy="137.3" r="2" opacity="0.45"/><circle class="s1" cx="361.2" cy="135.9" r="2" opacity="0.45"/><circle class="s1" cx="120.9" cy="93.8" r="2" opacity="0.45"/><circle class="s1" cx="153.7" cy="256.0" r="2" opacity="0.45"/><circle class="s1" cx="157.8" cy="185.8" r="2" opacity="0.45"/><circle class="s1" cx="130.7" cy="204.3" r="2" opacity="0.45"/><circle class="s1" cx="394.8" cy="114.2" r="2" opacity="0.45"/><circle class="s1" cx="357.9" cy="105.5" r="2" opacity="0.45"/><circle class="s1" cx="174.2" cy="141.4" r="2" opacity="0.45"/><circle class="s1" cx="330.0" cy="132.5" r="2" opacity="0.45"/><circle class="s1" cx="394.0" cy="153.8" r="2" opacity="0.45"/><circle class="s1" cx="394.0" cy="96.2" r="2" opacity="0.45"/><circle class="s1" cx="220.9" cy="95.0" r="2" opacity="0.45"/><circle class="s1" cx="262.8" cy="171.2" r="2" opacity="0.45"/><circle class="s1" cx="77.4" cy="111.5" r="2" opacity="0.45"/><circle class="s1" cx="342.3" cy="105.0" r="2" opacity="0.45"/><circle class="s1" cx="357.1" cy="85.3" r="2" opacity="0.45"/><circle class="s1" cx="129.1" cy="106.9" r="2" opacity="0.45"/><circle class="s1" cx="166.8" cy="135.0" r="2" opacity="0.45"/><circle class="s1" cx="246.4" cy="165.3" r="2" opacity="0.45"/><circle class="s1" cx="109.4" cy="152.3" r="2" opacity="0.45"/><circle class="s1" cx="85.6" cy="109.9" r="2" opacity="0.45"/><circle class="s1" cx="146.3" cy="215.4" r="2" opacity="0.45"/><circle class="s1" cx="180.7" cy="126.1" r="2" opacity="0.45"/><circle class="s1" cx="279.2" cy="132.9" r="2" opacity="0.45"/><circle class="s1" cx="132.3" cy="102.0" r="2" opacity="0.45"/><circle class="s1" cx="102.8" cy="168.8" r="2" opacity="0.45"/><circle class="s1" cx="111.8" cy="126.2" r="2" opacity="0.45"/><circle class="s1" cx="179.9" cy="192.0" r="2" opacity="0.45"/><circle class="s1" cx="334.1" cy="133.7" r="2" opacity="0.45"/><circle class="s1" cx="130.7" cy="224.2" r="2" opacity="0.45"/><circle class="s1" cx="248.8" cy="122.3" r="2" opacity="0.45"/><circle class="s1" cx="146.3" cy="164.0" r="2" opacity="0.45"/><circle class="s1" cx="101.2" cy="175.3" r="2" opacity="0.45"/><circle class="s1" cx="84.8" cy="225.7" r="2" opacity="0.45"/><circle class="s1" cx="113.5" cy="126.6" r="2" opacity="0.45"/><circle class="s1" cx="262.0" cy="200.6" r="2" opacity="0.45"/><circle class="s1" cx="131.5" cy="128.7" r="2" opacity="0.45"/><circle class="s1" cx="275.1" cy="134.9" r="2" opacity="0.45"/><circle class="s1" cx="207.0" cy="138.2" r="2" opacity="0.45"/><circle class="s1" cx="392.4" cy="135.2" r="2" opacity="0.45"/><circle class="s1" cx="357.9" cy="131.7" r="2" opacity="0.45"/><circle class="s1" cx="108.6" cy="130.1" r="2" opacity="0.45"/><circle class="s1" cx="272.6" cy="205.1" r="2" opacity="0.45"/><circle class="s1" cx="147.9" cy="249.5" r="2" opacity="0.45"/><circle class="s1" cx="343.2" cy="145.3" r="2" opacity="0.45"/><circle class="s1" cx="111.8" cy="198.4" r="2" opacity="0.45"/><circle class="s1" cx="389.1" cy="152.3" r="2" opacity="0.45"/><circle class="s1" cx="90.5" cy="190.2" r="2" opacity="0.45"/><circle class="s1" cx="348.9" cy="117.7" r="2" opacity="0.45"/><circle class="s1" cx="128.2" cy="207.7" r="2" opacity="0.45"/><circle class="s1" cx="82.3" cy="160.0" r="2" opacity="0.45"/><circle class="s1" cx="275.1" cy="125.8" r="2" opacity="0.45"/><circle class="s1" cx="112.7" cy="227.3" r="2" opacity="0.45"/><circle class="s1" cx="220.9" cy="138.9" r="2" opacity="0.45"/><polyline class="l2" points="81.8,143.2 109.3,156.8 143.8,152.5 200.0,152.1 254.0,151.9 329.4,132.1 410.7,115.3"/><circle class="s2 ring" cx="81.8" cy="143.2" r="4"/><circle class="s2 ring" cx="109.3" cy="156.8" r="4"/><circle class="s2 ring" cx="143.8" cy="152.5" r="4"/><circle class="s2 ring" cx="200.0" cy="152.1" r="4"/><circle class="s2 ring" cx="254.0" cy="151.9" r="4"/><circle class="s2 ring" cx="329.4" cy="132.1" r="4"/><circle class="s2 ring" cx="410.7" cy="115.3" r="4"/><text class="t-muted" x="280.0" y="314.0" text-anchor="middle">answer length (tokens)</text><text class="t-muted" x="20.0" y="38.0" text-anchor="start">reward</text><text class="t-tick t-strong" x="530.0" y="70.0" text-anchor="start">Spearman correlations</text><text class="t-tick" x="530.0" y="94.0" text-anchor="start">reward vs length: +0.15</text><text class="t-tick" x="530.0" y="116.0" text-anchor="start">GPT-4 rating vs length: +0.12</text><text class="t-tick" x="530.0" y="138.0" text-anchor="start">reward gap vs length gap: +0.20</text><text class="t-tick t-strong" x="530.0" y="180.0" text-anchor="start">accuracy when chosen is</text><text class="t-tick" x="530.0" y="204.0" text-anchor="start">longer: 76.2%</text><text class="t-tick" x="530.0" y="226.0" text-anchor="start">shorter: 61.5%</text><text class="t-muted" x="530.0" y="256.0" text-anchor="start">orange: mean reward per length bin</text></svg><figcaption>Reward against answer length for the 1,200 test answers, with the average reward per length bin (orange). Longer answers get somewhat higher rewards. Inside a pair, the reward model's preference tracks the length difference ten times more strongly than GPT-4's ratings do.</figcaption></figure>

Read the three lines in order:

- **Across all answers**, longer answers get slightly higher rewards (Spearman 0.15), and GPT-4's ratings show about the same tilt (0.12). So far the reward model is just copying its labels.
- **Inside a pair**, which is what actually matters for training a policy, the picture changes. How much longer the chosen answer is barely predicts how much better GPT-4 rated it (0.02). But it predicts how much higher *our reward model* scores it (0.21). The model leans on length more than its labels justify.
- **The accuracy split** shows the same thing from another side: 76.2% when the chosen answer is also the longer one, 61.5% when it is the shorter one. Chapter 3 found the same asymmetry in published reward models on RewardBench (Skywork: 94% against 77%).

Correlation is not a test, though. A direct test is to take an answer, change *only* its length, and see what happens to the reward. `ch7_eval.py` does this with three edits on 150 chosen test answers, and asks the gold reward model the same question:

```python
# simplified from ch7_eval.py
edits = {
    'add a polite closing line': lambda y: y + '\n\nI hope this helps! Let me know if you have any other questions.',
    'repeat the answer twice':   lambda y: y + '\n\n' + y,
    'cut the answer in half':    lambda y: ' '.join(y.split()[:len(y.split()) // 2]),
}
for name, f in edits.items():
    change = score(prompts, [f(y) for y in answers]) - score(prompts, answers)   # reward after minus before
```

```text
  add a polite closing line  our RM: mean change -0.125 (sd of RM 1.35), up in 0.47 | gold RM: mean change -0.159 (sd 2.96), up in 0.43
  repeat the answer twice    our RM: mean change -0.119 (sd of RM 1.35), up in 0.35 | gold RM: mean change -1.966 (sd 2.96), up in 0.01
  cut the answer in half     our RM: mean change -2.526 (sd of RM 1.35), up in 0.01 | gold RM: mean change -4.282 (sd 2.96), up in 0.01
```

<figure class="fig"><svg viewBox="0 0 800 276" role="img" aria-label="Bars for three edits: adding a polite closing line, repeating the answer and cutting it in half, showing how much our reward model and the gold reward model change their scores."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">Edit an answer, re-score it: mean change in reward, in units of each model's reward sd (150 answers)</text><line class="axis" x1="500" y1="48" x2="500" y2="248"/><text class="t-tick t-strong" x="20.0" y="82.0" text-anchor="start">add a polite closing line</text><g class="mark"><title>our RM: -0.09 sd, up in 47%</title><rect class="s1" x="489.8" y="60" width="10.2" height="18" rx="3"/></g><text class="t-val" x="508.0" y="73.0" text-anchor="start">our RM -0.09 (up in 47%)</text><g class="mark"><title>gold RM: -0.05 sd, up in 43%</title><rect class="s3" x="494.1" y="84" width="5.9" height="18" rx="3"/></g><text class="t-val" x="508.0" y="97.0" text-anchor="start">gold RM -0.05 (up in 43%)</text><text class="t-tick t-strong" x="20.0" y="146.0" text-anchor="start">repeat the answer twice</text><g class="mark"><title>our RM: -0.09 sd, up in 35%</title><rect class="s1" x="490.3" y="124" width="9.7" height="18" rx="3"/></g><text class="t-val" x="508.0" y="137.0" text-anchor="start">our RM -0.09 (up in 35%)</text><g class="mark"><title>gold RM: -0.67 sd, up in 1%</title><rect class="s3" x="426.8" y="148" width="73.2" height="18" rx="3"/></g><text class="t-val" x="508.0" y="161.0" text-anchor="start">gold RM -0.67 (up in 1%)</text><text class="t-tick t-strong" x="20.0" y="210.0" text-anchor="start">cut the answer in half</text><g class="mark"><title>our RM: -1.88 sd, up in 1%</title><rect class="s1" x="293.5" y="188" width="206.5" height="18" rx="3"/></g><text class="t-val" x="508.0" y="201.0" text-anchor="start">our RM -1.88 (up in 1%)</text><g class="mark"><title>gold RM: -1.45 sd, up in 1%</title><rect class="s3" x="340.7" y="212" width="159.3" height="18" rx="3"/></g><text class="t-val" x="508.0" y="225.0" text-anchor="start">gold RM -1.45 (up in 1%)</text><text class="t-muted" x="500.0" y="262.0" text-anchor="middle">no change</text></svg><figcaption>Average change in reward after each edit, in units of each model's own spread of rewards. Both models punish an answer cut in half. Only the gold model punishes an answer repeated twice; ours barely notices.</figcaption></figure>

The edits tell a more useful story than the correlation:

- **Cutting an answer in half** is punished by both models, in 99% of cases; relative to its spread, ours punishes it even harder (1.9 standard deviations against 1.4). Our reward model does notice missing content.
- **A polite closing line** changes nothing much for either model: up in about half the cases, down in the other half.
- **Repeating the whole answer** is the revealing one. The gold model lowers the reward in 99% of cases, by two-thirds of a standard deviation: a repeated answer is obviously worse. Our reward model shrugs: an average change of $$-0.12$$, a tenth of its spread, and it actually *raises* the reward in 35% of cases. Doubling the length of an answer is nearly free.

That last line is the kind of hole an optimiser finds. PPO does not need the reward model to *like* repetition; it is enough that repetition is not punished while everything else that comes with longer answers is mildly rewarded. With 3,200 training pairs, almost none of which contain repeated text, our reward model has simply never been shown that repetition is bad. Section 7.10 shows this kind of gap between proxy and gold under real optimisation pressure.

## 7.10 Overoptimisation: when the proxy and the truth part ways

A reward model is trained to rank answers like the ones in its training data. RLHF then uses it for something different: as a target to *maximise*. The optimiser searches for answers with the highest reward, and the highest-reward answers are disproportionately the ones where the reward model is wrong in the optimiser's favour. This is Goodhart's law ("when a measure becomes a target, it ceases to be a good measure") with a search algorithm attached. Chapter 3 introduced it under the name reward hacking; here we measure it.

> [!DEFINITION] Overoptimisation
> Optimising a policy against a learned (proxy) reward past the point where it helps: the proxy reward keeps rising, while the true quality first rises and then stalls or falls. Also called reward hacking or reward model overoptimisation.

### Gao et al.: a gold reward model in place of people

Measuring overoptimisation needs the *true* reward at every step of optimisation, which would mean asking people again and again. Gao, Schulman and Hilton (2022) used a trick: a large reward model plays the role of the people.

> [!PAPER] Gao et al. (2022), Scaling Laws for Reward Model Overoptimization · Figure 2 · page 4
> [![Diagram of two setups. Real RLHF: human labellers produce comparison data, which trains a proxy reward model that the policy is optimised against. Synthetic setup: a gold reward model produces the labels instead of humans, and the same gold model scores the optimised policy](https://ishwarj.com/img/training/ch7-gao-fig2.pngng/ch7-gao-fig2.png)](/img/training/ch7-gao-fig2.png)
>
> **Context:** the description of the experimental setup.
>
> **What it says:** "In our synthetic setting, we instead use a 'Gold RM' as our ground truth." The gold model is InstructGPT's 6B reward model. It labels 100,000 synthetic comparisons; proxy reward models of 3M to 3B parameters are trained on those labels; a policy is optimised against the proxy; the gold model says how good the result really is.
>
> **Why it matters:** because the gold model is cheap to query, you can trace the true reward along the whole optimisation and fit curves to it.

They optimised in two ways, best-of-n and RL (PPO), and measured how far the optimised policy had moved from the starting policy with the KL divergence ([Chapter 1](https://ishwarj.com/books/how-models-are-trained/01-from-next-word-to-assistant), Section 1.9). For best-of-n, the KL has an exact formula, so no estimate is needed:

$$
\text{KL}_{\text{bon}} = \log n - \frac{n - 1}{n}
$$

where:

- $$n$$ is the number of samples best-of-n chooses from;
- $$\text{KL}_{\text{bon}}$$ is the KL divergence, in nats, between the distribution of the kept answer and the original policy's distribution.

For $$n = 32$$ this is $$3.466 - 0.969 = 2.497$$ nats. It grows only like $$\log n$$: to reach 10 nats you would need about $$n = e^{11} \approx 60{,}000$$ samples.

Their main finding is a pair of formulas for the gold reward as a function of the distance $$d = \sqrt{\text{KL}}$$:

> [!PAPER] Gao et al. (2022) · Section 1 · page 2
> [![Gao et al.: the main results are functional forms for the gold reward as a function of d, the square root of the KL divergence from the initial policy; for best-of-n, R equals d times alpha minus beta d; for reinforcement learning, R equals d times alpha minus beta log d](https://ishwarj.com/img/training/ch7-gao-forms.pngg/ch7-gao-forms.png)](/img/training/ch7-gao-forms.png)
>
> **Context:** the summary of results in the introduction.
>
> **What it says:** "for best-of-n (BoN) sampling, $$R_{\text{bon}}(d) = d(\alpha_{\text{bon}} - \beta_{\text{bon}} d)$$, and for reinforcement learning, $$R_{\text{RL}}(d) = d(\alpha_{\text{RL}} - \beta_{\text{RL}} \log d)$$", where the coefficients depend on the size of the proxy reward model and its data.
>
> **Why it matters:** both curves rise, peak and fall. A bigger or better-trained proxy has a larger $$\alpha$$ and a smaller $$\beta$$: it peaks later and higher.

For best-of-n:

$$
R_{\text{bon}}(d) = d\,(\alpha - \beta d), \qquad d = \sqrt{\text{KL}_{\text{bon}}}
$$

where:

- $$R_{\text{bon}}(d)$$ is the gold reward gained over the starting policy ($$R(0) = 0$$);
- $$d$$ is the square root of the KL, a measure of how far optimisation has moved the policy;
- $$\alpha$$ is the initial slope: how much each unit of $$d$$ helps at first;
- $$\beta$$ is the rate at which the proxy's errors take over.

It is a downward parabola in $$d$$, with its peak at $$d^* = \alpha / (2\beta)$$. Optimising beyond $$d^*$$ makes the answers *worse* by the gold standard while the proxy keeps reporting progress.

The paper also measured how this depends on the proxy's training data:

> [!PAPER] Gao et al. (2022) · Figure 4 · page 6
> [![Gold and proxy reward against the square root of KL for best-of-n and RL, for 12M-parameter reward models trained on different amounts of data; with little data the gold reward barely rises and soon falls; with more data it rises higher and peaks later; proxy rewards (dotted) rise steadily in all cases](https://ishwarj.com/img/training/ch7-gao-fig4.pngng/ch7-gao-fig4.png)](/img/training/ch7-gao-fig4.png)
>
> **Context:** the reward model data scaling experiments.
>
> **What it says:** with a fixed 12M-parameter reward model, more comparison data gives "better gold scores and less goodharting". The text adds that with fewer than about 2,000 comparisons the proxies barely beat chance, and the gold reward after optimisation barely improves.
>
> **Why it matters:** this is the experiment we can afford to imitate: two proxies of the same size, trained on 400 and 3,200 pairs.


### Our version: best-of-32 against our reward model, judged by Skywork

We cannot run Gao et al.'s full study, but we can run its best-of-n half in miniature, with our own reward model as the proxy and a much stronger public reward model as the gold.

- **Policy:** Qwen2.5-0.5B-Instruct, the model Chapter 8 will train.
- **Prompts:** 100 held-out UltraFeedback prompts (none of them in the reward model test pairs), with at most 150 tokens each.
- **Samples:** 32 answers per prompt, temperature 1.0, at most 256 new tokens (`ch7_bon_gen.py`). 3,200 answers in total; only 27.5% of them end within 256 tokens, the rest are cut off.
- **Proxies:** our main reward model (3,200 pairs), the small one trained on 400 pairs, and two ensembles (Section 7.11).
- **Gold:** Skywork-Reward-V2-Qwen3-0.6B, which scored 78.0% on our test pairs against our 69.5%.

One difference from Gao et al. matters: our proxy was trained on GPT-4's labels, not on the gold model's. So the gap between proxy and gold mixes two things, the proxy's errors and genuine disagreement between GPT-4's taste and Skywork's. Read the gold as "a second, better judge", not as the truth.

To get the expected reward of best-of-n for every $$n$$ from 1 to 32 from the same 32 samples, `ch7_bon.py` uses the estimator Gao et al. took from WebGPT (Nakano et al., 2021). Sort a prompt's $$N = 32$$ samples by proxy reward. The sample with rank $$i$$ (1 = lowest) is the best of a random subset of size $$n$$ exactly when the subset contains it and $$n - 1$$ of the $$i - 1$$ samples below it, so

$$
\mathbb{E}\big[\text{gold of best-of-}n\big] = \sum_{i=1}^{N} \frac{\binom{i-1}{n-1}}{\binom{N}{n}}\; g_{(i)}
$$

where:

- $$N = 32$$ is the number of samples per prompt and $$n$$ the best-of-n size;
- $$g_{(i)}$$ is the gold reward of the sample with the $$i$$-th smallest *proxy* reward;
- $$\binom{i-1}{n-1} / \binom{N}{n}$$ is the probability that this sample is the one kept.

**Worked example.** For $$n = 2$$, the proxy's favourite ($$i = 32$$) has weight $$\binom{31}{1} / \binom{32}{2} = 31 / 496 = 0.0625$$, which is just $$2/32$$, the chance that it is one of the two drawn. The second-lowest sample ($$i = 2$$) has weight $$1/496$$: it is kept only if it is drawn together with the very lowest one. Averaging over all subsets this way is exact and has no sampling noise.

```python
# simplified from ch7_bon.py
def bon(proxy, target, n):                       # proxy, target: arrays of shape (prompts, 32)
    tot = 0.0
    for p, t in zip(proxy, target):
        order = np.argsort(p)                     # samples from lowest to highest proxy reward
        w = np.array([math.comb(i, n - 1) for i in range(N)]) / math.comb(N, n)   # i = number of samples below
        tot += np.dot(w, t[order])
    return tot / len(proxy)
```

All rewards are first standardised (each model's rewards over the 3,200 samples get mean 0 and standard deviation 1), so proxy and gold are in comparable units, and each curve is measured from its value at $$n = 1$$.

```text
proxy     n=1     n=2     n=4     n=8     n=16    n=32      (rewards in sd units, change from n=1)
main      proxy +0.000 +0.382 +0.667 +0.886 +1.058 +1.190
          gold  +0.000 +0.215 +0.377 +0.505 +0.618 +0.732
small     proxy +0.000 +0.419 +0.739 +0.962 +1.108 +1.206
          gold  +0.000 +0.095 +0.187 +0.276 +0.358 +0.433
gold      proxy +0.000 +0.384 +0.706 +0.975 +1.201 +1.384
          gold  +0.000 +0.384 +0.706 +0.975 +1.201 +1.384
KL(best-of-n || policy) in nats: 0.000 0.193 0.636 1.204 1.835 2.497
```

<figure class="fig"><svg viewBox="0 0 800 374" role="img" aria-label="Two panels. For each proxy reward model, the proxy score of the best-of-n answer rises steeply with n, while the gold score rises much less."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">Best-of-n on 100 prompts x 32 samples: what the proxy promises and what the gold RM sees</text><text class="t-tick t-strong" x="80.0" y="54.0" text-anchor="start">proxy = our RM (3,200 pairs)</text><line class="grid" x1="80" y1="270.0" x2="360" y2="270.0"/><text class="t-tick" x="72.0" y="274.0" text-anchor="end">0</text><line class="grid" x1="80" y1="203.3" x2="360" y2="203.3"/><text class="t-tick" x="72.0" y="207.3" text-anchor="end">+0.5</text><line class="grid" x1="80" y1="136.7" x2="360" y2="136.7"/><text class="t-tick" x="72.0" y="140.7" text-anchor="end">+1.0</text><line class="grid" x1="80" y1="70.0" x2="360" y2="70.0"/><text class="t-tick" x="72.0" y="74.0" text-anchor="end">+1.5</text><text class="t-tick" x="80.0" y="290.0" text-anchor="middle">1</text><text class="t-tick" x="157.9" y="290.0" text-anchor="middle">2</text><text class="t-tick" x="221.3" y="290.0" text-anchor="middle">4</text><text class="t-tick" x="274.5" y="290.0" text-anchor="middle">8</text><text class="t-tick" x="320.0" y="290.0" text-anchor="middle">16</text><text class="t-tick" x="360.0" y="290.0" text-anchor="middle">32</text><text class="t-muted" x="220.0" y="308.0" text-anchor="middle">n (x axis: square root of KL)</text><polyline class="l1" stroke-dasharray="6 4" points="80.0,270.0 157.9,219.1 221.3,181.1 274.5,151.9 320.0,128.9 360.0,111.3"/><polyline class="l3" points="80.0,270.0 157.9,241.4 221.3,219.8 274.5,202.7 320.0,187.6 360.0,172.4"/><circle class="s1 ring" cx="80.0" cy="270.0" r="3.5"/><circle class="s3 ring" cx="80.0" cy="270.0" r="3.5"/><circle class="s1 ring" cx="157.9" cy="219.1" r="3.5"/><circle class="s3 ring" cx="157.9" cy="241.4" r="3.5"/><circle class="s1 ring" cx="221.3" cy="181.1" r="3.5"/><circle class="s3 ring" cx="221.3" cy="219.8" r="3.5"/><circle class="s1 ring" cx="274.5" cy="151.9" r="3.5"/><circle class="s3 ring" cx="274.5" cy="202.7" r="3.5"/><circle class="s1 ring" cx="320.0" cy="128.9" r="3.5"/><circle class="s3 ring" cx="320.0" cy="187.6" r="3.5"/><circle class="s1 ring" cx="360.0" cy="111.3" r="3.5"/><circle class="s3 ring" cx="360.0" cy="172.4" r="3.5"/><text class="t-val" x="366.0" y="115.3" text-anchor="start">+1.19</text><text class="t-val" x="366.0" y="176.4" text-anchor="start">+0.73</text><text class="t-tick t-strong" x="470.0" y="54.0" text-anchor="start">proxy = small RM (400 pairs)</text><line class="grid" x1="470" y1="270.0" x2="750" y2="270.0"/><text class="t-tick" x="462.0" y="274.0" text-anchor="end">0</text><line class="grid" x1="470" y1="203.3" x2="750" y2="203.3"/><text class="t-tick" x="462.0" y="207.3" text-anchor="end">+0.5</text><line class="grid" x1="470" y1="136.7" x2="750" y2="136.7"/><text class="t-tick" x="462.0" y="140.7" text-anchor="end">+1.0</text><line class="grid" x1="470" y1="70.0" x2="750" y2="70.0"/><text class="t-tick" x="462.0" y="74.0" text-anchor="end">+1.5</text><text class="t-tick" x="470.0" y="290.0" text-anchor="middle">1</text><text class="t-tick" x="547.9" y="290.0" text-anchor="middle">2</text><text class="t-tick" x="611.3" y="290.0" text-anchor="middle">4</text><text class="t-tick" x="664.5" y="290.0" text-anchor="middle">8</text><text class="t-tick" x="710.0" y="290.0" text-anchor="middle">16</text><text class="t-tick" x="750.0" y="290.0" text-anchor="middle">32</text><text class="t-muted" x="610.0" y="308.0" text-anchor="middle">n (x axis: square root of KL)</text><polyline class="l1" stroke-dasharray="6 4" points="470.0,270.0 547.9,214.2 611.3,171.4 664.5,141.8 710.0,122.3 750.0,109.2"/><polyline class="l3" points="470.0,270.0 547.9,257.3 611.3,245.0 664.5,233.2 710.0,222.3 750.0,212.3"/><circle class="s1 ring" cx="470.0" cy="270.0" r="3.5"/><circle class="s3 ring" cx="470.0" cy="270.0" r="3.5"/><circle class="s1 ring" cx="547.9" cy="214.2" r="3.5"/><circle class="s3 ring" cx="547.9" cy="257.3" r="3.5"/><circle class="s1 ring" cx="611.3" cy="171.4" r="3.5"/><circle class="s3 ring" cx="611.3" cy="245.0" r="3.5"/><circle class="s1 ring" cx="664.5" cy="141.8" r="3.5"/><circle class="s3 ring" cx="664.5" cy="233.2" r="3.5"/><circle class="s1 ring" cx="710.0" cy="122.3" r="3.5"/><circle class="s3 ring" cx="710.0" cy="222.3" r="3.5"/><circle class="s1 ring" cx="750.0" cy="109.2" r="3.5"/><circle class="s3 ring" cx="750.0" cy="212.3" r="3.5"/><text class="t-val" x="756.0" y="113.2" text-anchor="start">+1.21</text><text class="t-val" x="756.0" y="216.3" text-anchor="start">+0.43</text><line class="l1" x1="160" y1="337" x2="182" y2="337" stroke-dasharray="6 4"/><text class="t-tick" x="188.0" y="341.0" text-anchor="start">proxy reward of the kept answer (dashed)</text><line class="l3" x1="480.0" y1="337" x2="502.0" y2="337"/><text class="t-tick" x="508.0" y="341.0" text-anchor="start">gold reward of the same answer</text><text class="t-muted" x="20.0" y="362.0" text-anchor="start">Rewards in units of each model's standard deviation over all samples, measured from n = 1.</text></svg><figcaption>Best-of-n with our reward models as the proxy. Dashed: the proxy reward of the kept answer, what the optimiser "thinks" it achieved. Solid: the gold reward of the same answer. For both proxies the gold improves, but much less than promised, and the shortfall grows with n. The weaker proxy delivers about a third of its promise.</figcaption></figure>

What we see:

- **The gold still improves.** Best-of-32 against our reward model raises the gold reward by 0.73 standard deviations. The proxy is not useless: picking what it likes helps.
- **The proxy over-promises, more and more.** At $$n = 2$$ the proxy claims +0.38 and the gold confirms +0.22, 56% of the claim. At $$n = 32$$ the claim is +1.19 and the gold confirms +0.73, 62%. In absolute terms the gap between the dashed and solid lines widens from 0.17 to 0.46. That widening gap is the beginning of overoptimisation.
- **A weaker proxy over-promises much more.** The 400-pair reward model promises almost the same (+1.21) but delivers +0.43, 36% of its claim. Its rankings within a prompt correlate only 0.21 with the gold's, against 0.52 for the main model.
- **The ceiling.** Using the gold model itself as the selector gives +1.38: that is what perfect agreement with the gold would buy at $$n = 32$$.
- **No peak yet.** Fitting Gao et al.'s form $$d(\alpha - \beta d)$$ to our gold curve gives $$\alpha = 0.479$$ and a $$\beta$$ of only 0.012: the curve is still almost a straight line in $$d$$. Our largest $$n$$ reaches a KL of 2.5 nats ($$d = 1.58$$), the far left of Gao et al.'s plots, where their gold curves also still rise. Seeing the turn-down by best-of-n alone would take thousands of samples per prompt. PPO travels much further in KL, which is why Chapter 8 needs a leash.

```text
main: picks the gold favourite of 32 in 0.22 of prompts; mean within-prompt rank correlation with gold 0.517
small: picks the gold favourite of 32 in 0.13 of prompts; mean within-prompt rank correlation with gold 0.209
```

What does a disagreement look like? The prompt where our reward model's favourite was furthest below the gold's favourite asks for a question whose answer is "break up", given a passage about Pangaea:

```text
  proxy pick: proxy +1.83, gold -0.05: 'Question: What happened at the end of the Mesozoic era when Pangaea broke apart? This question directly corresponds to the given answer "break up". It prompts the user to correctly identify the major '
  gold pick:  proxy +1.31, gold +2.61: 'Question: What phenomenon caused Pangaea to begin breaking apart millions of years ago?'
```

Our reward model prefers the answer that keeps talking, explaining its own question at length (and getting cut off); the gold model prefers the short question that does exactly what was asked. One example proves nothing, but it is the pattern Sections 7.8 and 7.9 predicted.

### What best-of-n selects

<figure class="fig"><svg viewBox="0 0 820 320" role="img" aria-label="Two line charts against n. Left: the share of kept answers that finished rises for every selector. Right: the length of the kept answer stays flat for our reward model and falls for the small and gold models."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">What does best-of-n select? Share of kept answers that finished, and their length</text><line class="grid" x1="60" y1="270.0" x2="310" y2="270.0"/><text class="t-tick" x="52.0" y="274.0" text-anchor="end">20%</text><line class="grid" x1="60" y1="228.0" x2="310" y2="228.0"/><text class="t-tick" x="52.0" y="232.0" text-anchor="end">30%</text><line class="grid" x1="60" y1="186.0" x2="310" y2="186.0"/><text class="t-tick" x="52.0" y="190.0" text-anchor="end">40%</text><line class="grid" x1="60" y1="144.0" x2="310" y2="144.0"/><text class="t-tick" x="52.0" y="148.0" text-anchor="end">50%</text><line class="grid" x1="60" y1="102.0" x2="310" y2="102.0"/><text class="t-tick" x="52.0" y="106.0" text-anchor="end">60%</text><line class="grid" x1="60" y1="60.0" x2="310" y2="60.0"/><text class="t-tick" x="52.0" y="64.0" text-anchor="end">70%</text><text class="t-tick" x="60.0" y="288.0" text-anchor="middle">1</text><text class="t-tick" x="110.0" y="288.0" text-anchor="middle">2</text><text class="t-tick" x="160.0" y="288.0" text-anchor="middle">4</text><text class="t-tick" x="210.0" y="288.0" text-anchor="middle">8</text><text class="t-tick" x="260.0" y="288.0" text-anchor="middle">16</text><text class="t-tick" x="310.0" y="288.0" text-anchor="middle">32</text><line class="axis" x1="60" y1="270" x2="310" y2="270"/><polyline class="l1" points="60.0,238.6 110.0,223.9 160.0,208.8 210.0,192.9 260.0,174.0 310.0,156.6"/><g class="mark"><title>our RM: 1, 27%</title><circle class="s1 ring" cx="60.0" cy="238.6" r="4"/></g><g class="mark"><title>our RM: 2, 31%</title><circle class="s1 ring" cx="110.0" cy="223.9" r="4"/></g><g class="mark"><title>our RM: 4, 35%</title><circle class="s1 ring" cx="160.0" cy="208.8" r="4"/></g><g class="mark"><title>our RM: 8, 38%</title><circle class="s1 ring" cx="210.0" cy="192.9" r="4"/></g><g class="mark"><title>our RM: 16, 43%</title><circle class="s1 ring" cx="260.0" cy="174.0" r="4"/></g><g class="mark"><title>our RM: 32, 47%</title><circle class="s1 ring" cx="310.0" cy="156.6" r="4"/></g><polyline class="l2" points="60.0,238.6 110.0,203.2 160.0,168.0 210.0,137.5 260.0,115.8 310.0,102.0"/><g class="mark"><title>small RM: 1, 27%</title><circle class="s2 ring" cx="60.0" cy="238.6" r="4"/></g><g class="mark"><title>small RM: 2, 36%</title><circle class="s2 ring" cx="110.0" cy="203.2" r="4"/></g><g class="mark"><title>small RM: 4, 44%</title><circle class="s2 ring" cx="160.0" cy="168.0" r="4"/></g><g class="mark"><title>small RM: 8, 52%</title><circle class="s2 ring" cx="210.0" cy="137.5" r="4"/></g><g class="mark"><title>small RM: 16, 57%</title><circle class="s2 ring" cx="260.0" cy="115.8" r="4"/></g><g class="mark"><title>small RM: 32, 60%</title><circle class="s2 ring" cx="310.0" cy="102.0" r="4"/></g><polyline class="l4" points="60.0,238.6 110.0,216.3 160.0,196.0 210.0,177.0 260.0,157.9 310.0,139.8"/><g class="mark"><title>ensemble: 1, 27%</title><circle class="s4 ring" cx="60.0" cy="238.6" r="4"/></g><g class="mark"><title>ensemble: 2, 33%</title><circle class="s4 ring" cx="110.0" cy="216.3" r="4"/></g><g class="mark"><title>ensemble: 4, 38%</title><circle class="s4 ring" cx="160.0" cy="196.0" r="4"/></g><g class="mark"><title>ensemble: 8, 42%</title><circle class="s4 ring" cx="210.0" cy="177.0" r="4"/></g><g class="mark"><title>ensemble: 16, 47%</title><circle class="s4 ring" cx="260.0" cy="157.9" r="4"/></g><g class="mark"><title>ensemble: 32, 51%</title><circle class="s4 ring" cx="310.0" cy="139.8" r="4"/></g><polyline class="l3" points="60.0,238.6 110.0,221.2 160.0,203.7 210.0,185.7 260.0,163.6 310.0,131.4"/><g class="mark"><title>gold RM: 1, 27%</title><circle class="s3 ring" cx="60.0" cy="238.6" r="4"/></g><g class="mark"><title>gold RM: 2, 32%</title><circle class="s3 ring" cx="110.0" cy="221.2" r="4"/></g><g class="mark"><title>gold RM: 4, 36%</title><circle class="s3 ring" cx="160.0" cy="203.7" r="4"/></g><g class="mark"><title>gold RM: 8, 40%</title><circle class="s3 ring" cx="210.0" cy="185.7" r="4"/></g><g class="mark"><title>gold RM: 16, 45%</title><circle class="s3 ring" cx="260.0" cy="163.6" r="4"/></g><g class="mark"><title>gold RM: 32, 53%</title><circle class="s3 ring" cx="310.0" cy="131.4" r="4"/></g><rect class="s2" x="322.0" y="97.0" width="10" height="10" rx="2"/><text class="t-tick" x="337.0" y="106.0" text-anchor="start">small RM</text><rect class="s3" x="322.0" y="126.4" width="10" height="10" rx="2"/><text class="t-tick" x="337.0" y="135.4" text-anchor="start">gold RM</text><rect class="s4" x="322.0" y="142.4" width="10" height="10" rx="2"/><text class="t-tick" x="337.0" y="151.4" text-anchor="start">ensemble</text><rect class="s1" x="322.0" y="158.4" width="10" height="10" rx="2"/><text class="t-tick" x="337.0" y="167.4" text-anchor="start">our RM</text><text class="t-muted" x="185.0" y="308.0" text-anchor="middle">n (log scale)</text><text class="t-muted" x="52.0" y="44.0" text-anchor="start">kept answer ended within 256 tokens</text><line class="grid" x1="470" y1="270.0" x2="690" y2="270.0"/><text class="t-tick" x="462.0" y="274.0" text-anchor="end">120</text><line class="grid" x1="470" y1="228.0" x2="690" y2="228.0"/><text class="t-tick" x="462.0" y="232.0" text-anchor="end">130</text><line class="grid" x1="470" y1="186.0" x2="690" y2="186.0"/><text class="t-tick" x="462.0" y="190.0" text-anchor="end">140</text><line class="grid" x1="470" y1="144.0" x2="690" y2="144.0"/><text class="t-tick" x="462.0" y="148.0" text-anchor="end">150</text><line class="grid" x1="470" y1="102.0" x2="690" y2="102.0"/><text class="t-tick" x="462.0" y="106.0" text-anchor="end">160</text><line class="grid" x1="470" y1="60.0" x2="690" y2="60.0"/><text class="t-tick" x="462.0" y="64.0" text-anchor="end">170</text><text class="t-tick" x="470.0" y="288.0" text-anchor="middle">1</text><text class="t-tick" x="514.0" y="288.0" text-anchor="middle">2</text><text class="t-tick" x="558.0" y="288.0" text-anchor="middle">4</text><text class="t-tick" x="602.0" y="288.0" text-anchor="middle">8</text><text class="t-tick" x="646.0" y="288.0" text-anchor="middle">16</text><text class="t-tick" x="690.0" y="288.0" text-anchor="middle">32</text><line class="axis" x1="470" y1="270" x2="690" y2="270"/><polyline class="l1" points="470.0,124.7 514.0,128.3 558.0,130.8 602.0,130.7 646.0,130.0 690.0,125.6"/><g class="mark"><title>our RM: 1, 154.591875</title><circle class="s1 ring" cx="470.0" cy="124.7" r="4"/></g><g class="mark"><title>our RM: 2, 153.74647177419357</title><circle class="s1 ring" cx="514.0" cy="128.3" r="4"/></g><g class="mark"><title>our RM: 4, 153.14328642936593</title><circle class="s1 ring" cx="558.0" cy="130.8" r="4"/></g><g class="mark"><title>our RM: 8, 153.156389449816</title><circle class="s1 ring" cx="602.0" cy="130.7" r="4"/></g><g class="mark"><title>our RM: 16, 153.32999548463062</title><circle class="s1 ring" cx="646.0" cy="130.0" r="4"/></g><g class="mark"><title>our RM: 32, 154.37</title><circle class="s1 ring" cx="690.0" cy="125.6" r="4"/></g><polyline class="l2" points="470.0,124.7 514.0,155.5 558.0,181.0 602.0,201.3 646.0,215.3 690.0,221.7"/><g class="mark"><title>small RM: 1, 154.591875</title><circle class="s2 ring" cx="470.0" cy="124.7" r="4"/></g><g class="mark"><title>small RM: 2, 147.26693548387095</title><circle class="s2 ring" cx="514.0" cy="155.5" r="4"/></g><g class="mark"><title>small RM: 4, 141.1915711902114</title><circle class="s2 ring" cx="558.0" cy="181.0" r="4"/></g><g class="mark"><title>small RM: 8, 136.35248050825706</title><circle class="s2 ring" cx="602.0" cy="201.3" r="4"/></g><g class="mark"><title>small RM: 16, 133.03384393117528</title><circle class="s2 ring" cx="646.0" cy="215.3" r="4"/></g><g class="mark"><title>small RM: 32, 131.5</title><circle class="s2 ring" cx="690.0" cy="221.7" r="4"/></g><polyline class="l4" points="470.0,124.7 514.0,136.2 558.0,143.2 602.0,144.7 646.0,143.0 690.0,133.9"/><g class="mark"><title>ensemble: 1, 154.591875</title><circle class="s4 ring" cx="470.0" cy="124.7" r="4"/></g><g class="mark"><title>ensemble: 2, 151.84981854838713</title><circle class="s4 ring" cx="514.0" cy="136.2" r="4"/></g><g class="mark"><title>ensemble: 4, 150.1949521690767</title><circle class="s4 ring" cx="558.0" cy="143.2" r="4"/></g><g class="mark"><title>ensemble: 8, 149.83279534335395</title><circle class="s4 ring" cx="602.0" cy="144.7" r="4"/></g><g class="mark"><title>ensemble: 16, 150.23558872777394</title><circle class="s4 ring" cx="646.0" cy="143.0" r="4"/></g><g class="mark"><title>ensemble: 32, 152.4</title><circle class="s4 ring" cx="690.0" cy="133.9" r="4"/></g><polyline class="l3" points="470.0,124.7 514.0,145.8 558.0,166.4 602.0,186.4 646.0,206.1 690.0,225.2"/><g class="mark"><title>gold RM: 1, 154.591875</title><circle class="s3 ring" cx="470.0" cy="124.7" r="4"/></g><g class="mark"><title>gold RM: 2, 149.56288306451614</title><circle class="s3 ring" cx="514.0" cy="145.8" r="4"/></g><g class="mark"><title>gold RM: 4, 144.65781618464965</title><circle class="s3 ring" cx="558.0" cy="166.4" r="4"/></g><g class="mark"><title>gold RM: 8, 139.91494152001746</title><circle class="s3 ring" cx="602.0" cy="186.4" r="4"/></g><g class="mark"><title>gold RM: 16, 135.21494875796895</title><circle class="s3 ring" cx="646.0" cy="206.1" r="4"/></g><g class="mark"><title>gold RM: 32, 130.66</title><circle class="s3 ring" cx="690.0" cy="225.2" r="4"/></g><rect class="s1" x="702.0" y="120.6" width="10" height="10" rx="2"/><text class="t-tick" x="717.0" y="129.6" text-anchor="start">our RM</text><rect class="s4" x="702.0" y="136.6" width="10" height="10" rx="2"/><text class="t-tick" x="717.0" y="145.6" text-anchor="start">ensemble</text><rect class="s2" x="702.0" y="216.7" width="10" height="10" rx="2"/><text class="t-tick" x="717.0" y="225.7" text-anchor="start">small RM</text><rect class="s3" x="702.0" y="232.7" width="10" height="10" rx="2"/><text class="t-tick" x="717.0" y="241.7" text-anchor="start">gold RM</text><text class="t-muted" x="580.0" y="308.0" text-anchor="middle">n (log scale)</text><text class="t-muted" x="462.0" y="44.0" text-anchor="start">words in the kept answer</text></svg><figcaption>What the selectors pick as n grows. Left: every selector, gold included, increasingly picks answers that finished within 256 tokens, since a cut-off answer is a worse answer. Right: the gold model also picks shorter answers (from 155 to 131 words), while our reward model keeps the length flat.</figcaption></figure>

```text
main      words  154.6  153.7  153.1  153.2  153.3  154.4
          done    0.27   0.31   0.35   0.38   0.43   0.47
gold      words  154.6  149.6  144.7  139.9  135.2  130.7
          done    0.27   0.32   0.36   0.40   0.45   0.53
```

Because three quarters of the samples are cut off, "did it finish?" dominates the selection here, and all selectors learn to prefer finished answers. The interesting difference is length: as $$n$$ grows, the gold model trades length away, our reward model does not. This is the length tilt of Section 7.9 seen under optimisation.

To check that cut-off answers are not the whole story, `ch7_bon.py` repeats the analysis using only finished answers, on the 35 prompts that have at least 8 of them (so $$n$$ goes up to 8):

```text
finished answers only: 35 prompts with at least 8 finished answers (of 32)
main      proxy +0.000 +0.349 +0.585 +0.746 | gold +0.000 +0.199 +0.311 +0.390 | words 88 89 91 96
small     proxy +0.000 +0.100 +0.173 +0.227 | gold +0.000 +0.119 +0.189 +0.219 | words 88 86 84 82
gold      proxy +0.000 +0.394 +0.689 +0.919 | gold +0.000 +0.394 +0.689 +0.919 | words 88 80 73 70
```

Among finished answers the same picture holds: our reward model's picks gain 0.39 gold for 0.75 promised, and grow *longer* (88 to 96 words) while the gold model's picks grow shorter (88 to 70).

## 7.11 Defences: margins, ensembles and a leash

No single trick removes overoptimisation, but several reduce it. We look at three, two of which we can test with the reward models we already trained.

### Margins: using how strongly people preferred

Llama 2 asked labelers not just which answer was better but by how much, on a four-level scale. Its reward model loss uses that grade:

> [!PAPER] Touvron et al. (2023), Llama 2 · Section 3.2.2 · page 11
> [![Llama 2 equation 2: the ranking loss minus log sigma of the reward of the chosen response minus the reward of the rejected response minus a margin m of r, where the margin is a discrete function of the preference rating, large for distinct responses and small for similar ones; the margin improves helpfulness reward model accuracy especially on more separable samples](https://ishwarj.com/img/training/ch7-llama2-margin.png7-llama2-margin.png)](/img/training/ch7-llama2-margin.png)
>
> **Context:** the training objective of the Llama 2 reward models.
>
> **What it says:** a margin $$m(r)$$, "a discrete function of the preference rating", is subtracted from the reward gap. "We use a large margin for pairs with distinct responses, and a smaller one for those with similar responses."
>
> **Why it matters:** the plain loss treats a landslide and a coin flip the same. The margin asks the model to separate clearly different answers by more.

$$
\mathcal{L}_{\text{ranking}} = -\log \sigma\big(r_\theta(x, y_c) - r_\theta(x, y_r) - m(r)\big)
$$

where:

- $$y_c$$ and $$y_r$$ are the chosen and rejected responses (Llama 2's names for $$y_w$$ and $$y_l$$);
- $$m(r)$$ is the margin, a number that depends on the preference rating $$r$$ of the pair (here $$r$$ is the labeler's grade, not a reward);
- everything else is as in Section 7.4.

The loss is now small only when the gap exceeds the margin. For a pair with margin 3 and a gap of 0.9, the loss is $$-\log\sigma(0.9 - 3) = -\log\sigma(-2.1) = 2.22$$ instead of 0.34: the model is told that 0.9 is not enough for a "significantly better" pair.

The margins Llama 2 used, and what they gained:

> [!PAPER] Touvron et al. (2023) · Tables 27 and 28 · page 52
> [![Table 27: two margin variants, small (1, 2/3, 1/3, 0) and large (3, 2, 1, 0) for significantly better, better, slightly better and negligibly better. Table 28: helpfulness reward model accuracy per rating: no margin 79.1, 66.9, 59.8, 54.5, average 62.5; margin small 80.4, 67.3, 60.4, 55.0, average 63.0; margin large 80.7, 67.5, 60.5, 54.3, average 62.9](https://ishwarj.com/img/training/ch7-llama2-table27.png-llama2-table27.png)](/img/training/ch7-llama2-table27.png)
>
> **Context:** the appendix ablation of the margin term.
>
> **What it says:** the large margin raises accuracy on "significantly better" pairs from 79.1% to 80.7%, while the average moves from 62.5% to 62.9%; it slightly hurts the closest pairs (54.5% to 54.3%).
>
> **Why it matters:** the gain is real but small, and concentrated on easy pairs. The appendix also notes that the margin pushes the reward distribution toward "more extreme scores", a side effect that matters for RL.

The same paper reports how accuracy depends on how distinct the two responses are, which is a useful way to read any reward model's accuracy:

> [!PAPER] Touvron et al. (2023) · Table 8 · page 12
> [![Llama 2 Table 8: accuracy per preference rating; the helpfulness reward model on the Meta helpfulness test set is 80.7% on significantly better pairs, 67.5% better, 60.9% slightly better, 54.7% negligibly better or unsure, average 63.2%](https://ishwarj.com/img/training/ch7-llama2-table8.png7-llama2-table8.png)](/img/training/ch7-llama2-table8.png)
>
> **Context:** the reward model results section.
>
> **What it says:** even Meta's helpfulness reward model, trained on over a million comparisons, is right only 54.7% of the time on pairs labelers themselves found negligibly different, and 80.7% on clearly different ones.
>
> **Why it matters:** an "average accuracy" of 63% sounds poor until you see that most comparisons are close calls. Our UltraFeedback rating gaps let us make the same table.

We trained a reward model with Llama 2's "margin large" (margins 0, 1, 2 and 3 for our four rating-gap buckets) and compared it with the plain loss **at the same learning rate, data, seed and schedule** ($$10^{-4}$$; Section 7.7 explained why our main model uses $$3 \times 10^{-4}$$):

```text
  lr1     accuracy 0.627  reward sd 1.212
  margin  accuracy 0.697  reward sd 3.299
  main    accuracy 0.695  reward sd 1.690
  share of pairs with |reward gap| > 2: main 0.242, lr1 0.093, margin 0.538
```

<figure class="fig"><svg viewBox="0 0 800 316" role="img" aria-label="Two histograms of reward gaps: the margin-trained model spreads its gaps more widely than the plain one."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">Reward gaps on the 600 test pairs: plain loss against the Llama 2 margin loss (same data, seed and lr)</text><polyline class="l1" points="60.0,250.0 60.0,250.0 71.8,250.0 71.8,250.0 83.6,250.0 83.6,250.0 95.4,250.0 95.4,250.0 107.1,250.0 107.1,250.0 118.9,250.0 118.9,250.0 130.7,250.0 130.7,250.0 142.5,250.0 142.5,250.0 154.3,250.0 154.3,250.0 166.1,250.0 166.1,250.0 177.9,250.0 177.9,250.0 189.6,250.0 189.6,250.0 201.4,250.0 201.4,250.0 213.2,250.0 213.2,250.0 225.0,250.0 225.0,250.0 236.8,250.0 236.8,248.4 248.6,248.4 248.6,250.0 260.4,250.0 260.4,248.4 272.1,248.4 272.1,248.4 283.9,248.4 283.9,238.7 295.7,238.7 295.7,237.1 307.5,237.1 307.5,203.2 319.3,203.2 319.3,143.5 331.1,143.5 331.1,71.0 342.9,71.0 342.9,50.0 354.6,50.0 354.6,83.9 366.4,83.9 366.4,138.7 378.2,138.7 378.2,195.2 390.0,195.2 390.0,217.7 401.8,217.7 401.8,224.2 413.6,224.2 413.6,240.3 425.4,240.3 425.4,246.8 437.1,246.8 437.1,248.4 448.9,248.4 448.9,250.0 460.7,250.0 460.7,250.0 472.5,250.0 472.5,250.0 484.3,250.0 484.3,248.4 496.1,248.4 496.1,250.0 507.9,250.0 507.9,250.0 519.6,250.0 519.6,250.0 531.4,250.0 531.4,250.0 543.2,250.0 543.2,250.0 555.0,250.0 555.0,250.0 566.8,250.0 566.8,250.0 578.6,250.0 578.6,250.0 590.4,250.0 590.4,250.0 602.1,250.0 602.1,250.0 613.9,250.0 613.9,250.0 625.7,250.0 625.7,250.0 637.5,250.0 637.5,250.0 649.3,250.0 649.3,250.0 661.1,250.0 661.1,250.0 672.9,250.0 672.9,250.0 684.6,250.0 684.6,250.0 696.4,250.0 696.4,250.0 708.2,250.0 708.2,250.0 720.0,250.0 720.0,250.0"/><polyline class="l2" points="60.0,250.0 60.0,248.4 71.8,248.4 71.8,250.0 83.6,250.0 83.6,250.0 95.4,250.0 95.4,250.0 107.1,250.0 107.1,250.0 118.9,250.0 118.9,250.0 130.7,250.0 130.7,250.0 142.5,250.0 142.5,248.4 154.3,248.4 154.3,248.4 166.1,248.4 166.1,250.0 177.9,250.0 177.9,250.0 189.6,250.0 189.6,245.2 201.4,245.2 201.4,246.8 213.2,246.8 213.2,246.8 225.0,246.8 225.0,243.5 236.8,243.5 236.8,238.7 248.6,238.7 248.6,243.5 260.4,243.5 260.4,235.5 272.1,235.5 272.1,227.4 283.9,227.4 283.9,225.8 295.7,225.8 295.7,227.4 307.5,227.4 307.5,185.5 319.3,185.5 319.3,203.2 331.1,203.2 331.1,191.9 342.9,191.9 342.9,187.1 354.6,187.1 354.6,193.5 366.4,193.5 366.4,185.5 378.2,185.5 378.2,179.0 390.0,179.0 390.0,200.0 401.8,200.0 401.8,209.7 413.6,209.7 413.6,196.8 425.4,196.8 425.4,203.2 437.1,203.2 437.1,217.7 448.9,217.7 448.9,212.9 460.7,212.9 460.7,217.7 472.5,217.7 472.5,232.3 484.3,232.3 484.3,224.2 496.1,224.2 496.1,245.2 507.9,245.2 507.9,241.9 519.6,241.9 519.6,240.3 531.4,240.3 531.4,237.1 543.2,237.1 543.2,241.9 555.0,241.9 555.0,246.8 566.8,246.8 566.8,238.7 578.6,238.7 578.6,241.9 590.4,241.9 590.4,245.2 602.1,245.2 602.1,245.2 613.9,245.2 613.9,248.4 625.7,248.4 625.7,248.4 637.5,248.4 637.5,248.4 649.3,248.4 649.3,250.0 661.1,250.0 661.1,250.0 672.9,250.0 672.9,250.0 684.6,250.0 684.6,250.0 696.4,250.0 696.4,248.4 708.2,248.4 708.2,248.4 720.0,248.4 720.0,250.0"/><line class="axis" x1="60" y1="250" x2="720" y2="250"/><text class="t-tick" x="60.0" y="266.0" text-anchor="middle">-12</text><text class="t-tick" x="107.1" y="266.0" text-anchor="middle">-10</text><text class="t-tick" x="154.3" y="266.0" text-anchor="middle">-8</text><text class="t-tick" x="201.4" y="266.0" text-anchor="middle">-6</text><text class="t-tick" x="248.6" y="266.0" text-anchor="middle">-4</text><text class="t-tick" x="295.7" y="266.0" text-anchor="middle">-2</text><text class="t-tick" x="342.9" y="266.0" text-anchor="middle">0</text><text class="t-tick" x="390.0" y="266.0" text-anchor="middle">2</text><text class="t-tick" x="437.1" y="266.0" text-anchor="middle">4</text><text class="t-tick" x="484.3" y="266.0" text-anchor="middle">6</text><text class="t-tick" x="531.4" y="266.0" text-anchor="middle">8</text><text class="t-tick" x="578.6" y="266.0" text-anchor="middle">10</text><text class="t-tick" x="625.7" y="266.0" text-anchor="middle">12</text><text class="t-tick" x="672.9" y="266.0" text-anchor="middle">14</text><text class="t-tick" x="720.0" y="266.0" text-anchor="middle">16</text><text class="t-muted" x="390.0" y="284.0" text-anchor="middle">reward gap r(chosen) - r(rejected)</text><line class="edge-dim" x1="342.9" y1="50" x2="342.9" y2="250"/><line class="l1" x1="40" y1="297" x2="62" y2="297"/><text class="t-tick" x="68.0" y="301.0" text-anchor="start">plain, lr 1e-4 (sd of rewards 1.21, accuracy 62.7%)</text><line class="l2" x1="437.0" y1="297" x2="459.0" y2="297"/><text class="t-tick" x="465.0" y="301.0" text-anchor="start">margin (sd 3.30, accuracy 69.7%)</text></svg><figcaption>Reward gaps on the test pairs for the plain loss and the margin loss, trained identically otherwise. The margin model spreads its scores almost three times as widely and pushes more than half of all pairs beyond a gap of 2, the "more extreme scores" Llama 2 reported.</figcaption></figure>

At first sight the margin is a big win: 69.7% against 62.7%, far more than Llama 2's half a point. But look at the third line. The plain loss with a three times larger learning rate reaches 69.5%, the same accuracy. The margin helped here mostly by *keeping the gradients large*: subtracting a margin keeps $$1 - \sigma(\Delta - m)$$ big even after the model has the pair right, so the model keeps learning, much like a larger learning rate. Once the plain loss is tuned, the margin's advantage disappears within our error bar, which matches Llama 2's small ablation. By rating gap (the table in Section 7.8), the margin model is slightly ahead of the tuned plain model on the two closest buckets (55.6% against 54.9%, 70.3% against 67.2%) and slightly behind on the two clearest (75.0% against 77.9%, 78.5% against 80.0%); none of these differences is beyond the noise of 130 to 190 pairs per bucket.

What the margin reliably changes is the *scale*: the standard deviation of its rewards is 3.3 against 1.7, and 54% of test pairs get a gap above 2 against 24%. For RL that is not a detail: the reward's scale sets how strongly PPO pushes relative to its KL penalty (Chapter 8). It is one more reason rewards are normalised before RL.

### Ensembles: several judges are harder to fool

If several reward models are trained independently (different seeds, different data), they make *different* mistakes. An answer that exploits one of them is less likely to exploit all of them. Christiano et al. already averaged an ensemble in 2017. Coste et al. (2023) tested ensembles specifically against overoptimisation, in Gao et al.'s gold-model setup:

> [!PAPER] Coste et al. (2023), Reward Model Ensembles Help Mitigate Overoptimization · Abstract · page 1
> [![Coste et al. abstract: a systematic study of ensemble-based conservative optimisation objectives, worst-case optimisation (WCO) and uncertainty-weighted optimisation (UWO), for best-of-n and PPO; conservative optimisation practically eliminates overoptimisation and improves performance by up to 70% for best-of-n sampling](https://ishwarj.com/img/training/ch7-coste-abstract.png-coste-abstract.png)](/img/training/ch7-coste-abstract.png)
>
> **Context:** the abstract.
>
> **What it says:** two conservative ways to combine an ensemble, **worst-case optimisation** (use the *minimum* reward over the members) and **uncertainty-weighted optimisation** (the mean minus a multiple of the members' disagreement), "practically eliminates overoptimization" for best-of-n.
>
> **Why it matters:** the minimum is a pessimistic judge: an answer scores high only if every member likes it. Eisenstein et al. (2023) later found that ensembles *mitigate but do not eliminate* reward hacking, because members trained on the same data share some of the same blind spots.


We have three reward models that differ only in seed and data shard: main, seed1 and seed2 (the last two trained on 1,600 pairs with $$10^{-4}$$, and therefore weaker). After scaling each to unit standard deviation, we combine them in two ways: the **mean** of the three rewards, and the **minimum** (Coste et al.'s worst case).

```text
  ensemble (mean of main, seed1, seed2 after scaling each to unit sd) accuracy 0.690
  the three agree on 0.73 of pairs: accuracy there 0.732; where they disagree 0.577
  correlation of rewards over the 1,200 answers: main-seed1 0.68, main-seed2 0.36, seed1-seed2 0.59, main-margin 0.83, main-gold 0.60, small-gold 0.27
```

<figure class="fig"><svg viewBox="0 0 800 312" role="img" aria-label="Horizontal bars of accuracy for each reward model: more training data helps, the ensemble and margin are close to the main model, the gold model is best."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="40.0" text-anchor="start">Accuracy on the same 600 held-out pairs (name: training pairs, learning rate)</text><text class="t-tick" x="222.0" y="68.0" text-anchor="end">small: 400, 1e-4</text><g class="mark"><title>small: 400, 1e-4: 65.2%</title><rect class="s1" x="230.0" y="53.0" width="260.7" height="20.0" rx="3"/></g><text class="t-val" x="496.7" y="68.0" text-anchor="start">65.2%</text><text class="t-tick" x="222.0" y="96.0" text-anchor="end">seed1: 1,600, 1e-4</text><g class="mark"><title>seed1: 1,600, 1e-4: 68.0%</title><rect class="s1" x="230.0" y="81.0" width="272.0" height="20.0" rx="3"/></g><text class="t-val" x="508.0" y="96.0" text-anchor="start">68.0%</text><text class="t-tick" x="222.0" y="124.0" text-anchor="end">seed2: 1,600, 1e-4</text><g class="mark"><title>seed2: 1,600, 1e-4: 64.8%</title><rect class="s1" x="230.0" y="109.0" width="259.3" height="20.0" rx="3"/></g><text class="t-val" x="495.3" y="124.0" text-anchor="start">64.8%</text><text class="t-tick" x="222.0" y="152.0" text-anchor="end">lr1: 3,200, 1e-4</text><g class="mark"><title>lr1: 3,200, 1e-4: 62.7%</title><rect class="s1" x="230.0" y="137.0" width="250.7" height="20.0" rx="3"/></g><text class="t-val" x="486.7" y="152.0" text-anchor="start">62.7%</text><text class="t-tick" x="222.0" y="180.0" text-anchor="end">margin: 3,200, 1e-4</text><g class="mark"><title>margin: 3,200, 1e-4: 69.7%</title><rect class="s1" x="230.0" y="165.0" width="278.7" height="20.0" rx="3"/></g><text class="t-val" x="514.7" y="180.0" text-anchor="start">69.7%</text><text class="t-tick t-strong" x="222.0" y="208.0" text-anchor="end">main: 3,200, 3e-4</text><g class="mark"><title>main: 3,200, 3e-4: 69.5%</title><rect class="s1" x="230.0" y="193.0" width="278.0" height="20.0" rx="3"/></g><text class="t-val" x="514.0" y="208.0" text-anchor="start">69.5%</text><text class="t-tick" x="222.0" y="236.0" text-anchor="end">ensemble: main+seed1+seed2</text><g class="mark"><title>ensemble: main+seed1+seed2: 69.0%</title><rect class="s1" x="230.0" y="221.0" width="276.0" height="20.0" rx="3"/></g><text class="t-val" x="512.0" y="236.0" text-anchor="start">69.0%</text><text class="t-tick" x="222.0" y="264.0" text-anchor="end">gold: Skywork V2</text><g class="mark"><title>gold: Skywork V2: 78.0%</title><rect class="s1" x="230.0" y="249.0" width="312.0" height="20.0" rx="3"/></g><text class="t-val" x="548.0" y="264.0" text-anchor="start">78.0%</text><text class="t-muted" x="20.0" y="296.0" text-anchor="start">The three ensemble members agree on 73% of pairs: accuracy 73.2% there, 57.7% where they disagree.</text></svg><figcaption>All the reward models of this chapter on the same 600 test pairs. More training data helps less than you might expect in this range; the learning rate matters a lot; the ensemble is no better than its best member; the gold model is in a different league.</figcaption></figure>

Three findings:

- **The ensemble's accuracy (69.0%) is no better than its best member (69.5%).** Averaging helps when members are about equally good and make independent errors. Ours are unequal: two weaker members dilute the strong one.
- **Disagreement is informative.** On the 73% of pairs where all three agree, the ensemble is right 73.2% of the time; where they disagree, 57.7%, little better than a coin. Disagreement between members is a cheap, useful signal of "the reward model does not know", which is exactly what uncertainty-weighted optimisation uses.
- **The members are less alike than you would think.** Trained on the same kind of data from the same backbone, two of them correlate only 0.36 across answers. Reward models are noisy functions; any single one has idiosyncrasies an optimiser can find.

Under best-of-n (same setup as Section 7.10):

```text
ens_mean  proxy +0.000 +0.289 +0.513 +0.690 +0.832 +0.944
          gold  +0.000 +0.190 +0.340 +0.456 +0.533 +0.535
ens_min   proxy +0.000 +0.326 +0.576 +0.770 +0.924 +1.057
          gold  +0.000 +0.166 +0.291 +0.381 +0.433 +0.472
```

Here the ensembles deliver *less* gold than our main model alone (+0.54 and +0.47 against +0.73 at $$n = 32$$), and the mean's gold curve flattens between $$n = 16$$ and $$n = 32$$. That is not a contradiction of Coste et al.: their members were equally strong and they measured far deeper into optimisation, where a single proxy collapses. With members this unequal and optimisation this light, the honest summary is: ensembles are a defence against *exploitation*, not a way to make a better reward model, and they only pay off when you optimise hard. They also cost one forward pass per member at every step of RL.

### The leash: a KL penalty

The most widely used defence is not about the reward model at all. It limits how far the policy may move from where it started. Chapter 6 introduced the per-token KL penalty: the reward the policy actually maximises is

$$
R(x, y) = r_\phi(x, y) - \beta\, \log \frac{\pi_\theta(y \mid x)}{\pi_{\text{ref}}(y \mid x)}
$$

where:

- $$r_\phi(x, y)$$ is the reward model's score (we write $$\phi$$ for its parameters, to keep $$\theta$$ for the policy);
- $$\pi_\theta$$ is the policy being trained and $$\pi_{\text{ref}}$$ the frozen starting model;
- $$\beta$$ is the strength of the penalty;
- the log-ratio, averaged over responses, is the KL divergence between the two models.

In the language of this section, the KL term caps how far to the right on Gao et al.'s curves the policy can go: it keeps the policy where the reward model was trained, among answers that look like the starting model's, where its judgements are still meaningful. Gao et al. found that, in their RL setup, the penalty did not change the shape of the gold-versus-KL curve; it mostly stops the run earlier on it. Chapter 8 sets $$\beta$$ for our reward model and watches the KL during training.

Other defences, briefly: collect fresh comparisons on the current policy's outputs and retrain the reward model during RL (Llama 2 did this over five rounds, and Christiano et al. showed that offline-only reward models get exploited); penalise length explicitly or train a separate length head and discard it (for example ODIN, Chen et al., 2024); and, where answers can be checked, use a checker instead of a learned reward (Chapter 2's RLVR).

## 7.12 Process rewards: grading the steps, not just the answer

Everything so far gives one reward for a whole response. For a multi-step maths solution that is a blunt signal: a solution with nine good steps and one slip gets the same low score as nonsense, and a solution that reaches the right number by a wrong argument gets full marks. A reward model that only sees outcomes is an **outcome reward model (ORM)**. The alternative is to judge every step.

> [!DEFINITION] Outcome and process reward models (ORM, PRM)
> An **outcome reward model** scores a whole solution, usually trained on whether its final answer is right. A **process reward model** scores each intermediate step (is this step correct?), trained on step-level labels.

Uesato et al. (2022) compared the two on grade-school maths (GSM8K). Outcome supervision reached similar final-answer error rates with fewer labels, but to get the *reasoning steps* right they needed process-based feedback, or a reward model trained to imitate it. Lightman et al. (2023), in "Let's Verify Step by Step", scaled the idea up. They had people label every step of 75,000 solutions to 12,000 MATH problems as positive, negative or neutral: 800,000 step labels in all (the PRM800K dataset):

> [!PAPER] Lightman et al. (2023), Let's Verify Step by Step · Figure 1 · page 4
> [![The PRM800K labelling interface: a MATH problem, a model solution split into steps, and for each step buttons to rate it as positive, neutral or negative](https://ishwarj.com/img/training/ch7-lightman-fig1.png7-lightman-fig1.png)](/img/training/ch7-lightman-fig1.png)
>
> **Context:** the data collection section.
>
> **What it says:** labelers see a problem and a model's solution split into lines, and rate each step.
>
> **Why it matters:** one solution yields many labels, and each label says *where* the solution went wrong, not just *that* it did. That is much richer feedback than one bit per solution, and also much more expensive to collect.

The PRM is a language model trained to predict, after each step, whether that step is correct. To compare solutions, it needs one number per solution:

> [!PAPER] Lightman et al. (2023) · Section 2.6 · page 6
> [![Lightman et al.: we define the PRM score for a solution to be the probability that every step is correct under the PRM, implemented as the product of the correctness probabilities for each step; process supervision deliberately supervises only up to the first incorrect step](https://ishwarj.com/img/training/ch7-lightman-score.png-lightman-score.png)](/img/training/ch7-lightman-score.png)
>
> **Context:** how the PRM's step scores become a solution score.
>
> **What it says:** "we define the PRM score for a solution to be the probability that every step is correct under the PRM. We implement this as the product of the correctness probabilities for each step."
>
> **Why it matters:** a product is dragged down by a single bad step. That is exactly the behaviour we want from a grader of reasoning.

As an equation:

$$
\text{score}(s) = \prod_{k=1}^{K} p_k
$$

where:

- $$s$$ is a solution made of $$K$$ steps;
- $$p_k$$ is the PRM's probability that step $$k$$ is correct;
- $$\prod$$ means "multiply together".

**Worked example** (illustrative step probabilities, computed by `ch7_bt.py`). A five-step solution where the PRM is confident in every step, $$0.98, 0.96, 0.97, 0.95, 0.94$$, scores $$0.815$$. A solution whose fourth step is wrong, $$0.98, 0.95, 0.97, 0.30, 0.90$$, scores $$0.244$$, although four of its five steps look fine. Taking the minimum step instead of the product gives 0.94 and 0.30, the same ordering.

```text
== 7. process reward: scoring a solution from its steps (illustrative step probabilities) ==
  right answer    steps [0.98, 0.96, 0.97, 0.95, 0.94]: product 0.815, minimum 0.94
  one wrong step  steps [0.98, 0.95, 0.97, 0.3, 0.9]: product 0.244, minimum 0.30
```

<figure class="fig"><svg viewBox="0 0 800 214" role="img" aria-label="Two solutions as rows of five steps with step probabilities; the product is 0.815 for the correct one and 0.244 for the one with a wrong fourth step."><defs><marker id="ah" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="arrow" d="M0,0L10,5L0,10z"/></marker><marker id="ah-on" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-on" d="M0,0L10,5L0,10z"/></marker><marker id="ah-2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path class="arrow-2" d="M0,0L10,5L0,10z"/></marker></defs><text class="t-title" x="20.0" y="24.0" text-anchor="start">Outcome reward vs process reward on a five-step solution (illustrative numbers, ch7_bt.py)</text><text class="t-tick t-strong" x="20.0" y="70.0" text-anchor="start">right answer</text><rect class="box-3" x="140.0" y="50.0" width="84.0" height="32.0" rx="6"/><text class="t-tick" x="182.0" y="64.0" text-anchor="middle">step 1</text><text class="t-tick" x="182.0" y="77.0" text-anchor="middle">p = 0.98</text><text class="t-muted" x="232.0" y="71.0" text-anchor="middle">x</text><rect class="box-3" x="240.0" y="50.0" width="84.0" height="32.0" rx="6"/><text class="t-tick" x="282.0" y="64.0" text-anchor="middle">step 2</text><text class="t-tick" x="282.0" y="77.0" text-anchor="middle">p = 0.96</text><text class="t-muted" x="332.0" y="71.0" text-anchor="middle">x</text><rect class="box-3" x="340.0" y="50.0" width="84.0" height="32.0" rx="6"/><text class="t-tick" x="382.0" y="64.0" text-anchor="middle">step 3</text><text class="t-tick" x="382.0" y="77.0" text-anchor="middle">p = 0.97</text><text class="t-muted" x="432.0" y="71.0" text-anchor="middle">x</text><rect class="box-3" x="440.0" y="50.0" width="84.0" height="32.0" rx="6"/><text class="t-tick" x="482.0" y="64.0" text-anchor="middle">step 4</text><text class="t-tick" x="482.0" y="77.0" text-anchor="middle">p = 0.95</text><text class="t-muted" x="532.0" y="71.0" text-anchor="middle">x</text><rect class="box-3" x="540.0" y="50.0" width="84.0" height="32.0" rx="6"/><text class="t-tick" x="582.0" y="64.0" text-anchor="middle">step 5</text><text class="t-tick" x="582.0" y="77.0" text-anchor="middle">p = 0.94</text><text class="t-note" x="644.0" y="71.0" text-anchor="start">= 0.815</text><text class="t-tick t-strong" x="20.0" y="122.0" text-anchor="start">one wrong step</text><rect class="box-3" x="140.0" y="102.0" width="84.0" height="32.0" rx="6"/><text class="t-tick" x="182.0" y="116.0" text-anchor="middle">step 1</text><text class="t-tick" x="182.0" y="129.0" text-anchor="middle">p = 0.98</text><text class="t-muted" x="232.0" y="123.0" text-anchor="middle">x</text><rect class="box-3" x="240.0" y="102.0" width="84.0" height="32.0" rx="6"/><text class="t-tick" x="282.0" y="116.0" text-anchor="middle">step 2</text><text class="t-tick" x="282.0" y="129.0" text-anchor="middle">p = 0.95</text><text class="t-muted" x="332.0" y="123.0" text-anchor="middle">x</text><rect class="box-3" x="340.0" y="102.0" width="84.0" height="32.0" rx="6"/><text class="t-tick" x="382.0" y="116.0" text-anchor="middle">step 3</text><text class="t-tick" x="382.0" y="129.0" text-anchor="middle">p = 0.97</text><text class="t-muted" x="432.0" y="123.0" text-anchor="middle">x</text><rect class="box-4" x="440.0" y="102.0" width="84.0" height="32.0" rx="6"/><text class="t-tick" x="482.0" y="116.0" text-anchor="middle">step 4</text><text class="t-tick" x="482.0" y="129.0" text-anchor="middle">p = 0.30</text><text class="t-muted" x="532.0" y="123.0" text-anchor="middle">x</text><rect class="box-3" x="540.0" y="102.0" width="84.0" height="32.0" rx="6"/><text class="t-tick" x="582.0" y="116.0" text-anchor="middle">step 5</text><text class="t-tick" x="582.0" y="129.0" text-anchor="middle">p = 0.90</text><text class="t-note" x="644.0" y="123.0" text-anchor="start">= 0.244</text><rect class="box-ghost" x="140.0" y="160.0" width="480.0" height="40.0" rx="8"/><text class="t-tick" x="380.0" y="178.0" text-anchor="middle">An ORM sees only the end: one label per solution, no idea where it broke.</text><text class="t-tick" x="380.0" y="194.0" text-anchor="middle">A PRM scores each step; the product collapses at the first wrong one.</text></svg><figcaption>An outcome reward model sees only the end of a solution. A process reward model scores every step; the product of step scores falls sharply at the first wrong step, so it locates the error as well as detecting it.</figcaption></figure>

How much better is it? Lightman et al. used best-of-N, as in Section 7.10, with each reward model picking the best of N sampled solutions:

> [!PAPER] Lightman et al. (2023) · Figure 3 · page 7
> [![Best-of-N accuracy on MATH problems against the number of solutions per problem, from 1 to about 1,860: the process-supervised reward model rises to about 78%, above the outcome-supervised reward model and majority voting, and the gap widens as N grows](https://ishwarj.com/img/training/ch7-lightman-fig3.png7-lightman-fig3.png)](/img/training/ch7-lightman-fig3.png)
>
> **Context:** the main result of the large-scale experiment.
>
> **What it says:** with the PRM picking among N solutions, the share of problems solved climbs to 78.2%; the ORM and majority voting fall behind, and the gap grows with N.
>
> **Why it matters:** the more you optimise against a reward model (larger N), the more its errors matter. A reward model that checks every step is harder to fool with a confident wrong solution, the failure we saw in Chapter 3's best-of-n experiment.

Process rewards are expensive to label by hand, so later work generates step labels automatically (for example, by checking how often completions from a given step reach the right answer). And for problems with a checkable final answer, the field has also moved the other way: Chapter 2's RLVR and GRPO skip the learned reward model entirely and use the checker as the reward. Learned reward models remain essential wherever no checker exists: helpfulness, tone, safety, writing.

## 7.13 Saving the reward model for Chapter 8

Chapter 8 trains Qwen2.5-0.5B-Instruct with PPO, and it needs a reward. It will use the main reward model from this chapter. `ch7_train.py` saved it with one line, `model.save_pretrained('results/ch7_rm')`, which writes only what was trained: the LoRA matrices and the score head (34 MB), not the 494 million frozen backbone weights. Loading it back:

```python
# simplified from ch7_common.py (load_rm) and results/ch7_rm/README.md
base = AutoModelForSequenceClassification.from_pretrained('Qwen/Qwen2.5-0.5B-Instruct', num_labels=1)
base.config.pad_token_id = tok.pad_token_id                  # as in training: find each chat's last real token
rm = PeftModel.from_pretrained(base, 'results/ch7_rm').eval()

text = tok.apply_chat_template([{'role': 'user', 'content': prompt},
                                {'role': 'assistant', 'content': response}], tokenize=False).rstrip('\n')
reward = rm(**tok(text, return_tensors='pt')).logits[0, 0].item()
```

- `from_pretrained(..., num_labels=1)` rebuilds the same architecture: backbone plus a (randomly initialised) score head.
- `PeftModel.from_pretrained` loads the adapter on top and *replaces* the random head with the trained one, because the head was saved through `modules_to_save`.
- The text must be formatted exactly as in training: Qwen's chat template, final newline stripped, so the last token is `<|im_end|>`. A reward model is only reliable on inputs that look like its training data; a different template is a distribution shift.

Three things Chapter 8 has to handle, all of which this chapter has measured:

1. **The scale is arbitrary.** Section 7.4 showed the loss ignores shifts. Before RL, the rewards are normalised using samples from the starting policy, so that a typical answer scores about 0 with a standard deviation of about 1.
2. **The reward model likes length** (Section 7.9). Without a counterweight, PPO will learn to write longer answers.
3. **It is a proxy that over-promises** (Section 7.10): under best-of-32 the gold reward confirmed only about 60% of the improvement it claimed, and the shortfall grew with optimisation. PPO pushes much harder than best-of-32. The KL penalty is what keeps the policy close to where the reward model's judgements are still meaningful, and an independent judge (such as the gold model used here) is needed to tell whether training really helped.

## Takeaways

> [!TAKEAWAYS]
> - RLHF learns a reward because people cannot score every response an optimiser produces. A reward model is a language model with its output head replaced by one number, read at the last token of the chat.
> - It is trained on comparisons. Comparisons lose the "how much" that ratings carry, but they are immune to each labeler's drifting scale; in our simulation they won exactly when raters drifted.
> - The Bradley-Terry model, $$P(y_w \succ y_l) = \sigma(r_w - r_l)$$, follows from a noisy judge; a reward gap is a log-odds, and 1 unit of reward is 173.7 Elo points. The loss is $$-\log\sigma(r_w - r_l)$$; its gradient, $$1 - \sigma(\Delta)$$, focuses training on the pairs the model gets wrong. Only gaps matter, so rewards are normalised before use.
> - Our reward model (Qwen2.5-0.5B-Instruct, LoRA, 3,200 UltraFeedback pairs, 38 minutes) reaches 69.5% held-out accuracy (95% interval 65.7% to 73.2%): 80% on clearly different pairs, 55% on near-ties, reasonably calibrated (ECE 0.049). The learning rate mattered more than the data size or the loss: 1e-4 gave 62.7%.
> - It leans on length more than its labels do (within-pair correlation 0.21 against 0.02), and it does not punish an answer repeated twice, which the gold model punishes in 99% of cases.
> - Under best-of-32 the gold reward rose by 0.73 standard deviations while the proxy claimed 1.19; a 400-pair proxy delivered only a third of its claim. This widening gap is the start of the overoptimisation Gao et al. measured; RL travels much further and needs a KL leash.
> - Margins (Llama 2) mostly change the reward scale; ensembles flag uncertainty (57.7% accuracy where members disagree) but only pay off under heavy optimisation; process reward models grade every step and catch errors outcome models miss.
> - The trained adapter is in `results/ch7_rm/` (34 MB). Chapter 8 uses it as the reward for PPO.

## References

### Papers

- Thurstone, L. L. (1927). A law of comparative judgment. *Psychological Review* 34(4). [doi.org/10.1037/h0070288](https://doi.org/10.1037/h0070288)
- Zermelo, E. (1929). Die Berechnung der Turnier-Ergebnisse als ein Maximumproblem der Wahrscheinlichkeitsrechnung. *Mathematische Zeitschrift* 29. [doi.org/10.1007/BF01180541](https://doi.org/10.1007/BF01180541)
- Bradley, R. A. and Terry, M. E. (1952). Rank Analysis of Incomplete Block Designs: I. The Method of Paired Comparisons. *Biometrika* 39(3/4). [doi.org/10.2307/2334029](https://doi.org/10.2307/2334029)
- Plackett, R. L. (1975). The Analysis of Permutations. *Applied Statistics* 24(2). [doi.org/10.2307/2346567](https://doi.org/10.2307/2346567)
- Christiano, P. et al. (2017). Deep reinforcement learning from human preferences. [arXiv:1706.03741](https://arxiv.org/abs/1706.03741)
- Ziegler, D. M. et al. (2019). Fine-Tuning Language Models from Human Preferences. [arXiv:1909.08593](https://arxiv.org/abs/1909.08593)
- Stiennon, N. et al. (2020). Learning to summarize from human feedback. [arXiv:2009.01325](https://arxiv.org/abs/2009.01325)
- Nakano, R. et al. (2021). WebGPT: Browser-assisted question-answering with human feedback. [arXiv:2112.09332](https://arxiv.org/abs/2112.09332)
- Ouyang, L. et al. (2022). Training language models to follow instructions with human feedback (InstructGPT). [arXiv:2203.02155](https://arxiv.org/abs/2203.02155)
- Bai, Y. et al. (2022), Anthropic. Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedback. [arXiv:2204.05862](https://arxiv.org/abs/2204.05862)
- Gao, L., Schulman, J. and Hilton, J. (2022). Scaling Laws for Reward Model Overoptimization. [arXiv:2210.10760](https://arxiv.org/abs/2210.10760)
- Uesato, J. et al. (2022). Solving math word problems with process- and outcome-based feedback. [arXiv:2211.14275](https://arxiv.org/abs/2211.14275)
- Lightman, H. et al. (2023). Let's Verify Step by Step. [arXiv:2305.20050](https://arxiv.org/abs/2305.20050)
- Touvron, H. et al. (2023). Llama 2: Open Foundation and Fine-Tuned Chat Models. [arXiv:2307.09288](https://arxiv.org/abs/2307.09288)
- Cui, G. et al. (2023). UltraFeedback: Boosting Language Models with Scaled AI Feedback. [arXiv:2310.01377](https://arxiv.org/abs/2310.01377)
- Coste, T. et al. (2023). Reward Model Ensembles Help Mitigate Overoptimization. [arXiv:2310.02743](https://arxiv.org/abs/2310.02743)
- Singhal, P. et al. (2023). A Long Way to Go: Investigating Length Correlations in RLHF. [arXiv:2310.03716](https://arxiv.org/abs/2310.03716)
- Tunstall, L. et al. (2023). Zephyr: Direct Distillation of LM Alignment. [arXiv:2310.16944](https://arxiv.org/abs/2310.16944)
- Eisenstein, J. et al. (2023). Helping or Herding? Reward Model Ensembles Mitigate but do not Eliminate Reward Hacking. [arXiv:2312.09244](https://arxiv.org/abs/2312.09244)
- Chen, L. et al. (2024). ODIN: Disentangled Reward Mitigates Hacking in RLHF. [arXiv:2402.07319](https://arxiv.org/abs/2402.07319)
- Lambert, N. et al. (2024). RewardBench: Evaluating Reward Models for Language Modeling. [arXiv:2403.13787](https://arxiv.org/abs/2403.13787)
- Liu, C. Y. et al. (2025). Skywork-Reward-V2: Scaling Preference Data Curation via Human-AI Synergy. [arXiv:2507.01352](https://arxiv.org/abs/2507.01352)

### Other sources

- UltraFeedback binarized dataset (Hugging Face H4). [huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized](https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized)
- Anthropic HH-RLHF dataset. [huggingface.co/datasets/Anthropic/hh-rlhf](https://huggingface.co/datasets/Anthropic/hh-rlhf)
- Skywork-Reward-V2-Qwen3-0.6B model card. [huggingface.co/Skywork/Skywork-Reward-V2-Qwen3-0.6B](https://huggingface.co/Skywork/Skywork-Reward-V2-Qwen3-0.6B)
- Qwen2.5-0.5B-Instruct model card. [huggingface.co/Qwen/Qwen2.5-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct)
- PEFT library documentation (LoRA). [huggingface.co/docs/peft](https://huggingface.co/docs/peft/index)
- PRM800K dataset. [github.com/openai/prm800k](https://github.com/openai/prm800k)

