Reasoning Models and Test-Time Compute
Reasoning models are large language models augmented with deliberate, extended inference-time computation—commonly manifested as explicit "chain-of-thought" traces, search trees, or iterative self-refinement loops—that allow the model to trade additional compute at test time for substantially higher answer quality. This paradigm matters because it decouples the cost of thinking from the cost of training, enabling smaller models to match or exceed larger ones on hard reasoning tasks by spending more tokens. The counterintuitive fact: a 7B-parameter model given a generous test-time compute budget can outperform a 70B model given none, meaning raw parameter count is no longer the sole axis of capability.
The central insight is that intelligence can be amortized differently: instead of baking all reasoning into weights through expensive pretraining, you can allow a model to "think out loud" at inference time—generating intermediate steps, checking its own work, and backtracking when wrong—converting wall-clock time (or token budget) directly into accuracy. The "aha moment" is recognizing that language model generation is itself a sequential decision process, and that any technique from planning and search (beam search, MCTS, best-of-N sampling) can be applied to token sequences, not just game states. This transforms inference from a one-shot read of compressed knowledge into an active, iterative problem-solving process.
How It Works
The Probability Framework
A standard autoregressive LM defines a distribution over completions. At training time we maximize log-likelihood; at test time we typically take the greedy or nucleus-sampled continuation. Reasoning models intervene in this generation process to search for higher-probability correct completions rather than just high-probability completions.
Best-of-N Sampling (the simplest baseline) Given a model , draw independent completions and score them with a reward model :
Explanation: We sample N candidate answers independently and return whichever the reward model rates highest—a pure exploitation of test-time compute that requires no change to the base model. Here is the prompt, is the -th sampled response, is a separately trained outcome reward model (ORM), and is the selected answer. The accuracy of Best-of-N scales roughly as where is single-sample accuracy, giving logarithmic returns.
Compute-Optimal Allocation Let be training FLOPs and be test-time FLOPs for samples each of length tokens. For a fixed total budget , the optimal split solves:
Explanation: This framing shows that training and test-time compute are substitutable resources, and the optimal balance depends on the task difficulty distribution—harder tasks favor more test-time compute per query.
Process Reward Models (PRMs) A PRM assigns a scalar to every reasoning step in a chain :
Explanation: By taking the product of per-step correctness probabilities, the PRM scores the entire reasoning chain and identifies the earliest incorrect step, enabling targeted search rather than discarding full rollouts.
Monte Carlo Tree Search over Token Sequences MCTS adapts naturally: the state is the current partial reasoning trace, actions are token-level or sentence-level extensions, and the value function is the PRM score. The UCB selection criterion at node with parent is:
Explanation: The first term exploits high-value reasoning paths found so far, while the second term explores rarely-visited branches—balancing breadth and depth of the reasoning tree. Here is the empirical mean PRM score of completions through node , and are visit counts for parent and child respectively, and is an exploration constant typically tuned in .
Outcome-Conditioned Reinforcement Learning (the DeepSeek-R1 / o1-style approach) Reasoning models trained with RL maximize expected verified reward:
Explanation: Group Relative Policy Optimization (GRPO) samples G rollouts per question, computes advantages relative to group mean reward, clips probability ratios to prevent large policy updates, and penalizes KL divergence from a reference policy to maintain coherence—this is how DeepSeek-R1 trains its extended thinking traces. Here is the importance weight, is the normalized group advantage, is the clipping threshold, controls KL penalty strength, and is the frozen reference model (typically the SFT checkpoint). ```python import torch import torch.nn.functional as F def grpo_loss( log_probs_new: torch.Tensor, # (G,) per-rollout log probs under new policy log_probs_old: torch.Tensor, # (G,) per-rollout log probs under old policy rewards: torch.Tensor, # (G,) scalar rewards (0 or 1 for math) log_probs_ref: torch.Tensor, # (G,) log probs under reference policy eps: float = 0.2, beta: float = 0.01, ) -> torch.Tensor:
# Normalize rewards to get advantages advantages = (rewards - rewards.mean()) / (rewards.std() + 1e-8)
# Importance ratios ratio = torch.exp(log_probs_new - log_probs_old)
# PPO-clip objective clipped = torch.clamp(ratio, 1 - eps, 1 + eps) policy_loss = -torch.mean(torch.min(ratio advantages, clipped advantages))
# KL penalty: KL(new || ref) ≈ log(new/ref) kl_penalty = torch.mean(log_probs_new - log_probs_ref) return policy_loss + beta * kl_penalty ```
Shazeer was a Google Brain researcher whose 2017 paper Attention Is All You Need (as a co-author) established the transformer architecture that underlies all modern reasoning models. His work on sparsely-gated mixture-of-experts demonstrated that conditional computation—activating different model subsets per input—is an early form of adaptive test-time routing, directly ancestral to reasoning model ideas. He later co-founded Character.AI after leaving Google, and his 2017 multi-query attention paper (reducing KV cache size) is a key enabler of long-context reasoning traces that would otherwise be memory-prohibitive.
Sutton is a professor at the University of Alberta and a Turing Award-adjacent figure who essentially wrote the textbook on reinforcement learning (Reinforcement Learning: An Introduction, with Barto). His 2019 essay "The Bitter Lesson" argued prophetically that methods leveraging search and learning—rather than human knowledge—always win in the long run, precisely describing the test-time compute paradigm a half-decade before it became mainstream. He developed temporal difference learning and policy gradient methods that form the mathematical substrate of GRPO and PPO used to train models like o1.
Intuition
Imagine you're sitting an extremely hard mathematics exam under two different regimes. In the first regime, you're a savant who has memorized every theorem and simply writes the answer immediately—no scratch work, no checking. In the second, you're a careful analyst who has scratch paper and works through the problem step by step, pauses to verify each algebra manipulation, and crosses out wrong approaches before they compound into a wrong answer. The savant (large model, no test-time compute) is faster but brittle: one flawed memory and the answer is wrong with no recovery. The careful analyst (smaller model with test-time budget) is slower but robust—each intermediate step is checkable. Now imagine the analyst can clone themselves times, each pursuing a different approach in parallel, with a trusted judge evaluating which approach is most promising at each branch. That's MCTS over reasoning traces. The key insight is that knowing you're wrong partway through is the superpower—it requires a process reward model, which is what makes test-time compute genuinely powerful rather than just expensive. Think of Best-of-N as "brainstorming then picking the best draft," beam search as "writing with a planner who scores each sentence before you commit," and RL-trained reasoning models (o1, R1) as "having done so much deliberate practice that your internal draft-and-check loop is now compressed into how you write the first draft."