Emergence and Effectiveness of Task Vectors in In-Context Learning: An Encoder Decoder Perspective
Not on the map. Why?
Abstract (arXiv)
Autoregressive transformers exhibit adaptive learning through in-context learning (ICL), which begs the question of how. Prior works have shown that transformers represent the ICL tasks as vectors in their representations. In this paper, we leverage the encoding-decoding framework to study how transformers form task vectors during pretraining and how their task encoding quality predicts ICL task performance. On synthetic ICL tasks, we analyze the training dynamics of a small transformer and report the coupled emergence of task encoding and decoding. As the model learns to encode different latent tasks (e.g., "Finding the first noun in a sentence.") into distinct, separable representations, it concurrently builds conditional decoding algorithms and improves its ICL performance. We validate this phenomenon across pretrained models of varying scales (Gemma-2 2B/9B/27B, Llama-3.1 8B/70B) and over the course of pretraining in OLMo-7B. Further, we demonstrate that the quality of task encoding inferred from representations predicts ICL performance, and that, surprisingly, finetuning the earlier layers can improve the task encoding and performance more than finetuning the latter layers. Our empirical insights shed light into better understanding the success and failure modes of large language models via their representations.
Key facts. Cited by 9 papers in the map (data through 13 Oct 2026). Builds on 42 of its 57 references that are in the map. First posted on arXiv 16 Dec 2024.
Builds on
42 of 57 references.
References · 42
- 2020Language Models are Few-Shot Learnerscited by 32,320
- 2023Mamba: Linear-Time Sequence Modeling with Selective State Spacescited by 4,658
- 2020The Pile: An 800GB Dataset of Diverse Text for Language Modelingcited by 2,379
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 1,994
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,424
- 2023Sparse Autoencoders Find Highly Interpretable Features in Language Modelscited by 1,391
- 2016Understanding intermediate layers using linear classifier probescited by 1,313
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 925
- 2022Fine-Tuning can Distort Pretrained Features and Underperform Out-of-Distributioncited by 732
- 2022Transformers learn in-context by gradient descentcited by 720
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 706
- 2023The Geometry of Truth: Emergent Linear Structure in Large Language Model Representations of True/False Datasetscited by 693
30 more
- 2024Dolma: an Open Corpus of Three Trillion Tokens for Language Model Pretraining Researchcited by 477
- 2023In-Context Learning Creates Task Vectorscited by 305
- 2023Function Vectors in Large Language Modelscited by 299
- 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 293
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 276
- 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 221
- 2024How to use and interpret activation patchingcited by 202
- 2020Causal Mediation Analysis for Interpreting Neural NLP: The Case of Gender Biascited by 187
- 2023Take a Step Back: Evoking Reasoning via Abstraction in Large Language Modelscited by 158
- 2023Large Language Models Are Latent Variable Models: Explaining and Finding Good Demonstrations for In-Context Learningcited by 149
- 2022Impact of Pretraining Term Frequencies on Few-Shot Reasoningcited by 142
- 2023Pretraining task diversity and the emergence of non-Bayesian in-context learning for regressioncited by 138
- 2023Circuit Component Reuse Across Tasks in Transformer Language Modelscited by 105
- 2023Language Models Implement Simple Word2Vec-style Vector Arithmeticcited by 98
- 2023Phenomenal Yet Puzzling: Testing Inductive Reasoning Capabilities of Language Models with Hypothesis Refinementcited by 89
- 2024In-Context Language Learning: Architectures and Algorithmscited by 88
- 2024Truth is Universal: Robust Detection of Lies in LLMscited by 79
- 2022Discovering Latent Concepts Learned in BERTcited by 56
- 2024Value Augmented Sampling for Language Model Alignment and Personalizationcited by 49
- 2024Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic taskscited by 40
- 2022Prompting Language Models for Linguistic Structurecited by 39
- 2024Emergence of Hidden Capabilities: Exploring Learning Dynamics in Concept Spacecited by 34
- 2024Not All LLM Reasoners Are Created Equalcited by 30
- 2023Prompting Frameworks for Large Language Models: A Surveycited by 29
- 2024Refusal in LLMs is an Affine Functioncited by 28
- 2024Does learning the right latent variables necessarily improve in-context learning?cited by 13
- 2024Abstraction-of-Thought Makes Language Models Better Reasonerscited by 11
- 2020On Convergence of Nearest Neighbor Classifiers over Feature Transformationscited by 7
- 2024Comparing Abstraction in Humans and Large Language Models Using Multimodal Serial Reproductioncited by 2
- 2024Why does in-context learning fail sometimes? Evaluating in-context learning on open and closed questionscited by 2
Built on by
Citing papers per year: 2025: 2; 2026: 7.
9 papers.
- 2026Training Language Models via Neural Cellular Automatacited by 15
- 2025Do different prompting methods yield a common task representation in language models?cited by 9
- 2026Causality neq Invariance: Function and Concept Vectors in LLMscited by 8
- 2025Task Vectors, Learned Not Extracted: Performance Gains and Mechanistic Insightcited by 3
- 2026Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledgecited by 2
- 2026Reconciling In-Context and In-Weight Learning via Dual Representation Space Encodingcited by 0
- 2026Distributional Alignment as a Criterion for Designing Task Vectors in In-Context Learningcited by 0
- 2026Few-Shot Demonstrations Elicit the Use of In-Context World Representations in LLMscited by 0
- 2026Capturing In-Context Learning Dynamics with Task Operatorscited by 0
- 2026Capturing In-Context Learning Dynamics with Task Operators1 Oct 2026
- 2026Few-Shot Demonstrations Elicit the Use of In-Context World Representations in LLMs21 Sep 2026
- 2026Distributional Alignment as a Criterion for Designing Task Vectors in In-Context Learning20 May 2026
- 2026Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledge21 Mar 2026
- 2026Reconciling In-Context and In-Weight Learning via Dual Representation Space Encoding13 Mar 2026
- 2026Training Language Models via Neural Cellular Automata9 Mar 2026
- 2026Causality neq Invariance: Function and Concept Vectors in LLMs25 Feb 2026
- 2025Task Vectors, Learned Not Extracted: Performance Gains and Mechanistic Insight29 Sep 2025
- 2025Do different prompting methods yield a common task representation in language models?17 May 2025