Understanding In-context Learning of Addition via Activation Subspaces
Not on the map. Why?
Abstract (arXiv)
To perform few-shot learning, language models extract signals from a few input-label pairs, aggregate them into a learned prediction rule, and apply this rule to new inputs. How is this implemented in the forward pass of modern transformer models? To explore this question, we study a structured family of few-shot learning tasks for which the true prediction rule is to add an integer k to the input. We introduce a novel method that localizes the model's few-shot learning ability to only a few attention heads. This method and the findings generalize to four additional task families spanning arithmetic and semantic tasks. We then perform an in-depth analysis of individual heads via dimensionality reduction and decomposition of the heads' output spaces. For example, in Llama-3-8B-Instruct, we reduce the mechanism underlying these tasks to just three attention heads with six-dimensional subspaces, in which four dimensions track the units digit using trigonometric functions with periods 2, 5, and 10, while two dimensions track magnitude using low-frequency components. To deepen our understanding of this mechanism, we also derive a mathematical identity relating the ''aggregator'' and ''extractor'' subspaces of attention heads, allowing us to track the flow of information from individual examples to a final aggregated concept. Our results demonstrate how tracking low-dimensional subspaces of localized heads throughout a forward pass can provide insight into fine-grained computational structures in language models. Our code is available at https://github.com/xyVickyHu/addition-subspaces.
Key facts. Cited by 8 papers in the map (data through 14 Oct 2026). Builds on 46 of its 68 references that are in the map. First posted on arXiv 8 May 2025.
Builds on
46 of 68 references.
References · 46
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2024Qwen2.5 Technical Reportcited by 4,942
- 2022Locating and Editing Factual Associations in GPTcited by 2,691
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,434
- 2023Sparse Autoencoders Find Highly Interpretable Features in Language Modelscited by 1,420
- 2022Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 smallcited by 1,165
- 2023Steering Llama 2 via Contrastive Activation Additioncited by 1,085
- 2019What Does BERT Look At? An Analysis of BERT's Attentioncited by 1,003
- 2023Progress measures for grokking via mechanistic interpretabilitycited by 839
- 2022Transformers learn in-context by gradient descentcited by 732
- 2023The Linear Representation Hypothesis and the Geometry of Large Language Modelscited by 716
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 715
34 more
- 2024Phi-4 Technical Reportcited by 711
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 684
- 2018What you can cram into a single vector: Probing sentence embeddings for linguistic propertiescited by 457
- 2021Causal Abstractions of Neural Networkscited by 422
- 2023Trained Transformers Learn Linear Models In-Contextcited by 337
- 2023In-Context Learning Creates Task Vectorscited by 312
- 2023Function Vectors in Large Language Modelscited by 308
- 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 298
- 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 222
- 2024Not All Language Model Features Are One-Dimensionally Linearcited by 212
- 2023How does GPT-2 compute greater-than?: Interpreting mathematical abilities in a pre-trained language modelcited by 202
- 2023Birth of a Transformer: A Memory Viewpointcited by 161
- 2023The Clock and the Pizza: Two Stories in Mechanistic Explanation of Neural Networkscited by 156
- 2023The mechanistic basis of data dependence and abrupt learning in an in-context classification taskcited by 118
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 118
- 2023How do Language Models Bind Entities in Context?cited by 108
- 2023Interpretability at Scale: Identifying Causal Mechanisms in Alpacacited by 103
- 2024Arithmetic Without Algorithms: Language Models Solve Math With a Bag of Heuristicscited by 97
- 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 96
- 2023A Mechanistic Interpretation of Arithmetic Reasoning in Language Models using Causal Mediation Analysiscited by 89
- 2024What needs to go right for an induction head? A mechanistic study of in-context learning circuits and their formationcited by 89
- 2023Successor Heads: Recurring, Interpretable Attention Heads In The Wildcited by 77
- 2023How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representationscited by 75
- 2025Language Models Use Trigonometry to Do Additioncited by 70
- 2022Rethinking the Role of Scale for In-Context Learning: An Interpretability-based Case Study at 66 Billion Scalecited by 64
- 2025Which Attention Heads Matter for In-Context Learning?cited by 61
- 2024Induction Heads as an Essential Mechanism for Pattern Matching in In-context Learningcited by 46
- 2024Interpreting and Improving Large Language Models in Arithmetic Calculationcited by 45
- 2024Pre-trained Large Language Models Use Fourier Features to Compute Additioncited by 39
- 2024Interpreting the Second-Order Effects of Neurons in CLIPcited by 36
- 2024Language Models Encode Numbers Using Digit Representations in Base 10cited by 32
- 2024Revisiting In-context Learning Inference Circuit in Large Language Modelscited by 17
- 2023Arithmetic with Language Models: from Memorization to Computationcited by 12
- 2025Contextualize-then-Aggregate: Circuits for In-Context Learning in Gemma-2 2Bcited by 10
Built on by
Citing papers per year: 2025: 4; 2026: 4.
8 papers.
- 2026When Models Manipulate Manifolds: The Geometry of a Counting Taskcited by 46
- 2026Language Model Circuits Are Sparse in the Neuron Basiscited by 25
- 2025Decomposing Representation Space into Interpretable Subspaces with Unsupervised Learningcited by 8
- 2025In-Context Algebracited by 5
- 2025Latent Concept Disentanglement in Transformer-based Language Modelscited by 3
- 2026Shattered Compositionality: Counterintuitive Learning Dynamics of Transformers for Arithmeticcited by 3
- 2025Function Induction and Task Generalization: An Interpretability Study with Off-by-One Additioncited by 2
- 2026Are In-Context Images Worth 10 Dimensions?cited by 0
- 2026Are In-Context Images Worth 10 Dimensions?29 Sep 2026
- 2026Language Model Circuits Are Sparse in the Neuron Basis30 Jan 2026
- 2026Shattered Compositionality: Counterintuitive Learning Dynamics of Transformers for Arithmetic30 Jan 2026
- 2026When Models Manipulate Manifolds: The Geometry of a Counting Task8 Jan 2026
- 2025In-Context Algebra18 Dec 2025
- 2025Decomposing Representation Space into Interpretable Subspaces with Unsupervised Learning3 Aug 2025
- 2025Function Induction and Task Generalization: An Interpretability Study with Off-by-One Addition14 Jul 2025
- 2025Latent Concept Disentanglement in Transformer-based Language Models20 Jun 2025