Can In-context Learning Really Generalize to Out-of-distribution Tasks?
Not on the map. Why?
Abstract (arXiv)
In this work, we explore the mechanism of in-context learning (ICL) on out-of-distribution (OOD) tasks that were not encountered during training. To achieve this, we conduct synthetic experiments where the objective is to learn OOD mathematical functions through ICL using a GPT-2 model. We reveal that Transformers may struggle to learn OOD task functions through ICL. Specifically, ICL performance resembles implementing a function within the pretraining hypothesis space and optimizing it with gradient descent based on the in-context examples. Additionally, we investigate ICL's well-documented ability to learn unseen abstract labels in context. We demonstrate that such ability only manifests in the scenarios without distributional shifts and, therefore, may not serve as evidence of new-task-learning ability. Furthermore, we assess ICL's performance on OOD tasks when the model is pretrained on multiple tasks. Both empirical and theoretical analyses demonstrate the existence of the low-test-error preference of ICL, where it tends to implement the pretraining function that yields low test error in the testing context. We validate this through numerical experiments. This new theoretical result, combined with our empirical findings, elucidates the mechanism of ICL in addressing OOD tasks.
Key facts. Cited by 23 papers in the map (data through 7 Oct 2026). Builds on 34 of its 38 references that are in the map. First posted on arXiv 13 Oct 2024.
Builds on
34 of 38 references.
References · 34
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2023GPT-4 Technical Reportcited by 18,132
- 2024The Llama 3 Herd of Modelscited by 14,192
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 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
- 2023Trained Transformers Learn Linear Models In-Contextcited by 331
- 2023Function Vectors in Large Language Modelscited by 292
- 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 291
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 274
22 more
- 2023Label Words are Anchors: An Information Flow Perspective for Understanding In-Context Learningcited by 235
- 2023What In-Context Learning "Learns" In-Context: Disentangling Task Recognition and Task Learningcited by 149
- 2023Pretraining task diversity and the emergence of non-Bayesian in-context learning for regressioncited by 138
- 2023The Learnability of In-Context Learningcited by 126
- 2024The Evolution of Statistical Induction Heads: In-Context Learning Markov Chainscited by 115
- 2023What and How does In-Context Learning Learn? Bayesian Model Averaging, Parameterization, and Generalizationcited by 112
- 2023In-Context Convergence of Transformerscited by 112
- 2024What needs to go right for an induction head? A mechanistic study of in-context learning circuits and their formationcited by 86
- 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examplescited by 55
- 2023In-Context Learning Learns Label Relationships but Is Not Conventional Learningcited by 48
- 2024Identifying Semantic Induction Heads to Understand In-Context Learningcited by 46
- 2024Induction Heads as an Essential Mechanism for Pattern Matching in In-context Learningcited by 46
- 2023Pretraining Data Mixtures Enable Narrow Model Selection Capabilities in Transformer Modelscited by 45
- 2024A Theoretical Understanding of Self-Correction through In-context Alignmentcited by 43
- 2024Dual Operating Modes of In-Context Learningcited by 42
- 2019More Data Can Hurt for Linear Regression: Sample-wise Double Descentcited by 37
- 2024How Do Nonlinear Transformers Learn and Generalize in In-Context Learning?cited by 35
- 2024Out-of-distribution generalization via composition: a lens through induction heads in Transformerscited by 28
- 2023A Closer Look at In-Context Learning under Distribution Shiftscited by 25
- 2024In-Context Learning with Transformers: Softmax Attention Adapts to Function Lipschitznesscited by 22
- 2024How do Large Language Models Learn In-Context? Query and Key Matrices of In-Context Heads are Two Towers for Metric Learningcited by 18
- 2024On Mesa-Optimization in Autoregressively Trained Transformers: Emergence and Capabilitycited by 5
Built on by
Citing papers per year: 2025: 11; 2026: 12.
23 papers.
Sort:
By area:
- 2025Is Chain-of-Thought Reasoning of LLMs a Mirage? A Data Distribution Lenscited by 42
- 2025Train Once, Reuse Everywhere: Generalizable Implicit In-Context Learning by Routing Attentioncited by 8
- 2025Out-of-Distribution Generalization of In-Context Learning: A Low-Dimensional Subspace Perspectivecited by 5
- 2025Can GRPO Help LLMs Transcend Their Pretraining Origin?cited by 5
- 2025A Theoretical Framework for OOD Robustness in Transformers using Gevrey Classescited by 4
- 2025Retrieval-Augmented Generation as Noisy In-Context Learning: A Unified Theory and Risk Boundscited by 2
- 2025InPhyRe Discovers: Large Multimodal Models Struggle in Inductive Physical Reasoningcited by 2
- 2025Review of Hallucination Understanding in Large Language and Vision Modelscited by 2
- 2026Bifrost: Steering Strategic Trajectories to Bridge Contextual Gaps for Self-Improving Agentscited by 2
- 2026Large language models reorganize representational geometry during in-context learningcited by 2
- 2025Binary Autoencoder for Mechanistic Interpretability of Large Language Modelscited by 1
- 2025Learning Linear Regression with Low-Rank Tasks in-Contextcited by 1
11 more
- 2026SAE as a Crystal Ball: Interpretable Features Predict Cross-domain Transferability of LLMs without Trainingcited by 1
- 2026Harnessing Synthetic Data from Generative AI for Statistical Inferencecited by 1
- 2026Can AI Scientist Agents Learn from Lab-in-the-Loop Feedback? Evidence from Iterative Perturbation Discoverycited by 1
- 2025Can Transformers Break Encryption Schemes via In-Context Learning?cited by 0
- 2026When Looks Do Not Lie: Discourse Structure Guided In-Context Learning for Faithful Diagram Generationcited by 0
- 2026Toward Robust In-Context Learning: Leveraging Out-of-distribution Proxies for Target Inaccessible Demonstration Retrievalcited by 0
- 2026The Effect of Training Task Diversity on In-Context Learning through the Lens of Low-Dimensional Subspacescited by 0
- 2026The Generalization Spectrum: A Chromatographic Approach to Evaluating Learning Algorithmscited by 0
- 2026A Unified Framework for In-Context Learning with Causal and Masked Language Modelscited by 0
- 2026A Minimal Interpretable Architecture for Zero-Shot Reconstruction of Dynamical Systemscited 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
- 2026A Minimal Interpretable Architecture for Zero-Shot Reconstruction of Dynamical Systems16 Jul 2026
- 2026A Unified Framework for In-Context Learning with Causal and Masked Language Models5 Jul 2026
- 2026The Generalization Spectrum: A Chromatographic Approach to Evaluating Learning Algorithms24 Jun 2026
- 2026The Effect of Training Task Diversity on In-Context Learning through the Lens of Low-Dimensional Subspaces5 Jun 2026
- 2026Large language models reorganize representational geometry during in-context learning16 May 2026
- 2026Toward Robust In-Context Learning: Leveraging Out-of-distribution Proxies for Target Inaccessible Demonstration Retrieval13 Apr 2026
- 2026Can AI Scientist Agents Learn from Lab-in-the-Loop Feedback? Evidence from Iterative Perturbation Discovery27 Mar 2026
- 2026Harnessing Synthetic Data from Generative AI for Statistical Inference5 Mar 2026
- 2026SAE as a Crystal Ball: Interpretable Features Predict Cross-domain Transferability of LLMs without Training3 Mar 2026
- 2026Bifrost: Steering Strategic Trajectories to Bridge Contextual Gaps for Self-Improving Agents5 Feb 2026
- 2026When Looks Do Not Lie: Discourse Structure Guided In-Context Learning for Faithful Diagram Generation28 Jan 2026
11 more
- 2025Can GRPO Help LLMs Transcend Their Pretraining Origin?14 Oct 2025
- 2025Learning Linear Regression with Low-Rank Tasks in-Context6 Oct 2025
- 2025Review of Hallucination Understanding in Large Language and Vision Models26 Sep 2025
- 2025Train Once, Reuse Everywhere: Generalizable Implicit In-Context Learning by Routing Attention26 Sep 2025
- 2025Binary Autoencoder for Mechanistic Interpretability of Large Language Models25 Sep 2025
- 2025InPhyRe Discovers: Large Multimodal Models Struggle in Inductive Physical Reasoning12 Sep 2025
- 2025Can Transformers Break Encryption Schemes via In-Context Learning?13 Aug 2025
- 2025Is Chain-of-Thought Reasoning of LLMs a Mirage? A Data Distribution Lens2 Aug 2025
- 2025Retrieval-Augmented Generation as Noisy In-Context Learning: A Unified Theory and Risk Bounds3 Jun 2025
- 2025Out-of-Distribution Generalization of In-Context Learning: A Low-Dimensional Subspace Perspective20 May 2025
- 2025A Theoretical Framework for OOD Robustness in Transformers using Gevrey Classes17 Apr 2025
- 2025Train Once, Reuse Everywhere: Generalizable Implicit In-Context Learning by Routing Attentioncited by 8
- 2025Out-of-Distribution Generalization of In-Context Learning: A Low-Dimensional Subspace Perspectivecited by 5
- 2025A Theoretical Framework for OOD Robustness in Transformers using Gevrey Classescited by 4
- 2025Review of Hallucination Understanding in Large Language and Vision Modelscited by 2
- 2026Large language models reorganize representational geometry during in-context learningcited by 2
- 2025Binary Autoencoder for Mechanistic Interpretability of Large Language Modelscited by 1
- 2025Learning Linear Regression with Low-Rank Tasks in-Contextcited by 1
- 2026SAE as a Crystal Ball: Interpretable Features Predict Cross-domain Transferability of LLMs without Trainingcited by 1
- 2026Harnessing Synthetic Data from Generative AI for Statistical Inferencecited by 1
- 2025Can Transformers Break Encryption Schemes via In-Context Learning?cited by 0
- 2026When Looks Do Not Lie: Discourse Structure Guided In-Context Learning for Faithful Diagram Generationcited by 0
- 2026Toward Robust In-Context Learning: Leveraging Out-of-distribution Proxies for Target Inaccessible Demonstration Retrievalcited by 0
12 most cited of 17 All 17 (JSON)
- 2026Theory on Attention Dynamics for Out-of-Distribution In-Context Learning29 Sep 2026
- 2026A Minimal Interpretable Architecture for Zero-Shot Reconstruction of Dynamical Systems16 Jul 2026
- 2026A Unified Framework for In-Context Learning with Causal and Masked Language Models5 Jul 2026
- 2026The Generalization Spectrum: A Chromatographic Approach to Evaluating Learning Algorithms24 Jun 2026
- 2026The Effect of Training Task Diversity on In-Context Learning through the Lens of Low-Dimensional Subspaces5 Jun 2026
- 2026Large language models reorganize representational geometry during in-context learning16 May 2026
- 2026Toward Robust In-Context Learning: Leveraging Out-of-distribution Proxies for Target Inaccessible Demonstration Retrieval13 Apr 2026
- 2026Harnessing Synthetic Data from Generative AI for Statistical Inference5 Mar 2026
- 2026SAE as a Crystal Ball: Interpretable Features Predict Cross-domain Transferability of LLMs without Training3 Mar 2026
- 2026When Looks Do Not Lie: Discourse Structure Guided In-Context Learning for Faithful Diagram Generation28 Jan 2026
- 2025Learning Linear Regression with Low-Rank Tasks in-Context6 Oct 2025
- 2025Review of Hallucination Understanding in Large Language and Vision Models26 Sep 2025
12 newest of 17 All 17 (JSON)