Assign and Add: A Mechanistic Study of Compositional Arithmetic
Not on the map. Why?
Abstract (arXiv)
Large language models are able to compose skills in order to perform complex tasks, many of which might not have been seen during training. The details of how exactly this composition occurs remain elusive. In this paper, we study a mechanism for compositional generalization in transformers by considering a simple controlled setting involving variable assignment and modular addition. By partitioning our training data into disjoint sets, we observe that small transformers are able to generalize to previously unseen combinations of variables and numbers. Our mechanistic analysis shows that the same ``modular addition'' MLP module is used whether the inputs are given directly or indirectly through a separate variable assignment mechanism. We also analyze the training dynamics from an empirical lens, which reveals three phases of learning: first, modular addition is learned, then the structure required for variable assignment, and finally a refinement phase where the model generalizes to some hard sequences not seen in training. Finally, we provide a theoretical framework to explain how compositionality emerges from training dynamics. These results suggest that compositional generalization can be a natural consequence of the compositionality of internal mechanisms in~transformers.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 25 of its 32 references that are in the map. First posted on arXiv 29 May 2026.
Builds on
25 of 32 references.
References · 25
- 2017Attention Is All You Needcited by 59,932
- 2022Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 smallcited by 1,130
- 2022Measuring and Narrowing the Compositionality Gap in Language Modelscited by 1,054
- 2022In-context Learning and Induction Headscited by 930
- 2023Progress measures for grokking via mechanistic interpretabilitycited by 822
- 2022Transformers learn in-context by gradient descentcited by 714
- 2023Faith and Fate: Limits of Transformers on Compositionalitycited by 496
- 2020COGS: A Compositional Generalization Challenge Based on Semantic Interpretationcited by 260
- 2022Transformers Learn Shortcuts to Automatacited by 260
- 2023How does GPT-2 compute greater-than?: Interpreting mathematical abilities in a pre-trained language modelcited by 199
- 2023Birth of a Transformer: A Memory Viewpointcited by 154
- 2022Analyzing Transformers in Embedding Spacecited by 131
13 more
- 2023The mechanistic basis of data dependence and abrupt learning in an in-context classification taskcited by 115
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 114
- 2022Unveiling Transformers with LEGO: a synthetic reasoning taskcited by 105
- 2024Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic taskscited by 40
- 2025Learning Compositional Functions with Transformers from Easy-to-Hard Datacited by 34
- 2023Feature emergence via margin maximization: case studies in algebraic taskscited by 33
- 2023Discovering Variable Binding Circuitry with Desideratacited by 32
- 2024Iteration Head: A Mechanistic Study of Chain-of-Thoughtcited by 31
- 2023Compositional Capabilities of Autoregressive Transformers: A Study on Synthetic, Interpretable Taskscited by 21
- 2025How Do Transformers Learn Variable Binding in Symbolic Programs?cited by 19
- 2025Alternating Gradient Flows: A Theory of Feature Learning in Two-layer Neural Networkscited by 11
- 2024Composing Global Solutions to Reasoning Tasks via Algebraic Objects in Neural Netscited by 5
- 2026On the Mechanism and Dynamics of Modular Addition: Fourier Features, Lottery Ticket, and Grokkingcited by 5
Built on by
Not cited yet.