Transformer的上下文学习不依赖最小二乘法,而是依赖预训练数据分布特征。
Transformers Don't In-Context Learn Least Squares Regression
- 通过分布外实验发现,Transformer无法泛化到新分布,排除了其在推理时实现最小二乘法的可能。
- 在同分布输入下,模型残差流中存在独特的谱特征,且该特征与低损失高度相关。
- 揭示了预训练数据分布对上下文学习行为的决定性作用,为理解ICL机制提供新视角。
上下文学习(ICL)已成为大预训练Transformer的重要能力,使其能在不进行梯度更新的情况下,仅凭输入输出样例对隐式解决新任务。尽管实践成功,但其内在机制仍不明朗。本文通过合成线性回归任务,探究Transformer在推理时如何实现学习。此前研究发现,Transformer可达到普通最小二乘(OLS)或梯度下降等学习规则的性能,并推测其通过学习实现这些算法。本工作通过一系列分布外泛化实验表明,经过ICL训练的Transformer在提示分布发生改变后无法泛化,这一行为与实现如OLS等算法的假设矛盾。最后,通过残差流中表示的谱分析,揭示了预训练语料库对ICL行为的塑造作用:与训练数据同分布的输入产生具有独特谱特征的表示——其前两个奇异向量相同;而分布外输入不具备此特征,且该特征的存在性与低损失高度相关。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。