Part III · RL for LLMs · Chapter 17

Process rewards and test-time compute

Rewarding steps vs. outcomes, PRMs, search, and trading inference compute for accuracy.

~150 minBefore this: MC & TD learning, Actor-critic & GAE, The wider landscape, RLVR & GRPOUpdated 2026-10

Here is a model that solves a certain competition problem 30% of the time. You can afford to run it 64 times. What should you do with the 64 answers? Submit the most common one? Ask a second model to grade them and submit the best? If you had a perfect grader, you would almost surely find a correct answer: all 64 attempts fail with probability 0.764≈1.2×10−100.7^{64} \approx 1.2 \times 10^{-10}. With an imperfect grader, the answer is less obvious. As you will see, more samples can make it worse.

Now flip to training. The model writes a 20-step solution and gets the final answer wrong. Chapter 15’s GRPO gives every token of that solution the same negative advantage, including the 15 steps that were fine. Which step was the mistake? If you could tell, you could push down only that step.

Both questions need the same tool: a verifier, a model that judges solutions, and in particular one that judges each step of a solution rather than only the final answer. This chapter is about such step-level judges, called process reward models, and about the other half of the story they made possible: test-time compute, spending extra computation at inference time to get better answers. You will see where the ideas come from (a Monte Carlo value estimate from Chapter 5, an advantage from Chapter 8, tree search from Chapter 10), what they buy, and why the large reasoning-model runs of 2025 mostly did not train with them.

Two ways to spend compute

Until 2024 the main way to get a better language model was to spend more compute before deployment: a bigger model, more pretraining data, more post-training. Test-time compute (also called inference-time compute) is the other knob: keep the model fixed and spend more computation per question when it is asked.

When OpenAI announced o1 in September 2024, its central claim was that accuracy kept improving along both axes: with more reinforcement-learning compute during training, and with more time spent “thinking” at test time. OpenAI did not disclose how. Chapter 15 told the training half of the story through DeepSeek-R1. This chapter tells the test-time half, and the two halves meet at the end.

There are two basic ways to spend test-time compute:

  • Parallel: sample NN independent solutions, then pick one. The ways to pick are majority vote, best-of-NN with a verifier, and weighted voting.
  • Sequential: make one solution better by spending more on it: revise it, check it, or think longer before answering.

Search mixes the two: grow many partial solutions in parallel, extend the promising ones step by step, and prune the rest. To prune, you need a judge of partial solutions, which is exactly what a process reward model is.

A note on letters. In this chapter NN is the number of samples drawn at test time. Chapter 15’s GG is the group size used during training. Both count samples per prompt, but they serve different purposes. We write pp for the probability that one sample is correct.

Parallel sampling: the ceiling

Start with the most optimistic case. Suppose an oracle could look at your NN samples and tell you which ones are right. Then you succeed whenever at least one sample is right. The probability of that is called pass@N.

Take the hook’s numbers: p=0.3p = 0.3 and N=4N = 4. A single sample is wrong with probability 0.70.7. All four samples are wrong with probability 0.74=0.24010.7^4 = 0.2401, so

pass@4=1−0.74=0.7599.\text{pass@4} = 1 - 0.7^4 = 0.7599.

In general, for independent samples,

pass@N=1−(1−p)N≈1−e−pN.\text{pass@}N = 1 - (1 - p)^N \approx 1 - e^{-pN}.

It rises quickly to 1 for any p>0p > 0. On a benchmark, each problem has its own pjp_j, and pass@N is the average of 1−(1−pj)N1 - (1 - p_j)^N over problems. Problems with pj=0p_j = 0 never get solved. On problems with small pjp_j, the term e−pjNe^{-p_j N} falls slowly, so averaged over a realistic mix of easy and hard problems pass@N tends to grow roughly linearly in log⁡N\log N for a long time. Brown et al. (2024, “Large Language Monkeys”) measured this across four orders of magnitude of samples. For example, they report that DeepSeek-Coder-V2 solves 15.9% of SWE-bench Lite issues with one sample and 56% with 250.

pass@N is a ceiling, not a strategy. It assumes you can recognize the right answer. Sometimes you can: a unit-test suite or a proof checker is close to an oracle, so for code with good tests “sample until the tests pass” works. (Even then, weak tests let wrong programs through. We return to this below.) For most questions you need some way to choose, and every way of choosing falls short of the ceiling.

∂ Estimating pass@k without bias (the Codex estimator)

In practice you draw nn samples per problem, find that cc of them are correct, and want pass@k for some k≤nk \le n. The obvious plug-in estimate 1−(1−c/n)k1 - (1 - c/n)^k is biased, because it is a nonlinear function of the noisy c/nc/n.

Chen et al. (2021, the Codex paper) give an unbiased estimator. Imagine choosing kk of your nn samples uniformly at random, without replacement. The chance that none of the chosen kk is correct is the number of all-wrong subsets divided by the number of subsets:

pass@k^=1−(n−ck)(nk).\widehat{\text{pass@}k} = 1 - \frac{\binom{n - c}{k}}{\binom{n}{k}}.

Why is it unbiased? Condition on the nn samples. The estimate is the exact probability that a random size-kk subset contains a correct sample. A random size-kk subset of nn i.i.d. samples is itself a set of kk i.i.d. samples. So averaging over the draw of the nn samples gives P(at least one of k i.i.d. samples is correct)=1−(1−p)kP(\text{at least one of } k \text{ i.i.d. samples is correct}) = 1 - (1 - p)^k.

Example: n=4n = 4, c=1c = 1, k=2k = 2 gives 1−(32)/(42)=1−3/6=0.51 - \binom{3}{2}/\binom{4}{2} = 1 - 3/6 = 0.5. (Exactly half of the 6 pairs contain the one correct sample.) Chapter 15’s pass@k debate uses this estimator. You implement it in Task 1 of the lab.

Majority vote: let the samples vote

The simplest way to choose needs no grader at all. Sample NN reasoning chains, read off each one’s final answer, and return the most common answer. Wang et al. (2022) called this self-consistency: different chains of thought that reach the same answer support each other. They report that it improved chain-of-thought prompting on GSM8K by 17.9 percentage points. It is also called majority voting, or maj@N (DeepSeek’s reports write cons@N).

Right or wrong: the jury theorem

Start with the simplest case, where every sample is either right or wrong, so there are only two possible answers. With N=3N = 3 samples, the vote is right when at least 2 of the 3 are right:

P(maj@3 right)=p3+3p2(1−p).P(\text{maj@3 right}) = p^3 + 3p^2(1 - p).

For p=0.6p = 0.6 this is 0.216+0.432=0.6480.216 + 0.432 = 0.648, better than 0.6. For p=0.4p = 0.4 it is 0.064+0.288=0.3520.064 + 0.288 = 0.352, worse than 0.4. In general, with cc the number of right samples,

P(maj@N right)=∑c>N/2(Nc)pc(1−p)N−c  (+12(NN/2)pN/2(1−p)N/2 for a tie, if N is even).P(\text{maj@}N \text{ right}) = \sum_{c > N/2} \binom{N}{c} p^c (1 - p)^{N - c}\;\Big(+\tfrac12 \binom{N}{N/2} p^{N/2}(1-p)^{N/2} \text{ for a tie, if } N \text{ is even}\Big).

This is the Condorcet jury theorem: if each juror is right more often than not, a large jury is almost always right. If each is wrong more often than not, a large jury is almost always wrong. For p=0.6p = 0.6, maj@11 is 0.753 and maj@101 is 0.979. The physics is the law of large numbers. The fraction of right votes concentrates around pp with width about p(1−p)/N\sqrt{p(1-p)/N}, so the vote’s outcome freezes onto whichever side of 12\tfrac12 the mean pp sits on.

Real answers are not binary. A wrong answer to a math problem can be any of many numbers. Majority vote doesn’t need a majority of right samples, only a plurality: the right answer must be more common than each wrong answer separately.

Take p=0.3p = 0.3. Suppose 30% of the wrong samples share one popular wrong answer (a common slip), so that answer has probability 0.3×0.7=0.210.3 \times 0.7 = 0.21, and the remaining wrong samples scatter over many different numbers. The right answer (0.3) is the single most likely answer. As NN grows, the empirical frequencies converge to these probabilities, so majority vote converges to the right answer even though 70% of the samples are wrong. Now change the common slip’s share to 60%. The popular wrong answer then has probability 0.42, more than 0.3, and majority vote converges to that answer with certainty.

Majority vote has two other limits. It needs answers you can compare for equality: a number, a multiple-choice letter, the output of a program. It does nothing for proofs or essays, where no two samples are identical. And it spends no effort judging anything. It trusts the model’s own distribution. That is a strength, because there is nothing to fool. It is also why a different idea is needed to get past the ceiling.

Quick check A model answers a problem correctly 25% of the time. Its wrong answers are spread evenly over 15 different numbers. What does majority vote converge to as N → ∞?

Verifiers: best-of-N and weighted voting

A verifier is a model that reads a problem xx and a solution yy and outputs a score, ideally the probability that yy is correct. Because it scores the outcome of a whole solution, it is also called an outcome reward model (ORM). It is the same object as Chapter 12’s reward model, trained on correct/incorrect labels instead of preferences. Cobbe et al. (2021) introduced the GSM8K benchmark together with this idea: they trained verifiers on model-written solutions labeled by whether the final answer was right, then used them to rerank samples.

Two ways to use a verifier on NN samples:

  • Best-of-N: return the answer of the single highest-scoring sample.
  • Weighted majority vote (Snell et al. call it “best-of-N weighted”): add up the scores of all samples that give the same final answer, and return the answer with the largest total. With equal scores it reduces to majority vote. With a perfect 0/1 verifier it reduces to “any verified answer”.

A model of an imperfect verifier

To reason about verifiers, you need a model of how they err. Use the simplest one from signal detection theory. The verifier computes a hidden score zz for each sample:

z∼N(d′,1) if the sample is correct,z∼N(0,1) if it is wrong.z \sim \mathcal N(d', 1) \text{ if the sample is correct}, \qquad z \sim \mathcal N(0, 1) \text{ if it is wrong}.

The single number d′d' (read “d-prime”) measures how far apart the two score distributions are, in units of their spread. d′=0d' = 0 is a useless verifier. d′=3d' = 3 separates the two groups well. For weighted voting you want a probability rather than a raw score. The demo and the lab report v=σ(d′(z−d′/2))v = \sigma\big(d'(z - d'/2)\big), which is exactly the posterior probability that the sample is correct when right and wrong samples are equally common a priori. (Check this with Bayes’ rule: the log-likelihood ratio of the two Gaussians at zz is d′z−d′2/2d' z - d'^2/2.)

Here is a worked example. Take N=2N = 2, one correct and one wrong sample. Best-of-2 picks the correct one when zright>zwrongz_\text{right} > z_\text{wrong}. The difference zright−zwrongz_\text{right} - z_\text{wrong} is Gaussian with mean d′d' and variance 2, so

P(pick the right one)=Φ ⁣(d′/2),P(\text{pick the right one}) = \Phi\!\big(d'/\sqrt2\big),

where Φ\Phi is the standard normal CDF. (This number is also the verifier’s AUC, the probability that it ranks a random right answer above a random wrong one.) For d′=2d' = 2, Φ(1.414)=0.921\Phi(1.414) = 0.921. Now average over what the two samples turn out to be, with p=0.3p = 0.3. Both are right with probability p2=0.09p^2 = 0.09, and one is right with probability 2p(1−p)=0.422p(1-p) = 0.42:

P(best-of-2 right)=0.09+0.42×0.921=0.477.P(\text{best-of-2 right}) = 0.09 + 0.42 \times 0.921 = 0.477.

That beats one sample (0.30) and majority vote at N=2N = 2 (also 0.30: a 1–1 split is a coin flip). It falls short of pass@2 (0.51).

Why an imperfect verifier eventually hurts

In this Gaussian model more samples only help: best-of-N climbs toward 1. Real experiments tell a different story. Cobbe et al. found that their 6B verifier’s accuracy improved as they reranked up to 400 completions per problem, and then decreased. They wrote that “the benefits of search are eventually outweighed by the risk of finding adversarial solutions that fool the verifier.” Stroebl, Kapoor and Narayanan (2024) found the same for code. Unit tests with limited coverage let some wrong programs pass (false positives), and resampling until the tests pass often peaks within 10 attempts before the curves bend down.

The missing ingredient is convincing wrong answers: rare wrong solutions that the verifier likes more than typical right ones. Add them to the model. Each wrong sample is convincing with a small probability ff, and then z∼N(d′+1,1)z \sim \mathcal N(d' + 1, 1).

Best-of-N is an extreme-value problem. It returns the maximum of NN scores, and the maximum comes from whichever group has the heaviest upper tail, weighted by how many members it has. While NN is small, the pool probably contains no convincing wrong answer, and the right answers’ tail wins. That is the rising part of the curve. The expected number of convincing wrong answers among NN samples is f(1−p)Nf(1 - p)N. Once that number reaches order 1, at

N⋆≈1f(1−p),N^\star \approx \frac{1}{f(1 - p)},

the pool usually contains one, and it outscores the honest answers. From there accuracy falls, toward zero as N→∞N \to \infty. With p=0.3p = 0.3 and f=2%f = 2\%, N⋆≈71N^\star \approx 71: the demo shows the peak somewhat before that and a steady decline after.

∂ The large-N limits of best-of-N

Write qc=pq_c = p for the fraction of correct samples and qf=f(1−p)q_f = f(1 - p) for the fraction of convincing wrong ones. Ignore the ordinary wrong samples. Their scores sit lower than the correct ones, so for large NN they almost never produce the maximum.

The maximum of mm i.i.d. standard normals is 2ln⁡m\sqrt{2 \ln m} to leading order, with fluctuations of order 1/2ln⁡m1/\sqrt{2 \ln m} that shrink as mm grows. So for large NN:

max⁡zcorrect≈d′+2ln⁡(qcN),max⁡zconvincing≈d′+b+2ln⁡(qfN),\max z_\text{correct} \approx d' + \sqrt{2\ln(q_c N)}, \qquad \max z_\text{convincing} \approx d' + b + \sqrt{2 \ln(q_f N)},

where bb is how much more the verifier likes convincing answers than right ones (b=1b = 1 in our model). The difference of the two square roots goes to zero:

2ln⁡(qcN)−2ln⁡(qfN)≈ln⁡(qc/qf)2ln⁡N→0.\sqrt{2\ln(q_c N)} - \sqrt{2 \ln(q_f N)} \approx \frac{\ln(q_c/q_f)}{\sqrt{2 \ln N}} \to 0.

Three cases follow.

  • b>0b > 0 (convincing answers score higher on average): the convincing group’s maximum eventually wins with probability approaching 1, so best-of-N accuracy goes to 0.
  • b=0b = 0 (the verifier cannot tell convincing wrong answers from right ones): the top sample is equally likely to be any member of the two groups. Accuracy tends to the verifier’s precision, pp+f(1−p)\dfrac{p}{p + f(1-p)}. With p=0.3p = 0.3 and f=0.02f = 0.02 that is 0.3/0.314=0.9550.3/0.314 = 0.955: a plateau, not a decline. This is Stroebl et al.’s ceiling for “resample until the tests pass”.
  • b<0b < 0: the right answers win eventually, but slowly.

In real systems b>0b > 0 is common: a learned verifier is an optimization target, and the samples it rates highest are often the ones that exploit its blind spots. Chapter 19 studies this effect, reward overoptimization, with real data.

Weighted voting resists this failure. A single convincing wrong answer contributes one score to its answer’s total. To win, a wrong answer must collect more total score than the right answer, which typically appears many times. So in the demo, weighted voting keeps most of best-of-N’s early gain and does not decline. It does inherit a version of majority vote’s plateau. This is one reason Snell et al. (2024), and many systems after them, aggregate with weighted voting rather than plain best-of-N.

Interactive Test-time scaling: four ways to spend N samples
Try:
Solving:
At N = accuracy

Start with 'A mixed benchmark': majority vote climbs and then flattens at its ceiling (about 53% here); best-of-N rises well above it, peaks near N = 32–64, and then declines; weighted voting rises and holds. Set f to 0 ('An honest verifier'): the decline disappears. Try 'One problem' and check the table: pass@4 should read 0.760, matching 1 − 0.7⁴, and the triangle marks N ≈ 1/(f(1 − p)). Then try 'A common mistake': the popular wrong answer beats the right one, so majority vote sinks to 0, while a verifier rescues you. Set d′ to 0 and see best-of-N collapse to a single sample and weighted voting become majority vote.

Quick check Best-of-N with a learned verifier gets worse once N is in the thousands. What is the most likely reason?

Outcome versus process: grading the steps

Return to the training question. A reasoning model writes a chain of steps z1,z2,…,zTz_1, z_2, \dots, z_T (a “step” might be one line of math or one paragraph) and then a final answer. (These zjz_j are pieces of text. They have nothing to do with the verifier score zz of the previous section.) Rewards come in two kinds:

  • Outcome supervision: one label for the whole solution, usually whether the final answer is correct. That is what an ORM predicts and what Chapter 15’s verifiable rewards provide.
  • Process supervision: a label for each step: is this step correct (and useful)? A model trained to predict these labels is a process reward model (PRM).

Process labels help with credit assignment, the problem you met in Chapter 1: when an outcome is bad, which decision caused it? An outcome label says that something in the 20 steps went wrong. A process label says which step.

Uesato et al. (2022, DeepMind) ran the first careful comparison, on GSM8K. Outcome supervision reached similar final-answer accuracy with fewer labels. But solutions that reach the right answer can still contain wrong reasoning, and getting the reasoning right needed process supervision, or a reward model trained to imitate it. They report improving the best results from 16.8% to 12.7% final-answer error, and from 14.0% to 3.4% reasoning error among solutions with correct final answers.

Let’s Verify Step by Step

Lightman et al. (2023, OpenAI) scaled this up. Human labelers marked each step of model-written solutions to MATH problems as positive, negative or neutral. Labeling stopped at the first mistake. For a correct solution, the process labels then carry the same information as the outcome label (“all fine”). For a wrong one, they add where it broke. The result is PRM800K: 800,000 step labels on 75,000 solutions to 12,000 problems.

To compare whole solutions, they need one score per solution. They used the probability that every step is correct, computed as the product of the PRM’s per-step probabilities p^j\hat p_j:

score(y)=∏j=1Tp^j.\text{score}(y) = \prod_{j=1}^{T} \hat p_j.

They generated 1,860 solutions per problem and picked the best by each method, on a 500-problem subset of the MATH test set. The PRM solved 78.2%, the ORM 72.4% and majority voting 69.6%. They also found that active learning, which spends the labeling budget on convincing wrong solutions (ones the current PRM rates highly but that reach a wrong answer), made the labels 2.6× more data-efficient.

Other papers aggregate the step scores differently. Math-Shepherd takes the minimum step score: a chain is only as strong as its weakest link. Snell et al. use the PRM’s prediction at the last step, which works when the PRM predicts values (next section) rather than step correctness.

Process labels for free: roll out from each step

Human step labels are expensive. PRM800K took a large labeling effort for one domain and one model’s style of solutions. Wang et al. (2024, Math-Shepherd) replaced the labeler with Monte Carlo rollouts.

Take a solution and cut it after step jj. From that prefix, let a model (the completer) finish the solution kk times, and check each final answer against the known answer. Then label step jj with one of the two labels below. (Math-Shepherd writes them ySEy^\text{SE} and yHEy^\text{HE}, for soft and hard estimation. We use ℓ\ell, because yy is the response in this course.)

soft label:   ℓjsoft=#{rollouts with the right answer}k,hard label:   ℓjhard={1if any rollout is right0otherwise.\text{soft label: } \; \ell^\text{soft}_j = \frac{\#\{\text{rollouts with the right answer}\}}{k}, \qquad \text{hard label: } \; \ell^\text{hard}_j = \begin{cases} 1 & \text{if any rollout is right} \\ 0 & \text{otherwise.} \end{cases}

You have seen this before. Chapter 5’s Monte Carlo prediction estimates Vπ(s)V^\pi(s) by averaging the returns of episodes that start from ss. Here the state is “problem plus the first jj steps”, the policy is the completer, and the return is 1 for a right final answer and 0 otherwise. So the soft label is a Monte Carlo estimate of a value function:

ℓjsoft≈Vπ(x,z≤j)=Pπ(final answer correct∣x,z1,…,zj).\ell^\text{soft}_j \approx V^\pi(x, z_{\le j}) = P_\pi(\text{final answer correct} \mid x, z_1, \dots, z_j).

Equivalently, it estimates the Q-value of writing step zjz_j after the prefix z<jz_{< j}, since in a language model the next state is fully determined by the action (the text just gets appended). A PRM trained on these labels is a learned value function, a critic. Snell et al. say so directly: their PRM’s per-step predictions “correspond to value estimates of reward-to-go for the base model’s sampling policy”.

A worked example

Make it concrete with the toy task used in this chapter’s second demo and in the lab. The problem: “Start with 4. Add 7, 3, 9, 5, 8, 2 in turn, writing only the last digit each time.” The right running digits are 1, 4, 3, 8, 6, 8. The policy slips at each step with a probability that grows with the number being added, e=0.04+0.03×(number)e = 0.04 + 0.03 \times (\text{number}): 25% for +7+7, 13% for +3+3, 31% for +9+9, then 19%, 28% and 10%. A slip writes one of the 9 wrong digits, chosen uniformly. After a slip it carries on from its own wrong digit, so one slip usually ruins the answer. Now and then a second slip lands back on the right track by luck.

Here is a solution that slips at step 3: it writes 1, 4, 2, 7, 5, 7 (4 + 9 = 13, so it should have written 3). Its final answer is 7, not 8. The exact value of each prefix, computed from the two-state Markov chain in the lab’s chain.py, is:

prefixstartafter 1after 2after 3after 4after 5after 6
VV0.2760.3440.3850.0520.0390.0110

Check one entry by hand. After step 2 the solution is on track, and the remaining four steps succeed with probability about 0.69×0.81×0.72×0.90=0.3620.69 \times 0.81 \times 0.72 \times 0.90 = 0.362. The exact 0.385 is a little higher because of lucky recoveries. After step 3 the solution is off track, and only a lucky slip can bring it back: for a step with slip probability ee, the chance of slipping onto exactly the right digit is e/9e/9. So the value collapses to 0.052.

Now define the process reward of step jj as the change in value it causes:

rj=Vj−Vj−1.r_j = V_j - V_{j-1}.

For our solution: r=(+0.068,+0.041,−0.333,−0.013,−0.028,−0.011)r = (+0.068, +0.041, -0.333, -0.013, -0.028, -0.011). The blame lands on step 3, as it should. Steps 1 and 2 get small positive rewards: they were good moves, each surviving a risky step. Compare outcome-only training with a baseline (Chapter 15’s group mean estimates V0V_0). Every step gets the same advantage, 0−0.276=−0.2760 - 0.276 = -0.276, so steps 1 and 2 are punished too.

The rollouts also bring their own errors. With few rollouts the soft labels are noisy, and a noisy drop can land on the wrong step. Hard labels have a subtler flaw. From the bad prefix after step 3 the true value is 0.052, but with k=16k = 16 rollouts the chance that at least one gets lucky is

1−(1−0.052)16=0.57,1 - (1 - 0.052)^{16} = 0.57,

so more than half the time the hard label calls the mistaken step “good”. With k=64k = 64 it rises to 0.97. The hard label’s expectation is 1−(1−V)k1 - (1 - V)^k, which is pass@k from that prefix. It answers “can this prefix still reach the right answer?” rather than “is this a good step?”. Hard labels get worse at flagging mistakes as kk grows. Math-Shepherd saw exactly this. Checked against 160 human-labeled steps, their hard labels were 86% accurate with 4 rollouts and became less accurate with more rollouts, which the authors attribute to false positives. They trained on hard labels anyway, and report that verifiers trained on soft or hard labels performed about the same.

Interactive Grading steps by rolling out

Labels for each prefixdots: one per rollout (filled = right answer)
Step rewards Vj − Vj−1dashed: outcome-only advantage , same for every step

Top chart: each column is a prefix of the solution. The dots are k rollouts from it (filled = reached the right answer), the blue bar is the soft label and the horizontal tick is the true value. Bottom chart: filled bars are the step rewards computed from the soft labels, outlined bars the true ones, and the dashed line is the outcome-only advantage. At k = 16 the biggest drop lands on step 3, the slip. Notice that the hard labels already call the bad prefixes after steps 3–5 '1'. Drag k down to 2–4 and press 'Roll out again' several times: the labels often blame the wrong step. Then tap step 5 twice to plant a +1 slip. It cancels the −1 at step 3, so the final answer is right for the wrong reasons. The outcome reward says 1 and can't tell. The step rewards still blame step 3, and they give step 5 a large positive reward: a lucky slip that got back on track. Value-based step rewards measure progress toward the answer, not whether each step is correct.

Quick check A Math-Shepherd soft label for step j is the fraction of k rollouts from the prefix (problem + steps 1..j) that reach the right answer. In RL terms it is…

What can go wrong with automatic labels

  • The labels belong to the completer. VπV^\pi depends on π\pi. A strong completer can recover from a sloppy step and rates it well. A weak completer fails even after a good step and rates it badly. Setlur et al. turn this into a design choice: they measure progress under a separate “prover” policy, and argue that a well-chosen prover can be weaker than the policy being improved.
  • Value is not correctness. A step can be correct but unpromising, or a lucky wrong step can still lead to the right number. Zhang et al. (2025, Qwen, “The Lessons of Developing PRMs in Mathematical Reasoning”) report that Monte Carlo labels gave worse PRMs than labels from an LLM judge or from humans. They also report that evaluating PRMs only by best-of-N accuracy gives a biased picture. ProcessBench (Zheng et al., 2024) asks PRMs to find the earliest error in competition-level solutions. It found that existing PRMs generalized poorly beyond GSM8K and MATH, and did worse than LLMs prompted to critique.
  • Steps are hard to define. Math solutions have lines. A long chain of thought that wanders, backtracks and says “wait” does not split cleanly into steps.

A PRM scores partial solutions, so you can use it during generation, not only after. This is decision-time planning, the idea behind Chapter 10’s Monte Carlo tree search, applied to text.

Step-level beam search with a PRM (beam width B, M proposals per beam)
beams ← [ empty solution ]
repeat until every beam has a final answer:
    candidates ← []
    for each prefix in beams:
        sample M next steps from the policy; append each to the prefix
        add the extended prefixes to candidates (drop duplicates)
    score every candidate with the PRM
    beams ← the B highest-scoring candidates
return the best-scoring finished solution

At each step, partial solutions the PRM dislikes are dropped before you spend any more tokens on them. The compute that best-of-N would have spent finishing doomed solutions goes into extending promising ones. With an accurate PRM this is a large saving. In the lab’s toy problem, beam search with a good PRM solves about 80% of problems using the compute of two full samples, where best-of-2 solves about half.

The catch is that the search is a stronger optimizer against the PRM than best-of-N is, so it finds the PRM’s mistakes faster. Snell et al. (2024) observed both sides on MATH, with a PRM trained from Monte Carlo labels:

  • At small generation budgets, beam search clearly beat best-of-N. As the budget grew, the advantage shrank, and beam search often fell behind.
  • On easy questions, beam search got worse with more budget, a sign of exploiting the PRM. They found search producing low-information repetitive steps, or solutions of only one or two steps. On harder questions it consistently beat best-of-N.
  • An even stronger search, lookahead (rolling out a few steps ahead before scoring, a little like MCTS), did worst at equal compute.

Tree search and AlphaZero

Chapter 10’s MCTS is the natural next step: select partial solutions with a UCB rule, expand with the policy, evaluate with a value function (a PRM) or a rollout, and back up. For board games this, plus learning, gave AlphaZero. For language it has been harder. DeepSeek-R1’s report describes an MCTS attempt guided by a learned value model and lists why it didn’t scale: the token-level search space is vastly larger than chess’s, and “training a fine-grained value model is inherently difficult”. Their conclusion: MCTS “can improve performance during inference when paired with a pre-trained value model”, but using self-search to improve the model iteratively, as AlphaZero does, “remains a significant challenge.”

Sequential revision, and which strategy to use when

Parallel samples are independent: sample 17 knows nothing about the first 16. Sequential revision conditions each new attempt on earlier ones: “here is your previous answer; find the error and try again.” Snell et al. fine-tuned a model to revise its own answers and compared spending a budget on parallel samples against sequential revisions. On easier questions revisions did better: the model was near a right answer and needed polishing. On harder questions parallel sampling did better: it had to explore entirely different approaches. The best mix depended on difficulty.

That gives the key idea of the paper, compute-optimal test-time scaling: estimate how hard a question is, then pick the strategy and budget per question. Snell et al. report that this allocation matches best-of-N while using up to 4× less test-time compute. In a FLOPs-matched comparison, a small model with optimal test-time compute could outperform a 14× larger model, but only on questions where the small model already had non-trivial success. On the hardest questions, a bigger pretrained model was the better use of compute. Exercise 17.6 builds the intuition with two problems and a fixed budget.

Quick check You have a fixed sampling budget for two questions. On question A one sample is right 60% of the time; on question B, 0.1% of the time. You pick answers by majority vote. Where should the budget go?

Using a PRM in training: dense rewards

Back to the original training question. A PRM, or Monte Carlo values, can turn a single end-of-solution reward into a reward per step, giving dense rewards. Plugged into a policy gradient, step jj‘s tokens get an advantage built from rewards at and after step jj (reward-to-go, Chapter 7), instead of one shared number.

  • Math-Shepherd trained Mistral-7B with “step-by-step PPO”, giving the PRM’s reward at the end of each step. They report GSM8K rising from 77.9% to 84.1% and MATH from 28.6% to 33.0%. Adding Math-Shepherd reranking at test time raised these further.
  • DeepSeekMath, the paper that introduced GRPO (Chapter 15), also describes a process-supervision variant. Each step’s PRM reward is normalized across the group, and the advantage of a token is the sum of the normalized rewards of all steps that end at or after it.
  • VinePPO (Kazemnejad et al., 2024) skips the learned PRM entirely. It keeps PPO (Chapters 8–9) but replaces the learned critic with Monte Carlo value estimates: a few rollouts from intermediate states. Language makes this possible, because you can “reset” generation to any prefix.

Why the big 2025 runs used outcome rewards

DeepSeek-R1’s report lists PRMs among its “unsuccessful attempts”, for three reasons: it is hard to define a step in general reasoning, hard to judge whether an intermediate step is correct (automatic labels were unsatisfactory and human labels don’t scale), and “once a model-based PRM is introduced, it inevitably leads to reward hacking”, with retraining the PRM adding cost and complexity. They conclude that PRMs are good at reranking and guided search, but that during large-scale RL the gains were small compared with the extra compute. Kimi k1.5, released the same week, likewise trained without MCTS, value functions or PRMs. Chapter 15’s rule-based outcome rewards won at scale.

Reward hacking is easy to picture. Suppose the PRM gives each step a reward near +1 when it looks correct. Then a policy can farm reward by writing many short steps that are correct but say nothing (“Let me restate the problem.”), padding a solution without making progress. Snell et al. saw search produce exactly this kind of low-information repetition. Defining step rewards as advantages (changes in value) instead of absolute scores removes the incentive to pad, because a step that changes nothing earns zero. This is part of Setlur et al.’s argument for rewarding progress.

Implicit PRMs and PRIME

A different fix makes the PRM cheap enough to retrain online. Yuan et al. (2024, “Free Process Rewards without Process Labels”) borrowed the parameterization of Chapter 13’s DPO. Train an outcome reward model whose reward is a log-likelihood ratio between two language models,

rϕ(y)=βlog⁡πϕ(y)πref(y),r_\phi(y) = \beta \log \frac{\pi_\phi(y)}{\pi_\text{ref}(y)},

using only response-level correct/incorrect labels. Because log⁡π(y)\log \pi(y) is a sum over tokens, the partial sums

qt=∑i≤tβlog⁡πϕ(yi∣y<i)πref(yi∣y<i)q_t = \sum_{i \le t} \beta \log \frac{\pi_\phi(y_i \mid y_{< i})}{\pi_\text{ref}(y_i \mid y_{< i})}

are defined for every prefix, and their differences give per-token (or per-step) rewards “for free”. They prove that qtq_t is a soft value of the prefix, so these are process rewards in the sense of this chapter. They report that this implicit PRM beat a Math-Shepherd-trained PRM using less than 1/38 of the training data.

∂ Why the partial sums are values: a free energy

Fix any πϕ\pi_\phi, and define the outcome reward r(y)=βlog⁡πϕ(y)πref(y)r(y) = \beta\log\frac{\pi_\phi(y)}{\pi_\text{ref}(y)}. Write a response as a prefix y≤ty_{\le t} and a continuation y>ty_{> t}. Average er/βe^{r/\beta} over continuations drawn from πref\pi_\text{ref}:

Ey>t∼πref(⋅∣y≤t) ⁣[er(y)/β]=∑y>tπref(y>t∣y≤t) πϕ(y≤t) πϕ(y>t∣y≤t)πref(y≤t) πref(y>t∣y≤t)=πϕ(y≤t)πref(y≤t)∑y>tπϕ(y>t∣y≤t).\mathbb E_{y_{>t} \sim \pi_\text{ref}(\cdot \mid y_{\le t})}\!\left[e^{r(y)/\beta}\right] = \sum_{y_{>t}} \pi_\text{ref}(y_{>t} \mid y_{\le t}) \,\frac{\pi_\phi(y_{\le t})\,\pi_\phi(y_{>t} \mid y_{\le t})}{\pi_\text{ref}(y_{\le t})\,\pi_\text{ref}(y_{>t} \mid y_{\le t})} = \frac{\pi_\phi(y_{\le t})}{\pi_\text{ref}(y_{\le t})}\sum_{y_{>t}} \pi_\phi(y_{>t} \mid y_{\le t}).

The last sum is 1. Taking βlog⁡\beta \log of both sides:

βlog⁡Eπref ⁣[er(y)/β | y≤t]=βlog⁡πϕ(y≤t)πref(y≤t)=qt.\beta \log \mathbb E_{\pi_\text{ref}}\!\left[e^{r(y)/\beta} \,\middle|\, y_{\le t}\right] = \beta\log\frac{\pi_\phi(y_{\le t})}{\pi_\text{ref}(y_{\le t})} = q_t.

The left side is a “soft” value of the prefix: a log-sum-exp average of future rewards. In the language of Chapter 10’s Gibbs variational principle, it is minus the free energy of the continuations, at temperature β\beta. It lies between the plain average of rr under πref\pi_\text{ref} (as β→∞\beta \to \infty) and the best achievable rr (as β→0\beta \to 0). So the implicit PRM’s step reward qt−qt−1q_t - q_{t-1} is again a change in value, an advantage.

PRIME (Cui et al., 2025) puts this into RL. The policy samples solutions, an outcome verifier labels them, and those same labels update the implicit PRM online with a cross-entropy loss. The dense token rewards from the PRM are combined with the outcome rewards in an RLOO-style advantage (Chapter 16). Because the PRM keeps training on the current policy’s samples, the policy has a harder time exploiting a frozen PRM’s blind spots. The paper names online PRM updates as the key ingredient. Starting from Qwen2.5-Math-7B-Base, they report a 15.1% average improvement over the SFT model across reasoning benchmarks, and a 2.5× gain in sample efficiency and a 6.9% improvement over outcome-only RL.

Generative verifiers and the generator–verifier gap

So far the verifier has been a classifier: a language model with a head that outputs one number. A generative verifier checks the solution in words, writing a critique step by step, and ends with a verdict such as “Is the answer correct? Yes”. Zhang et al. (2024, “Generative Verifiers”) train verification as ordinary next-token prediction, so a verifier can reason with chain of thought, and can sample several verification rationales and vote. Test-time compute then goes into checking as well as generating. ThinkPRM (Khalifa et al., 2025) applies the same idea to process verification. A long-chain-of-thought verifier checks every step, and with about 1% of PRM800K’s labels it beat discriminative PRMs in their experiments. Chapter 14 covers LLM judges and generative reward models more broadly.

Every method in this chapter rests on one assumption: checking is easier than generating. Call the difference the generator–verifier gap. When it is large, a model can usefully sample, judge and select, and even train on its own filtered outputs. Song et al. (2024, “Mind the Gap”) formalized self-improvement in terms of this gap and found that a version of it grows steadily with pretraining compute. Sudoku, code with tests and proofs with a checker have a large gap. Recalling a fact has almost none: if the model doesn’t know a capital city, asking it to check one won’t help. DeepSeekMath-V2 (2025) trains a proof verifier and then a generator rewarded by it. It spends extra compute on verification to keep the gap open as the generator improves. With heavy test-time compute it reports gold-level IMO 2025 performance and 118/120 on Putnam 2024.

Long chains of thought: search inside a single sample

There is a third way to spend test-time compute, and it is the one o1 and R1 use: one long sample. Chapter 15’s R1-Zero learned, from outcome rewards alone, to write longer and longer chains of thought that try an approach, check it, notice a problem (“Wait…”), backtrack and try again. That is search, but done by the policy inside its own context, not by an external algorithm. In a sense, RL with outcome rewards trains the model to be its own generator, verifier and search procedure at once.

This is AlphaZero’s idea in a new form. AlphaZero trains its policy network toward the move distribution found by tree search, so over training the network absorbs the search. Long-CoT RL trains the policy on the outcomes of its own extended reasoning, so the policy absorbs a search procedure, with the context window acting as the search tree.

Sequential test-time compute is then a dial on chain length. Budget forcing (Muennighoff et al., 2025, “s1”) turns it directly. To stop thinking early, append the end-of-thinking delimiter. To make the model think longer, suppress the delimiter when the model tries to stop and append “Wait”, which often makes it re-check its work. With only 1,000 curated training examples on top of Qwen2.5-32B-Instruct, budget forcing extended s1-32B’s AIME24 accuracy from 50% to 57%. The authors also report that the gains eventually flatten. Suppressing the end too often can push the model into repetitive loops.

Parallel and sequential compute combine. DeepSeek-R1’s first report gives R1-Zero 71.0% pass@1 on AIME 2024 and 86.7% with majority voting over 64 samples (cons@64). That is a self-consistency gain stacked on top of long chains of thought.

Summary

  • pass@N =1−(1−p)N= 1 - (1-p)^N is the ceiling for any way of picking one of NN samples. Estimate pass@k without bias with 1−(n−ck)/(nk)1 - \binom{n-c}{k}/\binom{n}{k}.
  • Majority vote (self-consistency) converges to the mode of the answer distribution: it amplifies when the right answer is the most common one and plateaus at the fraction of problems where it is. No verifier is needed, but answers must be comparable.
  • Best-of-N with a verifier can beat majority vote, but it is an extreme-value selection. Once the pool is likely to contain a wrong answer the verifier over-rates (around N≈1/(f(1−p))N \approx 1/(f(1-p))), accuracy falls. Weighted voting is more robust.
  • Process supervision labels steps, not just outcomes. Lightman et al.’s PRM beat both an ORM and majority vote for reranking (78.2% vs 72.4% vs 69.6% on a MATH subset).
  • Math-Shepherd labels (fraction of rollouts from a prefix that succeed) are Monte Carlo value estimates. Their differences Vj−Vj−1V_j - V_{j-1} are step-level advantages, which telescope to outcome minus baseline. Hard labels estimate pass@k from the prefix and miss mistakes as kk grows.
  • A PRM enables step-level search (beam search, lookahead, MCTS). It saves compute when the PRM is accurate, but a stronger optimizer exploits the PRM’s errors sooner. Compute-optimal allocation depends on question difficulty (Snell et al.).
  • In large-scale RL, PRMs have mostly lost to verifiable outcome rewards: steps are ill-defined, labels are noisy, and PRMs get hacked (DeepSeek-R1). Implicit PRMs / PRIME and Monte Carlo values (VinePPO) are ways to get dense rewards without a frozen, hackable PRM.
  • Long chain of thought is search learned by the policy itself. Budget forcing and majority voting turn the test-time dial further. Everything rests on a generator–verifier gap.

Exercises

Exercise 17.1Votes by handPen & paper●○○

(a) A model is right with probability p=0.6p = 0.6 on a right/wrong question. Compute maj@3 and maj@5 exactly.

(b) Show that with ties broken by a fair coin, maj@4 = maj@3 for every pp. (So even NN is wasted on binary questions.)

(c) For p=0.3p = 0.3, compute pass@4 and pass@16.

Solution

(a) maj@3 =p3+3p2(1−p)=0.216+0.432=0.648= p^3 + 3p^2(1-p) = 0.216 + 0.432 = 0.648.

maj@5 needs at least 3 of 5 right: (53)p3(1−p)2+(54)p4(1−p)+p5=10(0.216)(0.16)+5(0.1296)(0.4)+0.07776=0.3456+0.2592+0.07776=0.68256\binom53 p^3(1-p)^2 + \binom54 p^4(1-p) + p^5 = 10(0.216)(0.16) + 5(0.1296)(0.4) + 0.07776 = 0.3456 + 0.2592 + 0.07776 = 0.68256.

(b) Think of the 4th sample as added to a 3-sample vote. If the first three split 3–0, the fourth can’t change the winner. If they split 2–1 for the right answer, the fourth either makes it 3–1 (still right) or 2–2, a tie that a coin flip resolves correctly half the time. So, given a 2–1 split for the right answer,

P(right after 4)=p+(1−p)12.P(\text{right after 4}) = p + (1-p)\tfrac12 .

Given a 2–1 split for the wrong answer, P(right after 4)=(1−p)⋅0+p⋅12P(\text{right after 4}) = (1-p)\cdot 0 + p\cdot\tfrac12. The two 2–1 splits occur with probabilities 3p2(1−p)3p^2(1-p) and 3p(1−p)23p(1-p)^2. The change in accuracy from adding sample 4 is therefore

3p2(1−p)[p+1−p2−1]+3p(1−p)2[p2−0]=3p2(1−p)(−1−p2)+3p(1−p)2p2=0.3p^2(1-p)\Big[p + \tfrac{1-p}{2} - 1\Big] + 3p(1-p)^2\Big[\tfrac p2 - 0\Big] = 3p^2(1-p)\Big(-\tfrac{1-p}{2}\Big) + 3p(1-p)^2\tfrac p2 = 0.

The two effects cancel exactly. The same argument shows maj@(2m)(2m) = maj@(2m−1)(2m-1) for every mm.

(c) pass@4 =1−0.74=0.7599= 1 - 0.7^4 = 0.7599. pass@16 =1−0.716=1−0.00332=0.9967= 1 - 0.7^{16} = 1 - 0.00332 = 0.9967.

Exercise 17.2The majority-vote ceilingPen & paper●●○

A model’s wrong answers come in two kinds. A fraction ww of the wrong mass goes to one popular wrong answer, and the rest is scattered so thinly that it never wins a vote. On a given problem the model is right with probability pp.

(a) For which pp does majority vote converge to the right answer as N→∞N \to \infty? Write the condition as p>p⋆(w)p > p^\star(w).

(b) A benchmark’s problems have pp uniformly distributed on [0,1][0, 1]. What is the large-NN majority-vote accuracy for w=0.5w = 0.5? What is single-sample accuracy? Compare with pass@N as N→∞N \to \infty.

(c) In the demo’s benchmark mode the difficulties are not uniform: p∼Beta(2pˉ,2(1−pˉ))p \sim \text{Beta}(2\bar p, 2(1 - \bar p)). With pˉ=0.4\bar p = 0.4 and w=0.5w = 0.5 the table shows a ceiling of about 0.53. Explain qualitatively why it is below your answer to (b).

Hint
The popular wrong answer has probability w(1 − p). Majority vote converges to whichever single answer is most likely.
Solution

(a) Majority vote converges to the mode. The right answer is the mode when p>w(1−p)p > w(1-p), that is, p(1+w)>wp(1 + w) > w, so

p⋆(w)=w1+w.p^\star(w) = \frac{w}{1+w}.

For w=0.5w = 0.5, p⋆=1/3p^\star = 1/3. For w=0.3w = 0.3, p⋆=0.23p^\star = 0.23. If all wrong answers agree (w=1w = 1), p⋆=1/2p^\star = 1/2: the jury theorem. If the wrong answers are completely scattered (w→0w \to 0), p⋆→0p^\star \to 0, so any p>0p > 0 eventually wins.

(b) The fraction of problems with p>1/3p > 1/3 is 2/32/3, so maj@∞ ≈0.667\approx 0.667. Single-sample accuracy is E[p]=0.5\mathbb E[p] = 0.5. pass@∞ =P(p>0)=1= P(p > 0) = 1. Majority vote recovers about a third of the gap between one sample and the oracle, and no more.

(c) Beta(0.8,1.2)\text{Beta}(0.8, 1.2) has mean 0.4 (lower than 0.5) and piles up mass near p=0p = 0, where the right answer can never be the mode. So a smaller fraction of problems clears p⋆=1/3p^\star = 1/3, about 0.53 here.

Exercise 17.3When does best-of-N turn down?Pen & paper●●○

Use the chapter’s verifier model: correct answers score N(d′,1)\mathcal N(d', 1), ordinary wrong answers N(0,1)\mathcal N(0, 1), and a fraction ff of wrong answers are convincing, scoring N(d′+b,1)\mathcal N(d' + b, 1).

(a) For p=0.3p = 0.3, d′=2d' = 2 and N=2N = 2, ignoring convincing answers, compute the best-of-2 accuracy. (Use Φ(1.414)=0.921\Phi(1.414) = 0.921.)

(b) Estimate the NN at which you first expect one convincing wrong answer in the pool, for p=0.3p = 0.3 and f=0.02f = 0.02. Then for p=0.3p = 0.3 and f=0.001f = 0.001.

(c) Suppose b=0b = 0: the verifier cannot tell a convincing wrong answer from a right one. Argue that for very large NN the best-of-N accuracy tends to p/(p+f(1−p))p/(p + f(1-p)). Evaluate it for p=0.3p = 0.3, f=0.02f = 0.02.

(d) Check (b) and (c) against the demo (“One problem” preset). Is the peak at N⋆N^\star, before it, or after it? Why?

Hint
For (c): for large N the top score comes from either the correct group or the convincing group, which now have identical score distributions. Which member of the combined group holds the maximum is then uniformly random.
Solution

(a) p2+2p(1−p)Φ(d′/2)=0.09+0.42×0.921=0.477p^2 + 2p(1-p)\Phi(d'/\sqrt 2) = 0.09 + 0.42 \times 0.921 = 0.477.

(b) The expected count is f(1−p)Nf(1-p)N. Setting it to 1 gives N⋆=1/(f(1−p))N^\star = 1/(f(1-p)): 1/(0.02×0.7)≈711/(0.02 \times 0.7) \approx 71, and 1/(0.001×0.7)≈1,4301/(0.001 \times 0.7) \approx 1{,}430.

(c) For large NN, ordinary wrong answers essentially never hold the maximum, because their scores sit d′d' lower. The maximum is held by a member of the union of the correct samples (a fraction pp of samples) and the convincing ones (a fraction f(1−p)f(1-p)). With b=0b = 0 the two groups have the same score distribution, so by symmetry the maximum is equally likely to belong to any member of the union. The chance that it is a correct sample is the correct group’s share of the union:

pp+f(1−p)=0.30.3+0.014=0.955.\frac{p}{p + f(1-p)} = \frac{0.3}{0.3 + 0.014} = 0.955.

This is a plateau, not a decline. With b>0b > 0 the convincing group wins the extreme-value race, and accuracy goes to 0.

(d) The demo’s best-of-N peaks around N=16N = 16–3232, before N⋆≈71N^\star \approx 71, and declines steadily after. Before the peak, each extra sample mostly adds chances to find a right answer, but by N≈16N \approx 16 that gain has saturated (1−0.716>0.991 - 0.7^{16} > 0.99). Meanwhile the chance that the pool already contains a convincing wrong answer, 1−(1−0.014)N1 - (1 - 0.014)^N, grows from 0.2 at N=16N = 16 to 0.6 at N=64N = 64. The peak sits where the saturating gain stops outpacing the growing risk, which is before the expected count reaches 1.

Exercise 17.4Monte Carlo step labels are valuesPen & paper●●○

A prefix has true value VV under the completer (the probability that a rollout from it reaches the right answer). You run kk independent rollouts.

(a) Show that the soft label is an unbiased estimate of VV, and find its standard deviation.

(b) Show that the hard label’s expectation is 1−(1−V)k1 - (1-V)^k. Which earlier formula is this?

(c) In the worked example, the bad prefix after step 3 has V=0.052V = 0.052 and the good prefix after step 2 has V=0.385V = 0.385. For k=4k = 4, 1616 and 6464, compute the probability that the hard label calls the bad prefix “good”. Then compute the probability that the soft labels rank the good prefix above the bad one for k=4k = 4. (Ties count as failures.)

(d) In one sentence: why does more compute (kk) make hard labels worse at locating mistakes?

Hint
The number of successful rollouts is Binomial(k, V). For the ranking question in (c), enumerate the bad prefix’s success count (0, 1, …) and use the binomial distribution for the good one.
Solution

(a) The count of successes is S∼Binomial(k,V)S \sim \text{Binomial}(k, V), so E[S/k]=V\mathbb E[S/k] = V and sd(S/k)=V(1−V)/k\text{sd}(S/k) = \sqrt{V(1-V)/k}. For V=0.385V = 0.385 and k=16k = 16 that is 0.385×0.615/16=0.12\sqrt{0.385 \times 0.615/16} = 0.12, large compared with the gaps between neighboring values.

(b) The hard label is 1 unless all kk rollouts fail, so E[hard]=1−(1−V)k\mathbb E[\text{hard}] = 1 - (1-V)^k. This is pass@k from the prefix: “can at least one of kk attempts finish this correctly?”

(c) 1−0.948k1 - 0.948^k: for k=4k = 4, 1−0.8077=0.1921 - 0.8077 = 0.192; for k=16k = 16, 1−0.4256=0.5741 - 0.4256 = 0.574; for k=64k = 64, 1−0.0328=0.9671 - 0.0328 = 0.967.

Ranking with k=4k = 4: let Sb∼Bin(4,0.052)S_b \sim \text{Bin}(4, 0.052) and Sg∼Bin(4,0.385)S_g \sim \text{Bin}(4, 0.385). We need P(Sg>Sb)P(S_g > S_b).

P(Sb=0)=0.9484=0.8077P(S_b = 0) = 0.948^4 = 0.8077 and P(Sb=1)=4(0.052)(0.948)3=0.1772P(S_b = 1) = 4(0.052)(0.948)^3 = 0.1772. Higher values have total probability about 0.015.

P(Sg=0)=0.6154=0.1431P(S_g = 0) = 0.615^4 = 0.1431 and P(Sg=1)=4(0.385)(0.615)3=0.3582P(S_g = 1) = 4(0.385)(0.615)^3 = 0.3582, so P(Sg≥1)=0.8569P(S_g \ge 1) = 0.8569 and P(Sg≥2)=0.4987P(S_g \ge 2) = 0.4987.

P(Sg>Sb)≈0.8077×0.8569+0.1772×0.4987+(about 0.003)≈0.692+0.088+0.003=0.78P(S_g > S_b) \approx 0.8077 \times 0.8569 + 0.1772 \times 0.4987 + (\text{about } 0.003) \approx 0.692 + 0.088 + 0.003 = 0.78.

So with 4 rollouts, the soft labels misorder this clear-cut pair (0.385 vs 0.052) about one time in five.

(d) The hard label asks “is success possible from here?”, and with enough rollouts almost any prefix with a nonzero chance of recovery answers yes.

Exercise 17.5Process vs outcome credit, by handConcept●●○

A 5-step solution has true prefix values V0,…,V5=0.50,0.60,0.70,0.10,0.05,0V_0, \dots, V_5 = 0.50, 0.60, 0.70, 0.10, 0.05, 0 (the final answer is wrong).

(a) Compute the process rewards rj=Vj−Vj−1r_j = V_j - V_{j-1}, and check that they sum to outcome minus V0V_0.

(b) Under outcome-only training with a perfect baseline V0V_0 (as Chapter 15’s group mean estimates), what advantage does each step’s tokens get? Which steps are pushed in the wrong direction?

(c) With G=8G = 8 samples per prompt, about how many of them would you expect to be correct? Explain why GRPO, averaged over many samples, still pushes step 2 up even though this particular sample pushes it down. What does that cost you?

Hint
For (c), think about which other samples share steps 1–2 and what happens to them. The answer is about variance, not bias.
Solution

(a) r=(+0.10,+0.10,−0.60,−0.05,−0.05)r = (+0.10, +0.10, -0.60, -0.05, -0.05). Sum =−0.50=0−0.50= -0.50 = 0 - 0.50. ✓

(b) Every step gets 0−0.50=−0.500 - 0.50 = -0.50. Steps 1 and 2 (good moves that raised the success probability) are pushed down along with the real mistake at step 3.

(c) About 8×0.5=48 \times 0.5 = 4 correct samples. In expectation, outcome-only policy gradients are still right. For step jj‘s tokens, the outcome RR averaged over everything that happens after step jj is E[R∣z≤j]=Vj\mathbb E[R \mid z_{\le j}] = V_j. Swapping the baseline V0V_0 for Vj−1V_{j-1} changes nothing in expectation, because Vj−1V_{j-1} depends only on earlier steps (Chapter 7’s baseline result). So the weight R−V0R - V_0 on step jj has the same expected effect on the gradient as the process advantage Vj−Vj−1V_j - V_{j-1}. Other samples that also chose steps 1–2 succeed more often than average, so on average step 2 gets pushed up. But any single sample gives every step the same sign, so the push on step 2 is the small difference between large positive and negative contributions from different samples. That is high variance, and it grows with the number of steps. Process rewards (or good values) remove this noise by assigning credit inside each sample, so you need fewer samples for the same gradient quality.

Exercise 17.6Spending a fixed budget wellPen & paper●●●

You must answer two questions and have a budget of 16 samples in total. Question A: pA=0.6p_A = 0.6. Question B: pB=0.05p_B = 0.05. Your score is the expected number of questions answered correctly.

(a) Suppose you have an oracle checker (pass@N). Find the split (NA,NB)(N_A, N_B) with NA+NB=16N_A + N_B = 16 that maximizes pass@NA(pA)+pass@NB(pB)\text{pass@}N_A(p_A) + \text{pass@}N_B(p_B). Compare it with the even split 8/8.

(b) Now suppose you have no checker and must use majority vote, and both questions are right/wrong (binary answers). What is the best split now? How much is the extra budget on B worth?

(c) Snell et al.’s “compute-optimal” strategy picks the method and budget per question based on estimated difficulty. Using (a) and (b), say in two sentences why this beats spending the same amount on every question, and why it needs an estimate of difficulty.

Hint
For (a) the marginal value of one more sample on a question with success p, after n samples, is p(1−p)^n. Allocate greedily. For (b), recall that for binary answers with p < 1/2 majority vote only gets worse with N.
Solution

(a) The gain from adding one sample when you already have nn is pass@(n+1)−pass@n=p(1−p)n\text{pass@}(n+1) - \text{pass@}n = p(1-p)^n. Because these gains shrink with nn, giving each next sample to the question with the larger marginal gain is optimal.

A: 0.6(0.4)n0.6(0.4)^n = 0.6, 0.24, 0.096, 0.0384, 0.0154, 0.0061, … B: 0.05(0.95)n0.05(0.95)^n = 0.050, 0.0475, 0.0451, 0.0429, 0.0407, 0.0387, 0.0368, 0.0349, 0.0332, 0.0315, 0.0299, 0.0284, 0.0270, …

The 16 largest gains are A’s first four (down to 0.0384) and B’s first twelve (down to 0.0284). The next candidates, A’s fifth (0.0154) and B’s thirteenth (0.0270), are both smaller. So the optimum is NA=4N_A = 4, NB=12N_B = 12: (1−0.44)+(1−0.9512)=0.9744+0.4596=1.434(1 - 0.4^4) + (1 - 0.95^{12}) = 0.9744 + 0.4596 = 1.434. (Check the neighbors: (3,13)(3, 13) gives 0.936+0.487=1.4230.936 + 0.487 = 1.423 and (5,11)(5, 11) gives 0.990+0.431=1.4210.990 + 0.431 = 1.421, both lower.) The even split gives (1−0.48)+(1−0.958)=0.99934+0.3366=1.336(1 - 0.4^8) + (1 - 0.95^8) = 0.99934 + 0.3366 = 1.336. With an oracle, the hard question deserves most of the budget: rare successes are worth hunting.

(b) For B, p<1/2p < 1/2 with binary answers, so majority vote gets worse with more samples: maj@1 = 0.05 and then down toward 0. Give B exactly 1 sample. For A, maj@N rises with odd NN (even NN adds nothing, Exercise 17.1): NA=15N_A = 15 gives about 0.79. So the split is (15,1)(15, 1), scoring about 0.79+0.05=0.840.79 + 0.05 = 0.84. Extra budget on B is worth nothing (negative, in fact) without a checker.

(c) The best allocation depends sharply on each question’s difficulty and on the selection method: with an oracle the hard question deserves most of the samples, while with majority vote it deserves almost none. A uniform budget wastes compute in both cases, but choosing well requires knowing roughly how hard each question is in advance, which Snell et al. estimate with a learned or verifier-based difficulty predictor.

Exercise 17.7Hacking a process reward modelConcept●●○

You train a policy with GRPO-style updates, where the reward is the sum over steps of a PRM’s per-step score p^j∈(0,1)\hat p_j \in (0, 1) (“probability this step is correct”), plus 1 for a correct final answer.

(a) Describe two ways the policy could raise this reward without getting better at solving problems.

(b) Propose three changes that remove or reduce the incentives you found, and say what each costs.

Hint
Ask what happens to the reward when the policy adds one more harmless step, and what the PRM has never been trained to recognize. Then reread the callout “A process reward is an advantage”.
Solution

(a) Padding: every extra step adds a positive score, so writing many correct but empty steps (restating the problem, re-deriving known facts, splitting one step into five) raises the sum. Exploiting blind spots: steps the PRM rates highly but that are wrong, such as confident phrasing, familiar-looking manipulations, or a “verification” step that checks nothing, get high scores. A frozen PRM never learns that they are wrong. (Also: pushing the hard reasoning into one long “step” the PRM scores leniently.)

(b) Options (any three):

  • Use differences, not absolute scores (step reward = change in value, as with Math-Shepherd values or progress-based rewards). Padding then earns zero. Cost: you need a PRM that predicts values, and you must estimate them well.
  • Aggregate with min or product instead of a sum, so one bad step ruins the score and extra steps cannot add reward. Cost: a sparser, noisier signal. The product even penalizes each extra step, which invites the opposite hack: cramming the work into a few long steps.
  • Keep the outcome reward dominant (scale the process term down) and keep a verifiable final check. Cost: you lose part of the credit-assignment benefit.
  • Update the PRM online on the current policy’s samples with outcome labels (PRIME), so blind spots get patched as the policy finds them. Cost: extra training compute and a moving target.
  • A length penalty or fixed step budget. Cost: may cut genuinely useful long reasoning.
  • Monitor held-out outcome accuracy and PRM–outcome disagreement (Chapter 19).
Exercise 17.8Explore the two demosExplore the demo●○○

(a) In the test-time scaling demo, choose “One problem”, set p=0.3p = 0.3, wrong answers that agree = 30%, d′=2d' = 2, and f=0f = 0. Read best-of-N at N=1024N = 1024. Now raise ff to 0.5%, 2% and 5%, and note where best-of-N peaks each time. Does the peak move the way N⋆=1/(f(1−p))N^\star = 1/(f(1-p)) predicts?

(b) Find settings where majority vote beats best-of-N at N=1024N = 1024, and settings where weighted voting beats both.

(c) In the step-values demo, press Reset, then move the slip from step 3 to step 1: tap step 3 twice (each tap cycles −1 → +1 → none), then tap step 1 once (−1). Why is the drop at step 1 smaller than the drop at step 3 was, even though both slips ruin the answer?

Solution

(a) With f=0f = 0, best-of-N climbs to about 1.0. With f>0f > 0 it peaks and then declines. The peak is near N=32N = 32–6464 for f=0.5%f = 0.5\% (N⋆≈286N^\star \approx 286) and near N=16N = 16 for both 2% (N⋆≈71N^\star \approx 71) and 5% (N⋆≈29N^\star \approx 29). The peak height drops (about 0.94, 0.85, 0.73) and the decline after it gets steeper and starts earlier as ff grows. So the prediction holds in direction, and the peak sits several times below N⋆N^\star (see Exercise 17.3d). The peak can’t move much below N=16N = 16, because that is where the gain from finding a right answer saturates, whatever ff is. On a grid of powers of 2 that makes the 2% and 5% peaks look alike.

(b) Majority vote wins at large NN whenever the right answer is the mode and f>0f > 0, because best-of-N has declined. For example, with p=0.3p = 0.3, 40% of wrong answers agreeing, d′=2d' = 2 and f=2%f = 2\%, the demo reads majority 0.79 and best-of-N 0.62 at N=1024N = 1024. Weighted voting beats both when the popular wrong answer is the mode (more than 3/7≈43%3/7 \approx 43\% agreeing at p=0.3p = 0.3, so 45% or more on the slider) and the verifier is sharp (d′≥2d' \ge 2). Each right answer carries a weight near 0.8 while ordinary wrong answers carry weights near 0.2, so the verifier overturns the wrong plurality. The convincing answers are too rare (2%) to tip the totals. At 60% agreeing and f=2%f = 2\%, weighted voting reads 1.00, best-of-N 0.63 and majority vote 0.00.

(c) The drop at a step equals the value just before it minus the value just after. A slip at step 1 takes the value from 0.276 to 0.073 (a drop of 0.20). The slip at step 3 took it from 0.385 to 0.052 (a drop of 0.33). Before step 1 all six risky steps still lie ahead, so the value is low. Before step 3, two of them have been survived. (After an early slip there are also more steps left in which a lucky second slip can repair it, so the value after the slip is a little higher.) A slip costs whatever value was left, and less is left early on: when success was unlikely anyway, ruining it costs less. (This is also why the start of a long solution gets weak credit under any scheme.)

Exercise 17.9Lab, part 1: test-time computeCode●●○

In ttc.py (lab 17-process-rewards):

  • Task 1: pass_at_n(p, n) and the unbiased estimator pass_at_k(n, c, k).
  • Task 2: majority_vote_accuracy(p, n), the exact binomial sum with coin-flip ties.
  • Task 3: the three selectors majority_vote, best_of_n and weighted_vote, with ties going to the earliest answer.

Then run python run.py and look at panels (a) and (b): your simulated majority vote should sit on your exact formula, majority vote should plateau, and best-of-N with a fooled verifier should peak and decline.

Hint
For pass_at_k, return 1.0 when n − c < k before calling math.comb. For the selectors, a Counter or a dict of totals, followed by a scan of answers in order, handles ties exactly as the tests expect.
Solution

The reference is solutions/ttc.py. The key lines:

def pass_at_k(n, c, k):
    if n - c < k:
        return 1.0
    return 1.0 - comb(n - c, k) / comb(n, k)

def majority_vote_accuracy(p, n):
    total = 0.0
    for c in range(n + 1):
        prob = comb(n, c) * p**c * (1 - p) ** (n - c)
        total += prob if 2 * c > n else 0.5 * prob if 2 * c == n else 0.0
    return total

def weighted_vote(answers, scores):
    total = defaultdict(float)
    for a, s in zip(answers, scores):
        total[a] += float(s)
    best = max(total.values())
    return next(a for a in answers if total[a] == best)

majority_vote is weighted_vote with all scores equal to 1, and best_of_n is answers[int(np.argmax(scores))]. Scanning answers in order is what makes ties go to the first occurrence. The test test_scaling_story checks the chapter’s qualitative claims: best-of-16 ≫ one sample, best-of-512 well below best-of-16 when 5% of wrong answers fool the verifier, and weighted voting near 1.

Exercise 17.10Lab, part 2: Monte Carlo step labels and PRM-guided beam searchCode●●●

In process.py:

  • Task 4a: mc_step_labels(task, problem, steps, k, rng) returns the soft and hard labels for every prefix j=0..Tj = 0..T.
  • Task 4b: process_rewards(values) returns Vj−Vj−1V_j - V_{j-1}.
  • Task 5: beam_search(task, problem, prm, beam_width, expand, rng) is the step-level beam search from the chapter’s pseudocode, removing duplicate candidates and counting every generated step.

Run python run.py. In panels (c)–(d), check that your k=32k = 32 soft labels track the true values and that the most negative step reward lands on step 3. In panels (e)–(f), compare beam search with best-of-N at the same number of generated steps, with a good PRM (σ=1\sigma = 1) and a poor one (σ=3\sigma = 3). Explain the difference in two sentences.

Hint
In beam search, keep a set of tuples of the candidates already added, so duplicates are skipped but still counted in n_generated. Python’s sorted is stable, so sorting candidate indices by −score keeps ties in candidate order.
Solution

The reference is solutions/process.py. The core of the beam search:

beams, n_generated = [[]], 0
for _ in range(len(problem.ops)):
    candidates, seen = [], set()
    for prefix in beams:
        for _ in range(expand):
            new = prefix + [task.policy_step(problem, prefix, rng)]
            n_generated += 1
            if tuple(new) not in seen:
                seen.add(tuple(new))
                candidates.append(new)
    scores = [prm(problem, c) for c in candidates]
    order = sorted(range(len(candidates)), key=lambda i: -scores[i])
    beams = [candidates[i] for i in order[:beam_width]]
return beams[0], n_generated

mc_step_labels loops over jj, runs task.rollout kk times from steps[:j], and records the fraction of correct rollouts and whether any was correct. process_rewards is values[1:] - values[:-1].

What you should see: with a good PRM, beam search reaches about 0.8 accuracy at roughly 12 generated steps per problem, against about 0.5 for best-of-N at the same compute, because bad prefixes are pruned before they are finished. With a poor PRM, beam search loses most of that edge and mostly trails weighted voting, because it optimizes harder against the PRM’s errors. That is Snell et al.’s finding in miniature: search is only as good as the verifier it optimizes.

Files: README.md, ttc.py, process.py, chain.py, test_ttc.py, test_process.py, run.py

cd 17-process-rewards
python -m pytest -q          # your code: tests fail until you fill in the TODOs
RL_SOLUTIONS=1 python -m pytest -q   # reference solutions: all pass

First time? See Exercises & setup.

Further reading

Next, Chapter 18 takes the model out of the single-answer setting: agentic and multi-turn RL, where a trajectory includes tool calls and observations, and credit assignment over long horizons becomes the central problem.