发现大模型深层失效问题,提出简单方法提升深层贡献
The Curse of Depth in Large Language Models
- 提出层归一化缩放(LNS),缓解深层输出方差爆炸
- 实验显示在130M到7B模型上均显著提升预训练效果
- 适合关注模型深度优化与训练效率的研究者
本文提出‘深度诅咒’概念,揭示现代大语言模型中近半数层实际效能低于预期的现象。通过理论与实证分析,发现其根源在于广泛使用的预层归一化(Pre-LN)导致深层输出方差随深度指数级增长,使深层模块导数趋近单位矩阵,几乎不参与训练。为此,我们提出层归一化缩放(LNS),通过反比于层数平方根的方式缩放层归一化输出方差。该方法有效抑制深层方差膨胀,显著提升深层贡献。在130M至7B规模的多种模型上,LNS持续优于现有归一化与缩放技术,且提升效果可无缝迁移至有监督微调阶段。所有增益源于深层更有效参与训练。代码已开源。
原文摘要 · Abstract (English)
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 (LNS), 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. Across a wide range of model sizes (130M to 7B), our experiments show that LNS consistently outperforms previous normalization and scaling techniques in enhancing LLM pre-training performance. 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. Our code is available at \href{https://github.com/lmsdss/LayerNorm-Scaling}{LayerNorm-Scaling}.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。