What are induction heads?
Author: Mehdi Sadriu, independent educator. Last reviewed: 25 November 2026. How we check claims: methodology.
An induction head is an attention pattern that helps a model continue a repeated sequence: after seeing A B … A, it predicts B. Olsson et al. (2022) describe this as a pair of heads — a previous-token head and a copier — and report that they appear fairly suddenly during training and that they track in-context learning in those experiments. That is evidence about those models, not a claim that every in-context skill is only induction.
In one paragraph. Induction: attend from a repeated token back to what followed its earlier occurrence, and copy that continuation (Olsson et al., 2022).
Context: A B … A → predict B.
Head 1 (previous-token) at the second A attends to the first A's neighbour and writes 'the token after this was B'. Head 2 (induction) copies B into the residual stream at the prediction position. That is the Olsson et al. (2022) picture, drawn as text.
What is the plain-language trick?
If a document once said 'Mr. Dursley' and later says 'Mr.', a useful head looks up what followed 'Mr.' last time and copies 'Dursley'. The same trick works for few-shot patterns: 'foo → bar' then another 'foo' should yield 'bar'.
What is the two-head algorithm?
Olsson et al. (2022) : the previous-token head writes a pointer so that each token is associated with the token that came before it. A later head (the induction head) uses that pointer: at the second A it looks at the token after the first A, which is B, and copies B via OV.
What is the link to in-context learning?
The same paper reports a close match, in the models they trained and inspected, between the sudden appearance of this pattern and a jump in in-context learning scores. Brown et al. (2020) had already shown that large models can do tasks from prompt examples without weight updates. Induction is one mechanistic piece of that story, not the whole story (tasks that are not copy-pattern still exist).
What is the math?
Let t be the current position with token A, and let s < t be an earlier position with the same token A, followed at s+1 by B. An induction head at t has large attention weight on s+1, and OV maps the residual at s+1 toward B's unembedding direction. The previous-token head at s+1 had attended to s. Composition of those two attention patterns is the copy.
Worked example
Prompt: alpha nine alpha. After the second 'alpha', an induction head should up-weight 'nine'. In TransformerLens you would cache the attention pattern of a mid-layer head on repeated random tokens and look for the shift-by-one diagonal. mej7.com's toy attention grid cannot show this: its scores are a fixed teaching rule, not a learned copier.
Check your understanding
Five questions. Answers are in the disclosure under each item, so this page still works if JavaScript is off.
Further reading
- In-context Learning and Induction Heads — Olsson et al. (2022). Transformer Circuits (Anthropic).
- A Mathematical Framework for Transformer Circuits — Elhage et al. (2021). Transformer Circuits (Anthropic).
- Language Models are Few-Shot Learners — Brown et al. (2020). NeurIPS.
- Attention Is All You Need — Vaswani et al. (2017). NeurIPS.