Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 small
Wang et al. reverse-engineer how GPT-2 small completes sentences like 'When Mary and John went to the store, John gave a drink to' with 'Mary', finding a circuit of about two dozen attention heads in seven functional roles. The paper is the canonical end-to-end circuit analysis in a real language model, and just as importantly it proposes criteria (faithfulness, completeness, minimality) for judging whether a circuit explanation is any good.
Ready to ace your system design interview?
This article is just one piece. StackSweep gives you structured, interview-focused practice across every topic that comes up in senior engineering rounds.
- 1,000+ quiz questions across system design and ML/AI
- Spaced repetition to lock in what you learn
- Full case study walkthroughs of real interview topics
- Track streaks, XP, and progress over time
TL;DR
- The task is indirect object identification (IOI): given two names where one (the subject) is repeated, predict the other one (the indirect object).
- Using path patching, a refinement of activation patching that tracks effects along specific paths, the authors identify 26 heads grouped into classes such as duplicate token heads, S-inhibition heads and name mover heads.
- The algorithm, read in plain words: notice which name is duplicated, suppress attention to it, then copy the remaining name to the output.
- The model contains redundancy: backup name mover heads take over when the main name movers are knocked out, and negative name mover heads push against the answer.
- The authors evaluate the circuit with three criteria (faithfulness, completeness, minimality) and find it faithful in aggregate but not fully complete, a useful honest negative.
Why this paper matters
IOI is the reference example people reach for when discussing circuits, patching and self-repair, so a research engineer is expected to explain its method and, more importantly, its limits. Interviewers use it to test whether you understand what an ablation-based explanation can and cannot establish.
Breakdown
1.The task and why it was chosen
An IOI sentence has two names in an opening clause, then repeats one of them as the subject of a second clause: 'When Mary and John went to the store, John gave a drink to'. The correct next token is the name that was not repeated, the indirect object (IO), here 'Mary'. The repeated name is called S (subject), with S1 its first occurrence and S2 its second.
The task is a good target for three reasons. GPT-2 small does it reliably, so there is a real behavior to explain. It has a crisp metric: the logit difference between the IO name and the S name at the final position. And the dataset can be generated from templates, so the authors can build matched corrupted inputs that change exactly one thing.
The key corrupted dataset is called ABC: the same templates, but the three name slots are filled with three different names. In an ABC sentence there is no duplicated name, so whatever signal the model uses to find the IO should be absent. Replacing activations with their mean over ABC inputs (mean ablation) removes task information while keeping activations in a realistic range, which is more defensible than setting them to zero.
Discussion angle: A sharp interviewer asks why mean ablation over ABC rather than zero ablation or resampling from a single corrupted prompt. Zero ablation pushes activations off-distribution and can break the model for reasons unrelated to the task. Also ask: how much does the circuit depend on the template family? A circuit found on a small set of templates may not be the mechanism used on naturally occurring IOI-like text.
2.Path patching: tracing effects along routes, not just components
Ordinary activation patching asks: if I replace one component's output with its value on a corrupted input, how much does the metric change? That tells you a component matters, but not through which downstream route. A head can affect the logits directly, or by changing what a later head attends to.
Path patching restricts the intervention to a chosen path. You patch the sender head's output only into the inputs of specified receiver components (for example, only into the queries of the name mover heads), while every other component sees the clean value. If the metric drops, the sender matters through that particular route.
The authors work backward from the logits. First they find heads whose outputs directly raise the IO logit (the name movers). Then they ask which heads affect the name movers' queries (the S-inhibition heads), and then which heads affect the S-inhibition heads (induction and duplicate token heads, fed by previous token heads). Each step is a targeted path-patching experiment, followed by checks of attention patterns and of what each head's output-value (OV) circuit writes, to assign a role to each class.
Discussion angle: Ask what path patching assumes. It treats the network as a graph with chosen edges, and the results depend on which nodes you define (heads, not features or positions) and which corrupted distribution you patch from. A good follow-up: how would you scale this beyond a hand-chosen backward search? That is the motivation for automated methods like ACDC.
3.The circuit: three steps in seven head classes
The resulting algorithm has three stages.
First, detect the duplicate. At the S2 position, duplicate token heads attend back to S1 and signal 'this token appeared before'. Induction heads, helped by previous token heads, produce a similar signal by a different route: they attend to the token after S1.
Second, inhibit the subject. At the final position, S-inhibition heads attend to S2, pick up the duplicate signal, and write something that changes the queries of the name mover heads so they attend less to S.
Third, copy the answer. Name mover heads at the final position attend to the names in context and, through their OV circuits, copy whichever name they attend to into the output logits. Because S has been suppressed, they mostly attend to IO and copy it.
Two further classes complicate the picture. Negative name mover heads attend to names and write against them, lowering confidence in the answer. Backup name mover heads normally contribute little but become active when the main name movers are ablated. In total the authors report 26 heads across these seven classes.
Discussion angle: Interviewers like to ask why a model would contain heads that push against its own correct answer. The authors speculate these heads help the model hedge against confident mistakes; a related account, developed later as 'copy suppression', is that these heads reduce overconfidence by suppressing tokens that appear in context and are already being predicted. Also ask: are the role labels discrete facts about the model, or summaries of a continuum the authors chose to bin?
4.Faithfulness, completeness and minimality
Finding heads that matter is easy. Showing you have explained the behavior is hard. The paper proposes three tests.
Faithfulness: run the model with everything outside the circuit mean-ablated. Does the circuit alone reproduce most of the full model's logit difference? The authors report that it recovers most of it.
Completeness: for subsets K of the circuit, compare knocking out K from the circuit with knocking out K from the full model. If the circuit is complete, both should hurt equally, because nothing outside the circuit should compensate. Random subsets and whole head classes pass this test, but subsets found by a greedy search fail it badly, which the authors report openly: there are parts of the mechanism they have not captured.
Minimality: for each head in the circuit, there should be some subset of the rest where removing that head makes a real difference. This guards against padding the circuit with heads that do nothing.
As a further check, the authors use their understanding to design adversarial prompts (for example, repeating the IO name as well as S, so duplicate detection no longer singles out the subject) and find the model does err more on them, which is evidence the circuit captures a real mechanism rather than a curve fit.
Discussion angle: Expect to be asked why faithfulness alone is not enough. A circuit can reproduce the metric on average while being wrong about why, or while other components would compensate in subtle ways. Also ask what the metric hides: logit difference averaged over a dataset can mask prompts where the circuit fails badly.
5.Self-repair and what it means for ablation studies
The most consequential side finding is that the model partly repairs itself. When the name mover heads are knocked out, backup name movers increase their contribution and recover much of the lost logit difference. A single-component ablation therefore understates how important that component normally is, and effects of ablating several components are not simply additive.
This matters well beyond IOI. Many interpretability claims rest on the logic 'we removed X and behavior barely changed, so X is unimportant'. Self-repair breaks that inference. It also complicates attempts to localize safety-relevant behavior: if a model has redundant pathways, removing one may not remove the behavior.
The paper is also honest about scope. It explains one narrow behavior, on templated data, in a 124M parameter model, at the level of whole attention heads. Multi-layer perceptrons (MLPs) are mostly treated as part of the background. The work took substantial researcher effort, which is part of why later work focused on automating circuit discovery and on finer-grained units such as sparse autoencoder features.
Discussion angle: A good question: how would you measure a component's importance in the presence of self-repair? Options include comparing direct effects with total effects, ablating groups jointly, or freezing downstream components so they cannot compensate. Each answers a slightly different question, and you should say which question you mean.
Reading the evidence
What it shows
- A specific, testable algorithm implemented by about two dozen attention heads explains most of GPT-2 small's IOI behavior on the templated dataset.
- Path patching can trace how information flows between components, not just which components matter.
- Language models can contain redundant, self-repairing mechanisms (backup name movers), so single ablations understate importance.
- A mechanistic understanding can predict new failure cases, which the model then exhibits.
What it does not show
- That the circuit is complete: the authors' own completeness tests find parts of the mechanism missing.
- That the same mechanism drives IOI-like behavior on natural text rather than the templates studied.
- That larger models solve the task the same way, or that this level of manual analysis scales.
- What the MLP layers contribute, since the analysis works mainly at the level of attention heads.
The most boring explanation
A skeptic might say the 'circuit' is an artifact of the chosen ablation method and dataset: with a different corrupted distribution or metric you would carve out a different set of heads. The authors partly address this with three separate criteria and with adversarial predictions that the model then fails, but they acknowledge the circuit is not fully complete, and later work showed circuit results can be sensitive to ablation choices.
Key Concepts
Indirect object identification (IOI)
Predicting the non-repeated name in a sentence where two names appear and one is repeated as the subject of a later clause.
Path patching
Patching a sender component's corrupted output only into specific receiver components, to measure its effect through one route rather than its total effect.
Analogy: Instead of cutting a power line to a whole building, you disconnect it from one floor's circuit breaker and see which lights go out on that floor only.
Mean ablation
Replacing an activation with its average over a reference distribution (here the ABC dataset), removing task-specific information while keeping values in a realistic range.
S-inhibition heads
Heads at the final position that read the duplicate-name signal and change the name movers' queries so they attend less to the repeated subject.
Name mover heads
Heads that attend to a name in context and copy it to the output logits via their OV circuit; they do the final 'say this name' step.
Self-repair (backup heads)
When a component is ablated, other components change their behavior and partially compensate, so single ablations understate importance.
Analogy: Like a team where, when the lead goes on leave, a colleague quietly picks up the work. Measuring the lead's value by their absence underestimates what they normally do.
Faithfulness, completeness, minimality
Three criteria for a circuit: it reproduces the behavior alone, nothing outside it is needed, and every part of it contributes.
Lessons that use this paper
Knowledge Check
10 questions — your answers are saved locally so you can come back anytime.