Transformers are Minimax Optimal Nonparametric In-Context Learners
Juno Kim, Tai Nakamaki, Taiji Suzuki
Abstract
In-context learning (ICL) of large language models has proven to be a surprisingly effective method of learning a new task from only a few demonstrative examples. In this paper, we study the efficacy of ICL from the viewpoint of statistical learning theory. We develop approximation and generalization error bounds for a transformer composed of a deep neural network and one linear attention layer, pretrained on nonparametric regression tasks sampled from general function spaces including the Besov space and piecewise -smooth class. We show that sufficiently trained transformers can achieve -- and even improve upon -- the minimax optimal estimation risk in context by encoding the most relevant basis representations during pretraining. Our analysis extends to high-dimensional or sequential data and distinguishes the pretraining and in-context generalization gaps. Furthermore, we establish information-theoretic lower bounds for meta-learners w.r.t. both the number of tasks and in-context examples. These findings shed light on the roles of task diversity and representation learning for ICL.
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.
13 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Transformers learn to implement preconditioned gradient descent for in-context learning cites Language Models are Few-Shot Learners
- Transformers learn to implement preconditioned gradient descent for in-context learning cites Transformers Learn In-Context by Gradient Descent
- Transformers learn to implement preconditioned gradient descent for in-context learning cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection cites Language Models are Few-Shot Learners
- Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection cites Transformers Learn In-Context by Gradient Descent
- Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- In-Context Learning Is Provably Bayesian Inference: A Generalization Theory for Meta-Learning cites Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection
- In-Context Learning Is Provably Bayesian Inference: A Generalization Theory for Meta-Learning cites Language Models are Few-Shot Learners
- In-Context Learning Is Provably Bayesian Inference: A Generalization Theory for Meta-Learning cites Transformers Learn In-Context by Gradient Descent
- In-Context Learning Is Provably Bayesian Inference: A Generalization Theory for Meta-Learning cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- When Do Transformers Outperform Feedforward and Recurrent Networks? A Statistical Perspective cites Transformers learn to implement preconditioned gradient descent for in-context learning
- Understanding In-Context Learning on Structured Manifolds: Bridging Attention to Kernel Methods cites Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection
- Understanding In-Context Learning on Structured Manifolds: Bridging Attention to Kernel Methods cites Language Models are Few-Shot Learners
- Understanding In-Context Learning on Structured Manifolds: Bridging Attention to Kernel Methods cites Transformers Learn In-Context by Gradient Descent
- Understanding In-Context Learning on Structured Manifolds: Bridging Attention to Kernel Methods cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and Time cites Transformers learn to implement preconditioned gradient descent for in-context learning
- Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and Time cites Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection
- Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and Time cites Language Models are Few-Shot Learners
- Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and Time cites Transformers Learn In-Context by Gradient Descent
- Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and Time 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 Language Models are Few-Shot Learners
Cited by top-tier papers13
- Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and TimeBlake Bordelon, Mary I. Letey, Cengiz PehlevanICLR 2026 · 14 citations
- Understanding In-Context Learning on Structured Manifolds: Bridging Attention to Kernel MethodsZhaiming Shen, Alexander Hsu, Rongjie Lai, Wenjing LiaoICLR 2026 · 13 citations
- In-Context Learning Is Provably Bayesian Inference: A Generalization Theory for Meta-LearningTomoya Wakayama, Taiji SuzukiICML 2026 · 12 citations
- When Do Transformers Outperform Feedforward and Recurrent Networks? A Statistical PerspectiveAlireza Mousavi-Hosseini, Clayton Sanford, Denny Wu, Murat A. ErdogduNeurIPS 2025 · 6 citations
- Posterior Contraction for Sparse Neural Networks in Besov Spaces with Intrinsic DimensionalityKyeongwon Lee, Lizhen Lin, Jaewoo Park, Seonghyun JeongNeurIPS 2025 · 4 citations
Builds on20
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- What Can Transformers Learn In-Context? A Case Study of Simple Function ClassesShivam Garg, Dimitris Tsipras, Percy Liang, Gregory ValiantNeurIPS 2022 · 883 citations
- Transformers Learn In-Context by Gradient DescentJohannes von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento et al.ICML 2023 · 729 citations
- 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
- Transformers learn to implement preconditioned gradient descent for in-context learningKwangjun Ahn, Xiang Cheng, Hadi Daneshmand, Suvrit SraNeurIPS 2023 · 324 citations
Related papers
- In-Context Learning through the Bayesian PrismMadhur Panwar, Kabir Ahuja, Navin GoyalICLR 2024 · 79 citations
- 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
- When can in-context learning generalize out of task distribution?Page C. Goddard, Lindsay M. Smith, Vudtiwat Ngampruetikorn, David J. SchwabICML 2025
- In-Context Learning with Representations: Contextual Generalization of Trained TransformersTong Yang, Yu Huang, Yingbin Liang, Yuejie ChiNeurIPS 2024 · 45 citations
- Transformers as Algorithms: Generalization and Stability in In-context LearningYingcong Li, Muhammed Emrullah Ildiz, Dimitris Papailiopoulos, Samet OymakICML 2023 · 242 citations
