Lune

NeurIPS2023Top-tier venue

Pretraining task diversity and the emergence of non-Bayesian in-context learning for regression

Allan Raventós, Mansheej Paul, Feng Chen, Surya Ganguli

Abstract

Pretrained transformers exhibit the remarkable ability of in-context learning (ICL): they can learn tasks from just a few examples provided in the prompt without updating any weights. This raises a foundational question: can ICL solve fundamentally new\textit{new} tasks that are very different from those seen during pretraining? To probe this question, we examine ICL's performance on linear regression while varying the diversity of tasks in the pretraining dataset. We empirically demonstrate a task diversity threshold\textit{task diversity threshold} for the emergence of ICL. Below this threshold, the pretrained transformer cannot solve unseen regression tasks as it behaves like a Bayesian estimator with the non-diverse pretraining task distribution\textit{non-diverse pretraining task distribution} as the prior. Beyond this threshold, the transformer significantly outperforms this estimator; its behavior aligns with that of ridge regression, corresponding to a Gaussian prior over all tasks\textit{all tasks}, including those not seen during pretraining. These results highlight that, when pretrained on data with task diversity greater than the threshold, transformers can\textit{can} solve fundamentally new tasks in-context. Importantly, this capability hinges on it deviating from the Bayes optimal estimator with the pretraining distribution as the prior. This study underscores, in a concrete example, the critical role of task diversity, alongside data and model scale, in the emergence of ICL. Code is available at https://github.com/mansheej/icl-task-diversity.

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.

67 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

  • A Benchmark for Learning to Translate a New Language from One Grammar Book cites Multitask Prompted Training Enables Zero-Shot Task Generalization
  • A Benchmark for Learning to Translate a New Language from One Grammar Book cites Language Models are Few-Shot Learners
  • A Benchmark for Learning to Translate a New Language from One Grammar Book cites Finetuned Language Models are Zero-Shot Learners
  • A Benchmark for Learning to Translate a New Language from One Grammar Book cites Training language models to follow instructions with human feedback
  • Multitask Prompted Training Enables Zero-Shot Task Generalization cites Language Models are Few-Shot Learners
  • Multitask Prompted Training Enables Zero-Shot Task Generalization cites Finetuned Language Models are Zero-Shot Learners
  • Finetuned Language Models are Zero-Shot Learners cites Multitask Prompted Training Enables Zero-Shot Task Generalization
  • 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
  • An Explanation of In-context Learning as Implicit Bayesian Inference cites Multitask Prompted Training Enables Zero-Shot Task Generalization
  • An Explanation of In-context Learning as Implicit Bayesian Inference cites Language Models are Few-Shot Learners
  • An Explanation of In-context Learning as Implicit Bayesian Inference cites Finetuned Language Models are Zero-Shot Learners
  • Can large language models explore in-context? cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • Can large language models explore in-context? cites How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?
  • Can large language models explore in-context? cites Language Models are Few-Shot Learners
  • Can large language models explore in-context? cites How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representations
  • How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression? cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression? cites Language Models are Few-Shot Learners
  • Finetuned Language Models are Zero-Shot Learners cites Language Models are Few-Shot Learners
  • Finetuned Language Models are Zero-Shot Learners cites Training language models to follow instructions with human feedback
  • Training language models to follow instructions with human feedback cites Finetuned Language Models are Zero-Shot Learners
  • Training language models to follow instructions with human feedback cites Multitask Prompted Training Enables Zero-Shot Task Generalization
  • Training language models to follow instructions with human feedback cites Language Models are Few-Shot Learners
  • How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representations cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representations cites Language Models are Few-Shot Learners
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers67

  1. A Survey on In-context LearningQingxiu Dong, Lei Li, Damai Dai, Ce Zheng et al.EMNLP 2024 · 479 citations
  2. A Benchmark for Learning to Translate a New Language from One Grammar BookGarrett Tanzer, Mirac Suzgun, Eline Visser, Dan Jurafsky et al.ICLR 2024 · 97 citations
  3. Can large language models explore in-context?Akshay Krishnamurthy, Keegan Harris, Dylan J. Foster, Cyril Zhang et al.NeurIPS 2024 · 95 citations
  4. How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?Jingfeng Wu, Difan Zou, Zixiang Chen, Vladimir Braverman et al.ICLR 2024 · 94 citations
  5. How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with RepresentationsTianyu Guo, Wei Hu, Song Mei, Huan Wang et al.ICLR 2024 · 80 citations

Builds on16

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Training language models to follow instructions with human feedbackLong Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida et al.NeurIPS 2022 · 24,707 citations
  3. Finetuned Language Models are Zero-Shot LearnersJason Wei, Maarten Bosma, Vincent Y. Zhao, Kelvin Guu et al.ICLR 2022 · 4,966 citations
  4. Multitask Prompted Training Enables Zero-Shot Task GeneralizationVictor Sanh, Albert Webson, Colin Raffel, Stephen H. Bach et al.ICLR 2022 · 1,976 citations
  5. An Explanation of In-context Learning as Implicit Bayesian InferenceSang Michael Xie, Aditi Raghunathan, Percy Liang, Tengyu MaICLR 2022 · 1,030 citations

Related papers

  1. When can in-context learning generalize out of task distribution?Page C. Goddard, Lindsay M. Smith, Vudtiwat Ngampruetikorn, David J. SchwabICML 2025
  2. In-Context Learning through the Bayesian PrismMadhur Panwar, Kabir Ahuja, Navin GoyalICLR 2024 · 79 citations
  3. Pretrain–Test Task Alignment Governs Generalization in In-Context LearningMary Letey, Jacob A Zavatone-Veth, Yue M. Lu, Cengiz PehlevanICLR 2026 · 6 citations
  4. Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm SelectionYu Bai, Fan Chen, Huan Wang, Caiming Xiong et al.NeurIPS 2023 · 356 citations
  5. In-Context Learning with Representations: Contextual Generalization of Trained TransformersTong Yang, Yu Huang, Yingbin Liang, Yuejie ChiNeurIPS 2024 · 45 citations
Dusk over the sea between two cliffs drawn in fine vertical lines