Emergence of Minimal Circuits for Indirect Object Identification in Attention-Only Transformers
Rabin Adhikari · 2025
Read Emergence of Minimal Circuits for Indirect Object Identification in Attention-Only Transformers by Rabin Adhikari (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2510-25013.txt.
Introduction
Rabin Adhikari, the sole author, trains tiny attention only models from scratch and finds the least parts that can solve a known core task. The task asks a model to pick the right name for a phrase that points back in a line of text. Big trained models solve it, but their bulk hides how they do it.
A one layer model with just two heads got the task fully right, with no feed nets or norm steps at all. The two heads split into an add part and a contrast part that join to settle the pick. A two layer, one head form passed facts by its ask and key ties. Task built training gave clean, least parts.
Catalog record
| CREATOR | Rabin Adhikari |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 21 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2510-25013
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Emergence of Minimal Circuits for Indirect Object Identification in Attention-Only Transformers Rabin Adhikari Abstract Mechanistic interpretability aims to reverse-engineer large language models (LLMs) into human-understandable computational circuits. However, the complexity of pretrained models often obscures the minimal mechanisms required for specific reasoning tasks. In this work, we train small, attention-only transformers from scratch on a symbolic version of the Indirect Object Identification (IOI) task—a benchmark for studying coreference—like reasoning in transformers. Surprisingly, a single-layer model with only two attention heads achieves perfect IOI accuracy, despite lacking MLPs and normalization layers. Through residual stream decomposition, spectral analysis, and embedding interventions, we find that the two heads specialize into additive and contrastive subcircuits that jointly implement IOI resolution. Furthermore, we show that a two-layer, one-head model achieves similar performance by composing information across layers through query-value interactions. These results demonstrate that task-specific training induces highly interpretable, minimal circuits, offering a controlled testbed for probing the computational foundations of transformer reasoning. \workshoptitle Interpreting and Analyzing Neural Language Models 1 Introduction Large Language Models (LLMs) have achieved remarkable success across a vast range of natural language processing tasks [ 3 , 17 , 12 ] . Yet, their internal operations remain largely opaque, motivating the field of mechanistic interpretability, which seeks to reverse-engineer these “black boxes” into understandable circuits and algorithms [ 11 , 9 , 4 ] . The ultimate goal is to achieve a circuit-level understanding where individual components like neurons and attention heads are mapped to specific algorithmic roles [ 5 , 4 ] . However, the immense scale, residual connections, and non-linearities of modern LLMs present significant challenges to this endeavor. To navigate this complexity, researchers often start with simplified or “toy” models as controlled environments for developing and validating interpretability tools [ 6 , 19 , 9 ] . By training models on constrained, synthetic objectives, we can reduce confounding variables from complex linguistic structures and discover core computational mechanisms in a cleaner setting. A common approach to understanding these models involves analyzing pre-trained transformers [ 18 ] on specific tasks they can perform [ 2 , 1 ] . [ 19 ] introduced the Indirect Object Identification (IOI) task as a benchmark for studying such capabilities. In a typical IOI sentence, an initial dependent clause introduces two names (a subject, S , and an indirect object, IO ), and the main clause repeats the subject. The task is to predict the IO as the final token. [ 19 ] showed that GPT-2 small [ 13 ] implements IOI through a multi-hop attention circuit involving distinct classes of heads. However, this mechanism arises within a model pretrained for next-token prediction on natural text—an inherently complex optimization setting. In contrast, we train minimal, attention-only transformer models [ 18 ] from scratch exclusively on a symbolic version of the IOI task. We find that a straightforward model—a single-layer transformer with just two attention heads—can solve this task perfectly. Since we know that the task of IOI can’t be performed using a skip-gram model, our argument is similar in spirit to [ 14 ] that a one-layer attention-only transformer has a higher representational capacity than a skip-gram. Furthermore, a detailed analysis of this model uncovers a highly compact and interpretable circuit where the solution is computed via a direct additive combination of the two heads’ outputs, rather than a complex, multi-hop pipeline. Our contributions are threefold: 1. We demonstrate that a one-layer, two-head attention-only model is sufficient to solve the IOI task with a fixed template perfectly. 2. We provide a mechanistic analysis that uncovers a minimal circuit based on an additive combination of specialized attention head outputs. 3. We argue that the circuits in large, broadly pre-trained models may be overly complex due to multi-task pressures, whereas task-constrained training can reveal more parsimonious mechanisms. 2 Dataset and Model Configuration 2.1 The IOI Task in a Symbolic Setting To isolate the core relational reasoning challenge of the IOI task, we construct a symbolic dataset that abstracts away all linguistic and tokenization complexities. The task remains to identify the correct indirect object (IO) from the dependent clause, given a subject (S) from the main clause, but now these are simply names drawn from a small vocabulary. This formulation abstracts the essential relational pattern from the natural-language IOI task—“When John and Mary … John gave … to ___”—while removing all linguistic confounds. It enables precise inspection of what the model must represent to distinguish between “subject” and “object” roles. The training data consists of 6-token sequences built from two primary templates. Using “John” (S) and “Mary” (IO) as examples: 1. <BOS> John Mary Mary <MID> John 2. <BOS> John Mary John <MID> Mary Here, <BOS> marks the start of the sequence, and the model’s objective is to predict the IO token at the final position, following the <MID> token. The two names are drawn randomly from a vocabulary of six names, and the correct final token is chosen uniformly at random. 2.2 Model Configuration To maximize interpretability, we used simple attention-only transformer models. Feed-forward networks and layer normalization were omitted to isolate the function of the attention mechanism. The vocabulary consists of 6 name tokens plus the two special tokens <BOS> and <MID> , for a total size of 8 . The residual stream dimension was set to 8 , and the head dimension was d_{head}=\frac{8}{N_{h}} , where N_{h} is the number of heads. Training: Models were trained from scratch on the symbolic IOI dataset using a cross-entropy loss to predict the token at the <MID> position. Each training batch contained all 60 possible unique sequences ( 6\times 5\times 2=60 ). We used the AdamW optimizer [ 7 ] with a OneCycle learning rate scheduler [ 15 ] , a maximum learning rate of 0.1 , and weight decay of 0.01 . Training and analyses were performed on a single NVIDIA A40 GPU using the TransformerLens [ 8 ] library. 3 Results and Analysis 3.1 Single-Head, One-Layer Model Fails to Learn A single attention head outputs \approx 50\% probability for the names provided in the prompt, indicating that the model knows that the final answer is one of the two names provided. But it cannot distinguish which one is correct. The model attends roughly equally to both the names in the dependent clause (see figure 1(a) ), indicating that a single attention head cannot jointly encode the information required to (i) identify which token serves as the correct referent and (ii) propagate that information to the prediction position. The roles of “reference detection” and “copying” appear to be functionally incompatible within a single attention mechanism. (a) Average Attention Heatmap (b) QK Circuit (c) OV Circuit Figure 1 : Single-Head, One-Layer Model Fails to Learn IOI. (a) The attention heatmap showing the <MID> token attends uniformly to the two names. (b) The QK circuit reveals that the <MID> token attends uniformly to all tokens. (c) The OV circuit shows that each name token has a large positive contribution to its own logit and a small negative contribution to the other name’s logit. Following [ 5 ] , we analyze the QK and OV circuit to understand the failure mode of the single-head model. From the