Contextualize-then-Aggregate: Circuits for In-Context Learning in Gemma-2 2B
Not on the map. Why?
Abstract (arXiv)
In-Context Learning (ICL) is an intriguing ability of large language models (LLMs). Despite a substantial amount of work on its behavioral aspects and how it emerges in miniature setups, it remains unclear which mechanism assembles task information from the individual examples in a fewshot prompt. We use causal interventions to identify information flow in Gemma-2 2B for five naturalistic ICL tasks. We find that the model infers task information using a two-step strategy we call contextualize-then-aggregate: In the lower layers, the model builds up representations of individual fewshot examples, which are contextualized by preceding examples through connections between fewshot input and output tokens across the sequence. In the higher layers, these representations are aggregated to identify the task and prepare prediction of the next output. The importance of the contextualization step differs between tasks, and it may become more important in the presence of ambiguous examples. Overall, by providing rigorous causal analysis, our results shed light on the mechanisms through which ICL happens in language models.
Key facts. Cited by 10 papers in the map (data through 14 Oct 2026). Builds on 25 of its 37 references that are in the map. First posted on arXiv 31 Mar 2025.
Builds on
25 of 37 references.
References · 25
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2022Locating and Editing Factual Associations in GPTcited by 2,691
- 2024Gemma 2: Improving Open Language Models at a Practical Sizecited by 1,998
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,434
- 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
- 2019Are Sixteen Heads Really Better than One?cited by 816
- 2022Transformers learn in-context by gradient descentcited by 732
- 2023Towards Automated Circuit Discovery for Mechanistic Interpretabilitycited by 724
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 715
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 684
- 2021Causal Abstractions of Neural Networkscited by 422
13 more
- 2023In-Context Learning Creates Task Vectorscited by 312
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 279
- 2023Label Words are Anchors: An Information Flow Perspective for Understanding In-Context Learningcited by 236
- 2023Attribution Patching Outperforms Automated Circuit Discoverycited by 209
- 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 170
- 2024Have Faith in Faithfulness: Going Beyond Circuit Overlap When Finding Model Mechanismscited by 149
- 2023The Learnability of In-Context Learningcited by 127
- 2024Information Flow Routes: Automatically Interpreting Language Models at Scalecited by 95
- 2023A Theory of Emergent In-Context Learning as Implicit Structure Inductioncited by 86
- 2022Rethinking the Role of Scale for In-Context Learning: An Interpretability-based Case Study at 66 Billion Scalecited by 64
- 2024Induction Heads as an Essential Mechanism for Pattern Matching in In-context Learningcited by 46
- 2024Linear Transformers are Versatile In-Context Learnerscited by 28
- 2024How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regressioncited by 14
Built on by
Citing papers per year: 2025: 6; 2026: 4.
10 papers.
- 2025Just-in-time and distributed task representations in language modelscited by 9
- 2025Understanding In-context Learning of Addition via Activation Subspacescited by 8
- 2025Decomposing Representation Space into Interpretable Subspaces with Unsupervised Learningcited by 8
- 2026Causality neq Invariance: Function and Concept Vectors in LLMscited by 8
- 2025Born a Transformer -- Always a Transformer? On the Effect of Pretraining on Architectural Abilitiescited by 6
- 2025Discursive Circuits: How Do Language Models Understand Discourse Relations?cited by 4
- 2025Latent Concept Disentanglement in Transformer-based Language Modelscited by 3
- 2026Emergent Structured Representations Support Flexible In-Context Inference in Large Language Modelscited by 0
- 2026Symmetry Reveals Layerwise Dynamics: How Transformers Perform In-Context Classificationcited by 0
- 2026Are In-Context Images Worth 10 Dimensions?cited by 0
- 2026Are In-Context Images Worth 10 Dimensions?29 Sep 2026
- 2026Symmetry Reveals Layerwise Dynamics: How Transformers Perform In-Context Classification13 Apr 2026
- 2026Causality neq Invariance: Function and Concept Vectors in LLMs25 Feb 2026
- 2026Emergent Structured Representations Support Flexible In-Context Inference in Large Language Models8 Feb 2026
- 2025Discursive Circuits: How Do Language Models Understand Discourse Relations?13 Oct 2025
- 2025Just-in-time and distributed task representations in language models28 Aug 2025
- 2025Decomposing Representation Space into Interpretable Subspaces with Unsupervised Learning3 Aug 2025
- 2025Latent Concept Disentanglement in Transformer-based Language Models20 Jun 2025
- 2025Born a Transformer -- Always a Transformer? On the Effect of Pretraining on Architectural Abilities27 May 2025
- 2025Understanding In-context Learning of Addition via Activation Subspaces8 May 2025