arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2507.02559cs.LG
收藏

Transformer在推理时不需要LayerNorm:将LayerNorm移除扩展到GPT-2 XL及其对机制可解释性的影响

Transformers Don't Need LayerNorm at Inference Time: Scaling LayerNorm Removal to GPT-2 XL and the Implications for Mechanistic Interpretability

Luca Baroni, Galvin Khara, Joachim Schaeffer, Marat Subkhankulov, Stefan Heimersheim

AI总结:

本文证明GPT-2系列模型可在推理时完全移除LayerNorm层且性能损失极小,并发布无LN模型以提升机制可解释性研究的精确性。

摘要:

逐层归一化(LN)几乎是所有基于Transformer的大语言模型的基本组成部分。虽然其对训练稳定性的影响已有充分记录,但它在推理时的作用却鲜为人知。此外,LN层通过引入额外的非线性并增加各个模型组件之间的相互关联性,阻碍了机制可解释性研究。本文中,我们证明可以从所有GPT-2模型中移除全部LN层,而验证损失仅有小幅增加(例如GPT-2 XL的交叉熵损失增加0.03)。因此,LN在语言建模中不可能发挥实质性作用。我们发现,移除LN所需的微调数据量随模型参数呈亚线性增长,这表明扩展到更大模型是可行的。我们在Hugging Face上发布了一套无LN的GPT-2模型。此外,我们在无LN模型上测试了可解释性技术。直接logit归因现在可以给出各个组件的精确直接效应,而归因修补的准确率没有显著提升。我们还确认GPT-2的“置信神经元”在无LN模型中处于非活跃状态。我们的工作阐明了LN层在语言建模中的作用,表明GPT-2级别的模型可以在没有LN层的情况下正常工作。我们希望我们发布的无LN的GPT-2系列模型能够支持更精确的可解释性研究,并增进我们对语言模型的理解。

英文摘要:

Layer-wise normalization (LN) is an essential component of virtually all transformer-based large language models. While its effects on training stability are well documented, its role at inference time is poorly understood. Additionally, LN layers hinder mechanistic interpretability by introducing additional nonlinearities and increasing the interconnectedness of individual model components. Here, we show that all LN layers can be removed from every GPT-2 model with only a small increase in validation loss (e.g. +0.03 cross-entropy loss for GPT-2 XL). Thus, LN cannot play a substantial role in language modeling. We find that the amount of fine-tuning data needed for LN removal grows sublinearly with model parameters, suggesting scaling to larger models is feasible. We release a suite of LN-free GPT-2 models on Hugging Face. Furthermore, we test interpretability techniques on LN-free models. Direct logit attribution now gives the exact direct effect of individual components, while the accuracy of attribution patching does not significantly improve. We also confirm that GPT-2's "confidence neurons" are inactive in the LN-free models. Our work clarifies the role of LN layers in language modeling, showing that GPT-2-class models can function without LN layers. We hope that our LN-free analogs of the GPT-2 family of models will enable more precise interpretability research and improve our understanding of language models.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑