Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 small
Read first: A Mathematical Framework for Transformer Circuits · Towards Best Practices of Activation Patching in Language Models: Metrics and Methods
TL;DR. The indirect object identification (IOI) task asks GPT-2 small to complete “When Mary and John went to the store, John gave a drink to” with “Mary”. The authors trace the behaviour to 26 attention heads grouped into seven classes. The model detects the duplicated name, inhibits it, and copies the remaining one. They then test the explanation with three criteria: faithfulness, completeness and minimality.
Key idea
Section titled “Key idea”The main tool is path patching. You replace activations along one path, such as head h to the name movers’ queries, with activations from a corrupted prompt (one with different, unrelated names). Then you measure the change in the logit difference between the IO and S names. Working backwards from the logits gives the seven head classes:
- name movers, negative name movers and backup name movers;
- S-inhibition heads;
- induction heads, duplicate-token heads and previous-token heads (§3).
Key results
Section titled “Key results”The circuit covers 26 heads, 1.1% of (head, token position) pairs. It reaches 87% of the full model’s logit difference: |F(M) − F(C)| = 0.46, which is 13% of F(M) = 3.56 (§4). Prompts where the IO name also appears twice, built from the circuit’s reliance on duplicate detection, make the model pick S over IO 23% of the time. A control where S is repeated instead gives 0.4% (§4.4). The authors note the circuit’s completeness is not perfect, and some behaviour on adversarial examples is not fully understood.
Connections
Section titled “Connections”- A Mathematical Framework for Transformer Circuits: QK/OV and composition, which IOI applies to a real model with MLPs.
- In-context Learning and Induction Heads: induction heads appear here as one route to duplicate detection.
- Circuit Tracing: later, feature-level graphs instead of head-level circuits.
- Sparse Autoencoders Find Highly Interpretable Features: uses IOI as a test bed for patching SAE features.
- Open Problems in Mechanistic Interpretability: circuit-discovery pipelines and their validation problems.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Mechanism
Walk through the IOI algorithm for "When Mary and John went to the store, John gave a drink to", naming at which token each head class acts, what it attends to and what it writes, from duplicate detection to the final logit for "Mary".
What a strong answer covers
- Duplicate token heads (and induction heads, helped by previous-token heads) act at S2, the second "John". They attend to S1 and write that this token is a duplicate.
- S-inhibition heads act at END ("to"). They attend to S2 and write into the queries of the name movers, reducing their attention to S1 and S2.
- Name mover heads act at END. They attend to names in the sentence and copy the attended name; because John is inhibited, they attend mostly to Mary (IO) and raise its logit.
- Negative name movers write the opposite of the attended name, lowering confidence; backup name movers take over if the main name movers are knocked out.
- Critique
The circuit achieves 87% of the model's logit difference (|F(M) − F(C)| = 0.46 of 3.56), yet knocking out all name mover heads lowers the logit difference by only 5% because backup heads compensate. Explain what this says about knockout-based circuit claims and how the paper's three criteria try to address it.
What a strong answer covers
- Faithfulness only checks that the circuit alone reproduces the behaviour; it does not show that the model uses only the circuit.
- Backup heads mean that removing a component can understate its normal role, because other heads change their behaviour after the knockout (compensation).
- Completeness asks that the circuit and the full model respond similarly when any subset of circuit nodes is knocked out, which can expose missing components like backups.
- Minimality asks that each node matter for some subset, ruling out unnecessary heads. Even with all three, results depend on the ablation choice (mean ablation over a reference distribution) and the task distribution.
- Design
The authors used the circuit to build adversarial prompts in which the IO name is also repeated, which makes GPT-2 small predict the subject 23% of the time. Design an analogous circuit-informed stress test for an LLM that answers questions from a retrieved passage containing two candidate entities.
What a strong answer covers
- Identify the analogous mechanism: a duplicate-detection signal that suppresses entities mentioned more than once (here, the question entity) and a mover that copies the remaining candidate.
- Stress test: repeat the correct answer entity elsewhere in the passage so it looks like a duplicate and is inhibited, with a control where the distractor is repeated instead.
- Measure the rate of choosing the distractor and the logit difference, and check with activation patching that the same heads drive the change.
- Interpretation: a large drop only in the answer-repeated condition supports the circuit hypothesis; the control rules out a simple length or repetition effect.