Maps to: CMU 11-711 Spring 2026, Lecture 23 (04/14), “Inference-Time Scaling”, Sean Welleck; slides
anlp-s2026-23-inference-scaling.pdf; no course code. Readings: S. Welleck et al., From Decoding to Meta-Generation: Inference-time Algorithms for Large Language Models (TMLR 2024), §4–7. Additional: DeepSeek-AI, DeepSeek-R1 (2025); N. Muennighoff et al., s1: Simple test-time scaling (2025); P. Aggarwal, S. Welleck, L1: Controlling How Long a Reasoning Model Thinks with Reinforcement Learning (2025). Sources: the public slides, the readings, and the papers cited in each section. Numbers quoted from papers or slides are attributed to them. Every number labelled “measured” comes fromcode/lecture23/, run on the author’s machine (Apple M4 Pro, Python 3.13, PyTorch 2.14, one CPU thread). Code:code/lecture23/— five demos on “Chain World”, each under 40 seconds once the models are cached. Reading time: ~90 minutes for the prose; ~15 more for the demos. The last section is a wrap-up of the whole course.
0. How to read this lecture
0.1 Learning goals
After this lecture you should be able to:
- Explain test-time compute (测试时计算) as a scaling dimension, and the slides’ two strategies: generating multiple times and generating longer outputs.
- Define a meta-generation algorithm (元生成算法) and write its aggregation rules: best-of-N, majority voting, weighted voting; and refinement with feedback.
- Distinguish coverage from accuracy. Explain why best-of-N with a learned verifier over-optimizes, and how process labels and chain-of-thought verifiers try to help.
- State what voting converges to as N grows (Wu et al.’s Theorem 2), and when weighted voting beats plain voting.
- Explain why refinement depends on the quality and source of feedback (extrinsic vs intrinsic), and compute the slides’ noisy toy model exactly.
- Count inference compute (≈ 2 × parameters × tokens), and say when a smaller model with more samples is compute-optimal.
- Explain why chain of thought helps a fixed-depth model, what reasoning models (o1, R1) change, and how budget forcing (s1) and L1 control how long a model reasons.
0.2 Prerequisites and scope
- Prerequisites:
- Lecture 9: temperature sampling, minimum Bayes risk, the KV cache.
- Lecture 7: chain-of-thought prompting; compute-optimal training.
- Lecture 13: pass@k and its unbiased estimator.
- Lecture 17: reward models, over-optimization and best-of-N’s KL; GRPO and DeepSeek-R1.
- Lecture 14: how noisy a measurement on 100 problems is.
- Scope: the slides’ outline. Test-time scaling strategies: generating multiple times (parallel sampling, best-of-N, voting, refinement, inference scaling laws) and generating longer outputs (reasoning models, controlling the reasoning length).
- Not in scope:
- Tree search over partial solutions (step-level beam search, MCTS, REBASE). The slides name it and skip it; so do we.
- Training reasoning models with RL: Lecture 17.
- Serving systems (PagedAttention, continuous batching). Lecture 9 deferred them to “Lecture 23”, but the Spring 2026 slides do not cover them. Pointers are in Further reading.
0.3 Section → code map
| Section | Idea | Demo in code/lecture23/ |
|---|---|---|
| §1.3 | Chain World; compounding errors | 01_parallel_sampling.py Part A (+ chain_world.py) |
| §3.1 | coverage with N samples; perfect verifiers | 01_parallel_sampling.py Part B |
| §3.2–3.4 | learned outcome and process verifiers; best-of-N over-optimization | 02_verifiers.py (+ verifiers.py) |
| §4.1–4.3 | majority voting, weighted voting, voting’s limit | 01_parallel_sampling.py Part C, 02_verifiers.py Part B |
| §4.4 | temperature: diversity vs quality | 01_parallel_sampling.py Part D |
| §5 | refinement: the TAYLORSWIFT toy and Chain World | 03_refinement.py |
| §6 | small vs base model at equal inference FLOPs | 04_compute_optimal.py |
| §7 | how many steps to write; budget forcing; difficulty | 05_reasoning_length.py |
0.4 Notation
| Symbol | Meaning |
|---|---|
| input (a problem) | |
| output; for reasoning tasks : a reasoning chain , then an answer | |
| a generator: a model plus a decoding algorithm | |
| number of samples | |
| aggregation function: | |
| true reward (here: 1 if correct, else 0) | |
| verifier / reward model score, an approximation of | |
| feedback on an output | |
| , | parameters used per token; tokens processed per sample |
| inference compute in FLOPs |
1. A new dimension of scaling
1.1 Inference = a model + an algorithm
Most of this course has been about training-time scaling: more data, more parameters, more FLOPs (Lecture 7), and the systems that make them affordable (Lectures 19–22). At inference we mostly decoded one output with greedy search or sampling (Lecture 9).
The slides start from a simple observation: inference generates outputs with a model and an algorithm, and the algorithm can also be scaled. Think of a person facing a hard exam problem. Their knowledge is fixed during the exam, yet they can still:
- think longer;
- try several approaches;
- check their work and fix mistakes.
A deployed model is in the same position. Its training compute is spent, but how much compute it uses per question is still a choice. That choice is called test-time compute (or inference-time compute). The slides show four kinds of evidence that it scales:
- AlphaCode (Li et al., DeepMind 2022) samples up to millions of programs per competition problem. It filters them with the example tests and clusters the survivors. Its solve rate keeps rising roughly log-linearly with the number of samples.
- Sun et al. (2024) show MATH accuracy rising with the number of samples when a reward model weights the votes.
- Chain of thought (Wei et al., 2022) spends tokens on reasoning before the answer, and large models get much better at arithmetic word problems.
- Reasoning models: o1 (OpenAI, 2024), s1 (Muennighoff et al., 2025) and L1 (Aggarwal & Welleck, 2025). Accuracy rises with the number of “thinking” tokens.
1.2 Two strategies
The slides organise the lecture around two ways to spend more inference compute:
- Generate multiple times. Sample outputs, then combine them: pick one with a verifier, vote, or refine one output using feedback on the previous one (§2–§6).
- Generate longer outputs. Produce one output that contains more reasoning before the answer (§7).
Both strategies generate more tokens. Both also need a way to turn extra tokens into a better answer, and that is where they differ. Sampling more only helps if something can recognise the good sample. Thinking longer only helps if the extra thought actually moves toward the answer.
Why this matters economically. Training compute is paid once. Inference compute is paid per query, so it can be spent where it helps: a hard question can get more than an easy one. A model too expensive to train larger can sometimes still be made better by reasoning longer per query.
1.3 The test bed: Chain World
To measure coverage, verifier errors, voting limits and refinement, we need ground truth for every sample and every step. Real benchmarks give only the final answer; per-step labels need human annotators (§3.4). So the demos use a small world where everything is checkable.
Chain World (chain_world.py):
-
Problems. A start digit and 2–6 operations, all mod 10:
3 + 4 x 7 - 2 ?. -
Solutions. The prompt says how many steps to write (
? steps 3 :):steps solution 3 3 + 4 = 7 ; 7 x 7 = 9 ; 9 - 2 = 7 ; answer 7(one operation per step)2 3 + 4 x 7 = 9 ; 9 - 2 = 7 ; answer 7(two operations in the first step)0 answer 7(no reasoning) -
The generator. Lecture 5’s Transformer with , 2 layers and 4 heads (99,776 parameters per token). It was trained for 2,000 steps on random problems with every allowed number of steps. The loss is on the solution only. It is deliberately imperfect: a larger model (or twice the training) solves ~99% per sample and leaves nothing for test-time compute to fix.
-
The exact checker. It returns whether the answer is right, whether the running value is still right after each step, the first wrong step, and the number of tokens.
Measured (demo 01, Part A; 200 problems per row, 8 samples each, one operation per step):
| operations | greedy | sampled () | per-step success | per-step |
|---|---|---|---|---|
| 2 | 91.0% | 88.4% | 93.9% | 88.2% |
| 4 | 86.5% | 83.5% | 94.7% | 80.4% |
| 6 | 85.5% | 78.1% | 95.0% | 73.4% |
What to notice:
- Errors compound. Each step is right 95% of the time, and a chain is only right if all its steps are. A 6-step sample is right 78.1% of the time.
- The errors are not independent. If they were, a 6-step chain would be right of the time; it is right more often. Some problems are hard for this model and fail repeatedly, others almost never fail. That clustering will decide how far voting can go (§4.3).
- Sampling is worse than greedy per sample. Temperature 1 puts mass on the tail (Lecture 9). We sample anyway, because test-time scaling needs different candidates.
This is the setting test-time scaling addresses: a model that usually gets it right, with errors spread across steps and concentrated on some problems.
2. Meta-generation
2.1 Generators
Recall Lecture 9. A generator is a model plus a decoding algorithm: greedy, temperature sampling, top-p, and so on. Calling an LLM API is calling a generator: text in, text out, possibly random.
2.2 Meta-generation algorithms
Welleck et al. (2024) call strategies that call a generator multiple times meta-generation algorithms. A decoding algorithm calls the model’s next-token distribution; a meta-generator calls a whole generator, treating it as a black-box subroutine. It can also call other components: verifiers, compilers, test suites, retrievers, tools.
The common patterns:
- Parallel: draw independent outputs and aggregate them (§3–4).
- Refinement (sequential): each call conditions on the previous output, and possibly on feedback about it (§5).
- Tree search (step-level): expand partial solutions and prune them with a value function. Hybrids combine these. The slides skip tree search, and so do we.
2.3 Parallel generation
The design question is the aggregation function :
- take the output with the highest score (best-of-N, §3);
- take the most common answer (voting, §4.1);
- combine both (weighted voting, §4.2).
The calls are independent, so latency need not grow with ; only total compute does. The calls also share their prompt, so the prompt’s KV cache can be computed once and reused (Lecture 9).
3. Best-of-N and verifiers
3.1 Best-of-N with a perfect verifier: coverage
Best-of-N picks the candidate with the highest verifier score:
Suppose the verifier is perfect: . Then best-of-N is right whenever any sample is right. Its accuracy equals the coverage (覆盖率), also called pass@N:
For any this goes to 1. A problem the model solves only 5% of the time is covered 92% of the time with 50 samples.
Evidence. Brown et al. (2024, “Large Language Monkeys”) find coverage growing roughly log-linearly with the number of samples over four orders of magnitude. On SWE-bench Lite, sampling DeepSeek-Coder-V2-Instruct 250 times raised the share of issues solved from 15.9% (one sample) to 56%. The best single-attempt result at the time was 43%. Unit tests acted as the verifier.
Where perfect verifiers exist:
- Formal theorem proving. A proof checker (Isabelle, Lean) accepts only valid proofs. In Draft, Sketch, and Prove (Jiang et al., 2023), the success rate rises with the number of attempts per problem.
- Code with tests, though tests can be weak (Lecture 13).
- Math with a checkable final answer: checkable, but a right answer can come from wrong reasoning.
Measured (demo 01, Part B; 100 test problems with 6 operations, 64 samples each):
| N | pass@N, answer checked | pass@N, whole chain checked | random digits: |
|---|---|---|---|
| 1 | 81.0% | 78.0% | 10.0% |
| 2 | 86.0% | 84.0% | 19.0% |
| 4 | 91.0% | 89.0% | 34.4% |
| 8 | 97.0% | 96.0% | 57.0% |
| 16 | 100.0% | 98.0% | 81.5% |
| 64 | 100.0% | 99.0% | 99.9% |
Two lessons:
- Coverage climbs fast: 78% → 96% with 8 samples, 99% with 64. Most problems the model sometimes fails are problems it sometimes solves. Generating multiple times makes them solvable, if something can pick the right sample.
- An answer-only check is inflated when answers are few. With 10 possible answers, random digits already “cover” 81.5% of problems at . pass@N on multiple choice or small answer spaces must be read against this baseline. That is why the slides’ Brown et al. plots use tasks with tests.
The table uses the first of 64 samples, which is a single estimate. Lecture 13’s unbiased estimator averages over all subsets of size .
The gap between 78% (one sample) and 99% (coverage at 64) is what the rest of §3–§4 tries to close.
3.2 Learned reward models
Without a perfect verifier, we learn one: . Two flavours:
- a classifier: is this solution correct? (Cobbe et al., 2021)
- a preference model: which of two outputs is better? (the Bradley–Terry model of Lecture 17)
Cobbe et al. (2021) introduced GSM8K (8.5k grade-school math word problems) for this purpose:
- They fine-tuned a generator, sampled 100 solutions per training problem, and labelled each by whether its final answer was right.
- They trained a verifier on those labels. At test time they sampled 100 solutions and returned the one the verifier scored highest.
- Verification gave roughly the gain of a 30× larger model: a 6B generator with a verifier slightly outperformed a fine-tuned 175B model.
- A verifier that predicts correctness at every token worked better than one that scores only the end of the solution.
Our verifiers (verifiers.py):
- Architecture. A copy of the generator’s Transformer with a scalar head, so the verifier starts from the generator’s knowledge of the task.
- Training data. Binary cross-entropy on 4,800 of the generator’s own samples (1,200 problems × 4), labelled by the exact checker.
- ORM (outcome reward model): one label, at the answer: is the final answer right?
- PRM (process reward model): a label after every step (is the running value still right?) and at the answer. A solution’s score is its lowest step score: a chain is only as good as its weakest step.
Measured (demo 02, Part A; the 6,400 test samples of §3.1, 81.9% of them correct):
| verifier | accuracy at 0.5 | AUROC | mean score, correct | mean score, wrong |
|---|---|---|---|---|
| ORM (outcome labels) | 80.5% | 0.778 | 0.85 | 0.50 |
| PRM (step labels) | 67.9% | 0.799 | 0.65 | 0.25 |
AUROC is the probability that a random correct solution scores higher than a random wrong one (0.5 = chance, 1 = perfect ranking).
- The ORM separates the classes somewhat (0.85 vs 0.50 on average). Its accuracy at a 0.5 threshold, though, is no better than always saying “correct” (81.9%).
- The PRM ranks slightly better. Taking the minimum over steps makes it pessimistic: correct solutions average only 0.65.
- Both are weak verifiers. That is typical of a learned verifier trained on modest data. A side run with 3.3× the training problems and 2.5× the steps still over-optimized (§3.3; code README).
3.3 Why best-of-N works, and when it fails: over-optimization
The slides’ argument:
- The first arrow is why best-of-N gets better with . More candidates bring us closer to the global maximum of .
- The second step only holds if where it matters: at the top of ‘s ranking. A learned has errors. As grows, best-of-N finds the outputs where is most wrong in the optimistic direction. This is over-optimization, or reward hacking (Lecture 17 §4.4), an instance of Goodhart’s law: when a measure becomes a target, it ceases to be a good measure.
Cobbe et al. saw it on GSM8K: accuracy rose with the number of completions up to a few hundred and then fell, as the verifier was fooled by solutions that merely looked right. Gao et al. (2023) measured the same rise-then-fall for best-of-N against a “gold” reward model, as a function of best-of-N’s KL divergence from the generator.
Measured (demo 02, Part B; accuracy over 100 problems):
| N | majority | best-of-N, ORM | best-of-N, PRM | weighted vote, ORM | weighted vote, PRM | perfect verifier |
|---|---|---|---|---|---|---|
| 1 | 81.0% | 81.0% | 81.0% | 81.0% | 81.0% | 81.0% |
| 2 | 82.0% | 82.0% | 79.0% | 82.0% | 79.0% | 86.0% |
| 4 | 84.0% | 79.0% | 79.0% | 82.0% | 81.0% | 91.0% |
| 8 | 84.0% | 78.0% | 79.0% | 82.0% | 83.0% | 97.0% |
| 16 | 85.0% | 70.0% | 70.0% | 83.0% | 83.0% | 100.0% |
| 32 | 83.0% | 55.0% | 56.0% | 82.0% | 86.0% | 100.0% |
| 64 | 88.0% | 42.0% | 43.0% | 84.0% | 86.0% | 100.0% |
(The “perfect verifier” here checks the answer, so it includes lucky guesses; §3.1’s whole-chain column is the stricter version.)
- With a perfect verifier, best-of-N only improves: 81% → 100%.
- With either learned verifier, best-of-N gets worse with more samples: 81% → 42% (ORM) and 43% (PRM) at . That is about half of what a single sample gets.
Why so steep? The anatomy of the failures (demo 02, Part C, PRM at ):
- Best-of-64 picked a wrong solution for 57 of 100 problems. Every one of those 57 problems had a correct sample among the 64.
- On average, the picked wrong solution outscored the best correct one by 0.20 (PRM probability).
- The first errors of the picked solutions were spread over every step: step 1 for 15 problems, step 3 for 13, step 4 for 10, the others fewer.
The mechanism:
- In Chain World, every correct solution of a problem is the same token sequence: there is one right way to write it, checked for 100 of 100 problems. So all correct samples share one score .
- Every wrong sample is a different chain with its own score . Best-of-N is right only if . If a random wrong chain beats with probability , then with wrong samples
- A maximum does not average. It finds the verifier’s largest error, whether that error is systematic or random.
In real tasks, correct solutions also differ from each other. The best correct score then also grows with , which softens the effect. The direction is the same: Cobbe et al. and Gao et al. found it at scale. Its steepness here is a property of this toy.
Practical consequences:
- Tune for best-of-N on a development set; more is not always better.
- Prefer aggregation that needs agreement (§4).
- Improve the verifier: next section.
3.4 Better reward models I: process labels
An outcome label says whether the final answer is right. A process label says, for each step, whether that step is right. Process labels:
- tell the verifier where a solution goes wrong;
- do not reward a right answer reached through wrong reasoning, which outcome labels do (about 3 in 100 here: 81% of first samples have the right answer, but only 78% a right chain).
The catch, in the slides’ words: getting good labels is difficult in general.
Lightman et al. (2023), “Let’s Verify Step by Step”:
- They collected PRM800K: about 800,000 human labels on individual steps of model-written solutions to MATH problems.
- Best-of-1,860 with the PRM solved 78.2% of a representative subset of the MATH test set. The ORM got 72.4% and majority voting 69.6%.
- Process supervision was clearly better at that scale.
Automatic alternatives estimate a step’s correctness from rollouts: does continuing from this step usually reach the right answer? (Math-Shepherd; Wang et al., 2024.)
In Chain World the checker gives step labels for free, so the comparison is on equal footing. At our scale the PRM ranks slightly better (AUROC 0.799 vs 0.778). Its best-of-N curve is nearly identical to the ORM’s, and its weighted voting is 2 points better (86% vs 84%). We do not reproduce Lightman et al.’s gap. The likely reason is our small model and 4,800 training samples, not a contradiction of their result.
3.5 Better reward models II: chain-of-thought verifiers
A verifier can also be a language model that writes out a verification before it judges. Generative verifiers (Zhang et al., 2025) train the LM to produce a rationale (“let me check each step…”) and then answer “Is the answer correct? Yes/No”. The score is .
Two benefits, per the slides:
- Studies find that chain of thought tends to help the reward model.
- Verification compute can itself be scaled. Sample several verification rationales and average their verdicts: test-time scaling applied to the verifier.
Our verifiers are scalar heads, so this is not in the demos.
4. Voting
4.1 Majority voting (self-consistency)
Take the most common final answer.
- Pro: no reward model needed.
- Con: we need a notion of equivalence between outputs, such as “same final answer”.
- Easy for numbers. For programs, AlphaCode clusters them by their behaviour on generated inputs.
- For free text it needs a similarity: this is minimum Bayes risk decoding (Lecture 9). MBR with a 0/1 “same answer” utility is majority voting.
Evidence:
- Self-consistency (Wang et al., 2023) improved chain-of-thought prompting by 17.9 points on GSM8K.
- Minerva (Lewkowycz et al., 2022) went from 33.6% to 50.3% on MATH with majority voting over 64 samples. Voting beat best-of-N ranked by the model’s own log-likelihood.
- Voting still helps long-chain-of-thought models. DeepSeek-R1-Zero reports 71.0% pass@1 on AIME 2024 and 86.7% with voting over 64 samples (Lecture 17 §3).
Measured (demo 01, Part C):
| N | 1 | 2 | 4 | 8 | 16 | 32 | 64 |
|---|---|---|---|---|---|---|---|
| majority vote | 81% | 82% | 84% | 84% | 85% | 83% | 88% |
| perfect verifier (whole chain) | 78% | 84% | 89% | 96% | 98% | 98% | 99% |
Voting helps a little and then plateaus. It never collapses as best-of-N does, but it also ends far below coverage.
4.2 Weighted voting
Weighted voting combines both signals: each sample votes for its answer with weight equal to its verifier score.
- It can do better than unweighted voting, and it improves with a better reward model (Zhang et al., 2025).
- It can do better than best-of-N (Sun et al., 2024).
Measured (demo 02, Part B): weighted voting reaches 84% (ORM) and 86% (PRM) at . It never drops below 79%, while best-of-N with the same scores falls to 42%. One over-scored outlier cannot win a vote. Many samples must agree.
4.3 What is voting doing? (Wu et al.’s Theorem 2)
Write each output as : a reasoning chain and an answer. As , the vote share of answer converges to its total probability under the generator, summed over every chain that leads to it:
Voting therefore marginalizes out the reasoning chains and picks the mode of the answer distribution. Wu et al. (2024, Theorem 2) state the limit for weighted voting over test problems:
with for unweighted voting. The slides draw three takeaways:
- When is weighted voting better than voting? When puts more total mass on correct answers than alone does.
- Will accuracy keep improving with more samples? No. It converges to the limit above.
- How do we improve further? Improve the reward model , or improve the generator : a better model, or a better algorithm.
Measured (demo 01, Part C). We estimate the limit from the 64 samples: the share of problems whose most frequent answer is right is 88%. The per-problem share of correct samples shows where the other 12% go:
| share of the 64 samples that are correct | 0–10% | 10–20% | 20–30% | 30–40% | 40–50% | 50–90% | ≥ 90% |
|---|---|---|---|---|---|---|---|
| problems | 0 | 4 | 13 | 0 | 4 | 3 | 76 |
The distribution is bimodal.
- 76 problems are solved at least 90% of the time. Voting gets those for free.
- 17 problems are solved less than 30% of the time. On those the model makes a systematic error, and the wrong answer usually wins the vote. No number of votes can fix them. Yet a perfect verifier gets almost all of them, because they are sometimes solved (coverage 99%).
- That gap is the difference between “marginalize the chains” and “find the right chain”.
4.4 Diversity and temperature
Sampling temperature controls how different the samples are.
Measured (demo 01, Part D; 16 samples per problem):
| temperature | per sample | distinct solutions (of 16) | pass@16 (chain) | majority@16 |
|---|---|---|---|---|
| 0.5 | 85.6% | 1.9 | 98.0% | 88.0% |
| 1.0 | 81.9% | 2.6 | 99.0% | 87.0% |
| 1.5 | 58.9% | 7.4 | 95.0% | 87.0% |
- Low temperature gives accurate but repetitive samples (1.9 distinct of 16): little new to choose from.
- High temperature gives many distinct samples, mostly wrong (58.9%).
- Coverage needs diversity; selection needs accurate samples. Here coverage peaks at . Voting is flat because the right answer stays the plurality at every temperature.
5. Refinement
5.1 The idea
Instead of independent tries, feed the output back:
Generate an output, receive feedback, and generate a new output using the feedback. The slides’ key question is the quality and the source of the feedback:
- Extrinsic feedback (外部反馈): new external information enters the loop: test results, a verifier, a retriever, an environment.
- Intrinsic feedback (内部反馈): no external information enters. The same model critiques its own output.
5.2 Extrinsic feedback
Refinement tends to work well with “good” extrinsic feedback, which:
- adds new information the model did not have;
- is high quality: accurate and noise-free;
- is specific: it localizes errors and gives the model something concrete to fix.
Examples from the slides:
- Code generation with unit tests. Chen et al. (2023) feed back unit-test results (extrinsic) and the model’s own explanation of its code (intrinsic), for up to 10 refinement turns.
- Verified code generation. AlphaVerus (Aggarwal et al., 2024) uses the Verus formal verifier: generate a program with its proof, verify it, refine it using the verifier’s error messages.
- Other success cases: code execution, verifiers, retrievers (Self-RAG, Lecture 10), tools and agent environments (Lecture 18).
5.3 Intrinsic feedback
Self-refinement re-prompts the same model to generate, give feedback, and refine (Self-Refine; Madaan et al., 2023). It reports an average gain of about 20 points across seven tasks.
The results are mixed:
- It can work on tasks whose outputs are easy to evaluate. If we want 10 citations and the draft has 9, the model can see that and fix it.
- It is less clear for mathematical reasoning. Huang et al. (2024), “Large Language Models Cannot Self-Correct Reasoning Yet”, found that without external feedback, asking the model to review its answer often lowers accuracy: it changes right answers into wrong ones more often than it fixes wrong ones.
- The diagnosis on the slides: the feedback is too noisy.
5.4 A toy model for refinement
The slides’ toy (from the NeurIPS 2024 tutorial on LLM inference) makes “noisy feedback” precise:
- Task: generate the string
TAYLORSWIFT, 11 letters. - Generator: a unigram model over 26 letters. Each position is right with probability , so a fresh sample is right with probability .
- Feedback: which positions are wrong. With probability a flag is flipped: a right letter is flagged as wrong, or a wrong one passes.
- Refinement: regenerate only the flagged positions.
Each position is a two-state Markov chain. If is the probability that it is right,
The first term is a right letter that is kept, or flagged by mistake and regenerated right by luck. The second is a wrong letter that is flagged and regenerated right.
- Exact feedback (). , so after rounds .
- Noisy feedback (). converges to the fixed point
Every round, noisy flags re-break letters that were right. The cap is set by the noise, not by the number of rounds.
Measured (demo 03, Part A, computed exactly; per position / whole string):
| feedback noise | |||||
|---|---|---|---|---|---|
| 0.00 | 35.0% / 0.0% | 63.9% / 0.7% | 86.5% / 20.2% | 98.1% / 80.9% | 100.0% / 99.6% |
| 0.01 | 33.2% / 0.0% | 57.4% / 0.2% | 73.2% / 3.3% | 79.3% / 7.8% | 79.8% / 8.4% |
| 0.05 | 26.9% / 0.0% | 38.9% / 0.0% | 42.7% / 0.0% | 43.2% / 0.0% | 43.2% / 0.0% |
| 0.10 | 20.9% / 0.0% | 25.8% / 0.0% | 26.5% / 0.0% | 26.5% / 0.0% | 26.5% / 0.0% |
- With exact feedback, refinement achieves what no amount of independent sampling could: 80.9% for the whole string after 100 rounds.
- With 1% noise the whole string stalls at 8.4% (). With 10% noise it is hopeless.
- Errors compound across positions exactly as they do across reasoning steps (§1.3).
5.5 Refinement in Chain World
The same experiment with real samples (demo 03, Part B):
- Generate one solution per problem.
- Get feedback that names a step.
- Regenerate the solution from that step on, for 4 rounds. The last round’s solution is counted, with no oracle picking the best round.
| feedback | round 0 | 1 | 2 | 3 | 4 | tokens regenerated / problem |
|---|---|---|---|---|---|---|
| exact checker: first wrong step (extrinsic) | 79.0% | 85.5% | 90.0% | 92.0% | 93.5% | 12.9 |
| exact checker, 30% of the time a random step | 79.0% | 82.0% | 82.0% | 84.5% | 84.0% | 36.6 |
| learned PRM: first step scored < 0.5 | 79.0% | 75.0% | 79.5% | 75.5% | 79.0% | 35.5 |
| no information: restart from a random step | 79.0% | 75.0% | 76.5% | 76.5% | 73.5% | 78.5 |
- Accurate, localized, extrinsic feedback works. It goes from 79.0% to 93.5% in 4 rounds while regenerating only 12.9 tokens per problem on average, since only wrong solutions are touched.
- Noise caps it. With 30% of the feedback pointing at a random step, accuracy reaches 84.0%, and the cost almost triples: right solutions get regenerated too.
- The model’s own verifier gives no net gain (79.0% after 4 rounds). The PRM is pessimistic: it flags many correct solutions, which are then resampled and sometimes broken, and it misses some wrong ones. It is the toy’s in practice.
- Trying again with no information is worse than not trying (73.5%). Restarting a correct solution at temperature 1 can only break it. This matches Huang et al.: without external feedback, “self-correction” mostly resamples.
6. Inference scaling laws
6.1 Counting inference compute
The forward pass costs about 2 FLOPs per parameter per token (Lecture 7; with a KV cache, each generated token needs one pass). Generating samples of tokens with a model of parameters per token costs
The slides’ point: compute is a function of model size and of the number of generated tokens. Both can be traded. At a fixed budget we can use a larger model and generate less, or a smaller model and generate more: more samples, or longer ones.
6.2 What the papers find
- Wu et al. (2024), “Inference Scaling Laws”. They evaluated Pythia and Llemma models of several sizes on GSM8K and MATH with majority voting, weighted voting, best-of-N and tree search, at matched FLOPs.
- Using a smaller model and generating more can be preferred over using a larger model and generating less: Llemma-7B was often compute-optimal over Llemma-34B.
- The compute-optimal model size grows with the budget, because the small model’s voting accuracy saturates (§4.3).
- Their tree search (REBASE) gave a better accuracy–compute frontier than sampling.
- Snell et al. (2024) allocate test-time compute per problem by difficulty. On problems where the smaller model already has a non-trivial success rate, optimally spent test-time compute outperformed a 14× larger model at equal FLOPs; on the hardest problems, it did not.
- Brown et al. (2024): repeated sampling from a cheaper model can beat a single sample from a stronger, more expensive one, when a verifier picks the winner (§3.1).
6.3 Measured: a small and a base model at equal FLOPs
Demo 04 trains a second generator, small (), the same way, and gives it as many samples as the base model’s FLOPs allow:
| generator | parameters per token | tokens per sample | FLOPs per sample | accuracy per sample |
|---|---|---|---|---|
| small | 25,376 | 56.8 | 2.88 × 10⁶ | 45.4% |
| base | 99,776 | 56.9 | 1.14 × 10⁷ | 81.9% |
At equal inference FLOPs (budget in base-model samples; the small model gets 3.9× as many, rounded to the nearest power of two):
| budget | base: N | base: majority | base: perfect verifier | small: N | small: majority | small: perfect verifier |
|---|---|---|---|---|---|---|
| 1 | 1 | 81% | 78% | 4 | 58% | 68% |
| 2 | 2 | 82% | 84% | 8 | 63% | 82% |
| 4 | 4 | 84% | 89% | 16 | 65% | 90% |
| 8 | 8 | 84% | 96% | 32 | 71% | 95% |
| 16 | 16 | 85% | 98% | 64 | 75% | 99% |
- With majority voting, the bigger model wins at every budget (5 of 5), by 17 points on average. The small model’s votes converge to its own plurality answers, which are wrong more often: 75% at 64 samples vs the base model’s 85% at 16. That is takeaway 2 of §4.3 at work.
- With a perfect verifier, the gap nearly closes: 2 points on average. The small model is ahead at 2 of 5 budgets, which is within the noise of 100 problems (one problem is 1 point; Lecture 14).
The answer to “small and many, or large and few?” depends on the aggregation method. It favours “small and many” only with a verifier good enough to find the rare right sample. That is consistent with Wu et al. and Brown et al.
FLOPs are only one cost. Latency, memory traffic and batching (Lectures 9 and 20) can shift the comparison either way: decoding is often memory-bound, and many samples of one prompt share the weight reads.
7. Generating longer outputs
7.1 Chain of thought as test-time compute
Chain-of-thought prompting (Wei et al., 2022) puts worked reasoning into the few-shot examples, so the model writes reasoning before its answer. For PaLM 540B on GSM8K, accuracy went from 17.9% with standard prompting to 56.9% with chain of thought. Lecture 7 studied it as prompting. Here it is a way to spend more tokens per question.
Why does writing more help? A Transformer does a fixed amount of computation per generated token, bounded by its depth.
- A computation that needs many sequential steps cannot fit into one token’s forward pass.
- Writing intermediate results lets every later token condition on them. The model’s output becomes its working memory, and each new token gets a fresh pass of the network.
- Theory makes this precise: chain of thought increases what a fixed-size Transformer can compute (Feng et al., 2023; Merrill & Sabharwal, 2024).
Measured (demo 05, Part A; 200 problems with 6 operations, 8 samples each). The prompt asks for 0 to 6 steps:
| steps asked for | operations per step | tokens | wrote that many steps | accuracy |
|---|---|---|---|---|
| 0 | – | 2.0 | 99.8% | 13.5% |
| 1 | 6 | 18.0 | 100.0% | 14.5% |
| 2 | 3 | 22.0 | 99.8% | 14.1% |
| 3 | 2 | 26.0 | 99.6% | 16.4% |
| 6 | 1 | 37.9 | 99.7% | 75.9% |
- One operation per step is the only format that works. 75.9%, versus 13.5–16.4% for everything else. Chance is 10%.
- The model was trained on all five formats, yet it never learned to compose even two operations within one step. Each operation is a lookup on (value, operation, number) that this 2-layer model does reliably. Feeding one lookup’s result into the next within a single pass is beyond it.
- Writing the intermediate value as a token gives the next step a fresh start. That is the serial-computation argument in miniature.
Direct answers beat chance only through a shortcut. They are right 28.1% of the time when the last operation is x 2/4/5/6/8, which leaves at most 5 possible answers (after x 5 only 0 and 5 remain). Otherwise they are right 10.7% of the time.
Harder problems need longer chains, and still fail more (demo 05, Part C): 2 operations take 14 tokens and are solved 89.2% of the time; 6 operations take 38 tokens and are solved 74.1%. In this format the length is fixed at 6 tokens per operation. A reasoning model chooses its length, which is where §7.3–7.4 come in.
7.2 Long chain of thought: reasoning models
A reasoning model is trained to generate a “thought” before its final output :
At inference time we just sample a thought and an output, once. The slides’ observation: in principle, the model can learn a search algorithm inside the thought. It can try alternatives, check them, backtrack and refine, all in one long sequence. The meta-generation of §2–§5 moves inside the model.
How such models are trained.
-
Approach 1 on the slides: reinforcement learning with verifiable rewards (Lecture 17).
- o1 (OpenAI, 2024): accuracy on AIME rises smoothly with both train-time RL compute and test-time thinking compute, each on a log scale.
- DeepSeek-R1 (DeepSeek-AI, 2025):
- Trained with GRPO and rule-based rewards.
- R1-Zero’s AIME 2024 pass@1 rose from 15.6% to 71.0% during RL.
- Its average response length grew steadily, to thousands of tokens.
- Reflection appeared on its own (the “aha moment”).
-
Long chain-of-thought patterns (slides; credits Weihua Du). Typical behaviours inside the thought:
- verifying intermediate results (“let me check”);
- backtracking (“wait, that is wrong”);
- setting subgoals;
- exploring alternative approaches.
Gandhi et al. (2025) identify verification, backtracking, subgoal setting and backward chaining as the “cognitive behaviors” that let RL improve a model’s reasoning.
Generating longer combines with generating multiple times. R1’s voting results (§4.1) are parallel sampling on top of long chains.
7.3 Controlling the length: budget forcing (s1)
Long thinking costs tokens, and so latency and money. Some questions need 500 tokens, others 5,000. How do we control how long a model thinks?
s1 (Muennighoff et al., 2025) shows a simple test-time recipe:
- Training. Fine-tune Qwen2.5-32B-Instruct on s1K: 1,000 carefully selected questions with reasoning traces, chosen for difficulty, diversity and quality.
- Budget forcing at test time:
- to stop early, once the thinking budget is used, append the end-of-thinking delimiter (and “Final Answer:”), which forces the model to answer;
- to think longer, suppress the end-of-thinking delimiter when the model tries to stop, and append “Wait”. This often makes it re-check and fix its answer.
- Results. Accuracy rises with the number of thinking tokens: a sequential scaling curve. s1-32B exceeds o1-preview on competition math (MATH and AIME24) by up to 27%. Budget forcing pushes AIME24 from 50% to 57%, beyond what the model reaches without intervention.
Measured: truncating Chain World’s reasoning (demo 05, Part B). Take the model’s 6-step chains, cut them after steps, append answer, and read the model’s forced answer:
| steps kept (budget) | tokens | forced answer right | forced answer = last value written |
|---|---|---|---|
| 0 | 2.0 | 17.0% | 5.0% |
| 1 | 8.0 | 11.8% | 100.0% |
| 2 | 14.0 | 13.2% | 100.0% |
| 3 | 20.0 | 9.2% | 99.9% |
| 4 | 26.0 | 8.4% | 99.9% |
| 5 | 32.0 | 12.6% | 99.9% |
| 6 | 37.9 | 81.8% | 99.9% |
- This is not a smooth trade-off but a cliff: 81.8% with all 6 steps, 8.4–13.2% with 1–5 steps.
- The last column explains why. Forced to answer after step , the model answers with the last value it wrote in ≥ 99.9% of cases. It has learned “the answer is the final running value”. A truncated chain’s last value is an intermediate result, which happens to equal the answer only about 1 time in 10.
- With no steps it uses the shortcut of §7.1 (17.0%). Truncation throws even that away.
In s1, accuracy degrades gradually as the budget shrinks. Partial reasoning written in language still constrains the answer, and a large model can guess well from where it got to. Truncation only trades tokens for accuracy smoothly if the model can use partial reasoning. Our model cannot; it was never trained to answer from an unfinished chain.
The “Wait” direction cannot be measured here: a finished chain in this format has nothing left to reconsider.
7.4 Controlling the length: L1
Budget forcing is crude:
- It cuts the model off mid-thought or pushes it past where it wanted to stop.
- The model was never trained to plan for a budget.
L1 (Aggarwal & Welleck, 2025) trains the plan in:
- Length instruction. The prompt states a length constraint, e.g. “Think for 2,000 tokens” or “use up to 2,000 tokens”.
- Training. RL with a reward for correctness and a penalty for violating the length constraint: Length Controlled Policy Optimization (LCPO).
- L1-Exact penalizes .
- L1-Max treats the target as an upper limit.
- The slides’ example. The same problem answered incorrectly with 512 tokens and correctly with 3,600.
- Reported results.
- A smooth, controllable trade-off between tokens and accuracy, better than s1’s budget forcing at the same budgets.
- A surprising short-reasoning ability: their 1.5B L1 model surpasses GPT-4o at equal reasoning lengths.
Measured: length control from the prompt (Table of §7.1, column “wrote that many steps”). Our model writes exactly the requested number of steps in 99.6–100% of samples. Prompt-based length control can be learned from data that mixes lengths; here supervised fine-tuning was enough.
But following the requested length is not the same as using it well. A short budget cost us 60 points, because the model can only imitate the training formats. L1’s RL objective rewards correctness under the budget, so the model is pushed to find the best reasoning that fits. That is what an imitation objective cannot do.
8. Choosing a test-time strategy
| situation | strategy | why | measured here |
|---|---|---|---|
| a perfect verifier exists (tests, proof checker, exact checker) | sample many and keep a verified one; refine with the verifier’s feedback | accuracy = coverage → 1 | coverage 78% → 99% at ; refinement 79% → 93.5% in 4 rounds |
| answers are comparable, no verifier | majority voting | robust; plateaus at the plurality limit | 81% → 88% |
| a learned reward model | weighted voting; best-of-N only with tuned on held-out data | best-of-N over-optimizes | best-of-N 81% → 42%; weighted 84–86% |
| only self-critique (intrinsic) | be sceptical and measure | feedback noise caps refinement | PRM-guided 79% → 79%; random restart 73.5% |
| a fixed compute budget | compare model sizes at equal FLOPs, per aggregation method | small + many wins only with a good verifier | voting: base wins 5 of 5 budgets; perfect verifier: gap 2 points |
| a reasoning model | control the length (budget forcing, L1); add voting on top | accuracy rises with thinking tokens, at a latency cost | 13.5% (0 steps) → 75.9% (6 steps) |
Two cross-cutting rules:
- Every method is limited by the weakest component that chooses. That might be the verifier (best-of-N), the plurality (voting), the feedback (refinement) or the model’s use of partial reasoning (budget forcing).
- Always compare at equal compute, and against a voting baseline.
9. Course wrap-up
9.1 The arc
Lecture 1 introduced one recipe: a parameterized scoring function , with three decisions:
- model: the form of ;
- learning: how to set ;
- inference: how to choose .
The 23 lectures filled in each decision:
| Part | Lectures | What it added to the recipe |
|---|---|---|
| I · Fundamentals | 1–3 | the recipe; learned representations; autoregressive language models |
| II · Architectures | 4–5 | recurrence; attention and the Transformer |
| III · Learning and inference | 6–9 | pretraining; scaling laws and in-context learning; fine-tuning and distillation; decoding |
| IV · Modeling | 10–12 | retrieval as part of the model; images in and out |
| V · Evaluation and research | 13–14 | what a number means; how to run an experiment that can fail |
| VI · Beyond autoregression | 15 | diffusion and flows, including discrete diffusion LMs |
| VII · RL and agents | 16–18 | learning from rewards; RLHF and RL with verifiable rewards; acting in environments |
| VIII · Scaling and efficiency | 19–23 | fewer bits; more devices; sparse experts; long sequences; more compute at inference |
This lecture closes the loop on inference. Lecture 9 treated it as choosing one output from the model’s distribution. Here, the algorithm around the model became a lever as important as the model itself: sampling, verifying, voting, refining and reasoning longer can turn a 78%-per-sample model into a 99%-coverage system, or, with the wrong verifier, into a 42% one.
9.2 Themes that kept coming back
- Measure against ground truth. Many lectures built a small world where the right answer was known exactly: Cinema World, Errand World, Fact World, Mix World, Chain World. That made it possible to see mechanisms, such as why voting stops, why best-of-N collapses, or why an extrapolating model fails, not just scores. Each time we compared the toy’s behaviour with what the papers report at scale. Where they disagreed, we said so.
- Scaling is a set of trade-offs. Data vs parameters (Lecture 7), bits vs parameters (Lecture 19), total vs active parameters (Lecture 21), length vs compute (Lecture 22), model size vs samples (this lecture). Each comes with a law that holds in a regime and breaks outside it.
- Proxies get optimized. Perplexity is not task accuracy (Lecture 13), a reward model is not the reward (Lecture 17), and a verifier is not correctness (this lecture). Optimizing a proxy hard enough finds its errors.
- Systems constraints shape models. Memory, bandwidth and communication decided how we quantize, shard, route and attend (Lectures 19–22). They also decide what test-time compute really costs.
- Honest evaluation. Seeds, confidence intervals, baselines and controls (Lecture 14). A result within the noise of 100 problems was reported as exactly that.
9.3 Where to go next
- The project (Assignment 4). Pick a question where one of these levers matters to you, set up a measurement you trust, and compare against the strongest simple baseline.
- Related notes in this collection:
- CS329A · Self-Improving AI Agents: test-time compute, verifiers and self-improvement in depth.
- CMU 11-868 · LLM Systems: serving, PagedAttention, KV caches. That is the systems side that makes test-time compute affordable, and it was skipped here.
- CS336 · Language Modeling from Scratch: build every component at larger scale.
- CMU 11-667 · LLMs: Methods and Applications: a broader survey of the same landscape.
- Read the papers. Each lecture’s Further reading lists the primary sources. The field moves fast, but the questions behind them have stayed the same through this course:
- what to model;
- how to learn it;
- how to choose an output;
- how to know whether it worked.
Summary
- Test-time compute is a scaling dimension. Spend it by generating multiple times or by generating longer outputs. Both need a way to turn extra tokens into better answers.
- Meta-generation calls a generator multiple times: in parallel (best-of-N, voting, weighted voting), by refinement, or by tree search.
- Coverage grows fast with samples, but realising it needs a verifier.
- Measured: whole-chain coverage 78% → 99% at .
- Random guessing inflates answer-only coverage when answers are few.
- Best-of-N with a learned verifier over-optimizes. The maximum finds the verifier’s errors.
- Measured: 81% → 42–43% at , although a correct sample existed for every failed problem.
- Process labels and chain-of-thought verifiers make better verifiers; at our scale the PRM was only slightly better.
- Voting needs no verifier and is robust, but converges to the share of problems whose most likely answer is right (Wu et al.’s Theorem 2).
- Measured: 81% → 88%, limit 88%; 17 problems with systematic errors.
- Weighted voting (84–86%) never collapses.
- Refinement is as good as its feedback.
- The toy’s fixed point is .
- Measured in Chain World: exact feedback 79% → 93.5%; noisy 84%; the model’s own verifier 79%; no information 73.5%.
- Inference scaling laws. Compute ≈ 2 × parameters × tokens; smaller models with more samples can be compute-optimal.
- Measured: the bigger model wins 5 of 5 budgets with voting; with a perfect verifier the gap shrinks to 2 points.
- Longer outputs. Chain of thought gives a fixed-depth model serial computation; reasoning models learn long chains with RL (o1, R1).
- Budget forcing (s1) and L1 control the length.
- Measured: one operation per step 75.9% vs ≤ 16.4% for compressed steps.
- Truncation is a cliff, because the forced answer copies the last value written.
Common pitfalls
- Reporting best-of-N at large N with a learned verifier without checking that accuracy is still rising. Plot accuracy against .
- Reading pass@N without a guessing baseline on tasks with few possible answers. Check whole solutions, or report the random baseline.
- Comparing strategies at different compute. Count tokens × parameters × samples, or at least tokens.
- Treating self-correction as free accuracy. Without external information the “feedback” is the model’s own noise; measure the no-feedback control.
- Expecting voting to keep improving. It converges. To go further, improve the generator or add a verifier.
- Assuming a smaller model with more samples always wins. It does so only when the aggregator can find its rare right answers.
- Truncating a reasoning model’s thoughts and expecting graceful degradation. That works only if partial reasoning is informative to the model. Check the forced answers.
- Forgetting that correct solutions can all look alike. If they share one score, best-of-N compares it with the maximum of everything else.
Exercises
-
Coverage. A model solves a problem with probability per sample. How many samples are needed for 95% coverage? If the answer is one of 10 digits, what coverage would random guessing reach with the same number of samples?
Answer
We need 1 − 0.7^N ≥ 0.95, i.e. N ≥ ln 0.05 / ln 0.7 = 8.4, so N = 9. Random guessing: 1 − 0.9⁹ = 61%. An answer-only check would credit a random guesser with 61% "coverage", which is why whole-solution checks (or tests) matter. -
Best-of-N’s collapse. For one problem, 80% of samples are correct and all correct samples are identical, so they share one score. Each wrong sample, independently, outscores the correct one with probability . Estimate the probability that best-of-64 is right, and compare it with majority voting.
Answer
About 0.2 × 64 = 12.8 wrong samples are expected. Best-of-N is right if none of them outscores the correct score: (0.95)^12.8 ≈ e^(−0.657) ≈ 0.52 (the chance that no correct sample appears, 0.2⁶⁴, is negligible). Majority voting picks the right answer almost surely, since 80% of the votes agree. A 5% per-sample verifier error turns a near-certain problem into a coin flip; at N = 4 the same calculation gives (0.95)^0.8 ≈ 0.96. -
Voting’s limit. For one problem, the generator’s answer distribution is (correct), , and the rest is spread over other digits. Correct chains get an average verifier score of 0.9; chains answering 7 get 0.6. What do majority voting and weighted voting converge to? Which takeaway of Wu et al.’s theorem is this?
Answer
Majority voting converges to the mode, 7: wrong for every N large enough. Weighted voting compares 0.35 × 0.9 = 0.315 with 0.40 × 0.6 = 0.24 and converges to 3: right. Takeaway 1: weighted voting beats voting exactly when v · g puts more mass on the correct answer than g does. -
Weighted voting by hand. Six samples have answers and verifier scores . What do best-of-N, majority voting and weighted voting return?
Answer
Best-of-N: the highest score is 0.95, answer 2. Majority: 4 (three votes). Weighted: 4 gets 0.60 + 0.50 + 0.55 = 1.65; 7 gets 0.90 + 0.30 = 1.20; 2 gets 0.95. So 4. The single over-scored sample wins best-of-N but not the vote. -
The refinement fixed point. Derive from the per-position recurrence of §5.4. For , what is the long-run probability that all 11 letters are right?
Answer
Set c = c[(1−ε) + ε/26] + (1−c)(1−ε)/26. Multiply by 26: 26c = 26c(1−ε) + cε + (1−ε) − c(1−ε). Collect the c terms: c[26 − 26 + 26ε − ε + 1 − ε] = 1 − ε, so c(1 + 24ε) = 1 − ε. For ε = 0.01: c* = 0.99 / 1.24 = 0.798, and 0.798¹¹ = e^(11 ln 0.798) ≈ e^(−2.48) ≈ 0.084, i.e. 8.4%, as in demo 03's table at r = 200. -
Compute accounting. A 70B model answers with one 1,000-token solution. How many 1,000-token solutions can a 7B model generate for the same FLOPs? If the 7B model is right 30% of the time per sample and the 70B model 60%, which is better with a perfect verifier, and which with majority voting, assuming the 7B model’s most likely answer is wrong on this problem?
Answer
Compute ∝ parameters × tokens, so 70/7 = 10 samples. With a perfect verifier the 7B model's coverage is 1 − 0.7¹⁰ = 97%, versus 60% for one 70B sample: the small model wins. With majority voting the 7B model converges to its most likely answer, which is wrong here; the 70B single sample is right 60% of the time. That is §6.3's result: the aggregator decides. -
Why compose in steps? In demo 05 the 2-layer model was trained on solutions that compose 2, 3 or 6 operations in one step, yet it solves them at 14–16%. Explain, in terms of computation per token, why one operation per step works and two do not. What would you expect from a deeper model?
Answer
Each operation is a lookup from (value, operation, number) to a new value. Predicting a step's result token requires applying that lookup once to a value that is written in the context. Composing two operations needs the first lookup's result as the input to a second one inside the same forward pass: a serial dependency that a 2-layer network evidently could not learn here. Writing the intermediate value as a token turns the second lookup into a fresh, one-lookup prediction. A deeper model has more sequential layers per token and might learn to compose a few operations, but any fixed depth runs out on long enough chains. Chain of thought removes the limit by trading depth for tokens. -
Making truncation graceful. Demo 05’s forced answers copy the last value written. How would you change the training data so that a truncated chain still gives the best possible guess? What is the best possible guess after of 6 steps?
Answer
Add training examples whose chains stop early (after b steps, at random) followed by the *true final answer*. The model then learns to predict the answer from the partial chain plus the remaining operations, instead of copying. The Bayes-optimal guess is the most likely result of applying the remaining operations to the current value without computing them exactly. Usually that is weak (near 10%), but sharp when a remaining `x 5` or `x 2` collapses the possibilities, so accuracy would degrade smoothly with b instead of falling off a cliff. L1-style RL achieves something similar by rewarding correct answers under a budget.
Related assignment (concepts only)
- Assignment 4 (final project): if your project uses inference-time methods:
- report compute (samples, tokens, model size), and compare strategies at equal compute;
- include majority voting as a baseline, and tune for best-of-N on held-out data;
- for multiple-choice or short-answer tasks, report the guessing baseline next to pass@N;
- if you use refinement, run a no-feedback control to separate the feedback’s contribution from resampling.
- These notes do not provide assignment code.
Further reading
- S. Welleck, A. Bertsch, M. Finlayson, H. Schoelkopf, A. Xie, G. Neubig, I. Kulikov, Z. Harchaoui, “From Decoding to Meta-Generation: Inference-time Algorithms for Large Language Models”, TMLR 2024 (course reading), and the NeurIPS 2024 tutorial “Beyond Decoding: Meta-Generation Algorithms for Large Language Models”.
- DeepSeek-AI, “DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning”, 2025; N. Muennighoff et al., “s1: Simple test-time scaling”, 2025; P. Aggarwal, S. Welleck, “L1: Controlling How Long a Reasoning Model Thinks with Reinforcement Learning”, 2025; OpenAI, “Learning to Reason with LLMs”, 2024.
- Y. Li et al., “Competition-Level Code Generation with AlphaCode”, Science 2022; B. Brown et al., “Large Language Monkeys: Scaling Inference Compute with Repeated Sampling”, 2024; A. Jiang et al., “Draft, Sketch, and Prove”, ICLR 2023.
- K. Cobbe et al., “Training Verifiers to Solve Math Word Problems”, 2021; H. Lightman et al., “Let’s Verify Step by Step”, 2023; P. Wang et al., “Math-Shepherd”, ACL 2024; L. Zhang et al., “Generative Verifiers: Reward Modeling as Next-Token Prediction”, ICLR 2025; Z. Sun et al., “Easy-to-Hard Generalization: Scalable Alignment Beyond Human Supervision”, 2024; L. Gao, J. Schulman, J. Hilton, “Scaling Laws for Reward Model Overoptimization”, ICML 2023.
- X. Wang et al., “Self-Consistency Improves Chain of Thought Reasoning in Language Models”, ICLR 2023; A. Lewkowycz et al., “Solving Quantitative Reasoning Problems with Language Models” (Minerva), 2022; Y. Wu et al., “Inference Scaling Laws: An Empirical Analysis of Compute-Optimal Inference for Problem-Solving with Language Models”, ICLR 2025; C. Snell et al., “Scaling LLM Test-Time Compute Optimally can be More Effective than Scaling Model Parameters”, 2024.
- A. Madaan et al., “Self-Refine”, NeurIPS 2023; X. Chen et al., “Teaching Large Language Models to Self-Debug”, 2023; P. Aggarwal, B. Parno, S. Welleck, “AlphaVerus”, 2024; J. Huang et al., “Large Language Models Cannot Self-Correct Reasoning Yet”, ICLR 2024.
- J. Wei et al., “Chain-of-Thought Prompting Elicits Reasoning in Large Language Models”, NeurIPS 2022; G. Feng et al., “Towards Revealing the Mystery behind Chain of Thought”, NeurIPS 2023; W. Merrill, A. Sabharwal, “The Expressive Power of Transformers with Chain of Thought”, ICLR 2024; K. Gandhi et al., “Cognitive Behaviors that Enable Self-Improving Reasoners”, 2025.
- Serving and LM programs, skipped here (Lecture 9 pointed forward to them): W. Kwon et al., “Efficient Memory Management for Large Language Model Serving with PagedAttention” (vLLM), SOSP 2023; L. Zheng et al., “SGLang: Efficient Execution of Structured Language Model Programs”, 2024; O. Khattab et al., “DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines”, ICLR 2024.
After the course
This is the last lecture. §9 summarises the course and points to related notes in this collection. Every lecture’s notes and code stand alone. A good way to review is to rerun a lecture’s demos, predict each “Observations” line before reading it, and check where you were wrong.
术语表 (Glossary, English → 中文)
| English | 中文 |
|---|---|
| test-time / inference-time compute | 测试时 / 推理时计算 |
| test-time scaling | 测试时扩展 |
| generator / decoding algorithm | 生成器 / 解码算法 |
| meta-generation algorithm | 元生成算法 |
| parallel generation / refinement / tree search | 并行生成 / 精炼 / 树搜索 |
| aggregation | 聚合 |
| coverage / pass@N | 覆盖率 / N 次通过率 |
| best-of-N | 最优 N 选一 |
| verifier / reward model / value model | 验证器 / 奖励模型 / 价值模型 |
| perfect verifier / learned verifier | 完美验证器 / 学习得到的验证器 |
| outcome reward model (ORM) / process reward model (PRM) | 结果奖励模型 / 过程奖励模型 |
| outcome / process labels (supervision) | 结果 / 过程标注(监督) |
| generative (chain-of-thought) verifier | 生成式(思维链)验证器 |
| over-optimization / reward hacking / Goodhart’s law | 过度优化 / 奖励投机 / 古德哈特定律 |
| AUROC | 受试者工作特征曲线下面积 |
| majority voting / self-consistency | 多数投票 / 自洽性 |
| weighted voting | 加权投票 |
| plurality / mode of the answer distribution | 相对多数 / 答案分布的众数 |
| marginalize out | 边缘化掉 |
| diversity / temperature | 多样性 / 温度 |
| extrinsic / intrinsic feedback | 外部 / 内部反馈 |
| self-refinement / self-correction / self-debugging | 自我精炼 / 自我纠错 / 自我调试 |
| error localization | 错误定位 |
| fixed point | 不动点 |
| inference scaling law / compute-optimal inference | 推理扩展定律 / 计算最优推理 |
| FLOPs per token | 每词元浮点运算量 |
| chain of thought (CoT) / long CoT | 思维链 / 长思维链 |
| reasoning model / thinking tokens | 推理模型 / 思考词元 |
| serial computation / depth | 串行计算 / 深度 |
| verification / backtracking / subgoal setting | 验证 / 回溯 / 设定子目标 |
| budget forcing | 预算强制 |
| length control / length-controlled policy optimization (LCPO) | 长度控制 / 长度可控策略优化 |
| compounding errors | 误差累积 |
| shortcut | 捷径 |