大型语言模型能够解决训练集中未出现的任务。这一能力被认为源于上下文学习和技能组合。在本工作中,我们研究了一系列模算术任务中上下文学习与技能组合的出现。具体而言,我们考虑由向量$(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.
Shattered Compositionality: Counterintuitive Learning Dynamics of Transformers for Arithmetic
University of Wisconsin–Madison(威斯康星大学麦迪逊分校);Department of Computer Sciences, University of Wisconsin–Madison(威斯康星大学麦迪逊分校计算机科学系);Department of Statistics, University of Wisconsin–Madison(威斯康星大学麦迪逊分校统计学系)
RL Grokking Recipe: How Does RL Unlock and Transfer New Algorithms in LLMs?
University of California, Berkeley(加州大学伯克利分校);University of Wisconsin, Madison(威斯康星大学麦迪逊分校);University of Washington(华盛顿大学);Ai2 Main dataset contributor(Ai2 主数据贡献者)
Gaoling School of Artificial Intelligence, Renmin University of China(中国人民大学高瓴人工智能学院);Machine Learning Platform Department, Tencent(腾讯机器学习平台部);School of Computer Science, Wuhan University(武汉大学计算机学院)
Teaching Algorithmic Reasoning via In-context Learning
Mila(米拉研究所);Université de Montreal(蒙特利尔大学);Google Research(谷歌研究院)
大语言模型(LLM)通过扩展模型和数据大小,显示出越来越多的上下文学习能力。尽管取得了这些进展,LLM仍然无法解决算法推理问题。虽然为最终答案提供了一个基本原理,导致了多步推理问题的进一步改进,但Anil et al. 2022表明,即使是简单的算法推理任务,如奇偶校验,也远未解决。在这项工作中,我们确定并研究了成功教授算法推理的四个关键阶段:(1)将算法制定为技能,(2)同时教授多种技能(技能积累),(3)教授如何组合技能(技能组合)和(4)教授如何使用技能作为工具。我们表明,它是可以教算法推理LLMs通过上下文学习,我们称之为算法提示。我们评估我们的方法在各种算术和定量推理任务,并表现出显着的提升性能比现有的提示技术。特别是,对于长奇偶校验、加法、乘法和减法,与最佳可用基线相比,我们分别实现了约10倍、9倍、5倍和2倍的误差减少。
Academy of Mathematics and Systems Science, Chinese Academy of Sciences(中国科学院数学与系统科学研究院);School of Mathematical Sciences, University of Chinese Academy of Sciences(中国科学院大学数学科学学院);Shanghai Institute for Mathematics and Interdisciplinary Sciences (SIMIS)(上海数学与交叉学科研究院);Key Laboratory of Systems Health Science of Zhejiang Province, School of Life Science, Hangzhou Institute for Advanced Study, University of Chinese Academy of Sciences(浙江省系统健康科学重点实验室,中国科学院大学杭州高等研究院生命科学学院)