Amortized Inference

A slow solver can answer any one question well, but it starts from zero every time. Amortized inference pays once, in training, for a model that answers in a single pass. You save on every later question, but you lose accuracy on inputs unlike the ones it learned.

Learn when to solve each input from scratch and when to learn the solver. Then learn how to distil an expensive solver, even an agent, into a fast student you can trust.

Slide how many inputs you must answer, and watch the cost flip. Then push the hidden value outside the training range, and watch the one-pass answer drift while the solver still finds it.

You need a rough idea of what a function, an average and a neural network are. We build the rest from zero.

Solve every time, or learn the solver?

Ready
316
0.80

A toy built in this page. The solver is gradient descent run separately on each input. The one-pass model is a linear map trained on 2,000 solved examples with fade rates from 0.3 to 1.2 (the shaded band). The work units (60 solver steps per input, 20,000 steps of training) are illustrative.

Chapter 0

The line that will not wait

Run a factory line where every item needs a careful calculation, and see why solving each item from scratch stops working

A factory makes small batteries. Each battery gets a quick test. A probe charges it, lets go, and records how the voltage fades over a few seconds. Eight readings, one every half second.

From those eight readings you want one hidden number: how fast the voltage fades. Call it the fade rate, k. A healthy battery fades slowly. A faulty one fades fast. Nobody can see k directly. You can only see the noisy readings it causes.

Recovering a hidden cause from the effects you can see is called inference. Here the cause is k, and the effects are the eight readings. The careful way to infer k is to try a value, draw the curve it predicts, measure how far the readings sit from that curve, adjust k, and repeat. A computer does this in a few dozen small steps.

That is fine for one battery. But the line makes many batteries every second, and every one needs its own k.

The test station

Batteries arrive from the left. Each one waits for the solver, which needs a fixed time per battery. Raise the line speed and watch the queue.

4
2

Illustrative timings. A solve of 60 small steps is set to 0.3 s and one pass of a small trained model to 0.002 s. Real ratios depend on the problem, but a gap of a hundred times or more is common.

The slow way has a deeper waste than speed. Each solve starts from zero. Battery number ten thousand looks a lot like battery number nine thousand, nine hundred and ninety-nine. The solver learns nothing from the first to help with the second.

So here is the idea of this lesson. Solve a few thousand batteries the slow way, once. Keep each pair of readings and answer. Then train a model that maps readings straight to k in one pass. That model is an amortized solver. You pay a large cost once, and spread it over every battery that follows.

The same trade shows up all over machine learning. A variational autoencoder trains an encoder instead of optimising each image. A distilled network copies a big one. A game-playing network learns to predict what a long tree search would choose. And, in 2026, people argue for distilling slow agents into fast models:

"Distill these slow, expensive agentic systems into fast, amortized models. That is a data research problem."Guangzhao He, "A New Era for Agentic Vision and Robotics Research", 2026 · §1

That line is the reason this lesson exists. It is the background for Chapter 4 of the A New Era for Agentic Vision and Robotics lesson. Here we build the whole idea from zero.

  1. Per-instance inference: solve one input by searching for the best answer, step by step.
  2. Amortized inference: train one function that maps any input to its answer.
  3. The loan: the cost model, the break-even point, and what the hero's left slider means.
  4. The amortization gap: why one-pass answers drift on unusual inputs, and the hero's right slider.
  5. Two gaps, not one: the approximation gap and the amortization gap, with real numbers.
  6. One pattern, many costumes: where the idea came from, from human reasoning to VAEs.
  7. Closing the gap: refine the one-pass guess, or learn the optimiser itself.
  8. Distillation: teachers, students, soft targets, noisy labels and verifiers.
  9. Amortizing search: expert iteration, AlphaZero, and the Segment Anything data engine.
  10. The recipe: generate, verify, filter, train, measure the gap, and route hard cases back.
  11. Connections: a cheat sheet, the honest limits, and where to go next.
What makes solving each battery from scratch wasteful, apart from its speed?

Chapter 1

Per-instance inference

Write down what a good answer is for one input, then walk downhill to it and count the steps

Start with one battery. Its eight readings are y1 to y8, taken at times t = 0, 0.5, 1, … 3.5 seconds. Physics says the voltage fades like an exponential curve. So we have a model: a rule that says what readings each hidden value would produce.

ŷ(t)
The reading the model predicts at time t.
A
The starting voltage. It varies a little from battery to battery.
k
The fade rate: the hidden number we want.

Worked example: with A = 1 and k = 0.8, the prediction at t = 1 s is e−0.8 ≈ 0.45. At t = 2 s it is e−1.6 ≈ 0.20. Real readings add noise of about ±0.05 on top.

What "best answer" means

For one battery, a good guess (A, k) is one whose curve passes close to the readings. We measure "close" with the loss: the average squared distance between each reading and the curve.

L(A, k)
How badly the curve for this guess fits these readings. Lower is better.
⅛ Σi
Average over the eight readings.
yi
The i-th noisy reading, taken at time ti.

Worked example: suppose the readings at t = 1 and t = 2 are 0.47 and 0.18. The guess A = 1, k = 0.8 predicts 0.45 and 0.20. The two squared misses are 0.022 and 0.022, each 0.0004. Small misses mean a good guess.

Finding the (A, k) with the lowest loss is per-instance inference: inference done separately for each input, by optimisation. The standard tool is gradient descent. Stand at a guess, find which direction makes the loss fall fastest, take a small step that way, and repeat.

Walk downhill for one battery

The map shows the loss for every guess of k (across) and A (up). Heavy shading means a bad fit; the plain valley is where the fit is good. The solver starts at the average battery and steps downhill. Try a new battery, or change the step size.

1.0
60

Computed in this page. The solver is plain gradient descent on A and on the logarithm of k, starting from A = 1, k = 0.75. The ring is the exact best fit, found by a fine search over k.

Here is the whole solver in Python. It is short. Notice that it takes the readings y and returns an answer, and nothing carries over between calls.

import numpy as np
t = np.arange(8) * 0.5                       # 8 reading times, shape (8,)

def solve(y, steps=60, lr=1.0, A=1.0, k=0.75):
    u = np.log(k)                            # optimise log k so k stays positive
    for _ in range(steps):
        k = np.exp(u)
        m = np.exp(-k * t)                     # the curve's shape, (8,)
        e = A * m - y                          # misses, (8,)
        gA = np.mean(2 * e * m)                 # slope of the loss in A
        gu = np.mean(2 * e * A * -t * m * k)     # slope in log k
        A, u = A - lr * gA, u - lr * gu
    return A, np.exp(u)                     # the answer for THIS battery only

Per-instance inference has real strengths. It finds the best answer for exactly this input. It adapts if the input is odd: a strange battery just gets a different path. And it needs no training data at all, only the model of the physics.

Its weakness is cost. Every input pays for every step. Some batteries need ten steps, some need over a hundred. And the solver throws the work away when the answer comes out.

The solver needs 60 steps per battery, and the line tests 10,000 batteries. How much of the work on battery one helps with battery two?

Chapter 2

Amortized inference

Turn thousands of solved examples into one function that jumps from readings to answer, and watch it improve with data

The solver is a function. Readings go in, an answer comes out. We cannot write that function down as a formula; we can only run it. But we can run it many times and collect pairs: (readings, answer).

Now the trick. Train a second, fast function to copy the first. Feed it readings, compare its output with the solver's answer, and adjust it until they agree. This fast function is called an inference network, a recognition model or an encoder. All three names mean the same thing: a learned map from an input straight to its inferred hidden value.

fφ(x)
The fast model with adjustable weights φ. It maps the readings x to a guess in one pass.
θ*(x)
The per-instance answer for input x: what the slow solver returns.
Ex ~ D
The average over inputs drawn from D, the distribution of inputs you expect to see.
φ*
The weights that make the fast model agree with the solver best, on average.

Look at what changed. Per-instance inference minimises a loss for one x. Amortized inference minimises a loss averaged over all x. The optimisation still happens, but once, during training. After that, each new battery costs one pass.

Worked example. Our encoder is a plain linear map. Its input is 17 numbers: a constant 1, the 8 readings, and their 8 squares. Its output is 2 numbers, A and k. So it has 17 × 2 = 34 weights. One answer costs 34 multiplications. One solver step costs about 8 exponentials and 30 multiplications, and the solver takes 60 of them.

Train the one-pass model

Each dot is a fresh battery. Across: the solver's k. Up: the one-pass model's k. Dots on the diagonal mean perfect agreement. Change how many solved examples the model trains on (the buttons).

Trained in this page by ridge regression (least squares with a tiny penalty). Training batteries have A from 0.6 to 1.4, k from 0.3 to 1.2 and reading noise 0.05. The 150 test batteries come from the same ranges.

# 1. Pay once: solve many inputs the slow way (the "labels").
X = [simulate_readings() for _ in range(2000)]         # 2000 inputs, each (8,)
Y = [solve(y) for y in X]                                # 2000 answers, each (A, k)

# 2. Learn the map from input to answer.
F = np.array([np.concatenate([[1], y, y**2]) for y in X])   # features, (2000, 17)
W = np.linalg.solve(F.T @ F + 1e-3 * np.eye(17), F.T @ np.array(Y))  # weights, (17, 2)

# 3. Answer forever after in one pass.
def encode(y):
    return np.concatenate([[1], y, y**2]) @ W                 # (17,) @ (17, 2) -> (A, k)

Why a linear map on readings and their squares? Because it is the smallest model that works here, and it trains in a single matrix solve. A real system would use a neural network. The idea is identical: the network's weights store what thousands of solves taught it.

What exactly is averaged over many inputs in amortized inference?

Chapter 3

The loan: cost and break-even

Price the two strategies, find the number of inputs where learning the solver pays off, and see what fallbacks do to the bill

The word "amortize" comes from paying off a loan. You borrow a large sum now, then pay it back in many small parts. Each payment is small because the big cost is shared across all of them.

Amortized inference borrows in the same way. The big cost comes first: solve M examples the slow way and train the model. Then every answer is a small payment. The more answers you give, the less each one carries of the first cost.

Let us price both strategies for N inputs.

cp
The cost of one per-instance solve: all its steps.
M
How many examples you solve the slow way to make training labels.
T
The one-time cost of training the fast model.
cs
The cost of one pass of the fast model.
f
The share of inputs you still send to the slow solver, because the fast model was not sure (Chapter 10).
Costsolve
The total if you solve every input from scratch.
Costamortized
The total if you pay up front, answer fast, and fall back on a share f.

Set the two totals equal and solve for N. The answer is the break-even point, N*:

cp = 60 steps, cs = 1, M = 2,000, T = 20,000, f = 0 → N* = (120,000 + 20,000) / 59 ≈ 2,373 inputs

Read the denominator closely. It is what each answer saves. If the fallback share f grows, the saving shrinks. At f = 0.1, N* = 140,000 / 53 ≈ 2,642. If (1 − f) · cp ever drops to cs, the loan is never paid back.

Pay off the loan

The purple line is the cost per answer if you solve every input. The warm curve is the cost per answer if you amortize: the first cost shared across N answers, plus the small cost of each. Where they cross, the loan is paid.

60
2,000
0%
20,000

Costs are in "solver steps", an illustrative unit. One pass of the fast model costs 1. Swap in dollars or GPU seconds and the shape stays the same.

Three lessons fall out of the chart. First, amortizing never pays for a handful of inputs: the first cost dominates. Second, past N*, the cost per answer falls toward cs + f · cp, its floor. Third, a slow solver that is very expensive (an agent that runs for minutes) makes amortizing pay off early, because each answer saves so much.

Cost is not the only reason. Latency, the time to one answer, can matter more. A robot that must react in 50 milliseconds cannot wait for a 60-step solve at any price. There, amortizing is not a saving but the only way in.

With cp = 60, cs = 1, M = 2,000 and T = 20,000, what happens to the break-even point if 10% of inputs fall back to the solver?

Chapter 4

The amortization gap

Measure how far the one-pass answer sits from the best answer, and watch the distance grow off the training distribution

The solver finds the best answer for this input. The encoder gives the answer it learned for inputs like this one. The difference is the amortization gap.

Lx( fφ(x) )
The per-instance loss of input x, scored at the encoder's one-pass answer.
Lx( θ*(x) )
The same loss at the solver's best answer. Nothing can score lower.
gap(x)
The price of answering in one pass, for this input. It can never be negative, because θ*(x) is the best by definition.

Worked example from the device below: a battery with k = 0.8. The solver's best fit has loss 0.0009. The encoder's answer has loss 0.0010. The gap is 0.0001, tiny. Now a battery with k = 2.5, far outside the training range of 0.3 to 1.2. The solver's best fit lands at k = 2.83 (noise pulls it a little), with loss 0.0008. The encoder answers k = 1.74, with loss 0.0058. The gap, 0.0051, is seven times the solver's whole loss.

Where the one-pass answer drifts

Top: the readings for one battery, the solver's curve and the encoder's curve. Bottom: the error in k for both, across every fade rate. The green band is where the encoder was trained. Drag k out of the band. Then break a sensor.

0.80

Computed in this page. Errors are averaged over 24 noisy batteries per fade rate. With the broken sensor, the solver is told to ignore reading 2; the encoder cannot be told anything, because its input format is fixed.

Why the gap grows off-distribution

Training chose the encoder's weights to minimise the average loss over the training inputs. Nothing in training asked it to be right anywhere else. Inside the band, it interpolates between thousands of examples. Outside, it must extrapolate: guess a pattern it never saw. A linear map extrapolates in straight lines. A neural network extrapolates in ways that are hard to predict.

The solver has no such problem. It never learned a distribution. It just minimises the loss for the input in front of it, so a battery with k = 2.5 gets a path that ends near 2.5.

The broken sensor is a second kind of shift. A reading of zero is a value the encoder never met in that slot. The solver can be told to skip that reading. The encoder's input format is frozen, so it pays a large gap, even for a normal fade rate.

On the k = 2.5 battery, why does the solver land near 2.8 while the encoder answers about 1.7?

Chapter 5

Two gaps, not one

Split the total error of a variational autoencoder into the part the answer's shape causes and the part amortization causes, using measured numbers

So far the answer was a single number, k. In many models the answer is a whole distribution: a spread of plausible hidden values with their probabilities. That is what a variational autoencoder (a VAE) infers.

Here is the setting in plain words. A VAE has a decoder that turns a hidden code z into an image x. For a given image, many codes could have produced it. The true spread of those codes is the posterior, p(z | x). It is too complex to compute exactly. So we approximate it with a simple shape, q(z | x), such as a bell curve in each dimension. The encoder outputs the parameters of that bell curve, in one pass, for any image. That is amortized inference, and Kingma and Welling's 2014 paper introduced it for this purpose.

How good is q? We score it with the ELBO (evidence lower bound), written L[q]. It is never above log p(x), the log probability the model gives the image. The distance between them is the total inference gap.

Splitting the gap

Cremer, Li and Duvenaud (ICML 2018) asked where that gap comes from. They named two sources Cremer et al. · §3.1. Let q* be the best possible bell curve for this one image, found by optimising it on this image alone. Then:

G
The inference gap: how far the encoder's answer falls short of the truth, in nats (natural log units).
log p(x) − L[q*]
The approximation gap: even the best bell curve cannot match the true posterior's shape.
L[q*] − L[q]
The amortization gap: the encoder does not output the best bell curve for this image.

Worked example from their Table 2, MNIST digits with a factorised Gaussian q: log p(x) ≈ −89.80, L[q*] = −91.23, L[q] = −92.57. Approximation gap: 1.43 nats. Amortization gap: 1.34 nats. Total: 2.77 nats. Nearly half each.

Where the lost nats go

Each bar is the total inference gap for a trained VAE, split into its two parts. Pick a dataset and the shape of q. A flow is a more flexible shape than a factorised bell curve.

Numbers from Cremer, Li and Duvenaud (2018), Table 2: training-set bounds in nats, on 1,000 data points for MNIST and Fashion-MNIST and 100 for 3-bit CIFAR. "Flexible flow" is their qAF (auxiliary flow).

The pattern is the paper's main finding. On MNIST the two gaps are about equal. On the harder Fashion-MNIST, amortization is larger (4.22 against 3.06 nats). On 3-bit CIFAR it dominates: 37.47 nats against 14.75. The authors conclude that the encoder, not the shape of q, is "often" the main cause of the error Cremer et al. · abstract, §5.2.

Two more findings matter for practice. First, the decoder learns to make its posteriors easier for the chosen q to fit; the paper calls this the generator "accommodating" the approximation. Second, a bigger encoder can shrink the gap on training data but overfit, so the gap reopens on held-out images Cremer et al. · §5.4–5.5. That is Chapter 4's lesson again: the encoder is trained on a distribution, and away from it, it slips.

On 3-bit CIFAR with a factorised Gaussian, which gap is larger, and what does that suggest?

Chapter 6

One pattern, many costumes

Trace the idea from human reasoning to probabilistic programs and VAEs, then line up six systems and see the same pipeline in each

Where the name came from

In 2014, Samuel Gershman and Noah Goodman asked how people reason so fast with so little time Gershman & Goodman 2014. Exact probabilistic reasoning is expensive. But people meet the same kinds of question again and again. So, they argued, a mind can reuse past computation across related queries, instead of starting fresh each time. They called this reuse amortized inference, in a paper at the 36th annual conference of the Cognitive Science Society.

A year earlier, Stuhlmüller, Taylor and Goodman had built the machine version for probabilistic programs. They learned "stochastic inverses": models that run a program backwards, from outputs to likely inputs, trained on samples from the program itself (NeurIPS 2013).

Then, in 2014, two groups made it the core of deep generative modelling. Kingma and Welling's "Auto-Encoding Variational Bayes" (ICLR 2014) and Rezende, Mohamed and Wierstra (ICML 2014) trained an encoder network to output q(z | x) for every x at once. That is the VAE of Chapter 5. Before it, variational inference often fitted q separately for each data point, which does not scale to millions of images.

Since then the pattern has spread far beyond posteriors. Pick a system below. In each, look for three parts: a slow solver, the pairs it leaves behind, and the fast model trained on them.

Six costumes, one pipeline

Each system turns a slow per-input process into a fast learned map. Pick one to see what flows through it, with shapes.

Shapes are typical examples, not the only ones. Sources: Kingma and Welling 2014; Marino, Yue and Mandt 2018; Hinton, Vinyals and Dean 2015; Anthony, Tian and Barber 2017; Kirillov et al. 2023; Guangzhao He 2026. Each is covered in a chapter below.

Notice what differs between the costumes. In a VAE, no labels exist: the encoder trains on the objective directly. In distillation, the "solver" is a big network, and its output is the label. In search-to-policy, the solver is a tree search. In the SAM data engine and agent distillation, the solver includes people or an agent with tools, and the labels need checking.

According to Gershman and Goodman, why should a reasoner amortize?

Chapter 7

Closing the gap

Use the one-pass answer as a head start for a few solver steps, and see how much it saves on typical and unusual inputs

Amortized and per-instance inference are not rivals. They combine well. The simplest combination: let the encoder guess, then let the solver take a few steps from that guess. This is called semi-amortized inference, or a warm start.

Why does it work? The solver's cost depends on how far it starts from the answer. The encoder's guess is usually close. So the solver needs only a few steps to finish the job, and those steps close the amortization gap for this input. Kim and colleagues (ICML 2018) trained VAEs this way and called the result a semi-amortized VAE.

Start warm, or start cold

The purple curve starts the solver from the average battery. The warm curve starts it from the encoder's guess. Both curves show the error in k after each step. Slide the step budget and switch to an unusual battery.

5

Computed in this page with the Chapter 1 solver (step size 1) and the Chapter 2 encoder. "Done" means within 0.02 of the exact best fit.

On a typical battery, the encoder's guess is already within 0.02 of the best fit: zero refinement steps needed, against about 30 from cold. On the unusual battery, the guess is far off (1.65 for a best fit of 2.66), so the head start saves only 21 of 124 steps. Warm starts help most exactly where the gap is already small. So they pair well with Chapter 10's idea: detect the unusual inputs, and give only those the full solve.

Learning the optimiser itself

A deeper move is to amortize the steps, not the answer. Marino, Yue and Mandt's "Iterative Amortized Inference" (ICML 2018) trains such a network. It reads the current guess and the gradient of the loss, and outputs a better guess Marino et al. · eq. 6:

λt
The current answer, for example the mean and spread of q(z | x).
∇λ Lt
The gradient: which way the loss falls from here, for this input.
fφ
A learned update rule. Plain gradient descent is the special case λ − η · gradient.
λt+1
The improved answer after one learned step.

Worked example: plain gradient descent with η = 1 moves k by exactly one gradient. A learned rule can instead take a long step when the gradient points steadily one way, and a short one near the bottom. In our toy, that could cut the 30 cold steps to a handful. The paper reports that such iterative inference models beat standard encoders on several benchmarks, and frames them as "learning to learn" applied to inference.

Why does a learned update generalise better than a learned answer? Because it reads the gradient, which carries this input's own evidence. A pure encoder sees only the input and must remember the answer. An iterative model checks its answer against the loss at every step.

Why does a warm start save fewer steps on the unusual battery?

Chapter 8

Distillation: teacher and student

Copy a large model into a small one with soft targets, then see what a noisy teacher and a verifier do to the student

So far the slow solver was an optimiser. Now let it be a big, slow neural network, or a group of them, called the teacher. We want a small, fast student that answers like the teacher. Training the student on the teacher's outputs is knowledge distillation. Hinton, Vinyals and Dean named and popularised it in 2015 Hinton et al. 2015.

Soft targets carry more

Their key move: train the student on the teacher's full probability list, not just its top answer. A teacher looking at a handwritten 2 might say "2" with 0.9, "3" with 0.09, "7" with 0.01. Those small numbers say which digits look alike. A hard label "2" throws that away. The probability list is a soft target.

To make the small numbers visible, they soften the teacher's softmax with a temperature T:

zi
The teacher's raw score (logit) for class i.
T
The temperature. T = 1 is the normal softmax. Higher T flattens the list so small probabilities grow.
qi
The softened probability of class i: the soft target.

Worked example: scores z = (5, 2, 0). At T = 1 the probabilities are about (0.95, 0.05, 0.01). At T = 5 the scores become (1, 0.4, 0) and the probabilities about (0.52, 0.29, 0.19). The ranking stays; the hidden similarities become easy to learn from.

The paper's numbers

ExperimentResultWhere
MNIST: big net (2 × 1,200 units, heavily regularised) vs small net (2 × 800 units)Big net 67 test errors. Small net alone 146. Small net trained to match the big net's soft targets at T = 20: 74.§3
Speech recognition: one model vs an ensemble of 10, distilled back into oneFrame accuracy 58.9% baseline, 61.1% ensemble, 60.8% distilled single model. Word error rate 10.9%, 10.7%, 10.7%.§4, Table 1
Speech model trained on only 3% of the dataHard targets: test accuracy 44.5%, with early stopping. Soft targets: 57.0%, against 58.9% with all the data.§6, Table 5

The last row is the deep point. Soft targets carry so much information per example that a student learns from 3% of the data almost as well as from all of it. The teacher's knowledge is denser than its labels.

When the teacher is wrong

Distilling an optimiser or a trained network is safe: the teacher is consistent. Distilling an agent, a search or a crowd of annotators is not. Some of their answers are simply wrong. And their errors are rarely random. They cluster on the hard cases near a decision boundary, and they often lean one way.

A noisy teacher, a verifier, a student

The truth is a circle: inside is "pass" (green), outside is "fail" (grey). The teacher labels points; its mistakes lean toward calling borderline passes "fail". The verifier flags labels it doubts and sends them back to the slow solver. The student learns a curved boundary from the result.

15%
0%

A toy trained in this page. The student is logistic regression on (x, y, x², y², xy), so it can draw a circle. The verifier flags the stated share of wrong labels and 5% of right ones; flagged points go back to the slow solver, which labels them correctly. Soft targets give the student the teacher's confidence instead of a 0 or 1.

Three things to try. With 15% wrong labels, all leaning one way, the student's circle shrinks and it scores about 83%: it learns the teacher's bias. Raise the verifier to 70%: the flagged labels are re-solved and the student climbs to about 96%. Then drop to 40 points and switch on soft targets: with little data, the teacher's confidence teaches more than its yes-or-no (about 79% hard, 92% soft).

Why send flagged labels back instead of just deleting them? Here the errors sit on one side of the boundary. Deleting them leaves a hole full of "fail" labels and almost no "pass" labels near the edge, so the circle still shrinks. Re-solving the flagged cases costs more, but fills the hole with correct labels.

In Hinton et al.'s speech experiment, what did a student trained on soft targets from only 3% of the data reach?

Chapter 9

Amortizing search, people and agents

See how expert iteration turns tree search into instinct, and step through the data engine that built a billion masks

Thinking fast and slow

A game-playing program can look ahead with tree search: try moves, try replies, and pick the move whose future looks best. It is strong but slow. A neural network can instead glance at the board and output a move at once. It is fast but, alone, weaker.

Anthony, Tian and Barber's Expert Iteration (ExIt, NeurIPS 2017) joins them Anthony et al. · §3. The tree search is the expert. The network is the apprentice. They borrow the language of "System 2" (slow, deliberate) and "System 1" (fast, intuitive) thinking. The loop has two steps:

  1. Imitation. Run the expert on many positions. Train the apprentice to predict the expert's choices. This is amortization: the apprentice learns in one glance what the search found by looking ahead.
  2. Expert improvement. Use the apprentice to guide the search, so the search looks first at moves the apprentice likes. A better-guided search is a stronger expert. Go back to step 1.

In the paper, ExIt trained a Hex player from scratch, with no human games. Its final tree search player beat MoHex 1.0, the most recent Olympiad champion program that had been released publicly Anthony et al. · abstract. DeepMind's AlphaGo Zero (Silver et al., Nature 2017) used the same loop. Training pushes its network's move probabilities toward the visit counts of its own Monte Carlo tree search. That network then guides the next search.

def expert_iteration(apprentice, rounds):
    for r in range(rounds):
        states = self_play(apprentice)                     # positions the apprentice reaches
        targets = [tree_search(s, guide=apprentice)         # slow: the expert, per state
                   for s in states]                        # each target: move probabilities
        apprentice = train(apprentice, states, targets)    # amortize: fast map state -> move
    return apprentice

The Segment Anything data engine

Sometimes the slow solver includes people. Segment Anything (SAM; Kirillov et al., ICCV 2023) needed masks for every object in millions of images. No such dataset existed. So the team built a data engine: a loop where the model helps make labels, and the labels retrain the model Kirillov et al. · §4.

Run the data engine

Press Next stage. Each stage hands more of the work from people to the model. Bars are on a log scale, because the last stage is a hundred times larger than the first two together.

All numbers from Kirillov et al. (2023), §4 and §5: 4.3M masks on 120k images (assisted-manual), 5.9M more on 180k images (semi-automatic), 1.1B masks on 11M images (fully automatic), 99.1% of the final masks made automatically, 6 retrains and 34 to 14 seconds per mask in stage 1.

Look at the last stage. The model, prompted with a 32 × 32 grid of points, proposed masks on its own. A built-in quality predictor kept only the masks it was confident in, and a stability check kept only masks that did not change much when the threshold moved. That is a verifier doing the job people did in stage 1. When the authors had professionals check 500 images, 94% of automatic masks matched the corrected version at over 90% overlap (IoU) Kirillov et al. · §5.

Agents as the slow solver

The 2026 argument puts an agent in the solver's seat. An agent that searches the web, runs tools and checks its work is a very expensive per-instance solver: many model calls per task, minutes per answer. Guangzhao He's post proposes to treat it as a one-time teacher, and to distil what it finds into fast models. See the hub lesson for the full argument. The recipe in the next chapter is how to do it carefully.

In Expert Iteration, what does the apprentice learn, and how does it help the expert?

Chapter 10

The recipe: distil, then route

Follow six steps from an expensive solver to a fast student you can deploy, then set the confidence threshold that sends hard cases back

Everything so far adds up to one practical recipe. Use it to distil any slow solver: an optimiser, a search, an ensemble, a crowd, or an agent.

  1. Generate. Run the slow solver on inputs drawn like the ones you will meet in use. Cover the corners on purpose: the gap lives where training data is thin (Chapter 4).
  2. Verify. Check each answer with something cheaper than solving: re-render and compare, replay the trajectory, test the code, ask a second solver. Checking is usually far cheaper than solving.
  3. Filter. Drop answers that fail, or re-solve them carefully if dropping would leave a hole (Chapter 8). Keep the solver's confidence as a soft target if it has one.
  4. Train. Fit the fast student on the kept pairs.
  5. Evaluate the gap. Compare student and solver on held-out inputs, and on shifted inputs. Report the gap by slice, not just the average.
  6. Route. In use, let the student answer when it is confident. Send the rest to the slow solver. Log those cases: they are next round's training data.

Step 6 is called a cascade: a cheap model first, an expensive one only when needed. Viola and Jones made cascades famous for fast face detection in 2001. The same idea is selective prediction: a model that may abstain on inputs where it is unsure. For language models, FrugalGPT (Chen, Zaharia and Zou, 2023) learns which queries to send to which model. It reports matching GPT-4 with up to 98% lower cost Chen et al. · abstract.

Route the hard cases

Left: every input's student confidence, coloured by whether the student was right. Inputs below your threshold go to the slow solver. Right: accuracy against cost, for every threshold. Then let shifted traffic in.

0.80

Illustrative numbers. 4,000 inputs. The slow solver is 98% accurate at 60 units per input; the student costs 1 unit. On shifted inputs the student is often confidently wrong, as models out of distribution tend to be.

On traffic like the training data, the student's confidence is honest. Routing the least confident quarter (threshold 0.9) lifts accuracy from 90% to about 96.5%, at about 17 units per input instead of 60. Now switch on shifted traffic. Many shifted inputs get high confidence but wrong answers. They slip past any threshold. The cascade can only route what it can recognise as hard.

That is why step 5 measures the gap on shifted inputs. It is also why a deployed cascade needs a second signal: an out-of-distribution detector, a verifier on the output, or random audits by the solver.

def answer(x, student, solver, tau=0.8, audit=0.01):
    y, conf = student(x)                         # one pass: answer + confidence in [0, 1]
    if conf < tau or looks_unusual(x) or random() < audit:
        y = solver(x)                            # slow path: per-instance inference
        if verify(x, y): log_for_retraining(x, y)  # tomorrow's training pair
    return y
Why does the cascade lose accuracy on shifted traffic even with a high threshold?

Chapter 11

Connections

Decide when to amortize with one tool, review the whole lesson in a table, and see where the idea leads

Every chapter answered part of one question: should this solver be amortized? The device below puts the parts together.

Should you amortize?

Describe your situation. The advice combines the break-even point (Chapter 3), the gap (Chapters 4 and 5), warm starts (Chapter 7) and routing (Chapter 10).

100k
5%
60
1 s

A rule-of-thumb model with illustrative accuracies: solver 98%; student 97% on usual inputs and 60% on unusual ones; warm steps lift those to 97.8% and 75%; routing sends 8% of usual inputs and 70% of unusual ones to the solver. It picks the best accuracy after a penalty of 2 points for every tenfold rise in cost per answer. Costs use M = 2,000, T = 20,000 and 0.005 s per solver step.

The cheat sheet

IdeaIn one line
Per-instance inferenceOptimise or search for each input's answer from scratch. Best answer, full cost every time.
Amortized inferenceTrain fφ(x) on a loss averaged over inputs. One-time cost, then one pass per input.
Break-evenN* = (M·cp + T) / ((1 − f)·cp − cs). Latency can make amortizing the only option.
Amortization gapLx(fφ(x)) − Lx(θ*(x)) ≥ 0. Small in distribution, large off it.
Two gapsInference gap = approximation gap + amortization gap; amortization often dominates (Cremer et al. 2018).
Closing the gapWarm-start a few solver steps, or learn the update rule (Marino et al. 2018).
DistillationStudent copies teacher; soft targets carry more per example (Hinton et al. 2015).
Noisy teachersBiased errors do not average out; verify and filter before training.
Search to policyExpert iteration: the network learns the search, then guides it (Anthony et al. 2017).
Data engineModel helps label, labels retrain model; SAM's final 1.1B masks were 99.1% automatic.
CascadeStudent answers when confident; the solver takes the rest. Needs calibration and a shift check.

Honest limits

Where this sits in the field

Amortized inference is one of the quiet engines of modern machine learning. Every encoder, every distilled model and every policy trained from search is an instance of it. In 2026 the slow solvers worth amortizing have become agents. That is why the gap, the verifier and the router now matter so much: the teacher is powerful, but it is also expensive and sometimes wrong.

Where to go next

The takeaway. A slow solver answers one question well. An amortized model answers every question fast, at the price of a gap that grows away from its training data. Pay the first cost only when many answers will share it. Verify what you distil. And keep the slow solver on call for the inputs the fast one cannot handle.
You will answer only 200 inputs, each very different from the last. What does this lesson suggest?

Now press Present or Teach and explain, from memory, what the amortization gap is, why it grows off-distribution, and how a cascade keeps it from hurting you. Then go back to the hero and find the fade rate where the one-pass answer stops being trustworthy.

Sources: Gershman and Goodman, "Amortized Inference in Probabilistic Reasoning", CogSci 2014. Kingma and Welling, "Auto-Encoding Variational Bayes", ICLR 2014 (arXiv:1312.6114). Cremer, Li and Duvenaud, "Inference Suboptimality in Variational Autoencoders", ICML 2018 (arXiv:1801.03558). Marino, Yue and Mandt, "Iterative Amortized Inference", ICML 2018 (arXiv:1807.09356). Hinton, Vinyals and Dean, "Distilling the Knowledge in a Neural Network", 2015 (arXiv:1503.02531). Anthony, Tian and Barber, "Thinking Fast and Slow with Deep Learning and Tree Search", NeurIPS 2017 (arXiv:1705.08439). Kirillov et al., "Segment Anything", ICCV 2023 (arXiv:2304.02643). Chen, Zaharia and Zou, "FrugalGPT", 2023 (arXiv:2305.05176). Guangzhao He, "A New Era for Agentic Vision and Robotics Research", 2026 (post).
Back to Gleams