Theory on Attention Dynamics for Out-of-Distribution In-Context Learning
Not on the map. Why?
Abstract (arXiv)
Transformers have demonstrated remarkable in-context learning (ICL) capabilities, enabling them to perform new tasks without additional fine-tuning. However, their performance often deteriorates when encountering out-of-distribution (OOD) inputs that deviate from the training distribution, and the underlying theory remains poorly understood. To fill this gap, we characterize the OOD error under the input distribution shift through the interplay between the dynamics of the so-called α-type and β-type attention weights, which represent the transformer's confidence in identifying the correct and incorrect features, respectively. Our results indicate that the OOD error for each feature depends on all pairwise interactions between the training features and OOD features, and under certain cases the transformer performs no better than random guessing. To improve the OOD generalization performance, we next investigate the impact of model finetuning with the OOD data, and particularly, characterize the model forgetting performance on the source domain. Interestingly, the performance on the source domain may not always degrade after finetuning, which highly depends on the nature of the feature shift: finetuning on OOD domain keeps enhancing the confidence of identifying correct features from the original distribution, while the interference from other incorrect features may either increase or decrease. Extensive experiments on both synthetic and real data are conducted to corroborate the theoretical insights.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Builds on 61 of its 73 references that are in the map. First posted on arXiv 29 Sep 2026.
Builds on
61 of 73 references.
References · 61
- 2017Attention Is All You Needcited by 60,361
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2020The Many Faces of Robustness: A Critical Analysis of Out-of-Distribution Generalizationcited by 1,850
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,434
- 2022In-context Learning and Induction Headscited by 964
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 938
- 2023A Comprehensive Survey of Continual Learning: Theory, Method and Applicationcited by 872
- 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
- 2023Larger language models do in-context learning differentlycited by 394
- 2023Trained Transformers Learn Linear Models In-Contextcited by 337
38 more
- 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
- 2020Pretrained Transformers Improve Out-of-Distribution Robustnesscited by 294
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 279
- 2023Looped Transformers as Programmable Computerscited by 237
- 2022Why Can GPT Learn In-Context? Language Models Implicitly Perform Gradient Descent as Meta-Optimizerscited by 204
- 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 170
- 2021CDTrans: Cross-domain Transformer for Unsupervised Domain Adaptationcited by 129
- 2024In-Context Learning with Long-Context Models: An In-Depth Explorationcited by 128
- 2023The Learnability of In-Context Learningcited by 127
- 2023What and How does In-Context Learning Learn? Bayesian Model Averaging, Parameterization, and Generalizationcited by 118
- 2024How Transformers Learn Causal Structure with Gradient Descentcited by 118
- 2023In-Context Convergence of Transformerscited by 115
- 2024Revisiting Catastrophic Forgetting in Large Language Model Tuningcited by 99
- 2023A Theory of Emergent In-Context Learning as Implicit Structure Inductioncited by 86
- 2021Delving Deep into the Generalization of Vision Transformers under Distribution Shiftscited by 85
- 2023In-Context Learning through the Bayesian Prismcited by 83
- 2023How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representationscited by 75
- 2024Training Dynamics of Multi-Head Softmax Attention for In-Context Learning: Emergence, Convergence, and Optimalitycited by 74
- 2022Safe Self-Refinement for Transformer-based Domain Adaptationcited by 61
- 2024Unveiling Induction Heads: Provable Training Dynamics and Feature Learning in Transformerscited by 50
- 2023A Latent Space Theory for Emergent Abilities in Large Language Modelscited by 43
- 2024An Information-Theoretic Analysis of In-Context Learningcited by 40
- 2024In-Context Learning with Representations: Contextual Generalization of Trained Transformerscited by 38
- 2024On the Out-Of-Distribution Generalization of Multimodal Large Language Modelscited by 30
- 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
- 2022On the Compositional Generalization Gap of In-Context Learningcited by 24
- 2024Can In-context Learning Really Generalize to Out-of-distribution Tasks?cited by 23
- 2024In-Context Learning with Transformers: Softmax Attention Adapts to Function Lipschitznesscited by 22
- 2024Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannotcited by 22
- 2024Probing the Decision Boundaries of In-context Learning in Large Language Modelscited by 17
- 2024One-Layer Transformer Provably Learns One-Nearest Neighbor In Contextcited by 16
- 2025When can in-context learning generalize out of task distribution?cited by 16
- 2023Towards Understanding How Transformers Learn In-context Through a Representation Learning Lenscited by 15
- 2024Trained Transformer Classifiers Generalize and Exhibit Benign Overfitting In-Contextcited by 15
- 2024On the Training Convergence of Transformers for In-Context Classification of Gaussian Mixturescited by 15
- 2025Understanding In-Context Learning on Structured Manifolds: Bridging Attention to Kernel Methodscited by 15
50 most cited of 61 All 61 (JSON)
Built on by
Not cited yet.