Reasoning and Search with Deep Nets
Reasoning and Search with Deep Neural Networks
From learning to reasoning
Modern AI systems often combine two broad capabilities:
Learning: building a model from examples.
Reasoning and search: using a model to identify a strong answer or action rather than merely producing a likely one.
This distinction helps explain how systems built around large language models have developed. A model may learn how people tend to write, then use additional procedures to find a response that is more accurate, useful, or otherwise desirable.
Learning models the data distribution
A language model is commonly trained on a large text collection to predict the next token given the tokens that came before it. By learning these predictions across many examples, the model approximates patterns in its training data.
In probabilistic terms, learning estimates a distribution over inputs and outputs:
Here, x represents an input, such as a question, and y represents a possible output, such as an answer. For a chatbot, the model learns patterns in how text continues in response to a context.
This training objective does not, by itself, guarantee that the model will produce the most accurate or best answer to a user’s question. It teaches the model to produce plausible continuations based on the data it has learned from.
Reasoning searches for a good answer
Once a model has been learned, reasoning can be understood as using that model to choose an output for a particular input. Instead of generating a merely plausible response, the system attempts to identify a response that scores highly according to some objective.
If the model assigns probabilities to possible answers, a simple formulation is:
The notation argmax means “the value of y that makes the expression as large as possible.” More generally, a system can use a scoring function s(x,y) that measures how desirable an answer is:
The score need not be a probability. It could measure correctness, formal validity, usefulness, or another property.
Key distinction: Learning estimates what outputs are likely; reasoning or search attempts to select an output that is best according to a chosen criterion.
Terminology varies across fields
Terms such as inference, reasoning, prediction, thinking, cognition, and control do not have one universally agreed meaning. For example, statisticians may use inference to describe estimating a model from data, while machine-learning discussions may call the same process learning. In other contexts, inference can refer to using a learned model to produce a prediction.
The underlying processes matter more than the labels:
Model fitting: moving from data to a model of the data.
Decision or prediction: using a model to choose an output for a particular input.
Search: exploring possible outputs or actions to find one with a high score.
The model-development and deployment pipeline
A modern AI system may involve several stages. The boundaries between them are not always sharp, and organizations may use different names for different training phases.
Pre-training
During pre-training, a model learns broad patterns from a large dataset. For a language model, a common objective is to predict the next token from the preceding context. This creates a general-purpose base model that captures statistical regularities in text.
Pre-training is closely related to generative modeling: the model learns a distribution that can generate samples resembling its training data.
Adaptation and post-training
After pre-training, a model may be adapted to improve its behavior for particular tasks or goals. Examples include:
Fine-tuning, which updates the model using additional task-relevant data.
Transfer learning, which applies capabilities learned in one setting to another.
Other intermediate training stages, sometimes called post-training or mid-training.
These stages can change what the model tends to produce without changing the fact that it is built on a learned model of its data.
Test-time prompting and in-context learning
A model can also be guided at deployment time by providing instructions, examples, or other context in the prompt. This is often called in-context learning. The model’s behavior is influenced by the added context, even though the model’s weights are not necessarily updated.
For example, a user may provide examples of a desired format and ask the model to follow that format. This guidance is supplied at test time rather than incorporated into the model through a new training update.
Search at deployment time
A system can go beyond a single model completion by generating multiple possibilities, evaluating them, and selecting or combining the strongest ones. This kind of search happens at inference or deployment time and is distinct from training the model.
The development pipeline can therefore be viewed as a progression:
Pre-train a base model on broad data.
Adapt or fine-tune the model for particular needs.
Guide it with prompts or context at deployment.
Apply search procedures to compare possible outputs.
Scaling through learning and search
A major idea in AI is that relatively simple methods can produce large gains when they scale with more data or computation. Two important forms of scaling are:
Training-time scaling: learning
A system may improve when it is trained with more data and computational resources. This is training-time compute: computation used to fit or update the model.
Test-time scaling: search
A system may also improve by spending more computation after training, while answering a particular query. It can generate more candidate solutions, explore more possibilities, or evaluate candidates more carefully. This is test-time compute, often associated with search or reasoning.
The two kinds of scaling serve different roles:
Learning improves the model’s general capabilities.
Search uses computation on a particular problem to choose among possibilities.
The idea that progress can come from simple, scalable methods applies to both. Learning became a major driver of deep-learning progress; search is another powerful approach that can be combined with learned models.
Classical search and learned evaluation
Search has long been used in AI, including before deep learning became dominant.
Game-tree search
In a game such as chess, each possible move can lead to a set of possible opponent responses, which lead to further possible moves. These possibilities form a search tree.
A search procedure can:
Enumerate candidate moves.
Explore possible sequences of moves and responses.
Evaluate the resulting positions.
Choose an initial move that appears most likely to lead to a favorable outcome.
A chess system can explore this tree without using a deep neural network. Its strength comes from systematically examining possible future states and selecting a move based on the search.
Combining search with neural networks
A neural network can help evaluate positions at the leaves of a search tree. In this combination:
Search explores possible sequences of actions.
The neural network estimates whether a resulting state is favorable.
This allows a system to combine explicit exploration with learned judgments. Search does not replace learning, and learning does not replace search; each can provide information the other lacks.
Autoregressive language models and sequence probability
An autoregressive language model generates text one token at a time. At each step, it predicts a distribution over the next token based on the preceding context. A token may be a word, part of a word, or another unit of text.
The probability of a complete sequence can be expressed as a product of conditional probabilities. For tokens y1,…,yT given an input x:
Each term represents the probability of the next token given the input and all earlier tokens.
Why greedy decoding can miss the best complete answer
A simple decoding method chooses the most probable next token at every step. This is called greedy decoding. It is computationally straightforward, but it does not necessarily find the most probable complete sequence.
The best first token may lead to a continuation whose overall probability is low. A less likely first token may lead to a much stronger complete answer. Therefore, choosing the best token at each individual step is not generally equivalent to choosing the best whole sequence:
This motivates search procedures that consider more than one continuation.
Search methods for language generation
Best-of-n sampling
In best-of-n sampling, the model generates n candidate answers. A scoring procedure then evaluates the candidates, and the system selects the highest-scoring one.
A basic version uses the model’s own probability as the score:
Generate multiple candidate sequences.
Evaluate the probability or score of each complete sequence.
Return the candidate with the highest score.
For example, if a question about coffee leads to several sampled descriptions, the system can compare their model-assigned probabilities and select the strongest candidate among those generated.
Best-of-n sampling is simple, but it has an important limitation: it can select only from the candidates that were actually sampled. If the best possible answer is not among them, the method cannot return it.
Beam search
Beam search explores candidate sequences in a tree-like structure. Rather than committing immediately to one next token, it keeps several promising partial sequences and expands them.
A simplified process is:
Begin with the input context.
Generate several possible next tokens.
Keep a limited number of promising partial sequences.
Expand each retained sequence with further possible tokens.
Continue to a chosen length or stopping condition.
Select a high-scoring complete sequence.
Beam search is a structured alternative to generating fully independent samples. It concentrates computation on promising branches while retaining more alternatives than greedy decoding.
Explicit search versus model-generated reasoning
Traditional search algorithms are specified directly: their rules determine how states are expanded and evaluated. A different approach is to prompt the model to carry out a search-like procedure in natural language.
For instance, the model can be asked to:
Break a problem into steps.
Consider alternative solutions.
Use a search-tree strategy.
Explain intermediate reasoning before giving an answer.
The model may then produce a sequence of textual steps that resembles a search procedure. This is an emergent or learned form of search: the model has learned patterns of problem-solving from data and expresses them when prompted.
A prompt such as “think step by step” can encourage the model to produce intermediate steps. Those steps may help with multi-stage problems, but the process is not necessarily the same as running a formally specified beam-search algorithm.
Strengths and limitations of emergent search
Prompted reasoning can sometimes produce approaches that are more flexible than a hand-designed procedure. However, it differs from a classical algorithm in important ways:
Its behavior depends on patterns learned from training data.
It may vary across prompts or problems.
It does not automatically have the guarantees of a formally analyzed algorithm.
Its intermediate steps may be incorrect even when they sound convincing.
Classical algorithms can be studied and tested against explicit properties. Model-generated reasoning is more difficult to characterize, so tools for understanding and evaluating model behavior remain important.
Search guided by objectives other than probability
Search does not have to optimize the language model’s own probability. A system can instead search for an output that maximizes another score function.
A score function accepts a candidate and returns a scalar value indicating how well the candidate meets some objective. Examples include:
Whether a candidate contains a particular category, such as a cat rather than a dog.
How entertaining or engaging a description seems.
How well an answer matches a desired style.
Whether a program compiles or produces the correct result.
Whether a mathematical proof passes a proof checker.
The general objective can be written as:
where s(y) is a score assigned to candidate output y.
This approach separates generation from evaluation. The generative model proposes candidates, while a score function or verifier judges them. Search then uses those judgments to choose a better output.
Verifiers for mathematics and programming
A verifier checks whether a proposed solution satisfies specified conditions. In mathematics, a proof checker can determine whether a proof follows formal rules. In programming, a compiler can identify syntax errors, and tests or formal methods can check aspects of a program’s behavior.
For example, a program that generates the Fibonacci sequence can be checked by testing whether each new term equals the sum of the two preceding terms. The system may generate multiple candidate programs, and a verifier can reject candidates that fail checks while retaining a candidate that passes.
Verifiers are especially useful when correctness is easier to check than to achieve. A solution may be difficult to discover, yet straightforward to validate once it has been proposed.
Verification can be easier than generation
For many problems, finding a solution may be computationally difficult while checking a proposed solution is comparatively easy. In computer science, this distinction is associated with problems whose proposed solutions can be verified efficiently.
For example, finding an optimal route through many cities can be difficult because there may be a huge number of possible routes. Given a proposed route, however, it may be much easier to check whether it visits the required cities and to calculate its total length.
When a reliable verifier exists, it can guide generation:
Generate candidate solutions.
Verify each candidate.
Reject candidates that fail.
Select or refine candidates that pass.
This strategy is effective only to the extent that the verifier accurately measures what matters. Passing a narrow test does not always prove that a solution meets every real-world requirement.
Search with diffusion and other generative models
The same general search idea applies beyond autoregressive language models.
Diffusion models
A diffusion model commonly begins with a noisy representation, such as a noisy image, and gradually removes noise through a sequence of denoising steps. A simple generation process follows one sequence of denoising decisions.
Search can instead consider multiple possible paths through the denoising process and evaluate the resulting outputs. The search space is then made up of alternative denoising trajectories rather than alternative token sequences.
The underlying principle is the same:
A generative model proposes possible outputs or intermediate states.
Search explores alternatives.
A scoring procedure selects a promising result.
Similar ideas can apply to other generative models, including models that generate from latent representations.
Continuous search with gradient descent
Search is not limited to discrete choices such as words or game moves. In continuous models, the variables being optimized can take real-valued inputs, making gradient-based optimization possible.
Latent variables and generated images
A generative model can map a continuous latent vector z to an image:
Here, G is the generator and z is its input. A separate model can assign a score to the generated image:
The system can then adjust z to increase the score. If the score is differentiable, gradient descent or gradient ascent can guide the search through the continuous input space.
For example, a system may change the latent variables so that the generator produces an image predicted to be more memorable or more aesthetically pleasing.
Human-preference and perception scores
A scoring model can be trained to approximate a human judgment. For example, people can be shown images and asked which ones they remember more easily. A model trained on such judgments can estimate an image’s memorability.
The generator can then be searched to produce images with higher predicted memorability. The same general procedure can be adapted to optimize for other learned assessments, such as aesthetic preference or emotional tone.
A simplified optimization objective is:
In practice, this depends on the quality of both models:
The generator must produce meaningful images as its inputs change.
The scoring model must reliably reflect the desired human judgment.
The optimization process must not exploit weaknesses in the scorer in ways that produce undesirable results.
Connection to feedback-based optimization
Optimizing a model toward human preferences is related to reinforcement learning from human feedback. In both cases, information about human judgments is used to guide model behavior. The particular application may differ: continuous optimization can alter a generator’s input to produce a preferred image, while language-model training can alter which responses the system tends to produce.
Repeatedly asking for “more” of a quality, such as greater beauty, can also change generated outputs. This illustrates how a model may respond to increasingly strong preference language, though such prompting is not necessarily the same as running a formal optimization algorithm.
Reinforcement learning: using search to improve a model
Reinforcement learning connects search and learning. A system explores possible actions or outputs, evaluates their outcomes with a reward, and then updates its behavior to favor actions that lead to better results.
A simple conceptual loop is:
Try candidate actions or solutions.
Measure their outcomes using a reward or verifier.
Identify successful behavior.
Update the model so that successful behavior becomes more likely.
Search again using the improved model.
This is often summarized as search, learn, search, learn.
Search-generated training data
When a model searches for candidate answers and a verifier identifies correct ones, the successful examples can be reused as training data. The model can then be fine-tuned to produce those successful answers more often.
For a language model, a successful example may include both an answer and the reasoning trace, rationale, or sequence of steps that led to it. Training on these examples can encourage the model to produce similar successful behavior directly.
This process can be understood as:
Use search to find successful outputs.
Treat those outputs as useful synthetic training examples.
Update the model with supervised learning.
Repeat with the improved model.
The data are called synthetic because they are generated through model-based procedures rather than simply collected from ordinary human examples.
How learning can improve later search
The interaction also runs in the opposite direction. After training on successful solutions, a model can guide future search more effectively.
Instead of exploring all possibilities equally, the search procedure can give priority to candidates the improved model considers promising. This creates a feedback loop:
Search discovers useful behavior.
Learning makes that behavior more likely.
The improved model guides more efficient search.
Further search can discover additional useful behavior.
Reinforcement learning and supervised learning
In the search-and-reuse view, the learning stage may look like supervised learning: the model is shown successful examples and trained to reproduce them. This is one way to explain how search results can improve a model.
However, reinforcement learning as a broader field is not limited to this procedure. Some methods update a policy directly using reward signals, rather than converting every successful behavior into a supervised target. The key shared idea is that reward or outcome information changes the system’s future behavior.
Policy learning in games
A game-playing agent can learn a policy, a rule or model that selects an action in a given state. For example, a policy may learn to jump when a game character approaches an obstacle.
A reinforcement-learning system can:
Try action sequences in the game.
Receive rewards for outcomes, such as progress or winning.
Learn a policy that favors actions associated with higher reward.
Use the policy to guide future exploration.
A learned policy can make search more focused: it helps the system spend less effort on actions that are unlikely to succeed.
Combining reasoning traces with reinforcement learning
A language model can generate not just a final answer but also a chain of intermediate steps. When the answer is verified, the corresponding reasoning trace can be retained as a successful example.
A general process is:
Present a problem to the model.
Sample one or more reasoning traces and answers.
Check whether the final answer is correct.
Discard unsuccessful traces or give them less weight.
Use successful traces as training examples.
Repeat with additional problems and improved model behavior.
The model may learn to produce reasoning patterns that are more likely to lead to correct answers. At deployment time, a system may also apply additional search to the model’s outputs, or it may generate a single response using the improved model.
Policy-gradient approaches
A policy-gradient method updates a model’s action probabilities using feedback about the outcomes of actions. In a language-model setting, the “actions” can correspond to generated tokens or sequences of tokens, and the policy is the model’s distribution over possible outputs.
The essential idea is to make successful behavior more likely and unsuccessful behavior less likely based on reward. Policy gradients are a standard family of reinforcement-learning methods; they do not require the system to use an elaborate search procedure at deployment time.
Simplicity and scaling
A notable possibility is that effective systems may use relatively simple learning and reward mechanisms, even when their outputs appear sophisticated. Their performance can arise from repeated application of a simple loop over many problems and examples.
This is consistent with the broader scaling perspective: large gains may come from combining scalable computation, repeated feedback, and effective data rather than relying on a highly elaborate hand-designed procedure.
Key ideas to retain
Learning fits a model to data; reasoning and search use a model to select a strong output for a particular problem.
A language model’s most likely next token is not necessarily the first token of the most likely complete answer.
Best-of-n sampling, beam search, and prompted step-by-step reasoning are different ways to explore or select among candidate outputs.
Search can optimize objectives other than language-model probability, including human preferences and formal correctness.
Verifiers are valuable when solutions are difficult to generate but comparatively easy to check.
Search applies to both discrete generation, such as text, and continuous generation, such as images.
Reinforcement learning links search to training by using successful outcomes to make effective behavior more likely.
Search and learning can improve each other: search finds promising solutions, while learning helps later search focus on promising possibilities.

Ask anything
We've read this whole study set, so questions about it get the best answers.