Transformer neural networks can exhibit a surprising capacity for in-context learning (ICL) despite not being explicitly trained for it. Prior work has provided a deeper understanding of how ICL emerges in transformers, e.g. through the lens of mechanistic interpretability, Bayesian inference, or by examining the distributional properties of training data. However, in each of these cases, ICL is treated largely as a persistent phenomenon; namely, once ICL emerges, it is assumed to persist asymptotically. Here, we show that the emergence of ICL during transformer training is, in fact, often transient. We train transformers on synthetic data designed so that both ICL and in-weights learning (IWL) strategies can lead to correct predictions. We find that ICL first emerges, then disappears and gives way to IWL, all while the training loss decreases, indicating an asymptotic preference for IWL. The transient nature of ICL is observed in transformers across a range of model sizes and datasets, raising the question of how much to "overtrain" transformers when seeking compact, cheaper-to-run models. We find that L2 regularization may offer a path to more persistent ICL that removes the need for early stopping based on ICL-style validation tasks. Finally, we present initial evidence that ICL transience may be caused by competition between ICL and IWL circuits.
翻译:Transformer神经网络在未经过显式训练的情况下,展现出令人惊讶的上下文学习(ICL)能力。先前的研究通过机械可解释性、贝叶斯推断或训练数据分布特性等视角,深化了对Transformer中ICL涌现机制的理解。然而,这些研究大多将ICL视为持久性现象——即一旦涌现便能渐近保持。本文表明,在Transformer训练过程中,ICL的涌现实际上常具有瞬时性。我们使用合成数据训练Transformer,该数据设计使得ICL和权重学习(IWL)策略均可产生正确预测。研究发现,ICL首先涌现,随后消失并让位于IWL,同时训练损失持续下降,表明模型渐近偏好IWL。这种ICL的瞬时性在多种模型规模和数据集上均被观察到,引发关于在追求紧凑低成本模型时应如何避免"过度训练"Transformer的思考。我们发现L2正则化可能为更持久的ICL提供路径,从而消除基于ICL风格验证任务提前停止训练的必要性。最后,我们提供初步证据表明,ICL的瞬时性可能源于ICL与IWL电路间的竞争。