Learning Task Representations from In-Context Learning
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) have demonstrated remarkable proficiency in in-context learning (ICL), where models adapt to new tasks through example-based prompts without requiring parameter updates. However, understanding how tasks are internally encoded and generalized remains a challenge. To address some of the empirical and technical gaps in the literature, we introduce an automated formulation for encoding task information in ICL prompts as a function of attention heads within the transformer architecture. This approach computes a single task vector as a weighted sum of attention heads, with the weights optimized causally via gradient descent. Our findings show that existing methods fail to generalize effectively to modalities beyond text. In response, we also design a benchmark to evaluate whether a task vector can preserve task fidelity in functional regression tasks. The proposed method successfully extracts task-specific information from in-context demonstrations and excels in both text and regression tasks, demonstrating its generalizability across modalities.
Key facts. Cited by 11 papers in the map (data through 14 Oct 2026). Builds on 49 of its 78 references that are in the map. First posted on arXiv 8 Feb 2025.
Builds on
49 of 78 references.
References · 49
- 2017Attention Is All You Needcited by 60,361
- 2014Adam: A Method for Stochastic Optimizationcited by 37,240
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2022Locating and Editing Factual Associations in GPTcited by 2,691
- 2015Character-level Convolutional Networks for Text Classificationcited by 2,330
- 2018CommonsenseQA: A Question Answering Challenge Targeting Commonsense Knowledgecited by 1,822
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,434
- 2023Inference-Time Intervention: Eliciting Truthful Answers from a Language Modelcited by 1,302
- 2022Editing Models with Task Arithmeticcited by 1,120
- 2023Steering Llama 2 via Contrastive Activation Additioncited by 1,085
- 2019What Does BERT Look At? An Analysis of BERT's Attentioncited by 1,003
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 938
37 more
- 2019Attention is not Explanationcited by 929
- 2019Analyzing Multi-Head Self-Attention: Specialized Heads Do the Heavy Lifting, the Rest Can Be Prunedcited by 856
- 2022Transformers learn in-context by gradient descentcited by 732
- 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
- 2019Attention is not not Explanationcited by 636
- 2023Dissecting Recall of Factual Associations in Auto-Regressive Language Modelscited by 528
- 2017Word Translation Without Parallel Datacited by 487
- 2023Larger language models do in-context learning differentlycited by 394
- 2023Learning to Compress Prompts with Gist Tokenscited by 390
- 2023In-Context Learning Creates Task Vectorscited by 312
- 2019Revealing the Dark Secrets of BERTcited by 301
- 2013Direct and Indirect Effectscited by 280
- 2023In-context Vectors: Making In Context Learning More Effective and Controllable Through Latent Space Steeringcited by 245
- 2023Label Words are Anchors: An Information Flow Perspective for Understanding In-Context Learningcited by 236
- 2022Extracting Latent Steering Vectors from Pretrained Language Modelscited by 225
- 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 222
- 2019Visualizing and Measuring the Geometry of BERTcited by 216
- 2023Linearity of Relation Decoding in Transformer Language Modelscited by 200
- 2022Instruction Induction: From Few Examples to Natural Language Task Descriptionscited by 152
- 2023What In-Context Learning "Learns" In-Context: Disentangling Task Recognition and Task Learningcited by 152
- 2023Large Language Models Are Latent Variable Models: Explaining and Finding Good Demonstrations for In-Context Learningcited by 149
- 2023The Learnability of In-Context Learningcited by 127
- 2019Open Sesame: Getting Inside BERT's Linguistic Knowledgecited by 120
- 2023What and How does In-Context Learning Learn? Bayesian Model Averaging, Parameterization, and Generalizationcited by 118
- 2022Ground-Truth Labels Matter: A Deeper Look into Input-Label Demonstrationscited by 116
- 2023Task-Specific Skill Localization in Fine-tuned Language Modelscited by 105
- 2023Language Models Implement Simple Word2Vec-style Vector Arithmeticcited by 98
- 2018Context-Aware Neural Machine Translation Learns Anaphora Resolutioncited by 97
- 2019Do Attention Heads in BERT Track Syntactic Dependencies?cited by 88
- 2023Overthinking the Truth: Understanding how Language Models Process False Demonstrationscited by 81
- 2022Finding Skill Neurons in Pre-trained Transformer-based Language Modelscited by 66
- 2019Learning to Make Analogies by Contrasting Abstract Relational Structurecited by 53
- 2017Distinguishing Antonyms and Synonyms in a Pattern-based Neural Networkcited by 19
- 2023Dissecting Chain-of-Thought: Compositionality through In-Context Filtering and Learningcited by 19
- 2024In-Context Learning State Vector with Inner and Momentum Optimizationcited by 15
- 2024From Unstructured Data to In-Context Learning: Exploring What Tasks Can Be Learned and Whencited by 3
Built on by
Citing papers per year: 2025: 7; 2026: 4.
11 papers.
- 2025Large Language Models Encode Semantics and Alignment in Linearly Separable Representationscited by 17
- 2025Do different prompting methods yield a common task representation in language models?cited by 11
- 2025Internal Chain-of-Thought: Empirical Evidence for Layer-wise Subtask Scheduling in LLMscited by 9
- 2025Just-in-time and distributed task representations in language modelscited by 9
- 2025Schema for In-Context Learningcited by 4
- 2025Transmuting prompts into weightscited by 3
- 2025Beyond Plain Demos: A Demo-centric Anchoring Paradigm for In-Context Learning in Alzheimer's Disease Detectioncited by 0
- 2026Distributional Alignment as a Criterion for Designing Task Vectors in In-Context Learningcited by 0
- 2026Self-Improving In-Context Learningcited by 0
- 2026Efficient Task Adaptation in Large Language Models: A Survey of Weight-Based, Prompt-Based, and Embedding-Based Adaptationscited by 0
- 2026Capturing In-Context Learning Dynamics with Task Operatorscited by 0
- 2026Capturing In-Context Learning Dynamics with Task Operators1 Oct 2026
- 2026Efficient Task Adaptation in Large Language Models: A Survey of Weight-Based, Prompt-Based, and Embedding-Based Adaptations1 Oct 2026
- 2026Self-Improving In-Context Learning22 May 2026
- 2026Distributional Alignment as a Criterion for Designing Task Vectors in In-Context Learning20 May 2026
- 2025Beyond Plain Demos: A Demo-centric Anchoring Paradigm for In-Context Learning in Alzheimer's Disease Detection10 Nov 2025
- 2025Schema for In-Context Learning14 Oct 2025
- 2025Transmuting prompts into weights9 Oct 2025
- 2025Just-in-time and distributed task representations in language models28 Aug 2025
- 2025Large Language Models Encode Semantics and Alignment in Linearly Separable Representations13 Jul 2025
- 2025Internal Chain-of-Thought: Empirical Evidence for Layer-wise Subtask Scheduling in LLMs20 May 2025
- 2025Do different prompting methods yield a common task representation in language models?17 May 2025