Reasoning Models & Test-Time Compute
When thinking tokens pay for themselves, and how to prompt and evaluate reasoning models.
For most of the history of language models, quality was fixed when training ended. Reasoning models changed that. They can spend more computation on a hard question at the moment it is asked, by writing out intermediate work before they answer. Quality became a dial with a price on it. This chapter explains what the dial does, what it costs, and when it is worth turning.
The experiment above uses the small model from Chapters 7 and 9, stopped partway through learning the word-capitalizing task so that it is right about half the time. It cannot reason, but it shows the arithmetic of spending compute at answer time, which is the same at any scale.
10.1The idea
A model trained to think in tokens before it answers.
In 2022, researchers found that asking a model to “think step by step” before answering improved its results on math and logic problems. The model wrote out intermediate steps and its final answers got better. That trick, chain of thought, was prompting.
A reasoning model has the habit trained in. Before the visible answer, it generates a stretch of reasoning tokens: working, plans, checks, false starts. Three facts about those tokens explain most of how these models behave.
- They are ordinary output tokens. The architecture is the transformer of Chapter 5 and the loop is the one from section 2.1. There is no separate reasoning component.
- The skill is trained with checkable rewards. The model attempts problems whose answers can be verified, and reasoning that leads to correct answers is reinforced, the method of section 9.6.
- They are billed and timed like any output, whether or not you are shown them.
The first widely available reasoning model was OpenAI’s o1 in September 2024. DeepSeek-R1 followed in January 2025 with open weights and visible reasoning. Since then, most frontier models have offered a reasoning mode that can be switched on or scaled per request.
Common take“Reasoning models have a special reasoning module.”
Sharper take“Same architecture. They generate extra tokens of working before the answer, and they were trained with reinforcement learning to make that working useful.”
10.2Why it helps
A fixed network gets more steps to work with.
A transformer does a fixed amount of computation per token: one pass through its layers (section 5.9). A question that needs more sequential steps than the network has layers cannot be solved in a single pass, however large the model. Multi-digit arithmetic, multi-step deductions and plans with interacting constraints are like this.
Generated tokens get around the limit. Each token is another pass through the network, and everything already written is in the context for later tokens to attend to. The context serves as working memory. The difference is the one between mental arithmetic and pencil and paper: the same mind, with a place to keep intermediate results.
Two limits follow from the same picture.
- Thinking does not add knowledge. If the model lacks a fact, more reasoning produces a more elaborate guess (section 2.9).
- Errors carry forward. A wrong intermediate step is in the context like everything else, and later steps build on it.
Common take“More thinking always gives a better answer.”
Sharper take“More thinking gives more computation steps. It helps when the problem needs steps. It does nothing for a missing fact, and it can talk itself into a wrong answer.”
10.3Three ways to spend
Think longer, sample and vote, or sample and check.
| Method | How it works | Needs |
|---|---|---|
| Think longer | One attempt with a longer chain of reasoning | A model trained to reason |
| Sample and vote | Several independent attempts; return the most common answer. Also called self-consistency | Answers that can be compared for equality |
| Sample and check | Several attempts; return one that passes a test | A checker: unit tests, a proof checker, a constraint solver, or a judge model |
The first is serial and adds latency. The other two run in parallel and add cost. Which one pays depends on the task, and the next section measures the difference.
Common take“Test-time compute means a longer chain of thought.”
Sharper take“That’s one of three. I can also sample several answers and vote, or sample and check. With a real checker, the third is the most reliable of them.”
10.4Voting and checking, measured
A vote recovers the likeliest answer, a checker finds a right one.
The model from section 9.2, stopped at fine-tuning step 100, capitalizes an unseen word correctly 46% of the time when it gives its single most likely answer. For each of 200 test words I sampled 33 answers at temperature 1 and scored three strategies. The figure at the top of the chapter shows the result.
| Answers sampled per question | Majority vote is correct | A correct answer is among the samples |
|---|---|---|
| 1 | 24% | 24% |
| 3 | 28% | 44% |
| 5 | 35% | 54% |
| 9 | 41% | 64% |
| 17 | 44% | 72% |
| 33 | 43% | 79% |
Read the middle column first. One sampled answer is right only 24% of the time, worse than the greedy answer, because sampling sometimes picks unlikely characters. Voting repairs that, and then stops: at 17 samples it reaches 44%, and at 33 it is no higher. A majority vote recovers the model’s most likely answer. It cannot do better than that answer.
The right column is a different regime. Here a checker accepts an answer if it is correct, the way a unit test accepts working code. With 33 samples, 79% of questions had at least one correct answer to accept. The model’s single best guess was right 46% of the time, yet the right answer was somewhere in its samples far more often.
One word shows the limit of voting. For “bawdy”, the model’s first nine samples were all “BADDY”. When a model is consistently wrong, every vote agrees on the error.
Common take“Ask the model five times and take the majority. It’s more accurate.”
Sharper take“Voting recovers the model’s most likely answer. Here it went from 24% to 44% and stopped at the level of a single greedy answer. A checker is what turns extra samples into extra accuracy: 79% with 33 samples.”
10.5The bill
Thinking tokens are output tokens.
Reasoning is paid for at the output-token price and generated at output speed, whether it is shown, summarized or hidden. The table uses illustrative round numbers, $15 per million output tokens and 80 tokens per second; substitute your provider’s.
| Thinking tokens per request | Added cost per request | Added wait | Added cost per 100,000 requests |
|---|---|---|---|
| 1,000 | $0.01 | 12 seconds | $1,500 |
| 4,000 | $0.06 | 50 seconds | $6,000 |
| 16,000 | $0.24 | 3 minutes | $24,000 |
| 64,000 | $0.96 | 13 minutes | $96,000 |
Three practical points follow.
- Budgets are a setting. Providers expose a control, an effort level or a cap on thinking tokens, that can be set per request.
- The wait comes first. The user sees nothing until the thinking ends, so time to first visible token grows with the budget. Interfaces show progress or a running summary for that reason.
- Sampling multiplies. Five samples cost five times as much. Run in parallel, they do not add latency.
- thinking tokens
- visible answer
Common take“Use the strongest reasoning setting for everything, to be safe.”
Sharper take“Thinking is billed and timed as output. Sixteen thousand thinking tokens at these rates is 24 cents and more than three minutes for one request. I set the budget by task type.”
10.6When it pays
Route by difficulty, and by whether the answer can be checked.
| Task | Reasoning | Why |
|---|---|---|
| Extraction, classification, reformatting | Off | One pass is enough; latency and cost dominate |
| Answering from retrieved documents | Low | The work is finding and quoting, not deducing |
| Multi-step math, logic, data analysis | On | Needs more steps than one pass provides |
| Non-trivial code changes, debugging | On, with tests as the checker | Sequential reasoning, and answers can be verified |
| Planning with many constraints | On | Options have to be compared and revised |
| Open-ended writing | Low | No correct answer to converge on |
Two routing patterns cover most products. A router classifies each request and picks a tier. A cascade tries the fast setting first and escalates only when the answer fails validation or the model signals low confidence. Both rest on measurement: run your evaluation set at each setting and plot accuracy against cost per request (Chapter 23). The right setting is where the curve flattens.
Common take“Reasoning models are the new default.”
Sharper take“They are a tier. Most traffic in most products is simple and belongs on the fast path. I escalate the requests that need steps, and I find out which those are from an evaluation set.”
10.7Prompting
Say what you want and how you will judge it, not how to think.
Advice written for earlier models can work against a reasoning model.
- Drop the thinking instructions. “Think step by step” and scripted procedures are redundant, and a prescribed method can be worse than the one the model would choose.
- Give the goal, the constraints and the criteria for success. The model plans better when it knows what a good answer must satisfy.
- Give all the context at once. Thinking cannot recover information that was left out.
- Specify the output. Say what form the final answer should take; the reasoning is separate from it.
- Turn the dial before rewriting the prompt. If answers to hard questions are shallow, raise the effort setting first.
Chapter 13 covers prompting in general. The difference here is one of emphasis: with a reasoning model, more of the prompt should go to describing the destination and less to the route.
Common take“Add ‘think step by step’ to get better answers.”
Sharper take“For a reasoning model that instruction is already built in. I spend the prompt on the goal, the constraints and what a good answer looks like.”
10.8In the agent loop
Thinking between tool calls.
An agent alternates between the model and its tools: the model asks for a tool call, the result comes back, and the model decides what to do next (Part 5). A reasoning model can think at every turn of that loop: about what a result means, whether the plan still holds, and which call to make next. This is where reasoning has its largest practical effect, since a long task is a chain of decisions and each one benefits from deliberation.
Two engineering consequences follow. The cost of thinking is paid at every step, so a 30-step task with 2,000 thinking tokens per step spends 60,000 thinking tokens. And the reasoning from earlier steps is part of the conversation state: provider APIs expect it to be passed back unchanged on the next call, and agents that drop it lose the thread of their own plan.
Common take“Reasoning happens once, before the answer.”
Sharper take“In an agent it happens at every step, between tool calls. I budget thinking per step, and I make sure earlier reasoning is carried forward in the conversation.”
10.9Evaluating and distilling
Judge the answer, then move the skill into a smaller model.
Evaluate the final answer. The reasoning you are shown may be a summary, and even a full trace is not a reliable account of how the answer was produced. It is useful for debugging and unsafe as evidence. Compare settings at equal cost, and record tokens used alongside accuracy, since a higher score at four times the price is a different product.
Distill what works. When a reasoning model handles a narrow task well, its answers can become training data for a small, fast model: the supervised fine-tuning of section 9.2 with a strong teacher. The small model learns to produce the answer directly, without the long chain. The cost of reasoning is then paid once, when the data is generated, and not on every request. The checker from section 10.4 has a second use here: keep only the teacher’s verified answers.
Common take“I read the model’s reasoning to confirm the answer is right.”
Sharper take“I check the answer itself. The visible reasoning helps me debug, but it can look sound and end in a wrong result, or be a summary of something else.”
Key takeaways
- A reasoning model is an ordinary transformer trained to write out working before its answer. The working is output tokens.
- A network does fixed computation per token. Generating tokens gives it more steps and a place to keep intermediate results.
- Thinking adds steps, not knowledge. A missing fact stays missing.
- Compute at answer time can go to a longer chain, to sampling and voting, or to sampling and checking.
- Voting recovers the model’s most likely answer: 24% for one sample, 44% for a vote of 17, against 46% for the greedy answer.
- A checker turns samples into accuracy: 79% of questions had a correct answer among 33 samples.
- Thinking is billed and timed as output. At $15 per million tokens and 80 tokens per second, 16,000 thinking tokens is 24 cents and over three minutes.
- Route by difficulty and by whether answers can be checked. Most traffic belongs on the fast path.
- Evaluate final answers, not the reasoning text, and distill verified answers into a smaller model when a task is narrow.
Check your understanding
-
A product sends every request to a reasoning model at its highest setting. Median latency is 45 seconds and the monthly bill has tripled. About 70% of requests are simple lookups. Design a routing plan and say how you would validate it.
Answer outline
Send lookups, extraction and formatting to the fast path with reasoning off, and reserve reasoning for multi-step questions. Implement it as a small classifier or as a cascade that answers fast first and escalates when validation fails. Set a thinking budget per task type instead of the maximum. Validate on an evaluation set that mirrors real traffic: accuracy, cost and latency per request at each setting and for the routed system as a whole, plus the rate at which the router sends hard questions to the fast path. Ship when accuracy on hard questions is unchanged and the cost and latency of the easy 70% have fallen.
-
Your model classifies contract clauses with 82% accuracy at temperature 0. A teammate proposes sampling five answers at temperature 1 and taking the majority. Predict the result using this chapter’s experiment, and propose something more likely to help.
Answer outline
Expect little or no gain. In the experiment a vote over many samples climbed back to roughly the greedy answer and stopped, because voting recovers the model’s most likely answer, and that is what temperature 0 already returns. Clauses the model consistently misreads will be outvoted the wrong way. More promising: find out which clauses it gets wrong and why; supply definitions or similar labeled examples through retrieval; add a second pass that checks the label against explicit criteria; use a reasoning setting for the ambiguous cases; or fine-tune on labeled clauses. Measure each on a held-out set.
-
Your code-generation feature has a test suite available at generation time. How would you use compute at answer time, what does the experiment predict, and what are the risks?
Answer outline
Generate several candidates, run the tests on each, and return one that passes; as a cascade, generate one first and sample more only on failure. The experiment predicts a large gain: the chance that at least one candidate is right rises much faster with samples than the accuracy of any single one. Risks: tests that are incomplete will pass wrong code, the same loophole as reward hacking in section 9.6, so keep some tests hidden from the model and review what passes; cost grows with the number of candidates; and running generated code needs a sandbox and time limits.
Further reading
- Sebastian Raschka, Build a Reasoning Model (From Scratch): inference-time scaling, self-consistency and reinforcement learning for reasoning, implemented step by step.
- Wang et al. (2022), “Self-Consistency Improves Chain of Thought Reasoning in Language Models”: the sample-and-vote method.
- The DeepSeek-R1 paper (2025): how a reasoning model was trained with reinforcement learning on checkable problems, and then distilled into smaller models.
- Your provider’s documentation on reasoning or extended thinking: the current names of the budget controls, how thinking is billed, and the rules for carrying reasoning through tool calls.