TL;DR
Language models get much better at using earlier tokens in their context during a short, sudden phase early in training. Olsson and colleagues show that the same window is when a specific pair of attention heads, which they call induction heads, forms. An induction head completes the pattern A B ... A with B. Their evidence is strongest in small attention-only models, where removing the heads removes most of the in-context gain. For large models the link is correlational.
Builds on: In-Context Learning, Autoregressive Model · Leads to: Causal Tracing
Why it mattered
The paper gave interpretability researchers a concrete, checkable circuit to study. Before it, attention maps and neuron pictures were suggestive but hard to tie to a behaviour. Here there is a named mechanism, a precise definition, a measurable training event, and an intervention that removes the behaviour. Later work on how transformers copy and retrieve information builds on this kind of circuit analysis.
It also gave a concrete case for a safety-relevant point. A capability can switch on abruptly during training rather than grow smoothly, and in-context learning changes what a model can do with a prompt without any change to its weights. The authors argue that understanding the mechanics of such a switch could help with future problems of the same kind.
The problem
Language models are trained to predict the next token. Some of the things they do well with a long prompt, such as following an instruction shown in the prompt or continuing a pattern set by a few examples, look like learning, yet no weights change at test time. The paper calls the general phenomenon in-context learning and measures it with a simple score: the loss on the 500th token of a context minus the average loss on the 50th token. A lower loss far into the context means the model is using what it has already read.
Before this paper, a researcher could say that in-context learning happens, and could point at attention heads that look relevant, but could not say which parts of the network carry it or whether a specific mechanism causes it. The earlier paper by the same group had found induction heads in two-layer attention-only models, but the definition was loose: a cluster of behaviours that tended to occur together. This paper tightens the definition and tests whether it carries over to large models.
How it works
The paper's argument has three parts: a definition, a measurement of when the definition's heads appear, and interventions to test whether they matter. Start with the definition, since everything else depends on it.
An induction head is an attention head that does two things on a repeated sequence.
- Prefix matching. The head attends back to earlier positions whose preceding token equals the current token. In the sequence "cat dog fish ... cat", the current token is the second cat. The earlier position whose preceding token is cat is the position of dog, which came right after the first cat, so the head attends to dog.
- Copying. Having attended to that earlier position, the head copies the token there, dog, and raises the score of dog as the next prediction. The logit is the raw score the model gives each possible next token before it is turned into probabilities by softmax.
The paper gives the algorithm as A B ... A → B: when A appears again, predict the token that followed A last time. The rule works for any A and B, so it is a general procedure rather than a memorised table of word pairs.
Small models implement this with two heads in sequence:
- A previous-token head in an early layer copies the identity of each token into the next position. Now every position knows what came before it.
- The induction head in a later layer uses that information in its keys. When it sees the second A, it looks for positions whose previous token was A, which are the positions just after an earlier A, and copies the token there.
The two heads need two layers, which is why the paper finds the effect only in models with more than one layer. The mechanism is visible in the weights, and the paper checks it by reading how the query and key matrices interact.
- Watch the training run. For each checkpoint, measure the in-context learning score and a prefix-matching score for every head. The two rise together in a short window around 2.5 billion to 5 billion training tokens, and the training loss shows a visible bump there.
- Intervene. Knock out induction heads at test time in small models and in-context learning drops sharply. Change the architecture so that induction heads form earlier or later, and the in-context learning curve moves with them.
flowchart TD A["Sequence: ... A B ... A"] --> P["Layer 1: previous-token head copies token identity forward"] P --> I["Later layer: induction head matches the second A to the token after the first A"] I --> C["Copies B and raises its probability for the next token"] C --> M["Measured as a drop in loss on later tokens in the context"]
The math
Write the sequence of tokens as , and let be the average cross-entropy loss of predicting token over the dataset. The paper's in-context learning score is
where the expectation is over documents in the dataset. Read the subtraction in words: the loss at a late position, minus the loss at an earlier position. Because later tokens should be easier to predict when the model uses context, this number is negative for a model that learns in context, and more negative means better use of context. The indices 50 and 500 are the paper's choice: an early position and a late one, so the score measures how much the model gained from the context in between.
Step 1 in symbols is the induction rule. Let the current token be . If an earlier position has , meaning the token before position is the same as the current token, the induction head wants to predict . The ingredient for this is a prefix-matching score, which measures how much attention goes from position to positions with .
Step 2 in symbols is the copying score. For a head with attention weights and the output that would be produced by copying the token at each attended position, the copying score measures how much the head's output raises the logit of on repeated sequences. Both scores are empirical measurements. The paper defines an induction head by high values on both, so the mechanism is identified by behaviour as well as by weights.
Step 3 in symbols is the two-layer composition. The key at each position must carry the identity of the token , which the earlier head wrote there, and the query at the current position must carry . The two heads are linked through the residual stream, the running sum that each position carries from layer to layer, which the layers add into (see residual connections).
Results
Phase change. The in-context learning score drops and induction heads form in the same window of training, roughly 2.5 billion to 5 billion tokens. The training loss shows a visible bump in that window.
One-layer models. In one-layer models the phase change does not occur, induction heads never form, and in-context learning does not develop substantially. This matches the idea that induction heads need composition across layers.
Smeared keys. The authors modify attention so that each key is a learned mix of the current token and the previous token. This makes it easy for a single layer to express the induction pattern. With this change, in-context learning does form in one-layer models, and it forms earlier in two-layer and larger models. The authors take this as partial support, not as proof, since larger models can use other mechanisms too.
Ablations in small models. Removing induction heads in small attention-only models at test time removes most of their in-context learning. The authors note that ablating a single head measures its marginal effect, and two heads doing similar work can mask each other.
Large models. The authors did not run ablations on their full-scale models, which are much larger than the small models. Instead they found heads in the large models that match the induction definition on the prefix-matching and copying scores, and some of these heads also show more abstract pattern-matching behaviour. These are examples, not a count, and they support the claim that induction heads may be a general mechanism.
Limits. The evidence for the majority claim in large models is correlational. Confounds are possible: the same training event could change several things at once, and the in-context learning score is a heuristic. The authors state these limits directly and argue that reporting indirect evidence is worthwhile even when it is not conclusive.
Reading guide
- Abstract and introduction. Read them for the six lines of evidence. Prerequisites: In-Context Learning and Autoregressive Model, since the paper's whole claim is about how a next-token model uses its context.
- Key concepts. The in-context learning score and the induction-head definition. Prerequisites: Cross-Entropy Loss for the loss, Attention Mechanism for queries, keys and values, and Softmax for the attention weights.
- Phase change section. The training curves and the bump. Prerequisites: Perplexity if you want the loss in more familiar units, and Language Model for what the model is trained to do.
- Ablation and co-perturbation sections. Prerequisites: Multi-Head Attention (the heads being removed), Residual Connection (how heads add to the stream), and Transformer (the whole architecture).
- Mechanism section. The composition of two heads through queries and keys. Prerequisites: Matrix Multiplication and Positional Encoding, which the previous-token head interacts with when it moves token identity forward.
- Results and model table. The full-scale model sizes and the head examples.
Check yourself
QuestionRecall: what does the pattern A B ... A to B mean, and why is it called a rule rather than a lookup table?Show answer
When the token A appears again later in the sequence, the model predicts the token that followed A the first time, which is B. The rule uses only the positions of the repeated token, so it works for any A and B. A lookup table would need a separate entry for every pair of words; the induction rule is one procedure applied to all of them.
QuestionCompute: a model has average loss 2.1 at position 500 and average loss 3.0 at position 50. What is its in-context learning score, and what does the sign mean?Show answer
The score is the loss at 500 minus the loss at 50, which is 2.1 minus 3.0, or negative 0.9. A negative value means the loss is lower far into the context than early in it, so the model is using its context. A more negative number means stronger in-context learning.
QuestionWhy: why does the paper find the effect only in models with at least two layers, and what does that suggest about the mechanism?Show answer
Induction heads need two attention heads in sequence: an early head that moves token identity forward, and a later head that uses it to match the current token. One layer cannot do both, so the one-layer models do not form induction heads and do not show the phase change. The result is consistent with induction heads being the mechanism, though the authors note that it is weak evidence by itself because one-layer models differ in other ways too.
QuestionApplied: an ablation removes the induction heads in a small attention-only model, and in-context learning drops sharply. Does that show the heads are the main mechanism of in-context learning in a 13 billion parameter model?Show answer
No. The ablation is strong evidence for small attention-only models only. The authors did not run ablations on their full-scale models, and in models with MLP layers the in-context learning could also come from interactions between attention and MLP layers. For large models the paper offers correlational evidence and examples of matching heads, which makes the claim plausible but not established.