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.
翻译:预训练于多样化任务的Transformer展现出卓越的上下文学习能力,使其能够仅依据输入上下文解决未见过的任务,而无需调整模型参数。本文在最简设定下研究上下文学习:使用高斯先验对线性参数化的单层线性注意力模型进行预训练,以完成线性回归任务。我们建立了注意力模型预训练的统计任务复杂度界,表明有效预训练仅需少量独立任务。进一步证明,在固定上下文长度下,预训练模型与贝叶斯最优算法(即最优调参的岭回归)紧密匹配,在未见任务上实现了近乎贝叶斯最优的风险。这些理论发现补充了先前的实验研究,并阐明了上下文学习的统计基础。