How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?
Jingfeng Wu, Difan Zou, Zixiang Chen, Vladimir Braverman, Quanquan Gu, Peter L. Bartlett
TL;DR
<3-5 sentence high-level summary> The work analyzes in-context learning (ICL) in the simplest yet nontrivial setting by pretraining a restricted single-layer linear attention model for Gaussian-prior linear regression. It proves a dimension-free task-complexity bound showing that only a small number of independent tasks are needed for effective pretraining, and that the pretrained model can achieve nearly Bayes-optimal (ridge) risk on unseen tasks when the inference context length matches pretraining. To establish these results, the authors develop novel operator-theoretic tools—diagonalization and operator polynomials—to analyze 8th-order tensor recursions arising in SGD dynamics. They also provide a detailed comparison between the pretrained attention estimator and the Bayes-optimal ridge estimator, clarifying when ICL can be optimally or near-optimally realized, and complement prior empirical findings with a solid statistical foundation.
Abstract
Transformers pretrained on diverse tasks exhibit remarkable in-context learning (ICL) capabilities, enabling them to solve unseen tasks solely based on input contexts without adjusting model parameters. In this paper, we study ICL in one of its simplest setups: pretraining a linearly parameterized single-layer linear attention model for linear regression with a Gaussian prior. We establish a statistical task complexity bound for the attention model pretraining, showing that effective pretraining only requires a small number of independent tasks. Furthermore, we prove that the pretrained model closely matches the Bayes optimal algorithm, i.e., optimally tuned ridge regression, by achieving nearly Bayes optimal risk on unseen tasks under a fixed context length. These theoretical findings complement prior experimental research and shed light on the statistical foundations of ICL.
