Before you move a control in the demo, say what you expect to change.
Foundation reference
Transformer Circuits, Induction Heads & Mechanistic Interpretability
Circuit analysis traces a specific behavior of a trained transformer to particular attention heads and MLPs. Wang et al. (2023) traced indirect-object identification in GPT-2 small to a circuit of 26 attention heads.
Study guide
Where to start
How do the QK and OV matrices of two attention heads combine to implement an algorithm such as induction?
How to study this pagePredict · Check · Generalize · Continue
Compare what the demo shows with the key equation and with the papers cited below.
Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.
Use the prerequisites and related concepts at the end of the page to fill the next gap.
Why It Matters for Modern Models
- Circuit analysis traces a specific behavior of a trained transformer to particular attention heads and MLPs. Wang et al. (2023) traced indirect-object identification in GPT-2 small to a circuit of 26 attention heads.
- Knowing the mechanism behind a behavior makes it possible to test, edit or monitor that mechanism directly, which is why interpretability is studied as a tool for safety research.
Questions to Think About
- Which circuit motifs recur across models, beyond the few that have been studied in detail?
Interactive Demo
Core Math
If you prefer intuition first, try the demo above, then come back for the math.
Treat the residual stream as a shared channel: each attention head and each MLP reads from it and adds its output back:
Each head splits into a QK circuit, , which sets the attention pattern (which positions it attends to), and an OV circuit, , which sets what it copies from those positions. Once the pattern is fixed, the head acts linearly on the stream (Elhage et al., 2021).
Induction heads implement the pattern-completion rule
in two steps: an earlier previous-token head writes "the token before me was [A]" into the position of [B]; the induction head at the current [A] then attends to that position (the token after the earlier [A]) and copies [B] to the output.
Olsson et al. (2022) found that induction heads form at the same point in training as a sudden improvement in in-context learning, and give preliminary, indirect evidence that they may be the mechanism behind most in-context learning in large models.