arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.02550cs.LGcond-mat.dis-nnhep-thstat.ML
收藏

学习顿悟:模算术任务中上下文学习与技能组合的出现

Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic tasks

University of Maryland(马里兰大学);Meta AI

Tianyu He, Darshil Doshi, Aritra Das, Andrey Gromov

AI总结:

本研究通过模算术任务实验,发现GPT风格Transformer随预训练任务数量增加会从分布内泛化转向分布外泛化,最小模型需两个Transformer块,深层模型需早停,并揭示了注意力头与MLP中的结构化表示及算法转变。

摘要:

大型语言模型能够解决训练集中未出现的任务。这一能力被认为源于上下文学习和技能组合。在本工作中,我们研究了一系列模算术任务中上下文学习与技能组合的出现。具体而言,我们考虑由向量$(a, b) \in \mathbb{Z}_p^2$标记的有限个线性模函数$z = a \\, x + b \\, y \\;\mathrm{mod}\\; p$的集合。我们使用其中部分任务进行预训练,其余任务用于分布外测试。我们通过实验表明,随着预训练任务数量的增加,GPT风格的Transformer表现出从分布内泛化到分布外泛化的转变。我们发现,能够实现分布外泛化的最小模型需要两个Transformer块,而对于更深的模型,分布外泛化阶段是瞬态的,需要提前停止。最后,我们对预训练模型进行可解释性研究,揭示了注意力头和MLP中高度结构化的表示,并讨论了学习到的算法。值得注意的是,在更深的模型中,随着上下文示例从少到多,我们发现了算法上的转变。

英文摘要:

Large language models can solve tasks that were not present in the training set. This capability is believed to be due to in-context learning and skill composition. In this work, we study the emergence of in-context learning and skill composition in a collection of modular arithmetic tasks. Specifically, we consider a finite collection of linear modular functions $z = a \, x + b \, y \;\mathrm{mod}\; p$ labeled by the vector $(a, b) \in \mathbb{Z}_p^2$. We use some of these tasks for pre-training and the rest for out-of-distribution testing. We empirically show that a GPT-style transformer exhibits a transition from in-distribution to out-of-distribution generalization as the number of pre-training tasks increases. We find that the smallest model capable of out-of-distribution generalization requires two transformer blocks, while for deeper models, the out-of-distribution generalization phase is \emph{transient}, necessitating early stopping. Finally, we perform an interpretability study of the pre-trained models, revealing highly structured representations in both attention heads and MLPs; and discuss the learned algorithms. Notably, we find an algorithmic shift in deeper models, as we go from few to many in-context examples.

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

↑