AI Infra
0%
Part IV · Chapter 28

Training Models to Reason

AuthorChangkun Ou
Reading time~20 min

Reinforcement learning changes character when the reward is a checkable ground truth rather than a learned human-preference proxy. Where a verifier exists, it beats a reward model because it removes the learned proxy gap. group relative policy optimization (GRPO) and REINFORCE leave-one-out (RLOO) are policy-gradient variants that compute a baseline (the reference value an outcome is compared against to decide if it was better than typical) from sampled groups, and they simplify proximal policy optimization (PPO) by dropping its critic (a learned predictor of expected reward used as that baseline). The o1 and R1 line showed that long-horizon reasoning can emerge without step-level supervision, and the field still disagrees about whether that training teaches new reasoning or mainly reweights what the base model could already sample.

The thread that runs through every section is a single object, the verifier. Where it exists, this recipe applies. Lose it, and you are back to the learned reward model of Chapter 19. Once that object is fixed, each design choice has a visible cost.

A Reward Without a Learned Proxy Gap

Start with the failure that motivates everything here. A learned reward model is a proxy, and a policy trained against a proxy will find its argmax, not the true objective's. This is the over-optimization problem that haunts the RLHF of Chapter 19 (Gao et al. 2022): push hard enough on a model of human preference and the policy learns to satisfy the model rather than the human. The reward model has no ground truth to anchor it, so its blind spots become the policy's exploits.

For a large and valuable class of tasks there is a way out, because the answer can be checked. A program either passes its unit tests or it does not. A math answer equals the reference or it is wrong, with nothing in between. And a formal proof type checks in Lean or it fails to. On these tasks you can replace the learned reward with a verifier and optimize the policy against a reward that has no proxy gap to exploit. That move, reinforcement learning with verifiable rewards (RLVR), is the training-time analogue of the runtime verification loop that an agent harness runs at inference.

Swapping the proxy for a checker

The loop end to end is short. Sample completions for a prompt, run each through a verifier for a scalar reward that is often just binary, and update the policy toward the rewarded completions. The training data is prompts with a way to check the answer, not prompts with reference completions. The optimizer is the PPO machinery of Chapter 19 reused without change (Schulman et al. 2017): a policy, an advantage estimate, and a KL penalty against a frozen reference model. The innovation is the reward source, not the algorithm.

P Prompt with checkable answer S Sample G completions P->S V Verifier: tests, checker, proof S->V R Scalar reward per completion V->R A Group-relative advantage R->A U Policy update with KL anchor A->U U->S
Figure 28.1. The RLVR loop. Sample completions for a checkable prompt, score each with a verifier, turn rewards into a group-relative advantage, and update the policy under a KL anchor.

Everything downstream of this loop is determined by how good the checker in the middle box is. The next section opens it up.

Three kinds of verifier

The verifier is the part you cannot buy, and it comes in three families with different cost and coverage. Executable unit tests for code are cheap and high-signal, but coverage limited, and a solution that passes the tests while being wrong will be rewarded all the same. Answer checkers for math reduce to string, numeric, or symbolic equivalence, where the hard engineering is parsing and deciding equivalence rather than the check itself. Formal proof checkers in the Lean or Isabelle style are near unspoofable, but narrow and expensive to author. Each family trades coverage against integrity, and that trade is the recurring theme here. Figure 28.2 places the three families on that axis.

verifiers tests Unit tests (code) broad coverage, cheap spoofable: passes wrong solution checker Answer checker (math) string / numeric / symbolic hard part is equivalence proof Proof checker (Lean, Isabelle) near unspoofable narrow, expensive to author integrity more integrity coverage more coverage
Figure 28.2. The three verifier families trade coverage against integrity. Unit tests are broad but spoofable, formal proof checkers near unspoofable but narrow.
Constraint arrow

The shape of the RL recipe is dictated from below by whether a verifier exists. Where the answer is checkable, you get a reward without a learned proxy gap and this loop applies. Where it is not, you fall back to the learned reward model of Chapter 19 and inherit its over-optimization. This is why frontier reasoning work concentrates on math, code, and formal proof: the availability of a ground truth at the data layer, not a preference at the training layer, is what decides which algorithm you can run. The verifier's coverage is the real budget, though the closing section of this chapter shows that boundary being stretched in 2025.

Dropping the critic

With the reward source fixed, the optimizer earns one real simplification. PPO carries a value network, a critic, to estimate the baseline that lowers advantage variance, and that network doubles model memory and adds its own failure mode. Group Relative Policy Optimization, introduced for DeepSeekMath (Shao et al. 2024), drops the critic and estimates the advantage from the group of samples drawn for one prompt: normalize each reward against the group mean and standard deviation. For a group of GG completions with rewards rir_i,

Ai=rimean(r1,,rG)std(r1,,rG).A_i = \frac{r_i - \operatorname{mean}(r_1, \dots, r_G)}{\operatorname{std}(r_1, \dots, r_G)}.

Compute both baselines on the same reward vector and watch where they differ, and what a no-spread group does to each.

import numpy as np

def grpo_adv(r):
    s = r.std()
    if s == 0:            # all pass or all fail: no spread, no signal
        return np.zeros_like(r)
    return (r - r.mean()) / s

def rloo_adv(r):          # baseline = mean of the other G-1 samples
    G = len(r)
    return r - (r.sum() - r) / (G - 1)

for name, r in [("mixed   ", np.array([1., 0., 1., 0.])),
                ("all pass", np.array([1., 1., 1., 1.]))]:
    print(f"{name} rewards={r.tolist()}")
    print(f"   GRPO advantage = {np.round(grpo_adv(r), 3).tolist()}")
    print(f"   RLOO advantage = {np.round(rloo_adv(r), 3).tolist()}")
Figure 28.3. GRPO advantages for one group of completions. The solid bar is a completion's reward minus the group mean, divided by the group standard deviation, so no value critic is needed; the faint bar is the raw reward minus the mean. Drag the reward spread: the raw gaps grow and shrink with it, but the normalized advantages hold steady, because dividing by the standard deviation cancels the scale. Pull the spread to zero and every reward is equal, the standard deviation vanishes, and both collapse to nothing: a group that all passes or all fails gives no gradient. Illustrative.

This is cheaper than PPO with a critic and fits RLVR exactly, because sampling many completions per prompt is natural when each one is cheap to verify. The KL term against the reference is kept. RLOO, REINFORCE Leave-One-Out, makes the same bet with a different baseline (Ahmadian et al. 2024): each sample's baseline is the mean reward of the other samples in the group. GRPO and RLOO differ in their bias and variance trade-offs, but they agree on the structural claim that the critic was often unnecessary overhead. Figure 28.4 shows where the three methods get the baseline that turns a reward into an advantage.

cluster_PPO PPO cluster_GRPO GRPO cluster_RLOO RLOO p1 Reward per sample p2 Critic network estimates baseline p1->p2 g1 Rewards for group of G p1->g1 drops the critic p3 Advantage = reward minus critic p2->p3 g2 Baseline = group mean, scaled by group std g1->g2 g3 Advantage normalized within group g2->g3 r1 Rewards for group of G r2 Baseline = mean of the other G minus 1 r1->r2 r3 Advantage = reward minus leave-one-out mean r2->r3
Figure 28.4. PPO learns a separate critic network to estimate the baseline. GRPO and RLOO compute it from the group of samples drawn for one prompt, so no critic is carried.
Where this came from

The reward-prediction error that reinforcement learning optimizes, the gap between the reward expected and the reward received, is the same quantity midbrain dopamine neurons were later found to fire in proportion to, one of the few cases where an algorithm predated the neuroscience it turned out to describe. Chapter 3 traces that lineage and where the analogy stops.

What the loop produced: o1 and R1

The result that changed the field was that this loop, run on math and code with long chains of thought allowed, produces emergent long-horizon reasoning without any step-level supervision. Self-checking, backtracking, and longer deliberation appear from an outcome-only reward. OpenAI's o1 announced the capability (OpenAI 2024). DeepSeek-R1 is the open data point that showed the recipe (Guo et al. 2025).

R1 is clearest as two variants because the contrast carries the claim (Guo et al. 2025). R1-Zero applies RL directly to a base model with no supervised cold start, and reasoning behavior still emerges, which is the strong claim. R1 adds a short SFT cold start before the RL, drawing on the supervised fine-tuning of Chapter 17, not to teach reasoning but to fix readability and stability: the zero variant reasons in a way that is correct but hard to read and prone to language mixing. The cold start is a cosmetic and stabilizing prefix, and the reasoning gains come from the RL. Figure 28.5 contrasts the two pipelines.

B Base model RL1 RLVR on math and code B->RL1 CS Short SFT cold start: readability and stability B->CS Z R1-Zero: reasoning emerges, hard to read, language mixing RL1->Z RL2 RLVR on math and code CS->RL2 R R1: same reasoning gains, readable output RL2->R
Figure 28.5. R1-Zero applies RLVR directly to the base model. R1 inserts a short SFT cold start for readability and stability before the same RL, where the reasoning gains still come from.

The shipped R1 is more than a cold start bolted onto RL. Read in full it is a four-stage pipeline: a small cold-start SFT set to fix readability, a first reasoning-oriented RL stage, a rejection-sampling pass that keeps only verified-correct traces and folds in general SFT data, then a final RL stage run across both reasoning and general preferences (Guo et al. 2025). The reward in the zero variant is rule-based and composite, an accuracy reward that checks the answer plus a format reward that requires the chain of thought to sit between <think> and </think> tags; R1 adds a language-consistency reward, the fraction of the chain written in the target language, to stop the zero variant's language mixing at a small measured cost to raw accuracy (Guo et al. 2025).

RL runs straight on the base model with no cold start, and reasoning still emerges, but the chains are hard to read and mix languages.
A small supervised set enters first, not to teach reasoning but to give the base model a readable, stable format before any RL begins.
RLVR runs on math and code under a composite reward, where an accuracy check and a format reward grow the reasoning that R1-Zero showed is learnable.
Sampling keeps only verified-correct traces and folds in general SFT data, so the model relearns from filtered reasoning alongside broad behavior.
A last RL stage runs across reasoning and general preferences together, adding a language-consistency reward that ends the mixing R1-Zero left behind.
Figure 28.6. R1-Zero is RL straight on the base model; the shipped R1 wraps that same RL in four stages that buy readability and alignment. Step through each stage, or let it play.

Two of R1's reported dead ends teach as much as its successes (Guo et al. 2025). A process reward model (PRM) was tried and dropped: defining a fine-grained correct step in open reasoning is hard, judging each step is itself error-prone, and the learned PRM invited the reward hacking of Chapter 19 for a gain that did not justify the overhead. Monte Carlo tree search (MCTS) over the token stream was tried and dropped too, because token generation opens an exponentially larger search space than a board game and the step-value model it needs is hard to train. The signal that won was the plain outcome reward, not the denser, cleverer one. The other lesson is about who gets the reward: distilling R1's traces into a smaller dense model beat running the same RL on that small model directly, DeepSeek-R1-Distill-Qwen-32B reported above DeepSeek-R1-Zero-Qwen-32B, so the cheapest way to put reasoning into a small model is to let a large one find it and copy the result, a thread that Chapter 23 picks up.

What's contested

Whether RLVR instills new reasoning or only amplifies what the base model already knows is unsettled. The amplification position holds that RL with verifiable rewards sharpens a distribution the base model already places mass on: it raises pass@1 (the fraction of problems solved on the first try) by concentrating probability on reasoning paths the base model could already sample, and studies report that pass@k (the fraction solved within kk attempts) at large kk for the base model can match or exceed the RL-trained model, which would mean RL is eliciting and reweighting rather than teaching. The instillation position points to R1-Zero, where behaviors like backtracking and self-correction grow in frequency and length over training in a way that looks like acquisition, not just reweighting (Guo et al. 2025). The disagreement is partly about measurement, since pass@k, sampling temperature, and the strength of the base model all move the verdict, and it stays live because both sides can point to real runs. Treat a claim that RLVR teaches reasoning as base-model and metric dependent, not settled. Yue et al. sharpen the amplification case with large pass@k comparisons, arguing that the base model's broad sampling distribution already contains the paths the RL model concentrates (Yue et al. 2025). Spurious-reward experiments push that case further: on Qwen2.5-Math-7B, RLVR with random or even incorrect rewards recovers most of the ground-truth gain, +21.4 of +29.1 points on MATH-500, while the same spurious rewards fail on Llama and OLMo base models (Shao et al. 2025). A reward that carries no information cannot teach; it can only amplify what pretraining already put there. ProRL argues the opposite under prolonged RL with KL control and reference policy resetting, reporting tasks where the RL model solves problems the base model does not solve even under extensive sampling (Liu et al. 2025). Wen et al. add a measurement critique: ordinary Pass@K credits a correct final answer even when the chain is wrong, so they propose CoT-Pass@K, which requires both the reasoning path and the final answer to be correct (Wen et al. 2025). Figure 28.7 sketches the crossover the amplification position rests on.

2026-06-21T21:25:36.737700 image/svg+xml Matplotlib v3.11.0, https://matplotlib.org/
Figure 28.7. Schematic illustration of the amplification hypothesis: an RL-trained model raises pass@1 but saturates early, while the base model's pass@k keeps climbing and can overtake it at large . Idealized, not measured data.
Figure 28.8. RLVR boundary debate, illustrated. Raise base coverage to make the amplification story stronger; raise RL expansion to make the instillation story stronger; raise CoT strictness to see why Pass@K can overstate reasoning when correct answers arrive through flawed traces. Synthetic, not measured.

How much credit, and how often

The supervision question has its own lineage, and it is a second axis cutting across the verifier families. Outcome rewards score only the final answer, which is cheap and is the RLVR default, but assigns credit coarsely over a long chain. Process rewards score each step through a process reward model, a PRM, which Lightman et al. trained for "Let's Verify Step by Step" (Lightman et al. 2023) and Uesato et al. compared against outcome feedback earlier (Uesato et al. 2022). A PRM gives denser credit and helps long-horizon learning, but it reintroduces exactly what the verifier removed: a learned, hackable reward. The surprise of the R1 era is how far an outcome-only signal got without any process model at all.

Refining the group baseline

GRPO shipped the reasoning models, and the year after R1 was spent finding where its group baseline lies and correcting it. The sharpest reading came from Liu et al. (2025), which names two biases in the update. A length bias, because the per-token 1/oi1/|o_i| normalization gives a correct short answer a larger gradient than a correct long one and penalizes a wrong long answer less than a wrong short one, so the policy drifts toward longer wrong outputs. And a difficulty bias, because dividing the advantage by the group's standard deviation up-weights questions that are almost all-pass or all-fail, where the spread is smallest. Dropping the 1/oi1/|o_i| and standard-deviation terms removes both and recovers the unbiased PPO objective, reaching the same reasoning at fewer tokens, which is why the authors call it GRPO done right.

Two further fixes target a different failure, the policy collapsing onto a few high-reward modes as its entropy craters (its outputs lose diversity and converge to a few repeated patterns). DAPO (Yu et al. 2025) decouples the clip range so the upper bound can rise on its own, its clip-higher rule, which leaves room for low-probability exploratory tokens to grow rather than be clipped away, and it adds dynamic sampling, discarding prompts whose group is all-correct or all-wrong because a group with no spread produces no advantage and no gradient, the dead case the runnable above made visible. GSPO (Zheng et al. 2025), from the Qwen team, moves the importance ratio from the token to the sequence: it scores, clips, and optimizes on whole-sequence likelihood rather than per-token ratios, which it argues are ill-matched to a reward defined over the whole sequence, and the change stabilizes the otherwise brittle RL of mixture-of-experts models (the sparse, routed architecture of Chapter 9). The KL term also loses the necessity it had in Chapter 19: with a verifier there is no learned proxy to drift into, and DAPO drops the KL penalty that RLHF kept as a constraint, relying on clip-higher to keep entropy from collapsing instead.

Kimi k1.5 is the other important public data point because it lands on a similar practical lesson from a different route. Its report emphasizes long-context RL and improved policy optimization, and explicitly avoids MCTS, value functions, and process reward models while reaching strong math, code, and multimodal reasoning results (Kimi Team et al. 2025). It also introduces long2short methods, using long-CoT training to improve short-CoT models. That belongs to Chapter 29, but it matters here because it shows the training loop and the data loop are no longer separable: a long reasoning policy can become a teacher for a cheaper short reasoning policy.

Failure Modes and Payoff

The recipe is a set of balances, each with a knee. Read these as the dials you turn once the verifier is fixed.

  • Verifiable reward versus learned reward. A verifier is hard to exploit in the proxy sense but only exists where ground truth is checkable, and its coverage is the new attack surface. The learned reward model of Chapter 19 works on open-ended tasks but is an over-optimizable proxy. Real recipes mix both by domain (Lambert et al. 2024).
  • Outcome versus process supervision. Outcome rewards are cheap, robust, and sparse. Process rewards through a PRM are dense and better for long-horizon credit, but the PRM is a learned, exploitable reward and expensive to label (Uesato et al. 2022). This is signal density against reward integrity.
  • Critic versus critic-free. A value network lowers advantage variance but doubles model memory and adds a failure mode of its own. GRPO and RLOO trade that variance for simplicity and fit the many-samples shape of RLVR (Shao et al. 2024).
  • Exploration versus KL collapse. Too little KL, or too aggressive optimization, collapses the policy onto a few high-reward modes and stops exploration, so reward rises while held-out quality falls. Too much KL and the policy never moves off the reference. The KL coefficient and clip range are the central RLVR knob. Figure 28.9 sketches the knee where training reward keeps rising while held-out quality turns down.
2026-06-21T21:25:37.316305 image/svg+xml Matplotlib v3.11.0, https://matplotlib.org/
Figure 28.9. Schematic illustration of the exploration versus KL-collapse trade-off: as the policy moves further from the reference, training reward keeps climbing while held-out quality peaks and then falls into reward hacking and mode collapse. Idealized, not measured data.
  • Verifier coverage versus exploitability. A stricter, broader verifier resists exploitation but costs more and may reject correct-but-unusual answers, false negatives that starve learning. A loose verifier is cheap but leaks reward to wrong answers.

Most failures here are the optimizer finding what you measured rather than what you meant. The central one is reward hacking through verifier gaps: the policy discovers inputs the verifier scores correct that are not, tests passing on degenerate solutions, checkers fooled by formatting, hard-coded outputs for known cases. The reward to the optimizer is real and the answer to you is wrong. Next comes KL or mode collapse, where the policy concentrates on a few high-reward outputs, entropy craters, and held-out quality degrades while training reward climbs. Subtlest is reasoning that exploits the checker rather than the problem: the visible chain of thought steers toward whatever the verifier rewards, or does not faithfully drive the answer at all.

Two boundaries keep the method in check. RLVR is strongest where ground truth is checkable and does not transfer for free to open-ended tasks, so over-indexing on it skews the model and leaves a gap that only a learned reward or human judgment fills. The 2025 attempt to stretch the recipe past that boundary replaces the checker with an explicit rubric, scoring an open-ended answer against a written list of criteria rather than one ground truth, which recovers a denser-than-preference signal where no verifier exists (Gunjal et al. 2025). It buys reach at the cost of the property that made the verifier safe, since a rubric is itself a written proxy that can be exploited. Over-squeezing the reward also regresses the instruction-following, safety, and breadth installed in post-training, a catastrophic forgetting that the KL anchor here only partly prevents and that Chapter 47 must catch.

The boundary also moved from the frontier side. In July 2025, Gemini Deep Think, graded officially by IMO coordinators, and an experimental OpenAI model reached gold-medal standard at the International Mathematical Olympiad, 35 of 42 points, writing end-to-end natural-language proofs with no formal verifier and no per-problem checker at inference (Google DeepMind 2025). The reported ingredients are RL on hard-to-verify reasoning tasks plus parallel test-time compute. Read that as the verifiable-reward boundary being stretched, not erased: the reward can be softer than a mechanical check, but the training still leans on mathematics, where correctness is at least gradeable.

The self-improvement loop is the payoff when a verifier is sound. Generate candidate training data with the model, filter by the verifier to keep only verified-correct traces, and feed those into another SFT or RL round, then iterate. This is distinct from the distillation of Chapter 23 because the filter is a checker, not a stronger teacher, so the model can bootstrap past its current self. The hard limit is that it needs a verifiable signal to close the loop: a sound verifier gives a genuine bootstrap, an unsound one amplifies its own blind spots. Running the sampling and rollout fleet that feeds all of this at scale belongs to Chapter 10, and the inference-time analogue of spending more compute to reason better is Chapter 30.

Extending the same loop from rewarding an answer to rewarding a whole trajectory, training a model to act and not only to reason, is Chapter 37.

Further reading

  • Shao et al., “DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models” (introduces GRPO), 2024. arXiv:2402.03300
    DeepSeekMath 7B achieves 51.7
  • Guo et al., “DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement learning” (peer-reviewed version of arXiv:2501.12948, published 17 September 2025; DOI 10.1038/s41586-025-09422-z), 2025. arXiv:2501.12948
  • Schulman et al., “Proximal Policy Optimization Algorithms” (PPO; introduced in Chapter 19, reused here), 2017. arXiv:1707.06347
  • Lightman et al., “Let's Verify Step by Step” (process reward models / PRMs), 2023. arXiv:2305.20050
  • Uesato et al., “Solving Math Word Problems with Process- and Outcome-Based Feedback” (process vs outcome supervision), 2022. arXiv:2211.14275
    This paper compares process-supervised and outcome-supervised reward models for math reasoning on GSM8K, finding that a PRM reduces reasoning trace error from 14.0
  • Ahmadian et al., “Back to Basics: Revisiting REINFORCE-Style Optimization for Learning from Human Feedback in LLMs” (RLOO), 2024. arXiv:2402.14740
    Simple REINFORCE-style policy gradient (RLOO) outperforms PPO and DPO for RLHF alignment of LLMs, with lower compute cost and no need for PPO's actor-critic complexity.
  • OpenAI, “Learning to Reason with LLMs” (the o1 line; an official announcement / system report, not a peer-reviewed paper), 2024. openai.com
  • Lambert et al., “Tulu 3: Pushing Frontiers in Open Language Model Post-Training” (names/positions RLVR), 2024. arXiv:2411.15124
    Tülu 3 is a fully open post-training recipe (SFT, DPO, and a novel RLVR method) for Llama 3.1 base models, releasing weights, data, and training code that match or exceed proprietary model instruct variants.
  • Google DeepMind, “Advanced Version of Gemini with Deep Think Officially Achieves Gold-Medal Standard at the International Mathematical Olympiad” (IMO 2025 gold, 35/42, with end-to-end natural-language proofs graded by IMO coordinators), 2025. deepmind.google

Comments

Log in to comment