Induction heads blend n-gram estimates on synthetic data

The thing everyone assumed induction heads were doing

If you have read anything about how large language models learn from their own prompt, you have probably met the induction head. It is the most famous circuit in mechanistic interpretability — the sub-field that tries to reverse-engineer what specific computation a trained network is actually running, rather than just measuring how well it scores.

The standard picture is two layers of attention working together. Attention, in this context, is the mechanism that lets a model look back over everything it has read so far and decide which earlier positions are relevant to the token it is about to predict. In an induction head, the first layer builds a summary of what came just before each position, and the second layer scans backwards for a place where the same thing came just before — then copies whatever followed it last time. See A B earlier in the text, currently looking at A, predict B.

Described that way, an induction head is a lookup table. It finds exact matches and counts what came next. Statisticians have a name for that: it is the maximum-likelihood estimate, the "just count what you saw" answer.

A paper presented at ICML 2026 — Induction Heads Interpolate N-Grams, by Francesco D'Angelo, Oğuz Kaan Yüksel, Swathi Shree Narashiman and Nicolas Flammarion — argues that this picture is only the limiting case, and that the real behaviour is something far more interesting. It is worth saying up front that this went through peer review and was published as a conference paper, with an OpenReview record attached; that puts it in a different category from most of what lands on arXiv.

First, the thing from your NLP textbook

To see why the result is fun, you need one idea from the era before neural language models.

An n-gram model predicts the next word by counting. A trigram model asks: of all the times I've seen the two words "the weather is", what came next, and how often? Then it predicts proportionally. Simple, fast, and for decades it was the state of the art.

It also has a fatal flaw. Language is enormous and sparse, so most three-word sequences you'll ever encounter, you have never seen before. A count of zero becomes a probability of zero, and a probability of zero is not "unlikely" — in a language model it is impossible. One unseen trigram and the model assigns the whole sentence probability zero. It doesn't degrade; it breaks.

The fix is smoothing, and it comes in two flavours that every introductory NLP course covers:

There is a third relative, Katz back-off, which is stricter: use the longest context that has any data at all, and if it has none, fall back one level. Interpolation always mixes; back-off picks one.

None of this is neural. It is 1980s and 1990s statistical language modelling, and it is usually taught as background before the course gets to the interesting part.

Watch the video

What does the study show about how AI models learn from a prompt?

The authors study transformers trained on order-k Markov chains — synthetic sequences where the next token depends only on the previous k tokens, according to a hidden transition rule that is redrawn for each sequence. The model has to infer that rule from the sequence itself, which is in-context learning stripped down to something you can do exact maths on.

Their central move is to stop analysing the induction head in the hard-attention limit. Attention scores pass through a softmax, and how sharply it concentrates depends on the scale of the attention weights (the paper's parameter β). Push that scale to infinity and attention picks out exactly one thing — the exact match — and you recover the counting story. Every prior analysis, the authors note, did exactly that.

At finite attention scale, something else happens. The circuit does not just find exact matches; it scores every candidate position in the history by how much of the current context it overlaps with, and mixes in all of their predictions with weights that fall off exponentially as the overlap shrinks. A context that matches in all k positions dominates. A context that matches in only one still contributes something.

That is an interpolation across context orders — with mixing weights that depend on the data rather than being tuned by hand. Which is to say: Jelinek-Mercer smoothing, arrived at by gradient descent on a synthetic prediction task, with nobody having written it down.

The attention scale is the dial between the two classical regimes. Turn it up and you get Katz's hard rule: the longest matching context wins outright. Turn it down and you get a smooth, differentiable blend. And the back-off behaviour is automatic — when the full-length context has never occurred, its term is multiplied by a count of zero and simply vanishes, leaving the shorter contexts to carry the prediction. No if statement required.

One detail goes beyond the textbook. Classical interpolation and back-off both work with contiguous suffixes — the last two words, the last one word. The transformer's estimator also counts non-contiguous matches: contexts that agree with the current one in some positions and not others. It is averaging over all subsets of the context, not just the suffixes. That is a richer family than either classical method.

The second mechanism: BOS as imaginary evidence

The other half of the paper concerns a piece of plumbing that most people never think about.

Nearly every transformer prepends a beginning-of-sequence token. The usual justification is that attention heads need somewhere harmless to point when nothing in the context is relevant — an "attention sink", a parking space.

The paper shows it is doing real statistical work. Because BOS is always there and never depends on the sequence, attention paid to it contributes a constant amount to every prediction, regardless of what has been observed. A constant added to every count is precisely a pseudo-count — which makes the BOS token an implementation of add-α smoothing, built out of an architectural convention nobody chose for that reason.

The paper even derives roughly what attention scale corresponds to a given α, tying the knob to the classical parameter.

Constructed, then confirmed

The argument is made twice over, which is what makes it convincing.

First by construction: the authors build a disentangled transformer — a stripped-down variant with no MLPs, where each layer's output is concatenated onto the residual stream rather than added to it, so nothing gets tangled together and every computation stays legible. (This form is known to be equivalent to a standard attention-only transformer, so it is a fair object to reason about.) They set the weights analytically to the values their theory predicts, and the resulting model behaves as claimed.

Then by training: they train models from scratch and check whether they land in the same place. They do. The trained models reproduce the predicted attention patterns — a first layer copying at lag 1 and lag 2, a second layer matching contexts and grading its attention by overlap — and this holds for a fully standard two-layer transformer with LayerNorm, an MLP block, learned embeddings and additive residuals, not only for the interpretable stand-in.

The behaviour also adapts to the situation. With no BOS token available, trained models lean on soft context matching to interpolate across orders. With a BOS token, they use pseudo-counts instead — and where add-α is the Bayes-optimal thing to do, they match it. Where it isn't optimal, because the underlying task has structure that rewards backing off to shorter contexts, they combine both mechanisms and match or beat the classical count-based baselines.

That last point is the sharpest version of the finding. The network is not approximating the textbook estimator badly. Given a task where the textbook estimator is the right answer, it finds it; given a task where the textbook estimator is the wrong answer, it does better.

Caveats

Read this as a clean theoretical result, not a claim about ChatGPT.

The honest summary is that a specific, well-studied circuit has been given a precise statistical identity in a setting where you can prove things. That is genuinely useful — much of interpretability research is stuck at "this head seems to do something like X" — but it is a foundation, not a finding about deployed systems.

Why it's worth your time anyway

Mechanistic interpretability usually produces results of the form this attention head is involved in this behaviour. This one produces something rarer: the circuit is exactly this estimator, here is the derivation, and here is the classical algorithm it coincides with.

And the classical algorithm is one a lot of readers have already met and filed under history. If you have sat through a lecture on Jelinek-Mercer interpolation and add-α smoothing, and then separately learned how attention works, this paper connects the two — the sparse-data problem that broke n-gram models has not gone away, and a transformer trained on next-token prediction converges on the same family of solutions the field worked out by hand thirty years ago.

The authors' own framing is that transformers learn to regularise their in-context estimates rather than simply count. Counting was never the hard part. Knowing what to do when you haven't seen enough is.

Details

Sources

Related stories

More from Debug Duck

All stories from Debug Duck