Reasoning
How does a model learn to think before it answers, and what does thinking buy?
In 2022 one sentence, let's think step by step, lifted a model's arithmetic scores; in 2024 and 2025 o1 and DeepSeek-R1 were trained to think. The part tries each idea on three tiny transformers trained here. On the parity of 16 bits a 2-layer model stays at chance when it answers at once and is almost always right when it writes the running parity first: a chain of thought is extra serial computation. Many chains and a vote amplify the answer the model already prefers, and the bound that says when is derived; graders of answers and of steps are trained and found to mislead as more samples are drawn. Then the model learns from a checker: GRPO is derived from Part 26's policy gradient, with its group baseline, clip and KL estimators, and run on two-digit addition. The part turns to what that training costs: entropy collapses, chains grow until thought has a price, and exact pass@k shows RL sharpening one try while many tries gain little. It ends with computation spent at answer time, search over thoughts, latent reasoning, proofs checked in Lean and ARC-AGI.
What you need. Policy gradients, baselines and PPO's clip from Part 26, the KL-regularized objective and best-of-n from Part 27, and Hoeffding's inequality (Part 5).
- Mathematics and history
- chain of thought as computation, PRMs, RLVR, GRPO and its variants, pass@k, test-time scaling
- Models, data
- o-series, R1
What you will be able to do
Undergraduate
- Explain why writing intermediate steps lets a fixed-depth model compute something it cannot compute in one pass, using the parity experiment.
- Say when a majority vote over sampled chains helps and when it makes a wrong answer more certain.
Master's
- Derive GRPO's objective from the policy gradient: the group baseline, the ratio, the clip and the KL term.
- Prove that the pass@k estimator is unbiased and that k3 is a nonnegative, unbiased estimate of the KL.
- Bound the error of a vote over k chains with Hoeffding's inequality and a union bound.
Research
- Derive the first-order entropy change of a softmax policy under a policy-gradient step and explain entropy collapse with it.
- State the two sides of the debate on whether RL widens what a model can solve, and what exact pass@k on a small model can and cannot settle.
Engineering
- Compare GRPO with Dr. GRPO, DAPO, GSPO and CISPO by the term each changes, and recognize a collapsed run from its entropy and its share of groups with no signal.
- Choose between voting, best-of-N with a checker, beam search and a longer chain for a fixed budget of output tokens.
Contents
Each chapter has a home level. Choose a track to see what to read and watch: Undergraduate 20 min · Master's 43 min · Research 53 min · Engineering 30 min.
- 0From "let's think step by step" to o1 and R1Undergraduate4 min
- 1Thinking out loud is computingUndergraduate4 min
- 2Many chains, one voteUndergraduate4 min
- 3Checking the stepsMaster's4 min
- 4Learning from a checkerMaster's3 min
- 5GRPO, derivedMaster's4 min
- 6The successorsEngineering4 min
- 7Entropy collapseResearch3 min
- 8How long to thinkEngineering2 min
- 9Sharper, or wider?Research4 min
- 10Thinking at answer timeEngineering4 min
- 11Searching over thoughtsMaster's3 min
- 12Thinking without wordsResearch4 min
- 13Proofs a machine can checkUndergraduate3 min
- 14Puzzles nobody has seenUndergraduate3 min
- Recap, problems, and what comes nextAll tracks3 min
Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · 中文 · Build the film.
Lecture
The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film. A dashed box stands for a number the film computes when it is rendered (hover over it to see what is computed); the README's figures for each chapter, where it lists them, follow the chapter's text.
From "let's think step by step" to o1 and R1Undergraduate4 min
In January 2022, a team at Google described a simple idea. Instead of showing a large language model a few questions with their answers, they showed it eight questions with the working written out. In later experiments reported in the same paper, Google's 540-billion-parameter PaLM, on grade-school maths word problems, went from 18 percent right to 57: it wrote out its own working, and got far more right. In May 2022, a team from Tokyo and Google found you didn't even need the examples. One sentence, let's think step by step, took one of OpenAI's models from 18 to 79 percent on arithmetic word problems. The ability was already in the model. It only had to be asked to write its reasoning down.
For two years that was the method: ask for a chain of thought, sample a few, perhaps take a vote. Then, in September 2024, OpenAI introduced o1, trained with reinforcement learning to think before it answers, and released an early version called o1-preview. On the 2024 American Invitational Mathematics Examination, AIME, OpenAI's Appendix A lists GPT-4o at 9.3 percent pass at one. The prose says 12 percent; the post does not explain the difference. We show the metric-labeled table. For the research o1 model, that table lists 74.4 percent with one try and 83.3 with a vote over sixty-four. The prose reports 93 when a learned scorer picked from a thousand. In January 2025, DeepSeek showed how. R1-Zero: reinforcement learning straight from a base model, rewarded only by correctness and format rules. It climbed from 16 percent to 71, and to 87 with a vote, and its weights were open. In July 2025, laboratories reported gold-medal-level solutions at the International Mathematical Olympiad, in plain language, under competition time limits. And yet when ARC-AGI-3, a set of games no model had seen, launched in March 2026, every frontier model scored below one percent, while people solved them all.
That is the question of this part: how does a model learn to think, and what does thinking buy? We'll follow the field's own path: why writing a chain of thought adds computation; sampling many chains and voting; checking the steps; reinforcement learning from a checker of answers, derived; what thinking longer buys; search; and proofs a machine can check. And we'll try each idea here, on tiny models trained on the computer making this video. Evaluation uses fresh draws from the same task distributions; these can repeat training inputs.
This is Part 28 of AI, Built, the third part of the act on agency. In this part: why writing steps adds computation; many chains and a vote, and checking steps instead of answers; reinforcement learning from a checker, with GRPO derived and its successors; what that training does to a model, to its uncertainty, to how long it thinks, and to what it can solve at all; how to spend computation at answer time; and the frontier: thinking without words, tiny recursive models, formal proofs, and puzzles no model has seen.
1Thinking out loud is computingUndergraduate4 min
Here's a puzzle for a small transformer: sixteen bits. Is the number of ones odd? Trained to answer straight away, our two-layer model is right 50 percent of the time: a coin flip. Now train the very same model to write its work first: going along the bits, is the count odd so far? Each step is easy, just the last answer and one more bit. Its final answer is right 100 percent of the time. Same architecture and size, trained separately with labels for every intermediate step. This experiment combines extra computation with intermediate supervision.
Why does writing help? Look at the computation. A transformer runs every token through the same fixed stack of layers. Answering at once, the longest chain of steps that happen one after another is as tall as the stack: L layers, however hard the question. But a token it writes goes back in as input. So the chain of steps can climb the stack, come back down, and climb again, once per token. With k tokens of thought, L times k plus one steps in a row. The written tokens are a scratchpad, and a clock: each one buys another pass through the network.
Theory makes this precise. In 2023 William Merrill and Ashish Sabharwal showed that a transformer of fixed depth, answering at once, computes only what circuits of constant depth with threshold gates can compute, a class called TC zero. Problems believed to lie outside it need depth that grows with the input: composing a long list of permutations of five objects is the classic one. A chain of thought lifts the limit. With T tokens of thought, a constant-depth transformer can simulate any circuit of size T; with polynomially many, it decides exactly the problems a computer can solve in polynomial time. One honest caveat: parity itself is inside TC zero. A fixed-depth network can compute it in principle; what failed in our experiment is learning it, because every single bit flips the answer.
Is it the extra tokens, or what's in them? Give the model the same number of extra positions, filled with meaningless dots, and train it to answer after them. On sixteen bits, Jacob Pfau, Merrill and Sam Bowman showed in 2024 that dots can help on problems that split into independent parallel pieces, and that a model needs dense supervision to learn to use them.
Here are all our runs, on strings of four, eight and sixteen bits. Answering at once is solved at four bits, a coin flip at eight, and a coin flip at sixteen. The dots follow it down. With the running parity written first, all three are solved, in every run.
Here is the training at sixteen bits, replayed. On the left, accuracy as each model trains, three runs of each. On the right, the chain the model writes for three strings, checked bit by bit. At first the chain is noise. The chain is not just more powerful; it is easier to learn, because each step is a small, local problem.
2Many chains, one voteUndergraduate4 min
For the next chapters we need a model that can choose to think. Here is ours, trained on this computer. The question is a list of two to nine digits; the answer is their sum. The model may think first: it writes a think token, then the running total after each digit, then the answer. Or it may answer at once. Its training showed it both, and chains cut short, so it can stop thinking at any point. Sampled at temperature one, made to answer at once, it gets two digits right 90 percent of the time, and nine digits 38. Made to think, 96 and 64. Each step of thought is a small sum, but small sums still go wrong sometimes, and one wrong step spoils the chain.
In March 2022, two months after chain-of-thought prompting, Xuezhi Wang and colleagues at Google asked: if one chain can go wrong, why not sample several and take a vote? They called it self-consistency, and on grade-school maths it added eighteen points over a single chain. The intuition: different routes that reach the same answer are evidence for it. Mistakes, on the other hand, tend to scatter: wrong chains rarely agree on the same wrong answer. And it needs no checker at all, only the answers.
Here is one -digit list, and eight of the sixty-four chains our model wrote for it, made to think. Each step is coloured by whether it matches the true running total. Now tally all sixty-four answers. percent of them are the right sum, ;
When does voting work? Call the right answer y star, and its probability p star. The right answer wins outright when it appears more often than every wrong one. Ties depend on the tie-breaking rule; our code picks the smallest tied answer. Compare it with one wrong answer y: the difference in counts is a sum of k independent draws, each plus one, zero, or minus one, with mean k times p star minus p y. When p star is larger than p y, Hoeffding's inequality says the chance that the wrong answer catches up falls exponentially in k. So as the votes grow, its success probability approaches one if the right answer is the model's single most likely answer, and approaches zero if some wrong answer is more likely. In the large-sample limit, voting selects the model's mode. A finite vote can still be right by chance when a wrong answer is more likely.
Here it is on three hundred questions. One chain is right percent of the time. Voting over chains: percent. The dashed line marks the observed -sample vote, percent. It is not an independent estimate of the infinite-sample limit. If something could check the answers, any of chains being right would count: percent.
3Checking the stepsMaster's4 min
A checker of answers sees only the end. Here is a chain that adds five and three and writes nine, then adds eight and writes sixteen. Two mistakes, and they cancel: the final sum is right. A checker of answers rewards this. A checker of steps would flag two of them. How often does it happen? Among our model's right answers, percent lacked a complete, locally correct chain.
So there are two kinds of learned grader. An outcome reward model reads a whole solution and predicts whether its final answer is right. It is trained with one label per solution, which a checker of answers can supply. A process reward model judges every step: is this step right, given the ones before it? Here we multiply its scores over the steps. Interpreting that product as a probability requires calibrated conditional scores. It needs a label for every step. Either can rerank: sample N solutions and keep the one it scores highest. Or its score can be the reward for reinforcement learning.
The idea of a learned grader came with the grade-school maths benchmark itself. In 2021, Karl Cobbe and colleagues at OpenAI trained a verifier to pick among a hundred sampled solutions, and found it was worth about as much as a model thirty times larger. In 2022, Jonathan Uesato and colleagues at DeepMind compared the two kinds of feedback. Outcome feedback gave final answers about as good, with fewer labels; but to keep the reasoning inside right answers sound, they needed process feedback, or a grader trained to imitate it. In 2023, OpenAI's Let's Verify Step by Step paid people to label eight hundred thousand steps. On a representative subset of the MATH test set, reranking 1,860 solutions per problem, a majority vote solved 69.6 percent, the outcome grader 72.4, and the process grader 78.2.
We can run the comparison on our adding model. Take eight thousand of its solutions, made to think. Train one small grader on the final answers, and another on the steps, each step checked against the one before. Then, on new questions, sample N solutions and let each grader pick. The dashed line is a perfect checker; the gap below it is what a better grader could still win.
Here is one of the solutions, graded both ways. The colours are the truth: which steps really are right. The process grader gives every step a probability of being right. The outcome grader gives the whole solution one number, , and cannot say where it went wrong. That location is what makes step labels useful, for reranking and for teaching.
And yet the models that changed the field in 2025 mostly did not train against process graders. DeepSeek's R1 paper lists them among its unsuccessful attempts: it is hard to say what a step is in general reasoning, hard to check one, and a learned grader, pushed by reinforcement learning, gets exploited: in their words, it inevitably leads to reward hacking. So the recipe became reinforcement learning on outcomes that can be checked exactly: answers to maths problems, tests for code, proofs. Process graders live on for search and reranking, with step labels made automatically: finish a partial solution many times, and see how often it ends right. And the newest graders think before they judge. Learning from a checker is the subject of the next chapter.
4Learning from a checkerMaster's3 min
Chapter one showed that a chain of thought adds computation. But who teaches a model which chain to write, when nobody can write the steps down for it? In February 2024, DeepSeek's maths paper introduced an algorithm called GRPO: Part 26's PPO, without the critic. In September, OpenAI said o1 had learned to think through large-scale reinforcement learning. In November, the Allen Institute's Tülu 3 gave the method a name: reinforcement learning with verifiable rewards. And in January 2025, DeepSeek-R1 showed it at scale, with rewards from simple rules: is the final answer right, and is it written in the right format. The reward is one if a checker accepts the answer, zero otherwise. No person grades anything.
We do it here with a small transformer that has had a little practice at two-digit addition, answering at once. In this game the model is called the policy, pi: the rule that gives a probability to every answer it might write. Give it a question, and sample 8 answers. A checker marks each one: here 2 of 8 are right. Each answer's advantage is its reward minus the group's average, divided by the spread: right answers above the line, wrong ones below. Then nudge the model to make the good answers more likely and the bad ones less. That's GRPO, group relative policy optimization: each answer is judged against its own group. Part 26's actor-critic trained a second network, a critic, to predict the score you'd expect anyway; GRPO uses the group's average instead. And when every answer in a group is right, or every one wrong, the advantages are all zero: nothing to learn.
Repeat that for steps of thirty-two questions each, and replay the training. On the left, accuracy on five hundred new questions, for runs from the same start. On the right, one run's answers to six questions, eight tries each, at every checkpoint. It starts out right percent of the time. As it trains, the green spreads: of right at the start, at the end. The probability has moved onto the answers that check out.
5GRPO, derivedMaster's4 min
Let's derive it. The goal is the expected reward of the model's own answers. Its gradient, by the log-derivative trick of Part 26, is the reward times the gradient of the log-probability of each sampled answer. Subtracting a baseline that depends only on the question changes nothing on average, because the expected gradient of a log-probability is zero; but it can shrink the noise a great deal. GRPO's baseline is the average reward of a group of G answers to the same question, and it divides by their spread. That replaces PPO's critic, a whole second network. Sampling is the expensive part, so each batch is used for several updates. After the first, the model has moved, and the samples come from an older version, pi old: reweight each by the ratio rho, the importance-sampling correction. And clip it, exactly as PPO does, so that no single batch can move the model too far.
Here is the objective as DeepSeek published it, written per token. Each token of each answer gets its own ratio: how much likelier the model now makes it than when the answer was sampled. The advantage is the answer's, shared by its tokens, and the tokens of each answer are averaged. For a good answer, the objective grows with the ratio until the token is twenty percent likelier than it was; then it goes flat, and there's nothing more to gain. For a bad answer, it stops rewarding the push down once the token is twenty percent less likely. In our runs, with four updates per batch, the clip held back 5 percent of the tokens. And the last term keeps the model near where it started.
That last term needs the KL divergence from the reference model, Part 1's measure of how far one distribution is from another. Computing it exactly would mean summing over every possible answer, so it is estimated from the sampled answers. Write r for the reference model's probability over the current one's. The KL is the average of minus log r. So the simplest estimate, k one, is minus log r for each sample: right on average, but noisy, and it can come out negative, though a divergence never is. Now, r minus one has mean exactly zero, so adding it changes nothing on average. The sum, John Schulman's k three, is never negative, because log r is at most r minus one, and it is still unbiased. That is the estimate GRPO puts in its loss.
Our addition model makes this exact, because it has only a thousand possible answers. Take the model after chapter four's training, compute its true KL from where it started, nats per answer, and compare the estimates from single samples. One caution from 2025: an unbiased estimate of the KL is not an unbiased estimate of its gradient. Put straight into the loss, as GRPO does, k three pulls in a slightly different direction, and recent recipes often drop the term altogether.
Here is what the objective does to the model, step by step: three questions it was unsure of, and the probability it gives each candidate answer, the right one in green. Each step, answers that beat their group's average get pushed up and the rest pushed down; the clip keeps each push small.
6The successorsEngineering4 min
Since DeepSeek-R1, a small industry has picked GRPO apart. The first finding, from Zichen Liu and colleagues at Sea AI Lab, concerns that innocent average over an answer's tokens. It means each token's push is the advantage divided by the answer's length. A short right answer gets a big push up on each of its tokens. A long wrong answer gets only a small push down on each of its many. So the longer a wrong answer is, the less it is punished per token, and lengths drift upward for reasons that have nothing to do with thinking. They called their fix Doctor GRPO: drop the division by length, and also the division by the group's spread, which gives extra weight to questions that are nearly always right, or nearly always wrong.
Three more variants followed within months. Doctor GRPO, as we just saw: no division by length or by spread. DAPO, from ByteDance and Tsinghua, lets the clip go higher above than below, so unlikely good tokens can grow; it throws away groups that carry no signal; and it weighs every token in the batch equally. GSPO, from the Qwen team, takes one ratio per answer instead of per token: the geometric mean of its tokens' ratios. Multiply the ratios together and take the root, one per token, so a token that doubled and one that halved cancel out. It made reinforcement learning of their mixture-of-experts models stable. And CISPO, from MiniMax, clips the importance weight itself and treats it as a constant, so every token keeps its gradient, even the rare ones the PPO clip would silence. In MiniMax's own comparison it matched DAPO in half the steps.
We ran all of them on our addition model, from the same start, on the same kind of questions, three runs each. One cost the bars hide: DAPO's dynamic sampling drew times as many questions for its target batches. Each sampling round uses one optimizer update for the plain gradient and up to four for the other displayed recipes. These bars do not compare equal compute costs.
One of DAPO's fixes is worth seeing. When all eight answers to a question are right, or all are wrong, every advantage is zero: no policy-gradient reward signal. By the end, 31 percent of the groups carried no such signal. DAPO resamples to collect groups with mixed rewards. Our toy recipe caps this at four rounds, so a batch can remain short. By the end it drew 4.0 times the target batch.
And the offline alternative? Part 27 derived DPO, which learns from fixed pairs of a better and a worse answer, with no sampling during training. We gave it pairs of one right and one wrong answer, drawn once from the starting model. With a checker at hand, sampling from the model you are improving, on-policy, is what keeps paying.
7Entropy collapseResearch3 min
At the end of chapter five, the model's entropy fell as it learned. Here is why that always threatens. Entropy measures how spread out the model's choices are. Write the probabilities as a softmax of logits z, and differentiate: moving logit b changes the entropy by minus pi b times how much larger its log-probability is than average. So, to first order, a step changes the entropy by minus the covariance, over the model's own choices, between log-probability and the change in logit. For independent tabular logits, the expected policy-gradient step raises each logit in proportion to its probability times its advantage. When the answers the model already likes are the ones that score well, that covariance is positive, and the entropy falls. Reinforcement learning on a model's own samples can reinforce what was already likely. Shared network parameters couple these logit updates. Ganqu Cui and colleagues worked this out for language models in 2025.
Doctor GRPO, with GRPO's symmetric clip, ends at . CISPO ends at , and the plain gradient, with no clip at all, at .
Cui and colleagues found something stranger. Across many runs, accuracy was a simple function of entropy: R equals minus a times e to the H, plus b. Each dot here is one checkpoint of one of our runs, coloured by objective. And the fit extrapolates to zero entropy at percent. That is an empirical association in these runs, not a proven limit on accuracy or evidence that entropy alone causes it.
So the field fights the collapse. DAPO's clip-higher lets unlikely tokens grow faster than likely ones shrink. An entropy bonus pays the model a little for keeping options open. Cui's group restrains just the few tokens with the largest covariance, the ones driving the collapse. And NVIDIA's ProRL kept training stable for more than two thousand steps by controlling the KL and periodically resetting the reference model. Why it matters: a model that has stopped exploring has fewer different answers to offer when you ask it again. That is the question of chapter nine.
8How long to thinkEngineering2 min
When DeepSeek trained R1-Zero with reinforcement learning, something happened that nobody had asked for. Its thinking grew longer, steadily, throughout training, from hundreds of tokens to thousands, though the rules rewarded correctness and format, not length. And in the middle of one solution, an intermediate version wrote: wait, wait, wait. That's an aha moment I can flag here. Then it went back and redid the step. Re-checking, backtracking, trying another way appeared without an added supervised fine-tuning stage before RL. The base model still carried its pretraining.
Our adding model can show the same thing in miniature. Reward it only for the right sum, and replay the training. The map shows, for each length of list, how many steps of thought it chooses: the first column is answering at once, and the outlined cells are the whole chain. Watch the mass move. Mean thinking goes from steps to , and accuracy from percent to .
There is a cost hiding in that last number. In late 2024, researchers at Tencent and Shanghai Jiao Tong University named it: reasoning models overthink, spending far more tokens than needed on questions as easy as two plus three.
The fix is to make thought cost something: subtract a small amount c from the reward for every step of thought. We trained three ways, three runs each. The cost is a dial between overthinking and underthinking.
The frontier recipes do the same, more carefully. Moonshot's Kimi k1.5 adds a length reward measured within each group: among right answers, shorter earns more. L1, from Carnegie Mellon, puts the desired length in the prompt and rewards the model for hitting it. DAPO penalizes only answers that run past a maximum length. And the products expose the dial directly: a budget of thinking tokens, or an effort setting of low, medium or high.
9Sharper, or wider?Research4 min
To ask whether reinforcement learning teaches anything new, we need to measure what a model can do with many tries. The measure is pass at k: the chance that at least one of k tries is right, with a checker to say which. For a question where one try succeeds with probability p, that's one minus one minus p to the k. In practice we have n samples, c of them right. The obvious estimate plugs in c over n. But it is biased: one minus x to the k is convex, so by Jensen's inequality the plug-in estimate comes out too low on average. The fix, from OpenAI's Codex paper in 2021: choose k of your n samples at random, without replacement, and ask how likely they are to be all wrong. Any k of n independent tries are themselves k independent tries, so on average this is exactly one minus p to the k. Unbiased.
Here are both estimates on our addition model before reinforcement learning, where we know the exact answer. The plug-in estimate falls short, by up to 2 points. The unbiased one lies on the exact curve. For a single question the unbiased estimate is noisy, but centred on the truth; the plug-in one is centred too low. With a large benchmark, the noise averages out, and the bias doesn't.
In April 2025, Yang Yue and colleagues at Tsinghua asked exactly this; the paper became an oral at NeurIPS that December. After reinforcement learning, one try is far better. But give both models hundreds of tries, and the base model, the one RL started from, solves more problems. The curves cross. Their reading: RL sharpens; it moves probability onto reasoning the base model could already find, and narrows the rest. Distilling a stronger teacher, by contrast, can add new reasoning. The reply came within weeks. NVIDIA's ProRL trained much longer, keeping the KL in check and resetting the reference model, and reported strategies the base model could not reach. The two are compatible: a short run sharpens; a long, diverse one may widen.
We can check it exactly on our addition model, because we know its probability of every answer, so pass at k needs no sampling, even at a thousand tries. Before RL, one try is right percent of the time. After three hundred steps, about percent.
One warning about measuring with many tries. A checker rewards a lucky guess as much as a reasoned answer. Guess uniformly among the 179 possible sums, and pass at a thousand and twenty-four is 99.7 percent. At large k, pass at k can make guessing look like reasoning. That's why careful studies also check the chains, or use problems whose answers are too many to guess: proofs, and programs that must pass tests.
10Thinking at answer timeEngineering4 min
There are two ways to spend more computation once the question is asked. In parallel: sample many answers, and pick one, by a vote, a grader, or a checker. Or in sequence: one longer chain that re-checks, revises and goes on. Which is better? In 2024, Charlie Snell and colleagues at Berkeley and Google DeepMind found that it depends on the question: easy ones gain from revising, hard ones from searching wider. Choosing per question beat best-of-N four times over, and a small model given test-time compute could beat one fourteen times larger, on questions it could sometimes solve.
The sequential dial can be very simple. In January 2025, Niklas Muennighoff and colleagues at Stanford fine-tuned a model on just a thousand worked questions, and then controlled its thinking at answer time. To make it think longer, when it tried to stop they appended one word: wait. The model went back over its work, and sometimes fixed a mistake. To make it think less, they cut it off and made it answer. With more thinking forced, AIME scores rose from 50 to 57 percent, and the model beat o1-preview on competition maths by up to twenty-seven percent. They called it budget forcing.
Our adding model can be given a budget too. Make it think, and force it to answer after at most m steps, the way s1 cuts a model off. The parallel alternative: answer at once N times, and vote. The horizontal axis shows token budget caps; chains may stop early, and equal token caps need not cost equal computation.
The simplest parallel strategy with a checker is best-of-N: draw N answers and keep a right one. In the continuous-reward idealization, Part 27's best-of-N formula gives log N minus N minus one over N nats. For discrete answers, even unique reward values generally give only an upper bound. A checker's reward is all ties: right or wrong. So let's redo it. If one try is right with probability p, best-of-N is right with probability one minus one minus p to the N. Here we keep the first right draw, or the first draw if none is right. With that tie rule, which right answer it returns is in proportion to the model's own probabilities; the same for wrong ones. So the KL is just the divergence between two coins: one right with probability one minus q, the other with p. As N grows it levels off at log one over p, however many answers you draw, far below Part 27's formula, which in general is only an upper bound, as Ahmad Beirami and colleagues showed in 2024.
On our addition model, exactly. The KL of best-of-N with a checker levels off at nats, while the general upper bound is at tries. And accuracy:
11Searching over thoughtsMaster's3 min
Search is how Part 26's game players thought ahead, and the parts carry over almost one for one. A position becomes a partial chain of thought; a move, the next step. AlphaZero's policy network, its sense of which moves are worth trying, becomes the language model's own probabilities for the next step. The value network, how good a position looks, becomes a process reward model. And winning or losing becomes the checker. The difference is the size of the tree: a board offers at most a few hundred legal moves, a language model a whole vocabulary at every token, and a step of thought is many tokens long.
Sampling chains and voting treats each chain as a whole. Search works step by step: propose several next thoughts, judge them, and keep going from the most promising. In 2023, Tree of Thoughts let GPT-4 propose and judge its own next thoughts; on a puzzle, making 24 from four numbers, it went from 4 percent with a chain of thought to 74. In 2025, Microsoft's rStar-Math ran Monte Carlo tree search over steps, guided by a learned process model, and took a seven-billion-parameter model from 59 to 90 percent on competition maths. AlphaProof searched over steps of formal proofs, every step checked by a machine; we'll meet it in chapter thirteen. But DeepSeek tried tree search for R1 and gave up: over tokens the tree is enormous, and the value model that should guide it is hard to train. At the frontier, search mostly survives as sampling many chains in parallel.
Here is search on our adding model. At each step, every surviving partial chain proposes three next running totals; the process grader of chapter three scores every candidate; the best three survive. Green nodes are right totals, red are wrong ones that survived, grey were pruned.
Is search worth it? Compare these recipes using the same grader at matching width settings. Best-of-N samples N whole chains and keeps the one the grader likes best. Beam search proposes candidates step by step. Actual token and compute costs were not matched.
12Thinking without wordsResearch4 min
A chain of thought is computation, but it has a narrow throat. Each step, the model's last hidden state, thousands of numbers, is squeezed into a single token: with a vocabulary of a hundred thousand, about seventeen bits. Then the token is turned back into numbers for the next step. That limits the new input embedding; attention still has access to earlier hidden states, often stored in a key-value cache. Seventeen bits is not the model's total memory. So why not pass the state on directly?
That is Coconut, from Shibo Hao and colleagues at Meta, in December 2024. In a chain of thought, each step's state is turned into a token, and the token back into a state. In Coconut, for a stretch of reasoning, the last hidden state goes straight back in as the next input: a continuous thought. It is trained with a curriculum that replaces written steps with continuous ones, a few at a time. Something unexpected came out. A continuous thought need not commit to one next step: it can hold several at once, so the model searches breadth-first. On logic puzzles that need search, it beat a written chain of thought.
A second line of work drops the language model altogether. In June 2025, Sapient Intelligence's Hierarchical Reasoning Model, only twenty-seven million parameters, trained from scratch on about a thousand examples per task, scored 55 percent on extreme Sudoku and 74 percent on hard mazes, and reported 40 percent on ARC-AGI-1, puzzles we'll meet in chapter fourteen. Its idea: two recurrent modules, a slow one that plans and a fast one that computes, iterating many times before answering. The ARC Prize team checked. They reproduced most of the result, 32 percent on their held-out set, but found the hierarchy barely mattered: a transformer of the same size came within about five points. What mattered was an outer loop: the model's answer fed back in and refined, again and again.
In October 2025, Alexia Jolicoeur-Martineau at Samsung's lab in Montreal stripped the idea to its core. One tiny network, two layers. It reads the puzzle, x, and keeps two things: a latent scratchpad z, and its current answer y. It updates the scratchpad six times, then uses it to improve the answer. Then it does it all again. During training, the answer is supervised after each round, up to sixteen rounds. At inference, it iterates without access to the correct answer. With seven million parameters, it beat the Hierarchical Reasoning Model on every task: 87 percent on extreme Sudoku against 55, and 45 percent on ARC-AGI-1, ahead of many large language models. It won the first prize for papers in the 2025 ARC Prize. Depth through recurrence, instead of through tokens.
There's a price. A chain written in words can be read. In 2025, researchers from many labs together called this a new and fragile opportunity for safety: if a model plans to cheat, its written chain of thought may say so before it acts. Thinking in vectors may be more efficient, but nobody can read it. Whether we can trust what a chain of thought says is a question for Parts 30 and 31.
13Proofs a machine can checkUndergraduate3 min
Everything in this part has leaned on a checker, and checkers have limits: a right number can sit at the end of a broken argument. Mathematics has a way out. In a proof assistant such as Lean, a theorem and its proof are written as code, and a small trusted kernel checks every single inference. The code shown is illustrative; it has not been compiled here. No lucky guesses, no hand-waving: a proof is accepted, or it isn't. The guarantee is relative to the formal statement and its axioms. A reward checker must reject placeholders such as sorry and unapproved axioms, and check that the statement says what was meant. And since 2017 a community has been formalizing mathematics in Lean's library, Mathlib, which gives such systems something to build on.
Google DeepMind's AlphaProof put this to work. A Gemini model translated about a million maths problems from words into Lean, some eighty million formal statements. Then Part 26's AlphaZero went to work on them: search for proofs, keep the ones Lean accepts, and train the network on them, round after round. On the hardest problems it went further: at test time it generated variants of the problem, proved those, and learned from them, reinforcement learning during the exam. At the 2024 International Mathematical Olympiad, with AlphaGeometry 2 for the geometry, it scored 28 of 42, one point short of gold, solving four of the six problems, including the hardest, which only five contestants solved. Some proofs took it three days.
A year later the picture changed. At the 2025 Olympiad, a version of Google's Gemini with Deep Think, which explores many lines of thought in parallel, solved five of the six problems, 35 points, exactly the gold-medal line, writing in plain English. The lab reported meeting the four and a half hour competition limit; the Olympiad's coordinators graded the submitted solutions. OpenAI announced the same score for an experimental reasoning model, graded by former medallists. Harmonic's Aristotle released five Lean proofs. ByteDance's Seed-Prover officially earned 30 points with four complete solutions. Its geometry solution was in natural language; an additional Lean proof was completed after the competition. These are different evaluation conditions.
So here is the spectrum every reasoning method lives on. At one end, checkers that check a stated specification exactly: a formal proof or an answer key. Code tests check only the cases they cover; passing them does not prove a program correct on every input. At the other, learned graders, a process reward model, or another model acting as judge, which a strong enough optimizer will find ways around. Reasoning has advanced fastest exactly where the checker is exact: mathematics and code. Stretching it to everything else, essays, advice, research, is where the hard problems are.
14Puzzles nobody has seenUndergraduate3 min
How can a benchmark test skill acquisition on unfamiliar tasks? In 2019 François Chollet, who wrote the Keras library, argued that intelligence is something else: how efficiently you acquire a new skill. He built a test of it, the Abstraction and Reasoning Corpus, now called ARC-AGI. Each task gives a few pairs of coloured grids, an input and an output. Then a new input. What comes out? The aim is to infer a new rule from a few examples. Public tasks can enter training data, so held-out tasks and contamination controls matter.
ARC-AGI-1 resisted for five years. The 2020 Kaggle contest was won with about 20 percent, by searching over hand-written programs. In 2024, training on each task's own examples at test time reached 53.5. Then in December 2024, OpenAI's o3 scored 75.7 percent at about twenty-six dollars a task, and 87.5 with 172 times the compute. So in March 2025 a harder version, ARC-AGI-2, launched, and the best systems fell back to a few percent, while a person solves 60 percent on average. By December, a four-billion-parameter model trained on synthetic tasks won the Kaggle contest with 24 percent; Claude Opus 4.5 reached 37.6; and a refinement loop wrapped around Gemini 3 Pro, 54. ARC Prize named the year's theme: refinement loops, propose, check, improve. And in October 2026, ARC Prize reported about 91 percent for Google's Gemini 4 Argon at high reasoning on its Semi-Private ARC-AGI-2 set. Its published aggregate is 91.25 percent; the page prose shows 91.2, and the table 91.3. We use the underlying published aggregate, without rerunning the benchmark. These are reported scores with different evaluation sets and costs along the way.
So in March 2026 came ARC-AGI-3: interactive games, with no instructions. The player must explore, work out what the goal is, and plan, and is scored by how efficiently it gets there, against people. People could solve every game. At launch, every frontier model scored below one percent. In September, ARC Prize measured OpenAI's GPT-6 Astra at 62.7 percent with their standard harness. Each new test has been climbed faster than the last. And what solves them looks like every chapter of this part: propose, check, refine, in a loop.
Recap, problems, and what comes nextAll tracks3 min
Let's take stock. Writing out steps lets a model of fixed depth compute for longer: each token buys another pass through the network. Sampling many chains and voting amplifies whatever answer the model already prefers; a checker does better, and a learned grader helps only as far as it can't be fooled. Reinforcement learning from a checker, with GRPO's group baseline and its clip, moves probability onto answers that check out, and spends the model's entropy to do it. Left alone, it learns to think longer, sometimes too long, until thought is given a price. It sharpens what the model could already do, and may, with long enough training, widen it. And at answer time, more computation buys more right answers, in parallel or in sequence, as long as whatever chooses among them can be trusted.
All of this comes back. Reasoning over hundreds of steps, with tools, is what agents do, in Part 29. Every token of thought costs time to generate, and Part 19's inference tricks are what make long thinking affordable. Whether the chain a model writes is really how it reached its answer is a question for Part 30. And reward hacking, and watching a model's chain of thought for signs of it, come back in the last part.
Here are six problems to try, from GRPO's baseline to the entropy's fall. Pause here, and work through them; full solutions are in this part's notes.
Next time: agents, models that act over many steps, in the world or on a computer. Here is the problem they face, measured on our own chains. Each step of thought our adding model writes is right percent of the time. If errors were independent, with this same rate at every step, those chances would multiply. In that illustration, Our measured average does not establish independence or predict success on longer tasks. How agents plan, check themselves and recover over long horizons, and how they learn models of the worlds they act in: Part 29.
Nathan Lambert's free book on reinforcement learning from human feedback is the place to go deeper; it covers reinforcement learning with verifiable rewards and reasoning too. Thanks for watching, and see you in Part 29.
Where it goes next. Reasoning over hundreds of steps with tools is what the agents of Part 29 do, where per-step reliability sets the horizon; whether a written chain is how the model reached its answer is Part 30's faithfulness chapter; reward hacking and monitoring the chain of thought return in Part 31.
Key results
The part's results in one place, for revision.
Try it
Lab 28 · Learning from a checker: GRPO in miniature
Give a softmax policy 40 questions with 12 possible answers each and a checker that says only right or wrong; train it with GRPO's group advantages through the series' autodiff, and check the group baseline, the k1 and k3 KL estimators and the unbiased pass@k estimator against exact values.
python -m videos.ai.labs 28
needs numpy, scipy, matplotlib · download lab28.py ·
source on GitHubright on one try 12.9% before, 93.8% after 100 GRPO steps
entropy of the answer 2.81 bits before, 0.36 after
groups with no signal 48% at the start, 75% at the end
KL(trained || start), exact 2.2787 nats E[k1] = 2.2787 E[k3] = 2.2787 (k1 < 0 on 4% of samples)
pass@8 from 16 samples, start exact 0.4899 unbiased estimator 0.4899 plug-in 0.4383
pass@1024 1.0000 before, 1.0000 after (0 of 40 right answers drained below 1 in 1,000)
A checker's right-or-wrong signal is enough to move probability onto the right answers, and the policy pays for it in entropy: one try gets much better, while a thousand tries, which nearly always held a right answer already, gain almost nothing.
The code (126 lines; it asserts its own result)
"""Lab 28: train a tiny policy from a checker with GRPO, and measure what it sharpens: accuracy, entropy, pass@k."""
from math import comb
import numpy as np
from scipy import stats
from videos.coursekit import labs
from explainer.ai.autodiff import Tensor, log_softmax
TITLE = "Learning from a checker: GRPO in miniature"
GOAL = ("Give a softmax policy 40 questions with 12 possible answers each and a checker that says only right or wrong; "
"train it with GRPO's group advantages through the series' autodiff, and check the group baseline, the k1 and k3 "
"KL estimators and the unbiased pass@k estimator against exact values.")
TASKS = [
"Drop the division by the group's spread (Dr. GRPO's change). Which questions now learn more slowly, and why?",
"Shrink the group from 8 answers to 2. What share of groups carries no signal at the start, and what happens to the curve?",
"Train for 2,000 steps instead of 100 and plot pass@256 on the hardest five questions. Does it rise or fall?",
]
def pass_at_k(p, k):
"""Exact pass@k: the chance that at least one of k independent tries is right."""
return 1 - (1 - p) ** k
def unbiased(c, n, k):
"""Chen et al.'s estimator from c right answers among n samples: 1 - C(n - c, k) / C(n, k)."""
return 1 - comb(n - c, k) / comb(n, k)
def run(seed=0):
rng = np.random.default_rng(seed)
Q, m, G, steps, lr = 40, 12, 8, 100, 0.3
right = rng.integers(m, size=Q)
theta0 = 1.2 * rng.standard_normal((Q, m))
theta = Tensor(theta0.copy(), requires_grad=True)
rows = np.arange(Q)
def probs(t):
e = np.exp(t - t.max(1, keepdims=True))
return e / e.sum(1, keepdims=True)
def entropy(p):
return float(-(p * np.log(p)).sum(1).mean() / np.log(2))
p0 = probs(theta0)
acc, ent, silent = [], [], []
loo_gap = 0.0
for _ in range(steps):
p = probs(theta.data)
acc.append(p[rows, right].mean())
ent.append(entropy(p))
y = (rng.random((Q, G, 1)) > p.cumsum(1)[:, None, :]).sum(-1).clip(max=m - 1) # G sampled answers a question
r = (y == right[:, None]).astype(float)
mean, std = r.mean(1, keepdims=True), r.std(1, keepdims=True)
silent.append(float((std == 0).mean()))
loo = (r.sum(1, keepdims=True) - r) / (G - 1) # the leave-one-out baseline of problem 1
loo_gap = max(loo_gap, np.abs((r - mean) - (G - 1) / G * (r - loo)).max())
adv = (r - mean) / (std + 1e-6)
theta.grad = np.zeros_like(theta.data)
logp = log_softmax(theta)[np.repeat(rows, G), y.ravel()]
loss = -(logp * adv.ravel()).sum() * (1.0 / G) # the policy-gradient surrogate, one group a question
loss.backward()
theta.data -= lr * theta.grad
p1 = probs(theta.data)
acc.append(p1[rows, right].mean())
ent.append(entropy(p1))
# the KL from the trained policy back to the starting one, and its estimators, by exact enumeration
ratio = p0 / p1 # r = pi_ref / pi_theta
k1, k3 = -np.log(ratio), ratio - 1 - np.log(ratio)
kl = float((p1 * np.log(p1 / p0)).sum(1).mean())
e_k1, e_k3 = float((p1 * k1).sum(1).mean()), float((p1 * k3).sum(1).mean())
k1_negative = float((p1 * (k1 < 0)).sum(1).mean())
# pass@k from n = 16 samples: the expectation of each estimator over c ~ Binomial(n, p), exactly
n, k = 16, 8
pr = p0[rows, right]
c = np.arange(n + 1)
pmf = stats.binom.pmf(c[None, :], n, pr[:, None])
est_unbiased = float((pmf * np.array([unbiased(ci, n, k) for ci in c])).sum(1).mean())
est_plugin = float((pmf * (1 - (1 - c / n) ** k)).sum(1).mean())
exact = float(pass_at_k(pr, k).mean())
ks = 2 ** np.arange(11)
before = np.array([pass_at_k(p0[rows, right], kk).mean() for kk in ks])
after = np.array([pass_at_k(p1[rows, right], kk).mean() for kk in ks])
drained = int((p1[rows, right] < 1e-3).sum())
lab = labs.Lab()
lab.row("right on one try", f"{acc[0]:.1%} before, {acc[-1]:.1%} after {steps} GRPO steps")
lab.row("entropy of the answer", f"{ent[0]:.2f} bits before, {ent[-1]:.2f} after")
lab.row("groups with no signal", f"{silent[0]:.0%} at the start, {np.mean(silent[-10:]):.0%} at the end")
lab.row("KL(trained || start), exact", f"{kl:.4f} nats E[k1] = {e_k1:.4f} E[k3] = {e_k3:.4f} (k1 < 0 on {k1_negative:.0%} of samples)")
lab.row(f"pass@{k} from {n} samples, start", f"exact {exact:.4f} unbiased estimator {est_unbiased:.4f} plug-in {est_plugin:.4f}")
lab.row("pass@1024", f"{before[-1]:.4f} before, {after[-1]:.4f} after ({drained} of {Q} right answers drained below 1 in 1,000)")
lab.note = ("A checker's right-or-wrong signal is enough to move probability onto the right answers, and the policy "
"pays for it in entropy: one try gets much better, while a thousand tries, which nearly always held a right "
"answer already, gain almost nothing.")
assert loo_gap < 1e-12, "the group-mean baseline is the leave-one-out baseline times (G - 1)/G"
assert acc[-1] > acc[0] + 0.3, "GRPO learns from the checker"
assert ent[-1] < 0.6 * ent[0], "and spends entropy to do it"
assert abs(e_k1 - kl) < 1e-12 and abs(e_k3 - kl) < 1e-12 and k3.min() >= 0 and k1.min() < 0, "k1 and k3 are unbiased; only k3 is never negative"
assert abs(est_unbiased - exact) < 1e-12, "the pass@k estimator is unbiased"
assert est_plugin < exact - 0.005, "the plug-in estimate falls short"
assert after[0] - before[0] > 5 * (after[-1] - before[-1]), "RL sharpens one try far more than it widens many"
fig, ax = labs.figure(2, size=(11, 4.2))
t = np.arange(steps + 1)
ax[0].plot(t, acc, color=labs.GREEN, label="right on one try")
ax[0].set(title="GRPO from a right-or-wrong checker", xlabel="training step", ylabel="share right", ylim=(0, 1.02))
twin = ax[0].twinx()
twin.plot(t, ent, color=labs.PURPLE, label="entropy (bits, right axis)")
twin.set_ylim(0, ent[0] * 1.1)
twin.grid(False)
twin.spines["right"].set_visible(True)
lines = ax[0].get_lines() + twin.get_lines()
ax[0].legend(lines, [ln.get_label() for ln in lines], loc="center right")
ax[1].semilogx(ks, before, "o-", color=labs.MUTED, label="before training", base=2)
ax[1].semilogx(ks, after, "o-", color=labs.GOLD, label="after GRPO", base=2)
ax[1].set(title="Sharper, or wider? Exact pass@k", xlabel="tries k", ylabel="share of questions passed", ylim=(0, 1.02))
ax[1].legend(loc="lower right")
lab.fig = fig
return lab
Now change it
- Drop the division by the group's spread (Dr. GRPO's change). Which questions now learn more slowly, and why?
- Shrink the group from 8 answers to 2. What share of groups carries no signal at the start, and what happens to the curve?
- Train for 2,000 steps instead of 100 and plot pass@256 on the hardest five questions. Does it rise or fall?
Problems, with solutions
Try each problem before opening its solution.
1. GRPO's baseline. GRPO compares each answer's reward with the group's mean, which includes the answer's own reward. Show that the leave-one-out mean b_i = (1/(G−1)) Σ_{j≠i} r_j gives an unbiased gradient estimate, and that the plain group mean scales it by (G−1)/G.
Solution
The estimate is (r_i − b_i) ∇ log π(y_i). With the leave-one-out mean, b_i depends only on the other answers, which are independent of y_i, so E[b_i ∇ log π(y_i)] = E[b_i] · E[∇ log π(y_i)] = 0 (the score has mean zero: Σ_y π ∇ log π = ∇ Σ_y π = 0). What remains is E[r_i ∇ log π(y_i)] = ∇J. With the plain mean r̄, r_i − r̄ = r_i − (r_i + (G−1) b_i)/G = ((G−1)/G)(r_i − b_i): the same estimate, times (G−1)/G. (GRPO also divides by the group's spread, which Dr. GRPO removes.)
2. The k3 estimator. With y ~ π_θ and r = π_ref(y)/π_θ(y), show that k3 = (r − 1) − log r is never negative and that E[k3] = KL(π_θ ‖ π_ref).
Solution
E[r] = Σ_y π_θ(y) π_ref(y)/π_θ(y) = Σ_y π_ref(y) = 1, so E[r − 1] = 0 and E[k3] = E[−log r] = E[log π_θ(y)/π_ref(y)] = KL(π_θ ‖ π_ref). And f(r) = r − 1 − log r has f(1) = 0, f′(r) = 1 − 1/r, f″(r) = 1/r² > 0: a convex function with its minimum at r = 1, so f ≥ 0. (This is log r ≤ r − 1.)
3. The unbiased pass@k estimator. If c of n independent samples are right, each with probability p, prove E[C(n − c, k) / C(n, k)] = (1 − p)^k for k ≤ n.
Solution
Pick k of the n samples uniformly at random, independently of their values. Given the samples, the chance all k picked are wrong is C(n − c, k)/C(n, k). Unconditionally, the k picked samples are k independent draws, so the chance they are all wrong is (1 − p)^k. The second is the expectation of the first, by the law of total probability.
4. When the vote is right. The right answer has probability p*, every wrong answer y has p_y ≤ p* − Δ, and there are m possible answers. Bound the chance that a majority vote over k samples is wrong.
Solution
The vote is wrong only if some wrong y appears at least as often as the right one. For a fixed y, N_{y*} − N_y = Σ_i X_i with X_i = 1[Y_i = y*] − 1[Y_i = y] ∈ {−1, 0, 1}, independent, with mean at least Δ. Hoeffding's inequality for variables with range 2 gives P(Σ X_i ≤ 0) ≤ exp(−2(kΔ)²/(4k)) = exp(−kΔ²/2). A union bound over the m − 1 wrong answers: P(vote wrong) ≤ (m − 1) e^{−kΔ²/2}, which goes to zero as k grows. If instead some wrong answer is more likely than the right one, the same argument shows the vote is wrong with probability tending to one.
5. Best-of-N with a checker. Draw N answers from π and keep a right one if there is one (otherwise a wrong one). With a 0/1 reward and q = (1 − p)^N, show KL(π_N ‖ π) = KL(Bern(1 − q) ‖ Bern(p)), and find its limit as N → ∞.
Solution
The result is right with probability 1 − q; given that, it is a draw from π conditioned on being right, and given failure, from π conditioned on being wrong. So π_N(y) = π(y)(1 − q)/p for a right y and π(y) q/(1 − p) for a wrong one. The log-ratio log π_N/π is constant on each set, so KL = (1 − q) log((1 − q)/p) + q log(q/(1 − p)), the KL between two coins. As N → ∞, q → 0 and q log q → 0, so KL → log(1/p): bounded, unlike log N − (N − 1)/N, which is the KL only for rewards without ties and an upper bound in general (Beirami et al. 2024).
6. Why entropy falls. For π = softmax(z), show ∂H/∂z_b = −π_b (log π_b − E_π[log π]), and that a small step Δz changes the entropy by −Cov_{a∼π}(log π_a, Δz_a).
Solution
With ∂π_a/∂z_b = π_a(δ_ab − π_b): ∂H/∂z_b = −Σ_a (∂π_a/∂z_b)(log π_a + 1) = −π_b(log π_b + 1) + π_b Σ_a π_a (log π_a + 1) = −π_b (log π_b − E_π[log π]). To first order, ΔH = Σ_b (∂H/∂z_b) Δz_b = −E_π[(log π − E_π log π) Δz] = −Cov_π(log π, Δz). A policy-gradient step raises z_a by η π_a A_a, so when likely answers have positive advantages the covariance is positive and the entropy falls (Cui et al. 2025).
Notes and sources
Glossary
| English | 中文 |
|---|---|
| reasoning, reasoning model | 推理,推理模型 |
| chain of thought, scratchpad | 思维链,草稿(中间步骤) |
| "let's think step by step" | "让我们一步一步地思考" |
| thinking out loud, tokens of thought | 出声思考,思考词元 |
| filler tokens | 填充词元 |
| threshold circuit, TC⁰, NC¹ | 阈值电路,TC⁰,NC¹ |
| self-consistency, majority vote | 自洽性,多数投票 |
| verifier, checker | 验证器,检查器 |
| outcome reward model (ORM) | 结果奖励模型(ORM) |
| process reward model (PRM) | 过程奖励模型(PRM) |
| step label, right for the wrong reason | 步骤标签,歪打正着 |
| AUC (how well a grader tells right from wrong) | AUC(评分器区分对错的能力) |
| reinforcement learning with verifiable rewards (RLVR) | 可验证奖励的强化学习(RLVR) |
| group relative policy optimization (GRPO) | 组相对策略优化(GRPO) |
| group, group baseline, leave-one-out | 组,组基线,留一 |
| importance ratio, clip, clip-higher | 重要性比值,裁剪,放宽上界的裁剪(clip-higher) |
| KL estimator (k1, k2, k3), control variate | KL估计量(k1、k2、k3),控制变量 |
| length bias, difficulty bias | 长度偏差,难度偏差 |
| dynamic sampling, groups with no signal | 动态采样,没有信号的组 |
| sequence-level ratio, geometric mean | 序列级比值,几何平均 |
| entropy collapse, entropy bonus | 熵坍缩,熵奖励 |
| overthinking, underthinking, length penalty | 过度思考,思考不足,长度惩罚 |
| aha moment | 顿悟时刻(aha moment) |
| pass@k, unbiased estimator, plug-in estimator | pass@k,无偏估计量,代入估计量 |
| sharpen, widen (the reasoning boundary) | 锐化,拓宽(推理边界) |
| test-time compute, parallel, sequential | 测试时计算,并行,串行 |
| budget forcing | 预算强制 |
| best-of-N | 最优N选1 |
| beam search, tree search, Tree of Thoughts | 束搜索,树搜索,思维树 |
| latent reasoning, continuous thought | 隐式推理,连续思维 |
| recursion, deep supervision, refinement loop | 递归,深度监督,精炼循环 |
| proof assistant, kernel, formalization | 证明助手,内核,形式化 |
| harness (for ARC-AGI-3) | 测试框架(harness) |
| chain-of-thought monitorability | 思维链的可监控性 |
Names stay in Latin script: GRPO, Dr. GRPO, DAPO, GSPO, CISPO, DPO, o1, o3, R1, R1-Zero, s1, L1, Kimi k1.5, ProRL, rStar-Math, Coconut, HRM, TRM, AlphaProof, AlphaGeometry, Lean, Mathlib, Aristotle, Seed-Prover, ARC-AGI, NVARC, Poetiq.
About this partfrom its README
Part 28 of a thirty-one-part series on how modern AI works and how it came to be (see the series plan and the syllabus). How language models learned to reason, from "let's think step by step" (2022) to o1 (2024), DeepSeek-R1 (2025) and the 2026 frontier: why a chain of thought adds computation; many chains and a vote; grading answers or grading steps; reinforcement learning from a checker, with GRPO derived, its KL estimators and its successors (Dr. GRPO, DAPO, GSPO, CISPO); entropy collapse; how long to think; whether RL widens what a model can solve; spending computation at answer time; search over thoughts; thinking without words and tiny recursive models; proofs a machine can check; and ARC-AGI. Every experiment runs on three tiny transformers trained on this computer: parity, two-digit addition, and a "think or answer" model that sums lists of digits and may write its running total first.
- From "let's think step by step" to o1 and R1. Chain-of-thought prompting (Wei et al. 2022: PaLM 540B on GSM8K, 17.9% → 56.9%, with the paper's Figure 1 example); zero-shot "Let's think step by step" (Kojima et al. 2022: MultiArith 17.7% → 78.7%); o1 (September 2024; AIME 2024: GPT-4o 9.3% pass@1, o1 74.4% pass@1, 83.3% cons@64 (Appendix A), 93% (prose) reranking 1,000 with a learned scorer); R1-Zero (15.6% → 71.0%, 86.7% by a vote of 64; DeepSeek-AI 2025); gold-medal IMO 2025 solutions in natural language; ARC-AGI-3 (March 2026), where every frontier model started below 1%; the questions of the part and what it covers.
- 1. Thinking out loud is computing. Parity of 16 bits for a 2-layer transformer: answering at once stays at chance (49.9%, three runs 49.4–50.9%), writing the running parity first reaches 99.6% (98.8–100%); 4 bits: everything 100%; 8 bits: at once 46.7%, chain 100%. Depth: L steps in a row at once, L(k + 1) with k tokens of thought. Merrill & Sabharwal (2023): fixed depth with O(log n)-bit numbers stays in TC⁰; Li, Liu, Zhou & Ma (2024): T steps of thought simulate a circuit of size T, polynomially many decide P; Furst–Saxe–Sipser (1984), Barrington (1989), Hahn (2020), Feng et al. (2023); filler dots add positions but not sequential steps (Pfau, Merrill & Bowman 2024; ours: 49.4%); the chain model's training replayed with its chains at each checkpoint.
- 2. Many chains, one vote. The testbed: a 2-layer transformer that sums lists of 2–9 digits and may write the running total first (1,500 supervised steps; one sample at temperature 1: 90% → 38% at once, 96% → 64% thinking; left to choose, it thinks 65% of the time). Self-consistency (Wang et al. 2022, +17.9 points on GSM8K). One 7-digit list and 64 chains. When voting works, derived (Hoeffding and a union bound: P(vote wrong) ≤ (m − 1)e^{−kΔ²/2}); on 300 lists of 2–9 digits: one chain 81%, a vote of 64 98% (observed 64-sample mode right, 98%; not an independent asymptotic-limit estimate), any of 64 right 100%, a vote over answers given at once 74%.
- 3. Checking the steps. A right answer from a broken argument (ours, made to think: 27% of right answers lack a complete, locally correct chain, including early stopping); outcome and process reward models; Cobbe et al. (2021: a verifier worth a 30× larger model), Uesato et al. (2022), Lightman et al. (2023: PRM800K; best of 1,860 on a representative MATH test subset: vote 69.6%, ORM 72.4%, PRM 78.2%). Ours, both graders trained on the same 8,000 solutions, 300 new questions: one sample 80%; the graders' picks get worse as N grows (best of 64: process grader 50%, outcome grader 44%; vote 96%); AUC 0.76 and 0.66; 71% of the process grader's picks from 64 had stopped thinking early, against 35% of all solutions (a product of step scores favours short chains). One solution graded both ways. DeepSeek-R1's "unsuccessful attempts" with process reward models; Math-Shepherd's automatic step labels.
- 4. Learning from a checker. DeepSeekMath's GRPO (February 2024), o1 (September 2024), Tülu 3 names RLVR (November 2024), DeepSeek-R1 (January 2025); the reward 1[checker accepts]; the policy, a group of 8 answers, advantages against the group; on our two-digit addition model, 300 steps of 32 questions: 35% → 72–86% (three runs, mean 80%), replayed with six questions' answers at every checkpoint.
- 5. GRPO, derived. The log-derivative trick and a baseline (Part 26); the group mean and spread; PPO's ratio and clip; the published per-token objective with its KL term; the KL estimators k1 = −log r, k2 = ½(log r)², k3 = r − 1 − log r (Schulman 2020) on our model, where the true KL is exact (0.840 nats): k1 0.839 (10% negative, spread 0.91), k2 0.767 (biased low, spread 1.36), k3 0.744 (never negative, spread 6.25: unbiased, but heavy-tailed this far from the reference); Tang & Munos (2025) on estimating the KL's gradient; GRPO's training replayed on three uncertain questions (the right answer's probability 25% → 71% on average, not smoothly; entropy 0.92 → 0.17 bits a digit).
- 6. The successors. Dr. GRPO's length and difficulty biases (Liu et al. 2025); DAPO (clip-higher 0.2/0.28, dynamic sampling, token-level averaging, overlong shaping; Yu et al. 2025); GSPO's sequence ratio (Zheng et al. 2025); CISPO's clipped, stop-gradient weight (MiniMax 2025). Seven objectives on our model, three runs each, 300 steps: our toy GRPO recipe, the only one with a KL penalty (k3, β = 0.04), collapsed in two of three runs (to 2% and 5%; the third reached 88%); among the runs that learned (start 35%): plain 79%, Dr. GRPO 84%, DAPO 91%, GSPO 86%, CISPO 79%, a 12-point span against 19 points between runs of one method; the share of groups with no signal (the plain gradient's rises to 31% by the end); DAPO drew 2.9× the questions; offline DPO on pairs from the starting model (35% → 26%: on held-out pairs both the right and the wrong answers' log-probabilities fell, by 0.74 and 2.07 bits; likelihood displacement).
- 7. Entropy collapse. ∂H/∂z_b = −π_b(log π_b − E log π) and ΔH ≈ −Cov(log π, Δz), derived (Cui et al. 2025); entropy over training for four objectives (0.92 bits a digit at the start; at the end Dr. GRPO 0.14, DAPO 0.08, CISPO 0.16, the plain gradient 0.28: DAPO also ends with low entropy; this is not an isolated clip-higher ablation); the fit R = −a e^H + b on every checkpoint (R² = 0.80 over the 16 runs that did not collapse; the extrapolated value at H = 0, 86%, not a proven accuracy ceiling); remedies: clip-higher, entropy bonuses, Clip-Cov and KL-Cov, ProRL's long runs (more than 2,000 steps).
- 8. How long to think. R1-Zero's growing chains and its "aha moment" (DeepSeek-AI 2025, Table 3); RL with a reward for the right sum only, replayed as a map of how many steps it chooses for each length of list (thinking 66% → ~100% of the time, mean 3.0 → 5.5 steps, accuracy 77% → 96%); overthinking (Chen et al. 2024; on two-digit lists, 90% at once against 96% thinking, yet it thinks on 100% after RL); a cost per step of thought, three values, three runs each: c = 0 thinks on nearly everything (96% right), c = 0.005 thinks on 7% of two-digit lists and 90% of nine-digit ones (87%), c = 0.02 almost never thinks (77%; 39% on nine digits); Kimi k1.5's length reward, L1, DAPO's overlong penalty, products' thinking budgets.
- 9. Sharper, or wider? pass@k; the plug-in estimate's bias and the unbiased estimator 1 − C(n − c, k)/C(n, k), derived (Chen et al. 2021), on our model against the exact values (the plug-in falls short by up to 2 points); Yue et al. (NeurIPS 2025 oral) and ProRL's counterpoint; exact pass@k up to 1,024 before and after four RL objectives (one try: 33% before, about 82% after; at 1,024 tries 100% before, against 98.2% for Dr. GRPO, 98.8% for DAPO, 97.8% for CISPO and 99.99% for the plain gradient; the untrained model ahead of Dr. GRPO from 16 tries on; on about 3 of the 200 questions RL drained the right answer below one in a thousand); a uniform guesser among the 179 possible sums passes at 1,024 tries 99.7% of the time.
- 10. Thinking at answer time. Parallel against sequential; Snell et al. (2024: 4× more efficient than best-of-N, a small model plus test-time compute beating a 14× larger one); s1 (Muennighoff et al. 2025: 1,000 examples, budget forcing, AIME 2024 50% → 57%); ours on 9-digit lists: no thought 37%, thinking cut off part-way no better, the whole chain 63% with 12 tokens, a vote over answers at once at most 40% with up to 32 tokens; after RL, the whole chain 84%. Best-of-N with a 0/1 checker, derived: KL(π_N ‖ π) = KL(Bern(1 − q) ‖ Bern(p)) → log(1/p), below Part 27's log N − (N − 1)/N, an upper bound in general (Beirami et al. 2024); ours: 1.18 nats at N = 256 against 4.55; best-of-8 matches one try after RL.
- 11. Searching over thoughts. AlphaZero (Part 26) mapped onto reasoning; Tree of Thoughts (Yao et al. 2023: Game of 24, 4% → 74%), rStar-Math (Guan et al. 2025: MATH 58.8% → 90.0% at 7B), AlphaProof, R1's unsuccessful MCTS; beam search over running totals guided by the process grader, one tree drawn; beam search against best-of-N at matching width settings on 9-digit lists (token and compute costs were not matched): beam search ahead at every tested width (78% against 64% at 2 samples per step), but both fall as they widen (beam 78% → 52%, best-of-N 64% → 31%).
- 12. Thinking without words. The token bottleneck (about 17 bits per token, against tens of thousands in a hidden state); Coconut (Hao et al. 2024); HRM (Wang et al. 2025: 27M parameters, about 1,000 examples; Sudoku-Extreme 55%, Maze-Hard 74.5%, ARC-AGI-1 40.3%, ARC-AGI-2 5%) and ARC Prize's analysis (August 2025); TRM (Jolicoeur-Martineau 2025: 7M parameters, 87.4%, 85.3%, 44.6%, 7.8%); chain-of-thought monitorability (Korbak et al. 2025).
- 13. Proofs a machine can check. Lean and Mathlib; AlphaProof (Hubert et al., Nature 2025: about a million problems formalized into about 80 million statements; test-time RL) and the joint AlphaProof + AlphaGeometry 2 result at IMO 2024 (28 of 42, one short of gold); IMO 2025: Gemini Deep Think 35 (submitted solutions graded by the IMO's coordinators) and OpenAI's experimental model 35, in natural language; Harmonic's Aristotle released five Lean proofs; Seed-Prover officially scored 30 points with four complete solutions, including natural-language geometry, and completed an additional Lean proof after the competition; the spectrum of checkers.
- 14. Puzzles nobody has seen. Chollet (2019); ARC-AGI-1 from about 20% (2020) to 53.5% (test-time training, 2024) and o3's 75.7% and 87.5% (December 2024); ARC-AGI-2 (March 2025; people 60% on average): NVARC 24%, Claude Opus 4.5 37.6%, Poetiq on Gemini 3 Pro 54% (2025), Gemini 4 Argon 91.25% (published Semi-Private aggregate, high reasoning, October 2026); ARC-AGI-3 (March 2026): frontier models below 1% at launch, GPT-6 Astra 62.7% on ARC Prize's standard harness (September 2026).
- Recap in eight pictures from the part's own results, where it comes back (Parts 19, 29, 30, 31), six problems, Part 29's teaser (pooled step accuracy 98.2%; assuming independent steps with the same success rate, a chain of n steps is all right with probability 0.982^n: a coin flip by about 39 steps. The pooled rate alone does not establish that assumption).
What is computed and builtScope of the toy comparisons
The parity models share an architecture but are trained separately. The chain recipe receives a label for every intermediate parity step; the experiment combines additional sequential computation with intermediate supervision.
The objective variants implement selected mechanisms on fixed three-digit outputs, rather than reproducing the full published training systems. The previously documented numerical outcomes above are preserved; they are not a report of the new cloud QA rerun. A matched ablation would be needed to establish why a particular run collapsed. Fresh evaluation draws are sampled from the same finite task distribution as training; they are not guaranteed to be disjoint, previously unseen arithmetic problems.
The test-time plot uses output-token budget caps: a chain may stop before its cap. The search plot matches width settings, not measured token or compute costs. Beam search forces full chains and greedily decodes final answers, whereas the whole-chain sampler can stop early. These results compare the configured recipes; they do not establish equal-cost search efficiency. The entropy fit is descriptive, and its zero-entropy extrapolation is not a universal accuracy ceiling.
A kernel-checked proof guarantees only its formal statement relative to its assumptions. Reward validation must reject placeholders and unapproved axioms. Passing finite code tests does not prove correctness on every input. A token's vocabulary limits its discrete choice, not a transformer's total memory: attention can still access earlier hidden states.
The self-consistency limit concerns arbitrarily many independent samples. A finite vote can still select the right answer by chance when a wrong answer has greater probability; the limit does not make that finite probability zero.
Verifier AUC uses average ranks for tied scores; a vote with no valid decoded answers is a failure. Existing cache files are not migrated automatically by a source change. Recalculate these summaries only from their verified original score/answer arrays, preserving the original outputs and recording the measured change. The cloud QA rerun keeps its original cache and raw verifier scores alongside the separately reviewed metric correction.
The 2024 IMO score combines AlphaProof in Lean with AlphaGeometry 2's specialized geometry system. For the 2025 Gemini result, the IMO review covers submitted solutions; timing and process information is laboratory-reported.
The best-of-N equality with log N - (N - 1) / N uses a continuous reward-distribution idealization. For discrete
answers it is generally an upper bound, even when distinct answers have distinct reward values. The binary-checker
calculation here keeps the first correct draw, or the first draw if none is correct; choosing among tied samples by
their answer values can change the selected distribution and its KL. This makes the existing analytical policy
explicit and does not change the original numerical outputs.
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
- CoT as computation: TC⁰ vs serial steps, parity.
- Self-consistency.
- ORMs vs PRMs.
- RLVR; GRPO derived; the k1/k3 KL estimators.
- Variants: Dr. GRPO, DAPO, GSPO, CISPO.
- Entropy collapse and clip-higher; length and overthinking.
- pass@k's unbiased estimator; does RL widen the reasoning boundary? (the 2025 debate).
- Test-time scaling: parallel vs sequential, budget forcing.
- Best-of-N's KL ≤ log N − (N−1)/N.
- Tree search for LLMs.
- Latent reasoning (Coconut); tiny recursive models (HRM, TRM).
- Formal maths; ARC-AGI.
Computed: GRPO on a tiny arithmetic transformer on CPU.
中文讲义
本讲的中文部分(与英文版对应)。
习题与解答
1. GRPO的基线。 GRPO把每个回答的奖励和全组的平均比较,而这个平均里包含了它自己的奖励。证明:用"留一"平均 b_i = (1/(G−1)) Σ_{j≠i} r_j 作基线,梯度估计是无偏的;而用全组平均,梯度会被乘上 (G−1)/G。
解答
估计量是 (r_i − b_i) ∇log π(y_i)。用留一平均时,b_i 只依赖其他回答,与 y_i 独立,所以 E[b_i ∇log π(y_i)] = E[b_i]·E[∇log π(y_i)] = 0(得分函数的均值为零:Σ_y π ∇log π = ∇ Σ_y π = 0)。剩下的是 E[r_i ∇log π(y_i)] = ∇J。用全组平均 r̄ 时,r_i − r̄ = r_i − (r_i + (G−1) b_i)/G = ((G−1)/G)(r_i − b_i):同一个估计量, 乘以 (G−1)/G。(GRPO还要除以组内的标准差,Dr. GRPO把它去掉了。)
2. k3估计量。 设 y ~ π_θ,r = π_ref(y)/π_θ(y)。证明 k3 = (r − 1) − log r 永不为负,并且 E[k3] = KL(π_θ ‖ π_ref)。
解答
E[r] = Σ_y π_θ(y) π_ref(y)/π_θ(y) = Σ_y π_ref(y) = 1,所以 E[r − 1] = 0,E[k3] = E[−log r] = E[log π_θ(y)/π_ref(y)] = KL(π_θ ‖ π_ref)。又 f(r) = r − 1 − log r 满足 f(1) = 0,f′(r) = 1 − 1/r,f″(r) = 1/r² > 0: 一个在 r = 1 处取最小值的凸函数,所以 f ≥ 0。(这就是 log r ≤ r − 1。)
3. pass@k的无偏估计。 n个独立样本中有c个正确,每个正确的概率为p。证明对 k ≤ n, E[C(n − c, k) / C(n, k)] = (1 − p)^k。
解答
从n个样本里随机选k个,选法与样本的取值无关。给定样本,选出的k个全错的概率是 C(n − c, k)/C(n, k)。不加条件时, 选出的k个样本就是k次独立抽取,全错的概率是 (1 − p)^k。由全概率公式,后者正是前者的期望。
4. 投票什么时候对。 正确答案的概率是p*,每个错误答案y的概率 p_y ≤ p* − Δ,一共有m种可能的答案。给对k个样本做多数 投票出错的概率一个上界。
解答
只有当某个错误答案y出现的次数不少于正确答案时,投票才会错。固定y,N_{y*} − N_y = Σ_i X_i,其中 X_i = 1[Y_i = y*] − 1[Y_i = y] ∈ {−1, 0, 1},相互独立,均值至少为Δ。对取值范围为2的变量用霍夫丁不等式: P(Σ X_i ≤ 0) ≤ exp(−2(kΔ)²/(4k)) = exp(−kΔ²/2)。对m − 1个错误答案取并集上界:P(投票出错) ≤ (m − 1) e^{−kΔ²/2}, 随k增大趋于零。反过来,如果某个错误答案比正确答案更可能,同样的论证说明投票出错的概率趋于1。
5. 有检查器时的最优N选1。 从π中抽N个回答,有正确的就留一个正确的(否则留一个错的)。奖励是0或1,记 q = (1 − p)^N。 证明 KL(π_N ‖ π) = KL(Bern(1 − q) ‖ Bern(p)),并求 N → ∞ 时的极限。
解答
结果正确的概率是 1 − q;在正确的条件下,它是π限制在正确答案上的一次抽取;失败时,是π限制在错误答案上的一次抽取。 所以正确的y有 π_N(y) = π(y)(1 − q)/p,错误的y有 π_N(y) = π(y) q/(1 − p)。对数比 log π_N/π 在每个集合上是常数, 所以 KL = (1 − q) log((1 − q)/p) + q log(q/(1 − p)),正是两枚硬币之间的KL。N → ∞ 时 q → 0,q log q → 0, 所以 KL → log(1/p):有界,不像 log N − (N − 1)/N 那样无限增长;后者只在奖励没有并列时才等于KL,一般情况下是上界 (Beirami等,2024)。
6. 熵为什么会下降。 对 π = softmax(z),证明 ∂H/∂z_b = −π_b (log π_b − E_π[log π]),并且一个小步长 Δz 使熵改变 −Cov_{a∼π}(log π_a, Δz_a)。
解答
由 ∂π_a/∂z_b = π_a(δ_ab − π_b):∂H/∂z_b = −Σ_a (∂π_a/∂z_b)(log π_a + 1) = −π_b(log π_b + 1) + π_b Σ_a π_a (log π_a + 1) = −π_b (log π_b − E_π[log π])。一阶近似下,ΔH = Σ_b (∂H/∂z_b) Δz_b = −E_π[(log π − E_π log π) Δz] = −Cov_π(log π, Δz)。策略梯度的一步把 z_a 提高 η π_a A_a,所以当高概率的回答优势为正时, 协方差为正,熵就下降(Cui等,2025)。
Build the film
python -m videos.ai.ai28.compute # the part's numbers, into .cache/ai28
python tools/build.py ai28 # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py ai28 Hook # one chapter, silent, with a contact sheet
Scenes: videos/ai/ai28. Setup: see the course page. Source of these notes: the README and the scenes' narration.