Large language models are able to compose skills in order to perform complex tasks, many of which might not have been seen during training. The details of how exactly this composition occurs remain elusive. In this paper, we study a mechanism for compositional generalization in transformers by considering a simple controlled setting involving variable assignment and modular addition. By partitioning our training data into disjoint sets, we observe that small transformers are able to generalize to previously unseen combinations of variables and numbers. Our mechanistic analysis shows that the same ``modular addition'' MLP module is used whether the inputs are given directly or indirectly through a separate variable assignment mechanism. We also analyze the training dynamics from an empirical lens, which reveals three phases of learning: first, modular addition is learned, then the structure required for variable assignment, and finally a refinement phase where the model generalizes to some hard sequences not seen in training. Finally, we provide a theoretical framework to explain how compositionality emerges from training dynamics. These results suggest that compositional generalization can be a natural consequence of the compositionality of internal mechanisms in~transformers.
BRICKS: Compositional Neural Markov Kernels for Zero-Shot Radiation-Matter Simulation
Technical University of Munich(慕尼黑技术大学);Max-Planck Institute for Mathematics in the Sciences(马克斯·普朗克数学研究所);SLAC National Accelerator Laboratory(斯坦福直线加速器实验室);Haifa University(海法大学);Department of Physics(物理系);Indian Institute of Technology, Kanpur(印度理工学院坎普尔分校);Munich Center for Machine Learning(慕尼黑机器学习中心)
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(威斯康星大学麦迪逊分校统计学系)
NeuronDiscover: Agent-in-Twin for Mechanistic Discovery in Neuronal Microenvironments with World Action Models
Institute of Medical Technology, Peking University Health Science Center(北京大学医学部医学技术研究院);Beijing Key Laboratory of Intelligent Neuromodulation and Brain Disorder Treatment(北京智能神经调控与脑疾病治疗重点实验室);Department of Radiology, Peking University Third Hospital(北京大学第三医院放射科);National Biomedical Imaging Center, College of Future Technology, Peking University(北京大学未来技术学院国家生物医学成像中心)
Circuit Compositions: Exploring Modular Structures in Transformer-Based Language Models
MaiNLP, Center for Information and Language Processing, LMU Munich(MaiNLP、信息与语言处理中心、慕尼黑大学);Munich Center for Machine Learning (MCML), Munich(慕尼黑机器学习中心);Language Technology Group, University of Oslo(语言技术组、奥斯陆大学)