arXiv:2503.04598cs.CLcs.AI2025-03NeurIPS被引 21

提出混合归一化方法,提升Transformer训练稳定性和性能

HybridNorm: Towards Stable and Efficient Transformer Training via Hybrid Normalization

  • 在注意力层用QKV归一化,前馈网络用后归一化
  • 实测在多个大模型上优于传统前后归一化方案
  • 适合追求训练稳定与高性能的深度Transformer开发者

Transformers已成为众多机器学习任务的主流架构,尤其在大语言模型中表现突出。尽管性能优异,深层Transformer训练仍面临诸多挑战,尤其与层归一化的位置有关。Pre-Norm结构因更强的恒等路径而训练更稳定,但性能常不如Post-Norm。本文提出一种简单有效的混合归一化策略——HybridNorm,结合Pre-Norm与Post-Norm的优势:在注意力机制中采用QKV归一化,在每个Transformer块的前馈网络(FFN)中使用Post-Norm。我们从理论和实验两方面证明,HybridNorm能改善梯度流动并增强模型鲁棒性。在大规模Transformer模型(含密集与稀疏变体)上的广泛实验表明,HybridNorm在多个基准测试中持续优于Pre-Norm与Post-Norm。结果表明,HybridNorm是一种更稳定、高效的深度Transformer训练优化技术。代码已公开于https://github.com/BryceZhuo/HybridNorm。

原文摘要 · Abstract (English)

Transformers have become the de facto architecture for a wide range of machine learning tasks, particularly in large language models (LLMs). Despite their remarkable performance, many challenges remain in training deep transformer networks, especially regarding the position of the layer normalization. While Pre-Norm structures facilitate more stable training owing to their stronger identity path, they often lead to suboptimal performance compared to Post-Norm. In this paper, we propose $\textbf{HybridNorm}$, a simple yet effective hybrid normalization strategy that integrates the advantages of both Pre-Norm and Post-Norm. Specifically, HybridNorm employs QKV normalization within the attention mechanism and Post-Norm in the feed-forward network (FFN) of each transformer block. We provide both theoretical insights and empirical evidence to demonstrate that HybridNorm improves the gradient flow and the model robustness. Extensive experiments on large-scale transformer models, including both dense and sparse variants, show that HybridNorm consistently outperforms both Pre-Norm and Post-Norm approaches across multiple benchmarks. These findings highlight the potential of HybridNorm as a more stable and effective technique for improving the training and performance of deep transformer models. Code is available at https://github.com/BryceZhuo/HybridNorm.

Transformer归一化训练稳定大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。