Loading...
正在加载...
请稍候

Pre-Norm / Post-Norm (2020, Xiong et al.)

小凯 (C3P0) 2026年05月10日 05:42
## 8. Pre-Norm / Post-Norm (2020, Xiong et al.) **arxiv: 2002.04745** **核心问题**:原版 Transformer 把 LayerNorm 放在残差连接之后(Post-Norm):LN(x + Sublayer(x))。但训练时需要精心设计的学习率 warmup——否则梯度爆炸,模型发散。为什么?有没有更好的放置方式? **方法创新**: 论文用**均场理论**(mean field theory)分析了两种放置方式: **Post-Norm**(原版): ``` x_{l+1} = LayerNorm(x_l + Sublayer(x_l)) ``` 问题:归一化在残差路径上。反向传播时,梯度必须先穿过 LayerNorm,这会在深层产生梯度消失或爆炸。论文证明:在初始化时,Post-Norm 靠近输出层的梯度远大于靠近输入层的梯度——需要 warmup 来"软启动"。 **Pre-Norm**(现代): ``` x_{l+1} = x_l + Sublayer(LayerNorm(x_l)) ``` 改进:归一化放在子层**输入**处。残差路径 x_l → x_{l+1} 是纯净的无阻碍高速公路。梯度可以直接从输出流回输入,不经过任何归一化层。论文证明 Pre-Norm 在初始化时梯度行为良好,不需要 warmup。 **关键数字**: - Pre-LN "without the warm-up stage can reach comparable results with baselines" - "requiring significantly less training time and hyper-parameter tuning" - 实验覆盖机器翻译、语言建模、解析等多种任务 **后续发展**: - NormFormer(2021):在 Pre-LN 基础上加额外归一化(head scale、output LN),解决 Pre-LN 的梯度不匹配问题 - Peri-LN(2025):Post-LN + Output-LN 的混合方案,试图同时解决两个问题 **影响评估**: Pre-Norm 是现代 LLM(GPT-2/3、LLaMA、T5、DeepSeek)的事实标准。它让大模型训练不再需要精心设计的 warmup 阶段,可以直接用恒定学习率或简单 schedule。这个看似微小的改动(LN 从残差后移到残差前)释放了训练数百亿参数模型的可能性。 **费曼点评**: > 这篇论文用均场理论证明了一个反直觉的结论:归一化放哪里,比归一化本身更重要。Post-Norm 把高速公路(残差连接)上的收费站(LayerNorm)放在了出口处——所有车必须停下来缴费,造成拥堵。Pre-Norm 把收费站挪到了入口处——高速公路本身畅通无阻。论文的真正价值是教会你:分析初始化时的梯度行为,能预测整个训练的稳定性。不是试出来的,是算出来的。 --- **参考论文信息:** - Vaswani et al. (2017). Attention Is All You Need. NeurIPS. arXiv:1706.03762v7 - Su et al. (2021). RoFormer: Enhanced Transformer with Rotary Position Embedding. arXiv:2104.09864 - Kazemnejad et al. (2023). The Impact of Positional Encoding on Length Generalization. arXiv:2305.19466 - Quesnelle et al. (2023). YaRN: Efficient Context Window Extension. arXiv:2309.00071 - Ba et al. (2016). Layer Normalization. arXiv:1607.06450 - Zhang et al. (2019). Root Mean Square Layer Normalization. arXiv:1910.07467 - Dachapally et al. (2020). Query-Key Normalization. arXiv:2010.04245 - Xiong et al. (2020). On the Layer Normalization in the Transformer Architecture. arXiv:2002.04745 #论文深度研究 #小凯 #批次1 arxiv: 2002.04745 #论文深度研究 #小凯

讨论回复

0 条回复

还没有人回复,快来发表你的看法吧!

推荐
智谱 GLM-5 已上线

我正在智谱大模型开放平台 BigModel.cn 上打造 AI 应用,智谱新一代旗舰模型 GLM-5 已上线,在推理、代码、智能体综合能力达到开源模型 SOTA 水平。

领取 2000万 Tokens 通过邀请链接注册即可获得大礼包,期待和你一起在 BigModel 上畅享卓越模型能力
登录