↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

Copying what came after

An induction head is an attention head that completes a pattern it has already seen in the context: after the tokens A B, a later A is followed by B. It finds the earlier occurrence of the current token, looks one token to the right of it, and copies what it finds there into the prediction. This is the simplest form of in-context learning, and almost every language model has heads that do it.

Real text mixes copying with everything else a model knows, so the page isolates it. The Random tokens, said twice panel shows one of 32 sequences: <|endoftext|>, 25 token ids drawn uniformly from GPT-2's vocabulary, then the same 25 again, 51 tokens in all. Each token is shaded by GPT-2's loss on it, given the tokens before. Nothing in the first copy can be predicted, and GPT-2 pays 13.69 nats a token there, more than the 10.82 a uniform guess over its 50,257 tokens would cost, because it is confident in continuations that random text does not follow. In the second copy every token but the first can be read off the first copy, and the loss falls to 0.45 nats.

Three scores from the attention pattern

A head's attention pattern says how much each query position reads from each earlier key position. On repeated tokens of length , three diagonals of that pattern mean three different things, and the Every head panel averages each over the 32 sequences:

The duplicate score is attention to the earlier copy of the current token; the induction score is attention to the token after it, the one that comes next. Five heads score above 0.7 and are marked I: 5.5 (0.926), 6.9 (0.888), 5.1 (0.882), 7.10 (0.880) and 7.2 (0.784), counting layers and heads from 0. Their stripe is plain in the head's pattern at the right, a diagonal 24 positions below the main one, and the up-close head card shows the same rows token by token. Head 4.11 puts 0.989 of its attention on the previous token, and heads 3.0 and 0.5 are the strongest duplicate-token heads (0.639 and 0.614).

Two heads in a row

Attention alone cannot ask "which earlier position held the token that came before me?": a key only describes its own position. Induction needs two heads in sequence. A previous-token head in an earlier layer writes, at every position, a copy of the token before it into the residual stream. The induction head then forms its keys from that written copy and its query from the current token, so a query matches exactly the positions whose previous token equals the current one. Elhage et al. called this K-composition: one head's output changes another head's keys.

The page tests it. The induction, previous-token heads off view replaces the outputs of the four previous-token heads below layer 5 (4.11, 3.7, 2.2 and 3.2, whose previous-token scores are 0.989, 0.541, 0.496 and 0.418) by their means. The five induction heads' scores then fall from 0.87 to 0.48 on average, and the second copy's loss rises from 0.45 to 1.88 nats. The keys lost what the previous-token heads had written into them.

Copying the token

Attending to the right position is half the job; the head must also write that token's identity towards the output. The copying view measures it with the attribution tab's method: each head's output read through the final LayerNorm with its scale frozen at that position, as a share of , averaged over the second copy. The induction heads 7.2, 7.10 and 6.9 are among the largest (1.19, 0.96 and 0.92), but the two largest are 9.6 (1.25) and 9.9 (1.20). The IOI paper calls these name movers: they copy a name seen earlier in the sentence, the same move on a different task (see the Attribution and Patching tabs).

Taking them out

Correlation in a pattern is not proof that a head does the work, so the page also ablates heads. Mean ablation replaces a head's output at every position after the first with its average over all 32 sequences, so the head still writes something typical but nothing about this input. With the five induction heads ablated together, the second copy's loss goes from 0.45 to 4.59 nats. In the two sequences the page keeps, the right token stays first in the Next token bars at only 13 and 8 of the 24 positions where it was first at all of them. Eight random sets of five other heads give 0.33 to 0.68. The first copy barely moves, from 13.69 to 13.45 nats: nothing there was being copied.

The one more at a time chart ablates the induction heads in order of score: one, two, three, four and five heads give 0.54, 0.72, 2.43, 2.93 and 4.59 nats, while random heads stay near 0.5. Taken alone they matter less. Head 5.1 raises the loss by 0.53 and 5.5 by only 0.10, because the others still copy. The ablated alone view also shows the largest single effect, 0.83 nats, comes from head 0.3. That is not an induction head; it is a first-layer head whose output every later head reads, so a mean ablation there shows how much heads depend on each other, not what they copy.

Where it came from

Elhage et al. (2021) found induction heads while reverse-engineering attention-only transformers with one and two layers, and explained them with K-composition. Olsson et al. (2022) then showed that induction heads form at the same point in training as a sudden improvement in in-context learning, across model sizes, and argued that they implement much of it. Wang et al. (2022) met GPT-2's induction heads, 5.5 and 6.9 among them, inside the indirect-object circuit that the Patching tab traces. Later work studied how they form: Bietti et al. (2023) read the weights as associative memories, and Singh et al. (2024) intervened on the circuit's parts during training. The Transcoders and Circuits tabs move from heads to MLP features, and trace a whole prompt through them.

Papers

  1. In-context Learning and Induction Heads Catherine Olsson et al. · Transformer Circuits Thread 2022 Induction heads in models of every size, their prefix-matching and copying scores, and the phase change in training that ties them to in-context learning.
  2. A Mathematical Framework for Transformer Circuits Nelson Elhage et al. · Transformer Circuits Thread 2021 Where induction heads were first described, built from a previous-token head through K-composition in a two-layer attention-only model.
  3. Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 small Kevin Wang, Alexandre Variengien, Arthur Conmy, Buck Shlegeris, Jacob Steinhardt · ICLR 2022 GPT-2 small's indirect-object circuit, with induction heads 5.5 and 6.9, previous-token heads and the name movers 9.6 and 9.9.
  4. Birth of a Transformer: A Memory Viewpoint Alberto Bietti et al. · NeurIPS 2023 How an induction head forms in training, read as weight matrices acting as associative memories.
  5. What needs to go right for an induction head? A mechanistic study of in-context learning circuits and their formation Aaditya K. Singh et al. · ICML 2024 Causal interventions on the parts of an induction circuit during training, showing which must form, and in what order.
  6. Language Models are Unsupervised Multitask Learners Alec Radford et al. · OpenAI technical report 2019 GPT-2, the model whose heads this page scores and ablates.

See also