arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2507.09440cs.LGcs.AI
收藏

Transformers不能进行上下文学习最小二乘回归

Transformers Don't In-Context Learn Least Squares Regression

Joshua Hill, Benjamin Eyre, Elliot Creager

AI总结:

本文通过合成线性回归和分布外泛化实验发现,为ICL训练的transformers在提示分布偏移后无法泛化,其行为与实现OLS等算法不一致,并通过残差流谱分析揭示了预训练语料库对ICL行为的塑造作用。

摘要:

上下文学习(ICL)已成为大型预训练transformers的一项强大能力,使它们能够在没有任何梯度更新的情况下,解决示例输入输出对中隐含的新任务。尽管在实践中取得了成功,但ICL背后的机制在很大程度上仍然神秘。在这项工作中,我们研究合成线性回归,以探究transformers如何在推理时实现学习。先前的工作已经证明,transformers匹配了普通最小二乘(OLS)回归或梯度下降等学习规则的性能,并表明ICL在transformers中是通过学习实现这些技术之一来促进的。在这项工作中,我们通过一系列分布外泛化实验证明,为ICL训练的transformers在提示分布发生偏移后无法泛化,这种行为与transformers实现OLS等算法的概念不一致。最后,我们通过对残差流中学习到的表示进行谱分析,强调了预训练语料库在塑造ICL行为中的作用。来自与训练数据相同分布的输入产生具有独特谱特征的表示:来自该分布的输入倾向于具有相同的前两个奇异向量。这种谱特征不为分布外输入所共享,并且表征该特征存在的度量与低损失高度相关。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑