arXiv:2607.18363cs.LGcs.AI2026-07被引 1

去掉Transformer的前馈层,注意力机制仍能高效建模语言。

A Controlled Study of Attention-Only Transformers

论文配图:A Controlled Study of Attention-Only Transformers
图 1 · 摘自论文原文
  • 用纯注意力结构替换前馈层,控制参数、算力和深度一致。
  • 在1050亿词上训练,误差仅差0.006纳特,接近零差距。
  • 适合研究模型架构本质或追求轻量高效的开发者参考。

标准Transformer中前馈网络占非嵌入参数的三分之二,但尚未有实验在统一控制参数量、计算量与深度的前提下验证其必要性。本文预训练纯注意力解码器(简称SANs)与标准Transformer对比,分别在参数量、训练浮点运算次数(FLOPs)和层数(2至48层)上匹配,最大训练规模达1050亿词,参数范围为600万至8700万。移除前馈层代价显著:在相同层数下,标准模型领先0.47纳特;在相同算力下领先0.26纳特。但将释放的资源重分配给注意力深度后,差距缩小至0.006纳特(损失的0.27%),且在50亿、300亿、1050亿三类预算下持续缩小,并在29倍参数跨度下保持在0.02纳特以内。三项测量表明剩余差异源于参数记忆能力:纯注意力模型在依赖上下文回答时表现更优,但在需从权重中提取知识的任务上更差。权重谱分析显示:查询/键矩阵(Q/K)早期即结晶化,内容矩阵秩积累缓慢,而移除前馈层使该积累转移到注意力输出投影。关键发现:是QK归一化而非前馈或残差门控,维持了48层纯注意力堆栈的可训练性。缺陷集中在低上下文查询预测,且在最大规模下完全集中于此。一项预先注册的测试验证了这一解释:预测知识密集文本上存在0.02至0.05纳特差距,而基于fineweb-edu微调的对照对测得0.040纳特。在实验范围内,注意力机制足以完成语言建模任务。

原文摘要 · Abstract (English)

Feed-forward networks hold two thirds of a transformer's non-embedding parameters, yet the architecture has not received a necessity test that controls parameters, compute, and depth at once. We pretrain attention-only decoder transformers (Simple Attention Networks, SANs) against standard transformers matched separately for parameter count, training FLOPs, and depth (2 to 48 layers), for up to 105B tokens at 6M to 87M parameters. Deleting feed-forward layers in place is costly: the standard transformer leads by 0.47 nats at matched depth and 0.26 nats at matched FLOPs. Reallocating the freed budget into attention depth closes the gap: at matched parameters the difference is 0.006 nats (0.27 percent of loss), reproducible to one part in ten thousand across seed pairs, shrinking across 5B, 30B, and 105B budgets, and holding near 0.02 nats across a 29x size range. Three measurements localize the remaining gap to parametric recall: attention-only models are better on context-grounded answers and worse where knowledge must come from weights. Weight spectra show why: routing matrices (Q/K) crystallize early, content matrices accumulate rank slowly, and removing feed-forward layers relocates this accumulation to the attention output projection. QK-normalization, not feed-forward layers or residual gating, keeps 48-layer attention-only stacks trainable. The deficit concentrates on low-context query prediction and localizes there entirely by the largest budget. A pre-registered test confirms the account: it predicts a 0.02 to 0.05 nat gap on knowledge-dense web text; a matched pair trained on fineweb-edu measures 0.040. Within the tested regime, attention does the rest.

Transformer注意力机制模型压缩语言建模

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