arXiv:2603.03459cs.LGcs.CL2026-03

发现Transformer中多数非线性计算可被线性替代,且不损失性能。

Half the Nonlinearity Is Wasted: Measuring and Reallocating the Transformer's MLP Budget

  • 用门控机制动态决定是否用线性代替非线性MLP
  • GPT-2中25%-56%的MLP计算可线性化,困惑度损失<1%
  • 部分层线性化反而提升性能,说明原非线性可能有害

我们研究了Transformer中MLP非线性何时真正必要。一个含 $d+1$ 参数的门控机制决定是否用线性替代器替换完整MLP。在六种模型(162M-2.8B参数)、两种架构和三个语料库上系统评估发现,非线性需求无法由词元身份预测:跨语料相关性为零($r < 0.05$),路由决策完全依赖上下文。尽管单个实例可预测性弱,但该门控利用了高度偏斜分布——多数MLP计算接近线性,在GPT-2中实现25%-56%的线性路由,困惑度代价低于1%。在GPT-2 Large中,36层中有11层通过门控优于基线,无任何层超过3.7%全线性成本。该效果具有架构依赖性:Pythia模型成本更高,但Pythia-2.8B的32层全量测试显示有一层略优。作为概念验证,逐步将中间层MLP替换为冻结线性矩阵:24层中有5层可零成本线性化。使用完整训练预算时,4层线性化带来10.2%的困惑度改进;两阶段门控方法进一步提升至17.3%,超越原始微调控制,证实这些层的非线性MLP实际有害。

原文摘要 · Abstract (English)

We investigate when transformer MLP nonlinearity is actually necessary. A gate with $d+1$ parameters decides when to replace the full MLP with a linear surrogate. Through systematic investigation across six models (162M-2.8B parameters), two architectures, and three corpora, we establish that nonlinearity need cannot be predicted from token identity: cross-corpus correlation is zero ($r < 0.05$). The routing decision is fully contextual. Despite weak per-instance predictability, the gate exploits a heavily skewed distribution where most MLP computations are near-linear, achieving 25-56% linear routing at <1% perplexity cost in GPT-2. In GPT-2 Large, 11 of 36 layers beat baseline with gating and no layer exceeds 3.7% all-linear cost. This success is architecture-dependent: Pythia models show higher costs, though Pythia-2.8B's full 32-layer sweep reveals one layer that narrowly beats baseline. As a proof of concept, we progressively replace middle-layer MLPs with frozen linear matrices: 5 of 24 layers linearize at zero cost. With a full training budget, 4 linearized layers yield a 10.2% perplexity improvement -- and a two-phase gated approach pushes this to 17.3%, beating a vanilla fine-tuning control and confirming that the nonlinear MLPs at these layers were actively harmful.

TransformerMLP优化线性化

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