How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representations
Not on the map. Why?
Abstract (arXiv)
While large language models based on the transformer architecture have demonstrated remarkable in-context learning (ICL) capabilities, understandings of such capabilities are still in an early stage, where existing theory and mechanistic understanding focus mostly on simple scenarios such as learning simple function classes. This paper takes initial steps on understanding ICL in more complex scenarios, by studying learning with representations. Concretely, we construct synthetic in-context learning problems with a compositional structure, where the label depends on the input through a possibly complex but fixed representation function, composed with a linear function that differs in each instance. By construction, the optimal ICL algorithm first transforms the inputs by the representation function, and then performs linear ICL on top of the transformed dataset. We show theoretically the existence of transformers that approximately implement such algorithms with mild depth and size. Empirically, we find trained transformers consistently achieve near-optimal ICL performance in this setting, and exhibit the desired dissection where lower layers transforms the dataset and upper layers perform linear ICL. Through extensive probing and a new pasting experiment, we further reveal several mechanisms within the trained transformers, such as concrete copying behaviors on both the inputs and the representations, linear ICL capability of the upper layers alone, and a post-ICL representation selection mechanism in a harder mixture setting. These observed mechanisms align well with our theory and may shed light on how transformers perform ICL in more realistic scenarios.
Key facts. Cited by 75 papers in the map (data through 14 Oct 2026). Builds on 36 of its 42 references that are in the map. First posted on arXiv 16 Oct 2023.
Builds on
36 of 42 references.
References · 36
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2023GPT-4 Technical Reportcited by 18,396
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 13,028
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2022Locating and Editing Factual Associations in GPTcited by 2,691
- 2023Sparks of Artificial General Intelligence: Early experiments with GPT-4cited by 2,592
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,434
- 2021Calibrate Before Use: Improving Few-Shot Performance of Language Modelscited by 1,392
- 2016Understanding intermediate layers using linear classifier probescited by 1,353
- 2021What Makes Good In-Context Examples for GPT-3?cited by 1,195
- 2022Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 smallcited by 1,165
- 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,135
24 more
- 2022In-context Learning and Induction Headscited by 964
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 938
- 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
- 2021Learning To Retrieve Prompts for In-Context Learningcited by 648
- 2014Convex Optimization: Algorithms and Complexitycited by 575
- 2021MetaICL: Learning to Learn In Contextcited by 454
- 2021Causal Abstractions of Neural Networkscited by 422
- 2023Larger language models do in-context learning differentlycited by 394
- 2023Trained Transformers Learn Linear Models In-Contextcited by 337
- 2022Data Distributional Properties Drive Emergent In-Context Learning in Transformerscited by 309
- 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 298
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 279
- 2021Noisy Channel Language Model Prompting for Few-Shot Text Classificationcited by 165
- 2023Birth of a Transformer: A Memory Viewpointcited by 161
- 2023Pretraining task diversity and the emergence of non-Bayesian in-context learning for regressioncited by 146
- 2022Impact of Pretraining Term Frequencies on Few-Shot Reasoningcited by 142
- 2022Toward Transparent AI: A Survey on Interpreting the Inner Structures of Deep Neural Networkscited by 129
- 2023What and How does In-Context Learning Learn? Bayesian Model Averaging, Parameterization, and Generalizationcited by 118
- 2022General-Purpose In-Context Learning by Meta-Learning Transformerscited by 105
- 2023A Study on ReLU and Softmax in Transformercited by 53
- 2023Replacing softmax with ReLU in Vision Transformerscited by 44
- 2023Dissecting Chain-of-Thought: Compositionality through In-Context Filtering and Learningcited by 19
Built on by
Citing papers per year: 2023: 2; 2024: 40; 2025: 21; 2026: 12.
75 papers.
Sort:
By area:
- 2024The Evolution of Statistical Induction Heads: In-Context Learning Markov Chainscited by 118
- 2024Can large language models explore in-context?cited by 76
- 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examplescited by 57
- 2024Active-Dormant Attention Heads: Mechanistically Demystifying Extreme-Token Phenomena in LLMscited by 56
- 2024Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention Landscapecited by 46
- 2024Why Larger Language Models Do In-context Learning Differently?cited by 45
- 2024In-Context Learning with Representations: Contextual Generalization of Trained Transformerscited by 38
- 2024Transformers are Minimax Optimal Nonparametric In-Context Learnerscited by 37
- 2025Bayesian Teaching Enables Probabilistic Reasoning in Large Language Modelscited by 37
- 2024How Do Nonlinear Transformers Learn and Generalize in In-Context Learning?cited by 35
- 2023The Mystery of In-Context Learning: A Comprehensive Survey on Interpretation and Analysiscited by 34
- 2024In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initializationcited by 33
38 more
- 2024Iteration Head: A Mechanistic Study of Chain-of-Thoughtcited by 31
- 2024Pretrained transformer efficiently learns low-dimensional target functions in-contextcited by 31
- 2024A phase transition between positional and semantic learning in a solvable model of dot-product attentioncited by 30
- 2024Linear Transformers are Versatile In-Context Learnerscited by 28
- 2024A Percolation Model of Emergence: Analyzing Transformers Trained on a Formal Languagecited by 26
- 2024How Well Can Transformers Emulate In-context Newton's Method?cited by 25
- 2024In-context Time Series Predictorcited by 23
- 2024In-Context Learning with Transformers: Softmax Attention Adapts to Function Lipschitznesscited by 22
- 2024Bypassing the Exponential Dependency: Looped Transformers Efficiently Learn In-context by Multi-step Gradient Descentcited by 22
- 2025How Do LLMs Perform Two-Hop Reasoning in Context?cited by 20
- 2024What Can Transformer Learn with Varying Depth? Case Studies on Sequence Learning Taskscited by 19
- 2024Understanding the Language Model to Solve the Symbolic Multi-Step Reasoning Problem from the Perspective of Buffer Mechanismcited by 15
- 2024Intrinsic Self-correction for Enhanced Morality: An Analysis of Internal Mechanisms and the Superficial Hypothesiscited by 15
- 2024On the Training Convergence of Transformers for In-Context Classification of Gaussian Mixturescited by 15
- 2024A Survey to Recent Progress Towards Understanding In-Context Learningcited by 14
- 2024Reinforced In-Context Black-Box Optimizationcited by 14
- 2024Transformers Learn Low Sensitivity Functions: Investigations and Implicationscited by 14
- 2024How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regressioncited by 14
- 2024Training Nonlinear Transformers for Chain-of-Thought Inference: A Theoretical Generalization Analysiscited by 14
- 2025Formalizing Learning from Language Feedback with Provable Guaranteescited by 13
- 2024AlgoFormer: An Efficient Transformer Framework with Algorithmic Structurescited by 11
- 2025Solving Empirical Bayes via Transformerscited by 11
- 2025Talk to Your Slides: High-Efficiency Slide Editing via Language-Driven Structured Data Manipulationcited by 11
- 2025From Condensation to Rank Collapse: A Two-Stage Analysis of Transformer Training Dynamicscited by 10
- 2024Dissecting the Interplay of Attention Paths in a Statistical Mechanics Theory of Transformerscited by 9
- 2023Transformers are Provably Optimal In-context Estimators for Wireless Communicationscited by 8
- 2025Understanding In-context Learning of Addition via Activation Subspacescited by 8
- 2025On the Role of Transformer Feed-Forward Layers in Nonlinear In-Context Learningcited by 7
- 2024In-Context Learning of Linear Systems: Generalization Theory and Applications to Operator Learningcited by 6
- 2024Context-Scaling versus Task-Scaling in In-Context Learningcited by 6
- 2025Transformers Meet In-Context Learning: A Universal Approximation Theorycited by 6
- 2026Outcome-Based RL Provably Leads Transformers to Reason, but Only With the Right Datacited by 6
- 2024Task Diversity Shortens the ICL Plateaucited by 5
- 2024Global Convergence in Training Large-Scale Transformerscited by 5
- 2025In-Context Learning of Linear Dynamical Systems with Transformers: Approximation Bounds and Depth-Separationcited by 4
- 2025CoT-ICL Lab: A Synthetic Framework for Studying Chain-of-Thought Learning from In-Context Demonstrationscited by 4
- 2025On the Robustness of Transformers against Context Hijacking for Linear Classificationcited by 4
- 2025Improving Model Representation and Reducing KV Cache via Skip Connections with First Value Headscited by 4
50 most cited of 75 All 75 (JSON)
- 2026Retrieval-Based In-Context Learning: A Domain Adaptation Framework5 Oct 2026
- 2026Theory on Attention Dynamics for Out-of-Distribution In-Context Learning29 Sep 2026
- 2026Cross-lingual Functional Vectors for Emotion Detection in Large Language Models30 Aug 2026
- 2026Identifiability and Order-Dimension Limits of In-Context Learning on Partial Orders14 Aug 2026
- 2026Do Neural Networks Preserve Case Structure? Case-Based Decomposition, Interpretation, and Decision Consistency13 Jul 2026
- 2026Looped Transformers with Layer Normalization Provably Learn the Power Method30 May 2026
- 2026In-Context Learning Operates as Concept Subspace Learning12 May 2026
- 2026Transformers Efficiently Perform In-Context Logistic Regression via Normalized Gradient Descent7 May 2026
- 2026Understanding In-Context Learning for Nonlinear Regression with Transformers: Attention as Featurizer6 May 2026
- 2026Reconciling In-Context and In-Weight Learning via Dual Representation Space Encoding13 Mar 2026
- 2026Learning Nonlinear Systems In-Context: From Synthetic Data to Real-World Motor Control6 Feb 2026
- 2026Outcome-Based RL Provably Leads Transformers to Reason, but Only With the Right Data21 Jan 2026
38 more
- 2025Can Language Models Compose Skills In-Context?27 Oct 2025
- 2025Optimality and NP-Hardness of Transformers in Learning Markovian Dynamical Functions21 Oct 2025
- 2025Improving Model Representation and Reducing KV Cache via Skip Connections with First Value Heads19 Oct 2025
- 2025From Condensation to Rank Collapse: A Two-Stage Analysis of Transformer Training Dynamics8 Oct 2025
- 2025Achilles' Heel of Mamba: Essential difficulties of the Mamba architecture demonstrated by synthetic data22 Sep 2025
- 2025Towards Theoretical Understanding of Transformer Test-Time Computing: Investigation on In-Context Linear Regression11 Aug 2025
- 2025Assessing the Limits of In-Context Learning beyond Functions using Partially Ordered Relation16 Jun 2025
- 2025Brewing Knowledge in Context: Distillation Perspectives on In-Context Learning13 Jun 2025
- 2025Formalizing Learning from Language Feedback with Provable Guarantees12 Jun 2025
- 2025Transformers Meet In-Context Learning: A Universal Approximation Theory5 Jun 2025
- 2025Transformers as Multi-task Learners: Decoupling Features in Hidden Markov Models2 Jun 2025
- 2025Talk to Your Slides: High-Efficiency Slide Editing via Language-Driven Structured Data Manipulation16 May 2025
- 2025Understanding In-context Learning of Addition via Activation Subspaces8 May 2025
- 2025Bayesian Teaching Enables Probabilistic Reasoning in Large Language Models21 Mar 2025
- 2025In-Context Learning with Hypothesis-Class Guidance27 Feb 2025
- 2025On the Robustness of Transformers against Context Hijacking for Linear Classification21 Feb 2025
- 2025CoT-ICL Lab: A Synthetic Framework for Studying Chain-of-Thought Learning from In-Context Demonstrations21 Feb 2025
- 2025How Do LLMs Perform Two-Hop Reasoning in Context?19 Feb 2025
- 2025Solving Empirical Bayes via Transformers14 Feb 2025
- 2025In-Context Learning of Linear Dynamical Systems with Transformers: Approximation Bounds and Depth-Separation12 Feb 2025
- 2025On the Role of Transformer Feed-Forward Layers in Nonlinear In-Context Learning30 Jan 2025
- 2024Can Custom Models Learn In-Context? An Exploration of Hybrid Architecture Performance on In-Context Learning Tasks6 Nov 2024
- 2024Pretrained transformer efficiently learns low-dimensional target functions in-context4 Nov 2024
- 2024Global Convergence in Training Large-Scale Transformers31 Oct 2024
- 2024Active-Dormant Attention Heads: Mechanistically Demystifying Extreme-Token Phenomena in LLMs17 Oct 2024
- 2024Context-Scaling versus Task-Scaling in In-Context Learning16 Oct 2024
- 2024On the Training Convergence of Transformers for In-Context Classification of Gaussian Mixtures15 Oct 2024
- 2024Bypassing the Exponential Dependency: Looped Transformers Efficiently Learn In-context by Multi-step Gradient Descent15 Oct 2024
- 2024Transformers as Game Players: Provable In-context Game-playing Capabilities of Pre-trained Models13 Oct 2024
- 2024Task Diversity Shortens the ICL Plateau7 Oct 2024
- 2024Training Nonlinear Transformers for Chain-of-Thought Inference: A Theoretical Generalization Analysis3 Oct 2024
- 2024In-Context Learning of Linear Systems: Generalization Theory and Applications to Operator Learning18 Sep 2024
- 2024A Percolation Model of Emergence: Analyzing Transformers Trained on a Formal Language22 Aug 2024
- 2024Transformers are Minimax Optimal Nonparametric In-Context Learners22 Aug 2024
- 2024In-Context Learning with Representations: Contextual Generalization of Trained Transformers19 Aug 2024
- 2024How Transformers Utilize Multi-Head Attention in In-Context Learning? A Case Study on Sparse Linear Regression8 Aug 2024
- 2024Intrinsic Self-correction for Enhanced Morality: An Analysis of Internal Mechanisms and the Superficial Hypothesis21 Jul 2024
- 2024Iteration Head: A Mechanistic Study of Chain-of-Thought4 Jun 2024
50 newest of 75 All 75 (JSON)
- 2025Bayesian Teaching Enables Probabilistic Reasoning in Large Language Modelscited by 37
- 2024Iteration Head: A Mechanistic Study of Chain-of-Thoughtcited by 31
- 2025How Do LLMs Perform Two-Hop Reasoning in Context?cited by 20
- 2024Understanding the Language Model to Solve the Symbolic Multi-Step Reasoning Problem from the Perspective of Buffer Mechanismcited by 15
- 2024Training Nonlinear Transformers for Chain-of-Thought Inference: A Theoretical Generalization Analysiscited by 14
- 2026Outcome-Based RL Provably Leads Transformers to Reason, but Only With the Right Datacited by 6
- 2025CoT-ICL Lab: A Synthetic Framework for Studying Chain-of-Thought Learning from In-Context Demonstrationscited by 4
- 2026Outcome-Based RL Provably Leads Transformers to Reason, but Only With the Right Data21 Jan 2026
- 2025Bayesian Teaching Enables Probabilistic Reasoning in Large Language Models21 Mar 2025
- 2025CoT-ICL Lab: A Synthetic Framework for Studying Chain-of-Thought Learning from In-Context Demonstrations21 Feb 2025
- 2025How Do LLMs Perform Two-Hop Reasoning in Context?19 Feb 2025
- 2024Training Nonlinear Transformers for Chain-of-Thought Inference: A Theoretical Generalization Analysis3 Oct 2024
- 2024Iteration Head: A Mechanistic Study of Chain-of-Thought4 Jun 2024
- 2024Understanding the Language Model to Solve the Symbolic Multi-Step Reasoning Problem from the Perspective of Buffer Mechanism24 May 2024
- 2024The Evolution of Statistical Induction Heads: In-Context Learning Markov Chainscited by 118
- 2024Can large language models explore in-context?cited by 76
- 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examplescited by 57
- 2024Active-Dormant Attention Heads: Mechanistically Demystifying Extreme-Token Phenomena in LLMscited by 56
- 2024Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention Landscapecited by 46
- 2024Why Larger Language Models Do In-context Learning Differently?cited by 45
- 2024In-Context Learning with Representations: Contextual Generalization of Trained Transformerscited by 38
- 2024Transformers are Minimax Optimal Nonparametric In-Context Learnerscited by 37
- 2024How Do Nonlinear Transformers Learn and Generalize in In-Context Learning?cited by 35
- 2023The Mystery of In-Context Learning: A Comprehensive Survey on Interpretation and Analysiscited by 34
- 2024In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initializationcited by 33
- 2024Pretrained transformer efficiently learns low-dimensional target functions in-contextcited by 31
12 most cited of 64 All 64 (JSON)
- 2026Retrieval-Based In-Context Learning: A Domain Adaptation Framework5 Oct 2026
- 2026Theory on Attention Dynamics for Out-of-Distribution In-Context Learning29 Sep 2026
- 2026Cross-lingual Functional Vectors for Emotion Detection in Large Language Models30 Aug 2026
- 2026Identifiability and Order-Dimension Limits of In-Context Learning on Partial Orders14 Aug 2026
- 2026Do Neural Networks Preserve Case Structure? Case-Based Decomposition, Interpretation, and Decision Consistency13 Jul 2026
- 2026Looped Transformers with Layer Normalization Provably Learn the Power Method30 May 2026
- 2026In-Context Learning Operates as Concept Subspace Learning12 May 2026
- 2026Transformers Efficiently Perform In-Context Logistic Regression via Normalized Gradient Descent7 May 2026
- 2026Understanding In-Context Learning for Nonlinear Regression with Transformers: Attention as Featurizer6 May 2026
- 2026Reconciling In-Context and In-Weight Learning via Dual Representation Space Encoding13 Mar 2026
- 2025Can Language Models Compose Skills In-Context?27 Oct 2025
- 2025Optimality and NP-Hardness of Transformers in Learning Markovian Dynamical Functions21 Oct 2025
12 newest of 64 All 64 (JSON)