Lune

ICLR2024Top-tier venue

In-Context Learning through the Bayesian Prism

Madhur Panwar, Kabir Ahuja, Navin Goyal

Abstract

In-context learning (ICL) is one of the surprising and useful features of large language models and subject of intense research. Recently, stylized meta-learning-like ICL setups have been devised that train transformers on sequences of input-output pairs (x,f(x))(x, f(x)). The function ff comes from a function class and generalization is checked by evaluating on sequences generated from unseen functions from the same class. One of the main discoveries in this line of research has been that for several function classes, such as linear regression, transformers successfully generalize to new functions in the class. However, the inductive biases of these models resulting in this behavior are not clearly understood. A model with unlimited training data and compute is a Bayesian predictor: it learns the pretraining distribution. In this paper we empirically examine how far this Bayesian perspective can help us understand ICL. To this end, we generalize the previous meta-ICL setup to hierarchical meta-ICL setup which involve unions of multiple task families. We instantiate this setup on a diverse range of linear and nonlinear function families and find that transformers can do ICL in this setting as well. Where Bayesian inference is tractable, we find evidence that high-capacity transformers mimic the Bayesian predictor. The Bayesian perspective provides insights into the inductive bias of ICL and how transformers perform a particular task when they are trained on multiple tasks. We also find that transformers can learn to generalize to new function classes that were not seen during pretraining. This involves deviation from the Bayesian predictor. We examine these deviations in more depth offering new insights and hypotheses.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

27 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation cites Language Models are Few-Shot Learners
  • A Survey on In-context Learning cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • A Survey on In-context Learning cites Language Models are Few-Shot Learners
  • A Survey on In-context Learning cites Transformers Learn In-Context by Gradient Descent
  • A Survey on In-context Learning cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • An Explanation of In-context Learning as Implicit Bayesian Inference cites Language Models are Few-Shot Learners
  • Is In-Context Learning in Large Language Models Bayesian? A Martingale Perspective cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • Is In-Context Learning in Large Language Models Bayesian? A Martingale Perspective cites Language Models are Few-Shot Learners
  • In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initialization cites Language Models are Few-Shot Learners
  • In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initialization cites Transformers can optimally learn regression mixture models
  • In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initialization cites Transformers Learn In-Context by Gradient Descent
  • In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD Initialization cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • Transformers can optimally learn regression mixture models cites Language Models are Few-Shot Learners
  • Transformers can optimally learn regression mixture models cites Transformers Learn In-Context by Gradient Descent
  • Transformers can optimally learn regression mixture models cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • In-Context Learning Strategies Emerge Rationally cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • In-Context Learning Strategies Emerge Rationally cites Is In-Context Learning in Large Language Models Bayesian? A Martingale Perspective
  • In-Context Learning Strategies Emerge Rationally cites Language Models are Few-Shot Learners
  • In-Context Learning Strategies Emerge Rationally cites Transformers Learn In-Context by Gradient Descent
  • In-Context Learning Strategies Emerge Rationally cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • Transformers Learn In-Context by Gradient Descent cites Language Models are Few-Shot Learners
  • Transformers Learn In-Context by Gradient Descent cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • What Can Transformers Learn In-Context? A Case Study of Simple Function Classes cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • What Can Transformers Learn In-Context? A Case Study of Simple Function Classes cites Language Models are Few-Shot Learners
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers27

  1. A Survey on In-context LearningQingxiu Dong, Lei Li, Damai Dai, Ce Zheng et al.EMNLP 2024 · 479 citations
  2. Is In-Context Learning in Large Language Models Bayesian? A Martingale PerspectiveFabian Falck, Ziyu Wang, Christopher C. HolmesICML 2024 · 46 citations
  3. In-Context Learning of a Linear Transformer Block: Benefits of the MLP Component and One-Step GD InitializationRuiqi Zhang, Jingfeng Wu, Peter L. BartlettNeurIPS 2024 · 37 citations
  4. In-Context Learning Strategies Emerge RationallyDaniel Wurgaft, Ekdeep Singh Lubana, Core Francisco Park, Hidenori Tanaka et al.NeurIPS 2025 · 19 citations
  5. Transformers can optimally learn regression mixture modelsReese Pathak, Rajat Sen, Weihao Kong, Abhimanyu DasICLR 2024 · 16 citations

Builds on20

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Train Short, Test Long: Attention with Linear Biases Enables Input Length ExtrapolationOfir Press, Noah A. Smith, Mike LewisICLR 2022 · 1,168 citations
  3. An Explanation of In-context Learning as Implicit Bayesian InferenceSang Michael Xie, Aditi Raghunathan, Percy Liang, Tengyu MaICLR 2022 · 1,030 citations
  4. What Can Transformers Learn In-Context? A Case Study of Simple Function ClassesShivam Garg, Dimitris Tsipras, Percy Liang, Gregory ValiantNeurIPS 2022 · 883 citations
  5. Transformers Learn In-Context by Gradient DescentJohannes von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento et al.ICML 2023 · 729 citations

Related papers

  1. Transformers are Minimax Optimal Nonparametric In-Context LearnersJuno Kim, Tai Nakamaki, Taiji SuzukiNeurIPS 2024 · 42 citations
  2. Pretraining task diversity and the emergence of non-Bayesian in-context learning for regressionAllan Raventós, Mansheej Paul, Feng Chen, Surya GanguliNeurIPS 2023 · 174 citations
  3. When can in-context learning generalize out of task distribution?Page C. Goddard, Lindsay M. Smith, Vudtiwat Ngampruetikorn, David J. SchwabICML 2025
  4. Transformers as Algorithms: Generalization and Stability in In-context LearningYingcong Li, Muhammed Emrullah Ildiz, Dimitris Papailiopoulos, Samet OymakICML 2023 · 242 citations
  5. Technical Debt in In-Context Learning: Diminishing Efficiency in Long ContextTaejong Joo, Diego KlabjanNeurIPS 2025
Dusk over the sea between two cliffs drawn in fine vertical lines