The Curse of Depth in Large Language Models
本文提出了“深度诅咒”的概念,揭示了现代大型语言模型中深层层效率低下的现象,并提出了层归一化缩放(LayerNorm Scaling)方法来解决这一问题。
更新于 2025-02-11。作者:Wenfang Sun、Xinyuan Song、Pengxiang Li、Lu Yin、Yefeng Zheng、Shiwei Liu。
中文摘要
在这篇论文中,我们介绍了深度诅咒这一概念,它突出了、解释了并解决了现代大型语言模型(LLMs)中近期观察到的一种现象,即近一半的层的效果不如预期。我们首先确认了这一现象在Llama、Mistral、DeepSeek和Qwen等最受欢迎的LLM家族中广泛存在。我们的分析从理论和实证两方面确定了LLMs中深层层无效的根本原因是广泛使用预层归一化(Pre-LN)。虽然Pre-LN稳定了Transformer LLM的训练,但其输出方差随着模型深度的增加而指数级增长,这导致深层Transformer块的导数成为单位矩阵,从而几乎对训练贡献甚微。为了解决这一训练陷阱,我们提出了层归一化缩放(LayerNorm Scaling),它通过层的深度的平方根的倒数来缩放层归一化输出的方差。这种简单的修改减轻了深层Transformer层的输出方差爆炸,提高了它们的贡献。我们的实验结果涵盖了从1.3亿到10亿的模型大小,表明层归一化缩放与Pre-LN相比显著提高了LLM预训练性能。此外,这种改进无缝地延续到监督微调。所有这些收益都可以归因于层归一化缩放使得深层层在训练期间能够更有效地做出贡献。
英文摘要
In this paper, we introduce the Curse of Depth, a concept that highlights, explains, and addresses the recent observation in modern Large Language Models(LLMs) where nearly half of the layers are less effective than expected. We first confirm the wide existence of this phenomenon across the most popular families of LLMs such as Llama, Mistral, DeepSeek, and Qwen. Our analysis, theoretically and empirically, identifies that the underlying reason for the ineffectiveness of deep layers in LLMs is the widespread usage of Pre-Layer Normalization (Pre-LN). While Pre-LN stabilizes the training of Transformer LLMs, its output variance exponentially grows with the model depth, which undesirably causes the derivative of the deep Transformer blocks to be an identity matrix, and therefore barely contributes to the training. To resolve this training pitfall, we propose LayerNorm Scaling, which scales the variance of output of the layer normalization inversely by the square root of its depth. This simple modification mitigates the output variance explosion of deeper Transformer layers, improving their contribution. Our experimental results, spanning model sizes from 130M to 1B, demonstrate that LayerNorm Scaling significantly enhances LLM pre-training performance compared to Pre-LN. Moreover, this improvement seamlessly carries over to supervised fine-tuning. All these gains can be attributed to the fact that LayerNorm Scaling enables deeper layers to contribute more effectively during training.
解读
一句话总结
本文提出了“深度诅咒”的概念,揭示了现代大型语言模型中深层层效率低下的现象,并提出了层归一化缩放(LayerNorm Scaling)方法来解决这一问题。
问题1:这篇论文想要解决什么具体问题?
- 问题背景:现代大型语言模型(LLMs)的深层层往往比早期层效率低下,导致资源浪费。
- 现有方案不足:目前的方法未能有效解决深层层效率低下的问题,如预层归一化(Pre-LN)导致深层层输出方差爆炸。
- 研究目标:通过提出层归一化缩放(LayerNorm Scaling)方法,提高深层层的效率,从而提高LLMs的性能。
问题2:论文的核心创新点是什么?
- 技术创新:提出了层归一化缩放(LayerNorm Scaling)方法,通过按层深度倒数缩放层归一化输出,控制输出方差,提高深层层的效率。
- 方法改进:改进了Pre-LN的使用,通过缩放机制,避免输出方差爆炸,提高深层层的贡献。
- 优势:LayerNorm Scaling简单易行,无需超参数调整,不引入额外参数,计算效率高,适用于现有Transformer架构。
问题3:实验结果如何验证了方法的有效性?
- 关键实验:在多个LLMs上进行预训练和监督微调实验,包括LLaMA、Mistral、DeepSeek和Qwen。
- 性能提升:LayerNorm Scaling在预训练和监督微调中均显著提高了性能,特别是在大型模型上。
- 对比结果:与Pre-LN相比,LayerNorm Scaling在LLaMA-130M和LLaMA-1B上分别降低了0.97和1.31的困惑度,在多个下游任务上平均提高了1.86%。
问题4:这个研究的实际应用价值是什么?
- 应用场景:LayerNorm Scaling可应用于各种LLMs,提高其性能和效率。
- 实施建议:LayerNorm Scaling易于实现,建议在训练LLMs时采用。
- 局限与展望:LayerNorm Scaling主要针对Pre-LN导致的深度诅咒,未来可以探索其他归一化方法及其对深度诅咒的影响。
来源
机器可读索引:llms.txt