In-Context Learning with Representations: Contextual Generalization of Trained Transformers
Not on the map. Why?
Abstract (arXiv)
In-context learning (ICL) refers to a remarkable capability of pretrained large language models, which can learn a new task given a few examples during inference. However, theoretical understanding of ICL is largely under-explored, particularly whether transformers can be trained to generalize to unseen examples in a prompt, which will require the model to acquire contextual knowledge of the prompt for generalization. This paper investigates the training dynamics of transformers by gradient descent through the lens of non-linear regression tasks. The contextual generalization here can be attained via learning the template function for each task in-context, where all template functions lie in a linear space with m basis functions. We analyze the training dynamics of one-layer multi-head transformers to in-contextly predict unlabeled inputs given partially labeled prompts, where the labels contain Gaussian noise and the number of examples in each prompt are not sufficient to determine the template. Under mild assumptions, we show that the training loss for a one-layer multi-head transformer converges linearly to a global minimum. Moreover, the transformer effectively learns to perform ridge regression over the basis functions. To our knowledge, this study is the first provable demonstration that transformers can learn contextual (i.e., template) information to generalize to both unseen examples and tasks when prompts contain only a small number of query-answer pairs.
Key facts. Cited by 36 papers in the map (data through 7 Oct 2026). Builds on 34 of its 39 references that are in the map. First posted on arXiv 19 Aug 2024.
Builds on
34 of 39 references.
References · 34
- 2017Attention Is All You Needcited by 59,932
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2024Gemini 1.5: Unlocking multimodal understanding across millions of tokens of contextcited by 3,175
- 2022In-context Learning and Induction Headscited by 930
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
- 2022Transformers learn in-context by gradient descentcited by 714
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
- 2016Linear Convergence of Gradient and Proximal-Gradient Methods Under the Polyak-Lojasiewicz Conditioncited by 526
- 2023Larger language models do in-context learning differentlycited by 386
- 2023Trained Transformers Learn Linear Models In-Contextcited by 331
22 more
- 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 291
- 2023Looped Transformers as Programmable Computerscited by 224
- 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 220
- 2022Why Can GPT Learn In-Context? Language Models Implicitly Perform Gradient Descent as Meta-Optimizerscited by 204
- 2024Many-Shot In-Context Learningcited by 203
- 2021Inductive Biases and Variable Creation in Self-Attention Mechanismscited by 144
- 2023The Learnability of In-Context Learningcited by 126
- 2024The Evolution of Statistical Induction Heads: In-Context Learning Markov Chainscited by 115
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 114
- 2023What and How does In-Context Learning Learn? Bayesian Model Averaging, Parameterization, and Generalizationcited by 112
- 2023In-Context Convergence of Transformerscited by 112
- 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 93
- 2023A Theory of Emergent In-Context Learning as Implicit Structure Inductioncited by 86
- 2023In-Context Learning through the Bayesian Prismcited by 78
- 2023How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representationscited by 72
- 2024Training Dynamics of Multi-Head Softmax Attention for In-Context Learning: Emergence, Convergence, and Optimalitycited by 71
- 2020Global Convergence of Deep Networks with One Wide Layer Followed by Pyramidal Topologycited by 66
- 2024Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention Landscapecited by 43
- 2023A Latent Space Theory for Emergent Abilities in Large Language Modelscited by 42
- 2024An Information-Theoretic Analysis of In-Context Learningcited by 39
- 2023On the Optimization and Generalization of Multi-head Attentioncited by 37
- 2024What Can Transformer Learn with Varying Depth? Case Studies on Sequence Learning Taskscited by 19
Built on by
Citing papers per year: 2024: 3; 2025: 21; 2026: 12.
36 papers.
Sort:
By area:
- 2026Preconditioning Benefits of Spectral Orthogonalization in Muoncited by 28
- 2024On the Training Convergence of Transformers for In-Context Classification of Gaussian Mixturescited by 15
- 2025Short-length Adversarial Training Helps LLMs Defend Long-length Jailbreak Attacks: Theoretical and Empirical Evidencecited by 13
- 2025How Transformers Learn Regular Language Recognition: A Theoretical Study on Training Dynamics and Implicit Biascited by 10
- 2024Faster WIND: Accelerating Iterative Best-of-N Distillation for LLM Alignmentcited by 9
- 2025On the Role of Transformer Feed-Forward Layers in Nonlinear In-Context Learningcited by 7
- 2025Decoupling Positional and Symbolic Attention Behavior in Transformerscited by 6
- 2024In-Context Learning of Linear Systems: Generalization Theory and Applications to Operator Learningcited by 5
- 2025Out-of-Distribution Generalization of In-Context Learning: A Low-Dimensional Subspace Perspectivecited by 5
- 2025On the Convergence of Gradient Descent on Learning Transformers with Residual Connectionscited by 5
- 2025When and How Unlabeled Data Provably Improve In-Context Learningcited by 5
- 2025Can LLMs Reason Over Non-Text Modalities in a Training-Free Manner? A Case Study with In-Context Representation Learningcited by 5
24 more
- 2025Transformers Meet In-Context Learning: A Universal Approximation Theorycited by 4
- 2025Provable In-Context Learning of Nonlinear Regression with Transformerscited by 4
- 2025Provable Benefit of Curriculum in Transformer Tree-Reasoning Post-Trainingcited by 4
- 2025SpA2V: Harnessing Spatial Auditory Cues for Audio-driven Spatially-aware Video Generationcited by 2
- 2025On Theoretical Interpretations of Concept-Based In-Context Learningcited by 2
- 2025Review of Hallucination Understanding in Large Language and Vision Modelscited by 2
- 2025How Can Mamba Learn In Context with Outliers and Generalize Provably?cited by 2
- 2025Softmax ≥ Linear: Transformers may learn to classify in-context by kernel gradient descentcited by 2
- 2025Transformers Provably Learn Directed Acyclic Graphs via Kernel-Guided Mutual Informationcited by 2
- 2025In-Context Learning of Linear Dynamical Systems with Transformers: Approximation Bounds and Depth-Separationcited by 1
- 2025Learning-to-Context Slope: Evaluating In-Context Learning Effectiveness Beyond Performance Illusionscited by 1
- 2025Multi-Layer Attention is the Amplifier of Demonstration Effectivenesscited by 1
- 2025In-Context Learning for Non-Stationary MIMO Equalizationcited by 1
- 2026Understanding and Improving Continuous Adversarial Training for LLMs via In-context Learning Theorycited by 1
- 2026When Does Context Help? Error Dynamics of Contextual Information in Large Language Modelscited by 0
- 2026Covariance-Aware Transformers for Quadratic Programming and Decision Makingcited by 0
- 2026Demonstrations, CoT, and Prompting: A Theoretical Analysis of ICLcited by 0
- 2026Learning to Adapt: In-Context Learning Beyond Stationaritycited by 0
- 2026TabQL: In-Context Q-Learning with Tabular Foundation Modelscited by 0
- 2026The Stability of Singular Distribution: A Spectral Perspective on the Two-Phase Dynamics of Language Model Pre-trainingcited by 0
- 2026SCOPE: A Lightweight-training LLM Framework for Air Traffic Control Readback Monitoringcited by 0
- 2026RA-LWLM: Retrieval-Augmented In-Context Localization with Wireless Foundation Modelscited by 0
- 2026On the Capability and Limitation of Hard Promptcited by 0
- 2026Theory on Attention Dynamics for Out-of-Distribution In-Context Learningcited by 0
- 2026Theory on Attention Dynamics for Out-of-Distribution In-Context Learning29 Sep 2026
- 2026On the Capability and Limitation of Hard Prompt26 Sep 2026
- 2026RA-LWLM: Retrieval-Augmented In-Context Localization with Wireless Foundation Models1 Jun 2026
- 2026SCOPE: A Lightweight-training LLM Framework for Air Traffic Control Readback Monitoring28 May 2026
- 2026The Stability of Singular Distribution: A Spectral Perspective on the Two-Phase Dynamics of Language Model Pre-training26 May 2026
- 2026TabQL: In-Context Q-Learning with Tabular Foundation Models18 May 2026
- 2026Understanding and Improving Continuous Adversarial Training for LLMs via In-context Learning Theory14 Apr 2026
- 2026Learning to Adapt: In-Context Learning Beyond Stationarity13 Apr 2026
- 2026Demonstrations, CoT, and Prompting: A Theoretical Analysis of ICL20 Mar 2026
- 2026Covariance-Aware Transformers for Quadratic Programming and Decision Making16 Feb 2026
- 2026When Does Context Help? Error Dynamics of Contextual Information in Large Language Models9 Feb 2026
- 2026Preconditioning Benefits of Spectral Orthogonalization in Muon20 Jan 2026
24 more
- 2025Provable Benefit of Curriculum in Transformer Tree-Reasoning Post-Training10 Nov 2025
- 2025Transformers Provably Learn Directed Acyclic Graphs via Kernel-Guided Mutual Information29 Oct 2025
- 2025Softmax ≥ Linear: Transformers may learn to classify in-context by kernel gradient descent12 Oct 2025
- 2025In-Context Learning for Non-Stationary MIMO Equalization9 Oct 2025
- 2025Decoupling Positional and Symbolic Attention Behavior in Transformers3 Oct 2025
- 2025How Can Mamba Learn In Context with Outliers and Generalize Provably?1 Oct 2025
- 2025Review of Hallucination Understanding in Large Language and Vision Models26 Sep 2025
- 2025On Theoretical Interpretations of Concept-Based In-Context Learning25 Sep 2025
- 2025Can LLMs Reason Over Non-Text Modalities in a Training-Free Manner? A Case Study with In-Context Representation Learning22 Sep 2025
- 2025SpA2V: Harnessing Spatial Auditory Cues for Audio-driven Spatially-aware Video Generation1 Aug 2025
- 2025Multi-Layer Attention is the Amplifier of Demonstration Effectiveness1 Aug 2025
- 2025Provable In-Context Learning of Nonlinear Regression with Transformers28 Jul 2025
- 2025Learning-to-Context Slope: Evaluating In-Context Learning Effectiveness Beyond Performance Illusions29 Jun 2025
- 2025When and How Unlabeled Data Provably Improve In-Context Learning18 Jun 2025
- 2025On the Convergence of Gradient Descent on Learning Transformers with Residual Connections5 Jun 2025
- 2025Transformers Meet In-Context Learning: A Universal Approximation Theory5 Jun 2025
- 2025Out-of-Distribution Generalization of In-Context Learning: A Low-Dimensional Subspace Perspective20 May 2025
- 2025How Transformers Learn Regular Language Recognition: A Theoretical Study on Training Dynamics and Implicit Bias2 May 2025
- 2025In-Context Learning of Linear Dynamical Systems with Transformers: Approximation Bounds and Depth-Separation12 Feb 2025
- 2025Short-length Adversarial Training Helps LLMs Defend Long-length Jailbreak Attacks: Theoretical and Empirical Evidence6 Feb 2025
- 2025On the Role of Transformer Feed-Forward Layers in Nonlinear In-Context Learning30 Jan 2025
- 2024Faster WIND: Accelerating Iterative Best-of-N Distillation for LLM Alignment28 Oct 2024
- 2024On the Training Convergence of Transformers for In-Context Classification of Gaussian Mixtures15 Oct 2024
- 2024In-Context Learning of Linear Systems: Generalization Theory and Applications to Operator Learning18 Sep 2024
- 2026Preconditioning Benefits of Spectral Orthogonalization in Muoncited by 28
- 2024On the Training Convergence of Transformers for In-Context Classification of Gaussian Mixturescited by 15
- 2025How Transformers Learn Regular Language Recognition: A Theoretical Study on Training Dynamics and Implicit Biascited by 10
- 2025On the Role of Transformer Feed-Forward Layers in Nonlinear In-Context Learningcited by 7
- 2025Decoupling Positional and Symbolic Attention Behavior in Transformerscited by 6
- 2024In-Context Learning of Linear Systems: Generalization Theory and Applications to Operator Learningcited by 5
- 2025Out-of-Distribution Generalization of In-Context Learning: A Low-Dimensional Subspace Perspectivecited by 5
- 2025On the Convergence of Gradient Descent on Learning Transformers with Residual Connectionscited by 5
- 2025When and How Unlabeled Data Provably Improve In-Context Learningcited by 5
- 2025Transformers Meet In-Context Learning: A Universal Approximation Theorycited by 4
- 2025Provable In-Context Learning of Nonlinear Regression with Transformerscited by 4
- 2025SpA2V: Harnessing Spatial Auditory Cues for Audio-driven Spatially-aware Video Generationcited by 2
12 most cited of 30 All 30 (JSON)
- 2026Theory on Attention Dynamics for Out-of-Distribution In-Context Learning29 Sep 2026
- 2026On the Capability and Limitation of Hard Prompt26 Sep 2026
- 2026RA-LWLM: Retrieval-Augmented In-Context Localization with Wireless Foundation Models1 Jun 2026
- 2026SCOPE: A Lightweight-training LLM Framework for Air Traffic Control Readback Monitoring28 May 2026
- 2026The Stability of Singular Distribution: A Spectral Perspective on the Two-Phase Dynamics of Language Model Pre-training26 May 2026
- 2026TabQL: In-Context Q-Learning with Tabular Foundation Models18 May 2026
- 2026Learning to Adapt: In-Context Learning Beyond Stationarity13 Apr 2026
- 2026Demonstrations, CoT, and Prompting: A Theoretical Analysis of ICL20 Mar 2026
- 2026Covariance-Aware Transformers for Quadratic Programming and Decision Making16 Feb 2026
- 2026When Does Context Help? Error Dynamics of Contextual Information in Large Language Models9 Feb 2026
- 2026Preconditioning Benefits of Spectral Orthogonalization in Muon20 Jan 2026
- 2025Transformers Provably Learn Directed Acyclic Graphs via Kernel-Guided Mutual Information29 Oct 2025
12 newest of 30 All 30 (JSON)