[论文解读] The Lazy Neuron Phenomenon: On Emergence of Activation Sparsity in Transformers
本文识别并研究了训练后的Transformer模型中的“懒惰神经元”现象,即中间MLP激活表现出高度稀疏性——仅有3–6%的条目非零,尽管计算是密集的。这种稀疏性在不同架构和数据集的训练过程中自然出现,且通过Top-k剪枝强制实现更严格的稀疏性可提升模型的鲁棒性、校准能力与效率,而性能无损失。
This paper studies the curious phenomenon for machine learning models with Transformer architectures that their activation maps are sparse. By activation map we refer to the intermediate output of the multi-layer perceptrons (MLPs) after a ReLU activation function, and by sparse we mean that on average very few entries (e.g., 3.0% for T5-Base and 6.3% for ViT-B16) are nonzero for each input to MLP. Moreover, larger Transformers with more layers and wider MLP hidden dimensions are sparser as measured by the percentage of nonzero entries. Through extensive experiments we demonstrate that the emergence of sparsity is a prevalent phenomenon that occurs for both natural language processing and vision tasks, on both training and evaluation data, for Transformers of various configurations, at layers of all depth levels, as well as for other architectures including MLP-mixers and 2-layer MLPs. We show that sparsity also emerges using training datasets with random labels, or with random inputs, or with infinite amount of data, demonstrating that sparsity is not a result of a specific family of datasets. We discuss how sparsity immediately implies a way to significantly reduce the FLOP count and improve efficiency for Transformers. Moreover, we demonstrate perhaps surprisingly that enforcing an even sparser activation via Top-k thresholding with a small value of k brings a collection of desired but missing properties for Transformers, namely less sensitivity to noisy training data, more robustness to input corruptions, and better calibration for their prediction confidence.
研究动机与目标
- 理解为何在训练后的Transformer中,中间激活即使在密集计算下仍表现出高度稀疏性。
- 研究这种稀疏性是否源于数据集特定属性,还是在不同架构和数据类型中普遍存在的现象。
- 探讨稀疏性对模型效率、鲁棒性与校准能力的影响。
- 确定通过Top-k剪枝强制实现稀疏性是否能提升模型的泛化能力与可靠性。
- 通过训练动态而非显式正则化解释稀疏性的出现。
提出的方法
- 测量多种Transformer架构和任务中,ReLU激活的MLP输出中非零条目所占百分比,以衡量激活稀疏性。
- 在自然数据、随机数据和无限数据上训练模型,以隔离数据分布对稀疏性的影响。
- 使用不同宽度和优化器的两层MLP,研究简化模型中的稀疏性,并观察单峰稀疏性模式。
- 应用Top-k剪枝以强制实现极端稀疏性,并评估下游任务的鲁棒性与校准能力。
- 分析初始化时的梯度动态,将稀疏性的出现与训练动态联系起来。
- 比较不同模型深度、宽度和训练设置(训练/评估数据)下的稀疏性。
实验结果
研究问题
- RQ1Transformer中的激活稀疏性在不同架构、任务和数据分布中在多大程度上是普遍现象?
- RQ2稀疏性是由于数据集特征所致,还是由训练动态驱动?
- RQ3模型宽度、参数化区域(欠参数化/过参数化/中间区域)与激活稀疏性之间有何关系?
- RQ4通过Top-k剪枝强制实现极端稀疏性是否能提升模型的鲁棒性与置信度校准?
- RQ5为何在无显式正则化或稀疏性诱导目标的情况下,Transformer中仍会出现稀疏性?
主要发现
- Transformer MLP激活中的稀疏性极为普遍:T5-Base在自然数据上平均仅有2.7%的非零条目,ViT-B16为6.3%。
- 稀疏性随模型深度和宽度增加而增强,表明在更大模型中更显著。
- 稀疏性在自然数据和随机数据(包括无限数据设置)中均持续存在,表明其与数据无关。
- 即使在简单的两层MLP中,稀疏性依然出现,表明其是训练动态的特性,而非架构设计的结果。
- 使用较小的k值(如k=1或2)进行Top-k剪枝可提升对输入扰动的鲁棒性,并降低对噪声标签的敏感性。
- 稀疏性与更好的置信度校准相关,并可在不损失准确率的前提下实现显著的FLOP减少。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。