Lune

ICML2023Top-tier venue

Transformers as Algorithms: Generalization and Stability in In-context Learning

Yingcong Li, Muhammed Emrullah Ildiz, Dimitris Papailiopoulos, Samet Oymak

Abstract

In-context learning (ICL) is a type of prompting where a transformer model operates on a sequence of (input, output) examples and performs inference on-the-fly. In this work, we formalize in-context learning as an algorithm learning problem where a transformer model implicitly constructs a hypothesis function at inference-time. We first explore the statistical aspects of this abstraction through the lens of multitask learning: We obtain generalization bounds for ICL when the input prompt is (1) a sequence of i.i.d. (input, label) pairs or (2) a trajectory arising from a dynamical system. The crux of our analysis is relating the excess risk to the stability of the algorithm implemented by the transformer. We characterize when transformer/attention architecture provably obeys the stability condition and also provide empirical verification. For generalization on unseen tasks, we identify an inductive bias phenomenon in which the transfer learning risk is governed by the task complexity and the number of MTL tasks in a highly predictable manner. Finally, we provide numerical evaluations that (1) demonstrate transformers can indeed implement near-optimal algorithms on classical regression problems with i.i.d. and dynamic data, (2) provide insights on stability, and (3) verify our theoretical predictions.

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.

127 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

  • Function Vectors in Large Language Models cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • Function Vectors in Large Language Models cites Language Models are Few-Shot Learners
  • Function Vectors in Large Language Models cites Transformers Learn In-Context by Gradient Descent
  • Function Vectors in Large Language Models cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • In-context Convergence of Transformers cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • In-context Convergence of Transformers cites Language Models are Few-Shot Learners
  • In-context Convergence of Transformers cites Transformers Learn In-Context by Gradient Descent
  • In-context Convergence of Transformers cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • Understanding Catastrophic Forgetting in Language Models via Implicit Inference cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • Understanding Catastrophic Forgetting in Language Models via Implicit Inference cites Transformers Learn In-Context by Gradient Descent
  • Understanding Catastrophic Forgetting in Language Models via Implicit Inference 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
  • The Evolution of Statistical Induction Heads: In-Context Learning Markov Chains cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • The Evolution of Statistical Induction Heads: In-Context Learning Markov Chains cites Language Models are Few-Shot Learners
  • The Evolution of Statistical Induction Heads: In-Context Learning Markov Chains cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning Tasks cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning Tasks cites Language Models are Few-Shot Learners
  • Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning Tasks cites Transformers Learn In-Context by Gradient Descent
  • Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning Tasks 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 papers127

  1. Function Vectors in Large Language ModelsEric Todd, Millicent L. Li, Arnab Sen Sharma, Aaron Mueller et al.ICLR 2024 · 229 citations
  2. The Evolution of Statistical Induction Heads: In-Context Learning Markov ChainsEzra Edelman, Nikolaos Tsilivis, Benjamin L. Edelman, Eran Malach et al.NeurIPS 2024 · 140 citations
  3. Understanding Catastrophic Forgetting in Language Models via Implicit InferenceSuhas Kotha, Jacob Mitchell Springer, Aditi RaghunathanICLR 2024 · 131 citations
  4. Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning TasksJongho Park, Jaeseung Park, Zheyang Xiong, Nayoung Lee et al.ICML 2024 · 124 citations
  5. In-context Convergence of TransformersYu Huang, Yuan Cheng, Yingbin LiangICML 2024 · 114 citations

Builds on17

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. An Explanation of In-context Learning as Implicit Bayesian InferenceSang Michael Xie, Aditi Raghunathan, Percy Liang, Tengyu MaICLR 2022 · 1,030 citations
  3. What Can Transformers Learn In-Context? A Case Study of Simple Function ClassesShivam Garg, Dimitris Tsipras, Percy Liang, Gregory ValiantNeurIPS 2022 · 883 citations
  4. Transformers Learn In-Context by Gradient DescentJohannes von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento et al.ICML 2023 · 729 citations
  5. On the Theory of Transfer Learning: The Importance of Task DiversityNilesh Tripuraneni, Michael I. Jordan, Chi JinNeurIPS 2020 · 263 citations

Related papers

  1. 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
  2. In-Context Learning with Representations: Contextual Generalization of Trained TransformersTong Yang, Yu Huang, Yingbin Liang, Yuejie ChiNeurIPS 2024 · 45 citations
  3. 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
  4. In-Context Learning through the Bayesian PrismMadhur Panwar, Kabir Ahuja, Navin GoyalICLR 2024 · 79 citations
  5. Transformers are Minimax Optimal Nonparametric In-Context LearnersJuno Kim, Tai Nakamaki, Taiji SuzukiNeurIPS 2024 · 42 citations
Dusk over the sea between two cliffs drawn in fine vertical lines