2025-06-27 · 专家 · 机器学习 · 自然语言处理

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:这篇论文想要解决什么具体问题?

问题2:论文的核心创新点是什么?

问题3:实验结果如何验证了方法的有效性?

问题4:这个研究的实际应用价值是什么?

来源