Mechanistic Interpretability › Induction Heads: A Canonical Example
Language AI HandbookAll chapters Mechanistic Interpretability › Induction Heads: A Canonical ExampleOne section · Sections in this chapter4 / 12 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
The most celebrated circuit discovered through mechanistic interpretability is the induction head circuit. Induction heads are attention heads that implement "pattern completion" based on previous context. Understanding them provides a concrete demonstration of how circuit-level analysis works, and the story of their discovery illustrates the scientific method applied to neural network internals.
What Induction Heads Do
An induction head performs the following computation: given a sequence like [A][B]...[A], when the model sees the second occurrence of [A], it should predict [B] as the next token. This is because [B] followed [A] earlier in the context.
More precisely, if the model has seen token A followed by token B somewhere in its context window, and then sees token A again, an induction head will attend back to the first occurrence of A and copy what came after it (B) to the current position's representation. This enables in-context learning of simple patterns. The capability is not limited to exact token repetition; it generalizes to bigram patterns and, in stronger forms, to longer subsequences.
Induction heads are interesting as a mechanistic curiosity and as a potential substrate for in-context learning more broadly. In-context learning is the ability of large models to solve new tasks from a few examples in the prompt, without updating any weights. Olsson et al. (2022) argued that induction heads are a core mechanism enabling in-context learning: by detecting repeated patterns and completing them, the model can implicitly follow the "input-output" examples shown in the prompt.
The discovery of induction heads by Olsson et al. (2022) was significant because it showed that:
- A specific, identifiable circuit implements in-context learning behavior
- This circuit appears in virtually every transformer trained on natural language
- The circuit forms during a specific phase of training (the "induction bump")
- Ablating induction heads dramatically reduces in-context learning performance
The Two-Head Circuit
The induction head circuit consists of two attention heads working together:
-
Previous Token Head: An early-layer head (often layer 0) that attends to the token at position from position . It copies information about each token to the next position in the sequence.
-
Induction Head: A later-layer head that uses the information written by the previous token head to attend back to the position just before any repetition of the current token.
Let's trace through this step by step. Suppose the sequence contains ...[A][B]...[A][?]... and we're computing what the model predicts at position [?].
At position [B] in the early part of the sequence, the previous token head runs and copies information about [A] into [B]'s residual stream. Now [B]'s representation contains a blend of its own embedding and some information about [A].
At the second occurrence of [A], the induction head's query matrix processes [A]'s current representation. The key matrix processes all earlier positions' representations. Because [B]'s representation now contains [A] information (thanks to the previous token head), the induction head produces high attention from the current [A] position to the earlier [B] position.
The OV circuit of the induction head then copies [B]'s content to the current position, which causes the model to predict [B] (or whatever came after the previous [A]).
The two-head structure reflects a functional division of labor. The previous token head solves a sub-problem: "enrich each position's representation with information about its predecessor." The induction head solves a different sub-problem: "given my current token, find the position in context that followed this same token, and copy its content." Neither head alone can solve the full induction problem. The previous token head does not know which positions will later be queried. The induction head, without the enriched keys provided by the previous token head, has no way to locate the position following the first occurrence of the current token. It is their composition, mediated by the residual stream, that implements the full pattern-completion algorithm.
Formalizing the Mechanism
Let's formalize this. Let denote the embedding of token at position , and let denote the residual stream at position after layer 1 (which contains the previous token head).
The previous token head's OV circuit writes an approximation of to position . So after the previous token head runs:
where:
- : the embedding of the token at position
- : the embedding of the token at position
- : the mixing coefficient determined by the head's attention weight and OV circuit
Now, in the later layer, the induction head's QK circuit computes attention scores between the current position (the second [A]) and all earlier positions. The query for position is derived from (the embedding of [A]). The key for earlier position (the earlier [B]) is derived from .
The attention score between position and position is:
where:
- : the query weight matrix of the induction head
- : the key weight matrix of the induction head
- : the key dimension (for normalization)
When the QK circuit is tuned such that (the head strongly prefers matching the embedded query token to the same token in the key), this score becomes large for position (the [B] after the first [A]). This causes the induction head to attend to position and copy [B]'s representation forward, predicting [B] at position .
The elegance of this explanation is that it completely accounts for the induction head's behavior in terms of two simple weight interactions. No appeal to "the model knows how to continue patterns" is needed; the specific matrix multiplications implement the pattern-matching directly. This is what distinguishes a mechanistic explanation from a high-level behavioral description. The behavioral description ("the model completes patterns") is true but uninformative. The mechanistic description traces the exact sequence of weight operations that produce the behavior, making the claim verifiable and the mechanism transparent.
The Induction Bump
Evidence for the induction head story comes from training dynamics. When you train a small two-layer transformer from scratch and track its loss on a random token sequence (where the only structure is repeated tokens), the loss curve shows a characteristic sharp drop around a few thousand steps. This has been called the "induction bump."
Simultaneously, the previous token head and the induction head form during this phase. Before the bump, neither head shows induction-like behavior. After the bump, both heads are functional and the circuit is complete.
This phase transition in behavior corresponds to a discrete circuit forming, rather than gradual improvement across all components. It is consistent with the hypothesis that induction heads represent a coherent computational unit that is learned as a package rather than incrementally. The model does not first learn a partial induction ability and then improve it; rather, it relies on a suboptimal strategy for thousands of steps, then abruptly switches to the induction circuit strategy.
The induction bump has interesting implications for understanding how neural networks learn algorithms. The discrete transition suggests that the relevant algorithmic solution has a minimum viable complexity: there is no gradient-directed path from "no induction" to "partial induction" because partial induction does not reduce loss. The model must solve the two-head coordination problem jointly. This contrasts with how we might naively expect gradient descent to work, smoothly interpolating between solutions. The reality appears to be that some algorithms are all-or-nothing, and learning them requires a kind of combinatorial search that happens to succeed at a particular point in training.
It also raises questions about what comes before the induction bump. The model must be doing something during the thousands of steps before the circuit forms. Researchers have found that before the induction bump, the model relies more heavily on direct unigram statistics (predicting the most common token regardless of context). After the bump, in-context bigram patterns override those statistical priors when they are available. The circuit formation marks a discrete change in computational strategy rather than a smooth parameter update.