Where to find Grokking in LLM Pretraining? Monitor Memorization-to-Generalization without Test
该论文首次在大型语言模型(LLM)预训练过程中验证了“Groking”现象的存在,并通过分析LLM内部状态动态,揭示了从记忆到泛化的机制。
更新于 2025-07-11。作者:Ziyue Li、Chenrui Fan、Tianyi Zhou。
中文摘要
在神经网络训练中,最近观察到的一种现象,即“Grokking”(即测试性能在训练损失收敛后仍持续提升),使得泛化机制以及其他如推理等新兴能力变得神秘。以往的研究通常在数千个epoch内,在少量玩具或高度特定任务上训练小型模型,而我们进行了首次关于在7B大型语言模型(LLM)OLMoE的单次预训练过程中的检查点上的Grokking研究。我们计算了训练损失,并在包括数学推理、代码生成以及常识/特定领域知识检索任务在内的多种基准任务上评估了泛化能力。我们的研究首次验证,尽管不同数据可能异步进入Grokking阶段,但Grokking仍然发生在大规模基础模型的预训练过程中。我们进一步通过研究LLM的内部动态来揭开Grokking“泛化能力出现”的神秘面纱。具体来说,我们发现,在Grokking过程中,训练样本的路径(即层间的专家选择)从随机、实例特定转变为更加结构化和样本间可共享。此外,尽管损失已经收敛,样本路径的复杂性却有所降低。这些表明了从记忆到泛化的转换,为延迟泛化提供了机制上的解释。在研究中,我们开发了两个新的指标来量化路径距离和单个路径的复杂性。我们展示了它们在预测多种下游任务泛化提升方面的能力。这些指标计算高效、简单,且仅依赖于训练数据。因此,它们在预训练中具有实际价值,使我们能够在不进行微调和测试的情况下监控泛化性能。从理论上讲,我们证明了更加结构化的路径可以降低模型复杂性并提高泛化界限。
英文摘要
Grokking, i.e., test performance keeps improving long after training loss converged, has been recently witnessed in neural network training, making the mechanism of generalization and other emerging capabilities such as reasoning mysterious. While prior studies usually train small models on a few toy or highly-specific tasks for thousands of epochs, we conduct the first study of grokking on checkpoints during one-pass pretraining of a 7B large language model (LLM), i.e., OLMoE. We compute the training loss and evaluate generalization on diverse benchmark tasks, including math reasoning, code generation, and commonsense/domain-specific knowledge retrieval tasks. Our study, for the first time, verifies that grokking still happens in the pretraining of large-scale foundation models, though different data may enter grokking stages asynchronously. We further demystify grokking's "emergence of generalization" by investigating LLM internal dynamics. Specifically, we find that training samples' pathways (i.e., expert choices across layers) evolve from random, instance-specific to more structured and shareable between samples during grokking. Also, the complexity of a sample's pathway reduces despite the converged loss. These indicate a memorization-to-generalization conversion, providing a mechanistic explanation of delayed generalization. In the study, we develop two novel metrics to quantify pathway distance and the complexity of a single pathway. We show their ability to predict the generalization improvement on diverse downstream tasks. They are efficient, simple to compute and solely dependent on training data. Hence, they have practical value for pretraining, enabling us to monitor the generalization performance without finetuning and test. Theoretically, we show that more structured pathways reduce model complexity and improve the generalization bound.
解读
一句话总结
该论文首次在大型语言模型(LLM)预训练过程中验证了“Groking”现象的存在,并通过分析LLM内部状态动态,揭示了从记忆到泛化的机制。
问题1:这篇论文想要解决什么具体问题?
- 问题背景:在神经网络训练中观察到“Groking”现象,即训练损失收敛后测试性能仍然提高,这使泛化机制和其他能力如推理变得神秘。
- 现有方案不足:现有研究通常在高度特定或玩具任务上训练小型模型,且训练数以千计的周期,而LLM的预训练通常在大量真实数据上只进行一次。
- 研究目标:研究LLM预训练中的Groking现象,寻找对下游任务泛化出现的机制性解释。
问题2:论文的核心创新点是什么?
- 技术创新:首次在大型语言模型(LLM)预训练过程中研究Groking现象。
- 方法改进:通过分析LLM内部状态动态,特别是MoE路径的演变,揭示了从记忆到泛化的机制。
- 优势:提出两种新的度量标准来量化路径之间的距离和单个路径的复杂性,这些度量标准仅依赖于训练数据,因此可以有效地监控预训练过程中的泛化性能。
问题3:实验结果如何验证了方法的有效性?
- 关键实验:在数学推理、代码生成和常识/特定领域知识检索等多样化基准任务上评估了泛化能力。
- 性能提升:发现Groking现象在LLM预训练中仍然存在,且不同数据组/领域以不同步调开始泛化。
- 对比结果:提出的度量标准与测试性能表现出强相关性,证明了它们在监控预训练过程中的泛化性能方面的有效性。
问题4:这个研究的实际应用价值是什么?
- 应用场景:LLM预训练、模型开发和实践。
- 实施建议:使用提出的度量标准来监控预训练过程中的泛化性能,而无需微调或测试。
- 局限与展望:研究限于单一模型架构,理论分析仅限于单层MoE,未来研究可以扩展到更复杂的架构。