Understanding the Generalization of In-Context Learning in Transformers: An Empirical Study
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) like GPT-4 and LLaMA-3 utilize the powerful in-context learning (ICL) capability of Transformer architecture to learn on the fly from limited examples. While ICL underpins many LLM applications, its full potential remains hindered by a limited understanding of its generalization boundaries and vulnerabilities. We present a systematic investigation of transformers' generalization capability with ICL relative to training data coverage by defining a task-centric framework along three dimensions: inter-problem, intra-problem, and intra-task generalization. Through extensive simulation and real-world experiments, encompassing tasks such as function fitting, API calling, and translation, we find that transformers lack inter-problem generalization with ICL, but excel in intra-task and intra-problem generalization. When the training data includes a greater variety of mixed tasks, it significantly enhances the generalization ability of ICL on unseen tasks and even on known simple tasks. This guides us in designing training data to maximize the diversity of tasks covered and to combine different tasks whenever possible, rather than solely focusing on the target task for testing.
Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Builds on 30 of its 34 references that are in the map. First posted on arXiv 19 Mar 2025.
Builds on
30 of 34 references.
References · 30
- 2017Attention Is All You Needcited by 60,361
- 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
- 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,695
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,326
- 2019Unsupervised Cross-lingual Representation Learning at Scalecited by 3,935
- 2021The Power of Scale for Parameter-Efficient Prompt Tuningcited by 3,795
- 2023Qwen Technical Reportcited by 3,344
- 2021Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processingcited by 2,234
- 2023ToolLLM: Facilitating Large Language Models to Master 16000+ Real-world APIscited by 1,947
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,434
18 more
- 2021Calibrate Before Use: Improving Few-Shot Performance of Language Modelscited by 1,392
- 2021What Makes Good In-Context Examples for GPT-3?cited by 1,195
- 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,135
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 938
- 2021Robust fine-tuning of zero-shot modelscited by 797
- 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
- 2021MetaICL: Learning to Learn In Contextcited by 454
- 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 222
- 2022Why Can GPT Learn In-Context? Language Models Implicitly Perform Gradient Descent as Meta-Optimizerscited by 204
- 2023Real-World Humanoid Locomotion with Reinforcement Learningcited by 187
- 2021Meta-learning via Language Model In-context Tuningcited by 164
- 2022On the Relation between Sensitivity and Accuracy in In-context Learningcited by 72
- 2024Humanoid Locomotion as Next Token Predictioncited by 69
- 2023In-context Example Selection with Influencescited by 61
- 2023Pretraining Data Mixtures Enable Narrow Model Selection Capabilities in Transformer Modelscited by 45
- 2023Using In-Context Learning to Improve Dialogue Safetycited by 42
- 2023A Closer Look at In-Context Learning under Distribution Shiftscited by 25
Built on by
Citing papers per year: 2025: 3; 2026: 1.
4 papers.
- 2025Review of Hallucination Understanding in Large Language and Vision Modelscited by 2
- 2025Multi-Layer Attention is the Amplifier of Demonstration Effectivenesscited by 1
- 2025Closing the Curvature Gap: Full Transformer Hessianscited by 0
- 2026Towards Universal Calibration for In-Context Classificationcited by 0
- 2026Towards Universal Calibration for In-Context Classification12 Oct 2026
- 2025Closing the Curvature Gap: Full Transformer Hessians19 Oct 2025
- 2025Review of Hallucination Understanding in Large Language and Vision Models26 Sep 2025
- 2025Multi-Layer Attention is the Amplifier of Demonstration Effectiveness1 Aug 2025