你可以通过微调移除GPT2的LayerNorm
摘要
GPT类 transformer 模型中的 LayerNorm(LN)层长期以来一直是 mechanistic 可解释性 research 的瓶颈。LN 是维持大型语言模型训练稳定性的关键组件,LN 或类似的 RMSNorm 被用于实质所有基于 transformer architecture 的大型语言模型。LN 的非线性特性是 mechanistic 可解释性的障碍,因为它阻碍了对残差流的解释,并使将模型分解为 circuit 变得困难。一些研究者甚至将其称为"解释性研究者厌恨的layer norm的原因"。本文我们展示了通过在5000万 token 的训练数据上进行微调,可以从预训练的GPT2-small模型中移除 LN 层。我们证明了该无LN模型在 OpenWebText 和 ThePile 数据集上表现与原始模型相似(-0.05 交叉熵损失),在 Hellaswag 基准测试中也表现良好(-0.5% 准确率)。我们在https://github.com/ApolloResearch/gpt2_noLN 提供了我们的实现,并在https://huggingface.co/apollo-research/gpt2_noLN提供了微调后的GPT2-small模型。我们的工作不仅为 mechanistic 可解释性 research 提供了一个简化的模型,还提供了证据表明在推理时,LN 层在 transformer 模型中并不起关键作用。
引用
@article{arxiv.2409.13710,
title = {You can remove GPT2's LayerNorm by fine-tuning},
author = {Stefan Heimersheim},
journal= {arXiv preprint arXiv:2409.13710},
year = {2024}
}
备注
Presented at the Attributing Model Behavior at Scale (ATTRIB) and Interpretable AI: Past, Present, and Future workshops at NeurIPS 2024