mlsanityData to 7 Oct 2026

What and How does In-Context Learning Learn? Bayesian Model Averaging, Parameterization, and Generalization

arXiv 2305.19420 ↗First posted 30 May 2023stat.ML cs.LGcited by 112

Not on the map. Why?

Abstract (arXiv)

In this paper, we conduct a comprehensive study of In-Context Learning (ICL) by addressing several open questions: (a) What type of ICL estimator is learned by large language models? (b) What is a proper performance metric for ICL and what is the error rate? (c) How does the transformer architecture enable ICL? To answer these questions, we adopt a Bayesian view and formulate ICL as a problem of predicting the response corresponding to the current covariate, given a number of examples drawn from a latent variable model. To answer (a), we show that, without updating the neural network parameters, ICL implicitly implements the Bayesian model averaging algorithm, which is proven to be approximately parameterized by the attention mechanism. For (b), we analyze the ICL performance from an online learning perspective and establish a O(1/T) regret bound for perfectly pretrained ICL, where T is the number of examples in the prompt. To answer (c), we show that, in addition to encoding Bayesian model averaging via attention, the transformer architecture also enables a fine-grained statistical analysis of pretraining under realistic assumptions. In particular, we prove that the error of pretrained model is bounded by a sum of an approximation error and a generalization error, where the former decays to zero exponentially as the depth grows, and the latter decays to zero sublinearly with the number of tokens in the pretraining dataset. Our results provide a unified understanding of the transformer and its ICL ability with bounds on ICL regret, approximation, and generalization, which deepens our knowledge of these essential aspects of modern language models.

Key facts. Cited by 112 papers in the map (data through 7 Oct 2026). Builds on 54 of its 76 references that are in the map. First posted on arXiv 30 May 2023.

Builds on

54 of 76 references.

References · 54

  1. 2017Attention Is All You Needcited by 59,932
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  3. 2021Learning Transferable Visual Models From Natural Language Supervisioncited by 33,456
  4. 2020Language Models are Few-Shot Learnerscited by 32,199
  5. 2022Training language models to follow instructions with human feedbackcited by 15,712
  6. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
  7. 2022Large Language Models are Zero-Shot Reasonerscited by 4,323
  8. 2021Finetuned Language Models Are Zero-Shot Learnerscited by 3,747
  9. 2022Self-Instruct: Aligning Language Models with Self-Generated Instructionscited by 2,674
  10. 2022Emergent Abilities of Large Language Modelscited by 2,483
  11. 2021Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processingcited by 2,222
  12. 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,413
38 more
  1. 2022Least-to-Most Prompting Enables Complex Reasoning in Large Language Modelscited by 1,397
  2. 2017Deep Setscited by 1,394
  3. 2021What Makes Good In-Context Examples for GPT-3?cited by 1,184
  4. 2019TinyBERT: Distilling BERT for Natural Language Understandingcited by 1,153
  5. 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,122
  6. 2022Large Language Models Are Human-Level Prompt Engineerscited by 1,020
  7. 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
  8. 2019Are Sixteen Heads Really Better than One?cited by 803
  9. 2022Transformers learn in-context by gradient descentcited by 714
  10. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
  11. 2022Automatic Chain of Thought Prompting in Large Language Modelscited by 684
  12. 2017Spectrally-normalized margin bounds for neural networkscited by 681
  13. 2018MINE: Mutual Information Neural Estimationcited by 680
  14. 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
  15. 2019Unified Language Model Pre-training for Natural Language Understanding and Generationcited by 668
  16. 2021Learning To Retrieve Prompts for In-Context Learningcited by 641
  17. 2016Error bounds for approximations with deep ReLU networkscited by 567
  18. 2021MetaICL: Learning to Learn In Contextcited by 450
  19. 2019Are Transformers universal approximators of sequence-to-sequence functions?cited by 404
  20. 2017A PAC-Bayesian Approach to Spectrally-Normalized Margin Bounds for Neural Networkscited by 309
  21. 2023Towards Revealing the Mystery behind Chain of Thought: A Theoretical Perspectivecited by 293
  22. 2022OPT-IML: Scaling Language Model Instruction Meta Learning through the Lens of Generalizationcited by 235
  23. 2020FLAMBE: Structural Complexity and Representation Learning of Low Rank MDPscited by 232
  24. 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 220
  25. 2020Rethinking Positional Encoding in Language Pre-trainingcited by 197
  26. 2022Instruction Induction: From Few Examples to Natural Language Task Descriptionscited by 152
  27. 2021Inductive Biases and Variable Creation in Self-Attention Mechanismscited by 144
  28. 2020Tensor Programs II: Neural Tangent Kernel for Any Architecturecited by 139
  29. 2022Signal Propagation in Transformers: Theoretical Perspectives and the Role of Rank Collapsecited by 136
  30. 2023The Learnability of In-Context Learningcited by 126
  31. 2022A Kernel-Based View of Language Model Fine-Tuningcited by 118
  32. 2020Infinite attention: NNGP and NTK for deep attention networkscited by 117
  33. 2021Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformerscited by 101
  34. 2019Deep Neural Network Approximation Theorycited by 92
  35. 2023A Theory of Emergent In-Context Learning as Implicit Structure Inductioncited by 86
  36. 2020A PAC-Bayesian Approach to Generalization Bounds for Graph Neural Networkscited by 84
  37. 2022Self-Generated In-Context Learning: Leveraging Auto-regressive Language Models as a Demonstration Generatorcited by 68
  38. 2020A Mathematical Theory of Attentioncited by 43

50 most cited of 54 All 54 (JSON)

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2023: 16; 2024: 37; 2025: 31; 2026: 28.

112 papers.

Sort:

By area:

  1. 2023Trained Transformers Learn Linear Models In-Contextcited by 331
  2. 2023Function Vectors in Large Language Modelscited by 292
  3. 2023In-Context Convergence of Transformerscited by 112
  4. 2023Are Emergent Abilities in Large Language Models just In-Context Learning?cited by 109
  5. 2025A Survey of Frontiers in LLM Reasoning: Inference Scaling, Learning to Reason, and Agentic Systemscited by 108
  6. 2023Should we be going MAD? A Look at Multi-Agent Debate Strategies for LLMscited by 103
  7. 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 93
  8. 2024Position: Graph Foundation Models are Already Herecited by 84
  9. 2024Can large language models explore in-context?cited by 75
  10. 2023How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representationscited by 72
  11. 2025Test-time regression: a unifying framework for designing sequence models with associative memorycited by 63
  12. 2024Is In-Context Learning in Large Language Models Bayesian? A Martingale Perspectivecited by 51
38 more
  1. 2023Let Models Speak Ciphers: Multiagent Debate through Embeddingscited by 49
  2. 2023In-Context Learning Learns Label Relationships but Is Not Conventional Learningcited by 48
  3. 2023Reason for Future, Act for Now: A Principled Framework for Autonomous LLM Agents with Provable Sample Efficiencycited by 46
  4. 2024Transformers Learn Nonlinear Features In Context: Nonconvex Mean-field Dynamics on the Attention Landscapecited by 43
  5. 2024A Theoretical Understanding of Self-Correction through In-context Alignmentcited by 43
  6. 2024An Information-Theoretic Analysis of In-Context Learningcited by 39
  7. 2024In-Context Learning with Representations: Contextual Generalization of Trained Transformerscited by 36
  8. 2023The Mystery of In-Context Learning: A Comprehensive Survey on Interpretation and Analysiscited by 34
  9. 2024Do LLM Agents Have Regret? A Case Study in Online Learning and Gamescited by 33
  10. 2024Large Language Models as Markov Chainscited by 33
  11. 2024Pretrained transformer efficiently learns low-dimensional target functions in-contextcited by 29
  12. 2024Deciphering the Factors Influencing the Efficacy of Chain-of-Thought: Probability, Memorization, and Noisy Reasoningcited by 27
  13. 2024Unveiling the Statistical Foundations of Chain-of-Thought Prompting Methodscited by 27
  14. 2024Mind the Inconspicuous: Revealing the Hidden Weakness in Aligned LLMs' Refusal Boundariescited by 26
  15. 2025From Debate to Equilibrium: Belief-Driven Multi-Agent LLM Reasoning via Bayesian Nash Equilibriumcited by 24
  16. 2025Belief Dynamics Reveal the Dual Nature of In-Context Learning and Activation Steeringcited by 24
  17. 2024Can In-context Learning Really Generalize to Out-of-distribution Tasks?cited by 23
  18. 2025AURORA:Automated Training Framework of Universal Process Reward Models via Ensemble Prompting and Reverse Verificationcited by 22
  19. 2024Estimating the Hallucination Rate of Generative AIcited by 20
  20. 2025LongSpec: Long-Context Lossless Speculative Decoding with Efficient Drafting and Verificationcited by 19
  21. 2025Enough Coin Flips Can Make LLMs Act Bayesiancited by 19
  22. 2024Bayesian scaling laws for in-context learningcited by 18
  23. 2023Trainable Transformer in Transformercited by 17
  24. 2025In-Context Learning Is Provably Bayesian Inference: A Generalization Theory for Meta-Learningcited by 17
  25. 2024LLMs as Models for Analogical Reasoningcited by 16
  26. 2023Towards Understanding How Transformers Learn In-context Through a Representation Learning Lenscited by 15
  27. 2024On the Training Convergence of Transformers for In-Context Classification of Gaussian Mixturescited by 15
  28. 2025A Theoretical Perspective: How to Prevent Model Collapse in Self-consuming Training Loopscited by 15
  29. 2025Toward Efficient Exploration by Large Language Model Agentscited by 15
  30. 2023In-Context Learning Dynamics with Random Binary Sequencescited by 13
  31. 2024Everything Everywhere All at Once: LLMs can In-Context Learn Multiple Tasks in Superpositioncited by 13
  32. 2024A Survey to Recent Progress Towards Understanding In-Context Learningcited by 12
  33. 2024LightTransfer: Your Long-Context LLM is Secretly a Hybrid Model with Effortless Adaptationcited by 11
  34. 2025Learning Task Representations from In-Context Learningcited by 11
  35. 2024Dissecting the Interplay of Attention Paths in a Statistical Mechanics Theory of Transformerscited by 9
  36. 2024Training Dynamics of Transformers to Recognize Word Co-occurrence via Gradient Flow Analysiscited by 8
  37. 2023Gen-Z: Generative Zero-Shot Text Classification with Contextualized Label Descriptionscited by 7
  38. 2024Rectifying Demonstration Shortcut in In-Context Learningcited by 7

50 most cited of 112 All 112 (JSON)