Abstract
In-context learning (ICL) has emerged as a powerful capability of large pretrained transformers, enabling them to solve new tasks implicit in example input-output pairs without any gradient updates. Despite its practical success, the mechanisms underlying ICL remain largely mysterious. In this work we study synthetic linear regression to probe how transformers implement learning at inference time. Previous works have demonstrated that transformers match the performance of learning rules such as Ordinary Least Squares (OLS) regression or gradient descent and have suggested ICL is facilitated in transformers through the learned implementation of one of these techniques. In this work, we demonstrate through a suite of out-of-distribution generalization experiments that transformers trained for ICL fail to generalize after shifts in the prompt distribution, a behaviour that is inconsistent with the notion of transformers implementing algorithms such as OLS. Finally, we highlight the role of the pretraining corpus in shaping ICL behaviour through a spectral analysis of the learned representations in the residual stream. Inputs from the same distribution as the training data produce representations with a unique spectral signature: inputs from this distribution tend to have the same top two singular vectors. This spectral signature is not shared by out-of-distribution inputs, and a metric characterizing the presence of this signature is highly correlated with low loss.
Abstract (translated)
上下文学习(ICL)已经成为大规模预训练变压器的强大能力,使它们能够在不进行任何梯度更新的情况下解决隐含在示例输入-输出对中的新任务。尽管其实用性得到了成功验证,但其背后的机制仍然很大程度上是个谜。在这项工作中,我们研究了合成线性回归问题,以探讨变压器如何实现在推理过程中学习的能力。先前的工作已经证明,变压器可以达到诸如普通最小二乘(OLS)回归或梯度下降等学习规则的性能,并且提出了变压器通过实现这些技术之一来促进上下文学习的观点。在本项工作中,我们通过一系列分布外泛化实验展示了针对ICL进行训练的变压器在提示分布发生变化后无法推广的行为,这种行为与认为变压器实施诸如OLS算法的观点不符。 最后,我们通过对残差流中所学表示的谱分析强调了预训练语料库在塑造ICL行为中的作用。来自与训练数据相同分布的输入会产生具有独特谱特征的表示:这些分布中的输入通常具有相同的前两个奇异向量。这种谱签名不会被分布外的输入共享,且一个表征该签名存在性的度量高度相关于较低损失值。 简而言之,这项研究表明预训练的数据对于上下文学习行为至关重要,并且变压器在处理新任务时的行为并不总是遵循传统算法如OLS的学习规则。
URL
https://arxiv.org/abs/2507.09440