In-Context Algebra
Not on the map. Why?
Abstract (arXiv)
We investigate the mechanisms that arise when transformers are trained to solve arithmetic on sequences where tokens are variables whose meaning is determined only through their interactions in-context. While prior work has studied transformers in settings where the answer relies on fixed parametric or geometric information encoded in token embeddings, we devise a new in-context reasoning task where the assignment of tokens to specific algebraic elements varies from one sequence to another. Despite this challenging setup, transformers achieve near-perfect accuracy on the task and even generalize to unseen groups. We develop targeted data distributions to create causal tests of a set of hypothesized mechanisms, and we isolate three mechanisms models consistently learn: commutative copying where a dedicated head copies answers, identity element recognition that distinguishes identity-containing facts, and closure-based cancellation that tracks group membership to constrain valid answers. Our findings show that the kinds of reasoning strategies learned by transformers are dependent on the task structure and that models can develop symbolic reasoning mechanisms when trained to reason in-context about variables whose meanings are not fixed.
Key facts. Cited by 5 papers in the map (data through 14 Oct 2026). Builds on 71 of its 88 references that are in the map. First posted on arXiv 18 Dec 2025.
Builds on
71 of 88 references.
References · 71
- 2017Attention Is All You Needcited by 60,361
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,305
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
- 2013Distributed Representations of Words and Phrases and their Compositionalitycited by 3,474
- 2022Locating and Editing Factual Associations in GPTcited by 2,691
- 2016Understanding intermediate layers using linear classifier probescited by 1,353
- 2022Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 smallcited by 1,165
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 938
- 2021Probing Classifiers: Promises, Shortcomings, and Advancescited by 876
- 2023Progress measures for grokking via mechanistic interpretabilitycited by 839
- 2022Transformers learn in-context by gradient descentcited by 732
38 more
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 684
- 2022Grokking: Generalization Beyond Overfitting on Small Algorithmic Datasetscited by 629
- 2024GSM-Symbolic: Understanding the Limitations of Mathematical Reasoning in Large Language Modelscited by 550
- 2022Emergent World Representations: Exploring a Sequence Model Trained on a Synthetic Taskcited by 431
- 2023In-Context Learning Creates Task Vectorscited by 312
- 2023Function Vectors in Large Language Modelscited by 308
- 2013Direct and Indirect Effectscited by 280
- 2022Transformers Learn Shortcuts to Automatacited by 268
- 2022Towards Understanding Grokking: An Effective Theory of Representation Learningcited by 230
- 2023Finding Alignments Between Interpretable Causal Variables and Distributed Neural Representationscited by 209
- 2023Causal Abstraction: A Theoretical Foundation for Mechanistic Interpretabilitycited by 205
- 2023The Clock and the Pizza: Two Stories in Mechanistic Explanation of Neural Networkscited by 156
- 2024Fine-Tuning Enhances Existing Mechanisms: A Case Study on Entity Trackingcited by 149
- 2023Pretraining task diversity and the emergence of non-Bayesian in-context learning for regressioncited by 146
- 2022Analyzing Transformers in Embedding Spacecited by 132
- 2023Sudden Drops in the Loss: Syntax Acquisition, Phase Transitions, and Simplicity Bias in MLMscited by 124
- 2023How do Language Models Bind Entities in Context?cited by 108
- 2024Physics of Language Models: Part 2.1, Grade-School Math and the Hidden Reasoning Processcited by 108
- 2022Unveiling Transformers with LEGO: a synthetic reasoning taskcited by 106
- 2022General-Purpose In-Context Learning by Meta-Learning Transformerscited by 105
- 2023Interpretability at Scale: Identifying Causal Mechanisms in Alpacacited by 103
- 2024Arithmetic Without Algorithms: Language Models Solve Math With a Bag of Heuristicscited by 97
- 2024In-Context Language Learning: Architectures and Algorithmscited by 89
- 2024What needs to go right for an induction head? A mechanistic study of in-context learning circuits and their formationcited by 89
- 2022Meaning without reference in large language modelscited by 76
- 2025Language Models Use Trigonometry to Do Additioncited by 70
- 2025Which Attention Heads Matter for In-Context Learning?cited by 61
- 2024Competition Dynamics Shape Algorithmic Phases of In-Context Learningcited by 54
- 2024ICLR: In-Context Learning of Representationscited by 50
- 2024A Mechanistic Analysis of a Transformer Trained on a Symbolic Multi-Step Reasoning Taskcited by 49
- 2024Identifying Semantic Induction Heads to Understand In-Context Learningcited by 47
- 2024NNsight and NDIF: Democratizing Access to Open-Weight Foundation Model Internalscited by 45
- 2024Talking Heads: Understanding Inter-layer Communication in Transformer Language Modelscited by 41
- 2024Loss Landscape Degeneracy and Stagewise Development in Transformerscited by 40
- 2024Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic taskscited by 40
- 2024Pre-trained Large Language Models Use Fourier Features to Compute Additioncited by 39
- 2025Language Models use Lookbacks to Track Beliefscited by 39
- 2024The broader spectrum of in-context learningcited by 35
50 most cited of 71 All 71 (JSON)
Built on by
Citing papers per year: 2026: 5.
5 papers.
- 2026Interpreting and Steering State-Space Models via Activation Subspace Bottleneckscited by 3
- 2026When Symbol Names Should Not Matter: A Logistic Theory of Fresh-Symbol Classificationcited by 0
- 2026Data-Efficient Adaptation of LLMs via Attention Head Reweightingcited by 0
- 2026Causal and Interpretable Structures in LLM Compositional Taskscited by 0
- 2026Conditional Transfer from Controlled Pretraining Mixtures to Codecited by 0
- 2026Conditional Transfer from Controlled Pretraining Mixtures to Code8 Oct 2026
- 2026Causal and Interpretable Structures in LLM Compositional Tasks28 Sep 2026
- 2026Data-Efficient Adaptation of LLMs via Attention Head Reweighting15 Jul 2026
- 2026When Symbol Names Should Not Matter: A Logistic Theory of Fresh-Symbol Classification8 May 2026
- 2026Interpreting and Steering State-Space Models via Activation Subspace Bottlenecks26 Feb 2026
Similar, not cited
Close in wording, no citation either way
- 2026To See the Unseen: on the Generalization Ability of Transformers in Symbolic Reasoning
- 2024Unraveling Arithmetic in Large Language Models: The Role of Algebraic Structures
- 2025Tokenization Constraints in LLMs: A Study of Symbolic and Arithmetic Reasoning Limits
- 2024Grokked Transformers are Implicit Reasoners: A Mechanistic Journey to the Edge of Generalization
- 2026The Geometry of Logic: Stratification Induces Semantic Structure and Robust Reasoning
- 2025How do Transformers Learn Implicit Reasoning?
- 2026Artificial Intelligence for Mathematical Reasoning: An Integrated Survey of Language Models, Neuro-symbolic Systems, and Verified Discovery
- 2025Semantic Deception: When Reasoning Models Can't Compute an Addition