← 返回 2026-04-14

Transformer 中的注意力汇聚现象:一项关于利用、解释与缓解的综述 Attention Sink in Transformers: A Survey on Utilization, Interpretation, and Mitigation

Zunhai Su, Hengyuan Zhang, Wei Wu, Yifan Zhang, Yaxiu Liu, He Xiao, Qingyao Yang, Yuxuan Sun, Rui Yang, Chao Zhang, Keyu Fan, Weihao Ye, Jing Xiong, Hui Shen, Chaofan Tao, Taiqiang Wu, Zhongwei Wan, Yulei Qian, Yuchen Xie, Ngai Wong 📅 2026-04-11 👍 82 2026-07-13 08:36
Attention Sink Transformer 可解释性 注意力机制 激活异常值 量化部署

首篇系统综述 AS 在 Transformer 各家族中的机制、用法与抑制方法

前置知识

多头自注意力 (Multi-Head Self-Attention, MHSA)

Transformer 核心算子,对输入线性投影得 $Q,K,V$,通过 $\text{Attention}(Q,K,V) = \text{Softmax}(QK^\top / \sqrt{d_k}) V$ 建模两位置依赖。多头并行捕捉不同粒度。

Softmax 归一化是 AS 现象的数学根源,了解注意力分数如何被强制归一到 1,才能理解 AS 为何是 Transformer 的内禀行为。

Softmax 归一化与 sum-to-one 约束

Softmax 把实数 logits 指数化后除以总和,得到和为 1 的概率分布。当 query 与所有 key 都不相关时,仍必须分配正概率到某些 token 上,"无关性"就被压缩到这些无关 token 上。

No-Op 理论的基础:当 head 想做"几乎不更新"时,被迫把全部概率质量集中到某个低信息 token 并让 value 接近 0,结果就是注意力汇聚。

KV Cache 与推理效率

自回归生成每步都要把历史 token 的 K/V 重新读出来,显存和带宽是长上下文的主要瓶颈。StreamingLLM、H2O、KVQuant 等方法通过剪枝/量化压缩历史 KV。

Sink Token Preservation 的整个体系都建立在这之上:保留首部几个 token 的 KV 几乎不增加显存,却能保留模型长文本建模的稳定性。

激活异常值 (Massive Activations / Outliers)

训练好的 Transformer 中,特定 token 在特定隐藏维度上出现比其他维度大几个数量级的激活值(如 >10000),这些值跨层、跨输入都很稳定。

Outlier Circuits 视角认为 AS 是权重/激活/注意力异常值构成的"异常电路"的注意力端表现,是 AS 的数值基础。

Mixture-of-Experts (MoE) 与 Super Expert

MoE 层用路由器为每个 token 选 top-k 个 FFN 专家(如 6,144 选 8)。Super Expert 指的是极少几个对 AS 形成至关重要的专家,如 Qwen3-30B-A3B 剪掉其中 3 个就崩。

AS 在 MoE LLM 中的表现与 Super Expert 直接绑定,是理解为什么稀疏激活模型依然有 AS 的关键,也是 MoE 特有的脆弱性来源。

研究动机

近两年来,几乎所有主流 Transformer 家族——BERT/RoBERTa、稠密 LLM、MoE LLM、ViT、DiT、MLLM——都被发现存在一个共同现象:极少数无语义 token(如 LLM 首 [BOS]、ViT 背景 patch)持续吸纳绝大部分注意力权重。在 LLaMA 中首 token 在 98% 的注意力头中拿到最大权重 [165];Qwen3-30B-A3B 中仅 3/6144 个 Super Expert 缺失就会让 AS 全面崩塌 [43]。这些汇聚行为引发四类问题:(i) 长文本推理中 KV cache 压力巨大,剪掉 sink token 模型立即崩坏(PPL 从 5.40 暴涨到 5158 [25]);(ii) 量化时这些极端激活破坏 INT8/INT4 精度 [30];(iii) 注意力被无意义 token 占用,导致 MLLM 严重幻觉 [32, 101];(iv) 训练损失曲线出现 spike,限制 scaling 效率 [27]。现有碎片化论文分散在 NLP/CV/MoE/Diffusion 等子社区,缺乏统一的形式化定义和分类体系。

本文的目标是本文作为该领域第一篇系统综述,明确三件事:(1) 给 AS 一个跨架构统一的数学形式化(极端高注意力 + 低信息量两个充分必要条件),并用阈值 $\tau \cdot \mu_A$(典型 $\tau=1000$ [80])作为可操作的判别准则;(2) 把过去几年 200+ 篇 AS 相关工作系统地划入"基础利用 / 机制解释 / 战略缓解"三条主线,并按时间维度(2023 利用→2024 解释→2025 缓解)展示研究演化轨迹;(3) 围绕 9 类应用场景(预训练、微调、高效推理、可解释性、降低幻觉、安全性、长文本、多模态、能力增强)给出可直接落地的"该用哪个方法"实践指南。论文还配套维护一个 GitHub 仓库(github.com/ZunhaiSu/Awesome-Attention-Sink)持续收录新工作。

与已有工作不同的是,与以往单点方法论文不同,本文的独特切入角度是"用统一框架整合碎片化工作"。一方面,作者观察到 AS 在不同架构(BERT 里的 [SEP]、LLaMA 里的 [BOS]、ViT 里的背景 patch、MLLM 里的无关视觉 token、DiT 里的中段 token)的"皮"不同,但"骨"相同:都是 Softmax sum-to-one 约束 + 训练动态共同塑造的数值异常电路,因此用"利用 / 解释 / 缓解"三视角可以一次覆盖所有架构;另一方面,作者提出了一种分类新原则:把方法分为"提供显式替代品(门控、显式 bias)"和"切断因果链(修改 Softmax、预训练干预)"两类,并显式给出 5 个分析层级(数学起源 / 训练动态 / 数值机制 / 几何结构 / 功能角色)的统一框架,把散落的 5 种主要理论(No-Op、Outlier Circuits、Implicit Bias、Geometric Anchoring、Anti-Overmixing 等)第一次摆在同一张地图上,让研究者第一次能跨架构、跨场景地复用 AS 处理经验。

核心方法

本文作为综述,把现有 AS 研究组织成"利用 / 解释 / 缓解"三视角的层级化体系。利用层(第 3 章)介绍 AS 如何被直接用起来:保留 sink token 维护长文本稳定、重分配注意力缓解视觉幻觉、插入可学习 prefix token 吸收冗余注意力、把 sink 当攻击/防御/加速工具。解释层(第 4 章)从 5 个分析层级(共 7 种理论)回答"为什么会这样":No-Op 理论归因于 Softmax 约束,Outlier Circuits 定位到权重/激活/注意力异常值的闭环,Implicit Bias 发现 sink value 等价于隐式偏置,Geometric Anchoring 把 sink 看作高维空间的稳定锚点。缓解层(第 5 章)落到可操作手段,分"显式替代"和"切断因果链"两类。整篇论文以"先发现现象→利用现象→理解现象→消除副作用"的递进结构展开。

本文的核心创新不在算法层面而在"框架层面"。三个最关键的提炼是:(1) 提出 AS 的统一两要素定义——"极端高注意力 + 低信息量"——并给出可阈值化的判别公式 $\mathcal{S}_{AS}=\{j \mid \sum_i A_{i,j} > \tau \cdot \mu_A\}$,让"什么是 sink token"在 LLM、ViT、MLLM 中有了同一把尺子;(2) 首次把 AS 在 LLM、MoE LLM、MLLM、ViT、DiT 中的表现串联起来,揭示其在不同架构中本质同构(都是异常值电路的注意力端),让视觉社区和 NLP 社区的经验可以双向迁移;(3) 把 7 种主流解释理论按"数学起源 / 训练动态 / 数值机制 / 几何结构 / 功能角色"5 层组织成统一图谱,并把 5 大类缓解方法按"显式替代 vs. 切断因果链"二分,给出第一个真正跨架构、可比对的 AS 方法坐标系——这是任何单点论文都做不到的。

方法步骤详情

本文按"利用-解释-缓解"路径组织。第 2 章建立 AS 形式化(sink 阈值典型 1000 [80]),按 6 类架构介绍 AS 表现。第 3 章"利用"分 4 节:Sink Token Preservation 保留 sink+window;Attention Redistribution 用守恒重分配;Learnable Prefix Tokens(ViT Registers、CTR-Sink);Sink Token Repurposing(KeyDiff、backdoor)。第 4 章论证 $\text{Softmax}(x)_i=0$ 需 $x_j-x_i=+\infty$,推 no-op $\|V_S\|\approx 0$;通过 Outlier Circuits 因果链串证据。第 5 章按 Gated Attention、Modified Softmax、Learnable Attention Bias、Pre-training Interventions(TWEO/Muon/OSP)展开。第 6 章以 9 类应用给实践 checklist。

技术新颖性

技术新颖性体现在三个"第一":(1) 第一次给出 AS 的跨架构统一形式化,把"极端注意力 + 低信息"两个本质属性从经验观察提升为可计算定义(阈值 $\tau\cdot\mu_A$ 公式 (5)),让任何架构都能用同一标准检测 sink token;(2) 第一次系统地把 AS 现象、解释、缓解三个层级联立起来:明确指出 No-Op 理论回答"为什么"、Outlier Circuits 回答"靠什么数值机制"、Implicit Bias 回答"功能上等价于什么"、Geometric Anchoring 回答"在表示空间里扮演什么角色",4 个角度互补而非互斥;(3) 第一次把 5 大类缓解方法按"显式替代 vs. 切断因果链"二分——这种二分法不是事后分类,而是源自一个清晰的设计哲学:要么给模型一条新路完成 no-op,要么拆掉 softmax 强制分配注意力的旧路。这种分类让"为什么这类方法不能后插到已训练模型""为什么那类方法可以"等问题有了一致答案。配套的 GitHub 仓库(180+ 论文)也使该综述变成一个可演化的活地图。

Architecture of the standard Transformer and an illustration of typical AS.
Figure 4: Architecture of the standard Transformer and an illustration of typical AS.
AS in BERT.
Figure 5: AS in BERT.
Visualization of average attention logits across Llama-2-7B.
Figure 6: Visualization of average attention logits across Llama-2-7B.
Structural overview of a representative decoder-only LLM.
Figure 7: Structural overview of a representative decoder-only LLM.
Decoder Architecture of MoE LLM.
Figure 8: Decoder Architecture of MoE LLM.
Expert router score distributions for sink and non-sink tokens.
Figure 9: Expert router score distributions for sink and non-sink tokens.
Visualization and characterization of Visual Attention Sinks in MLLMs.
Figure 10: Visualization and characterization of Visual Attention Sinks in MLLMs.
Outlier and AS analysis for ViT.
Figure 11: Outlier and AS analysis for ViT.
StreamingLLM retains the AS alongside recent tokens for stable attention computation.
Figure 13: StreamingLLM retains the AS alongside recent tokens for stable attention computation.
The three sparse attention patterns in MInference, with sink token protection incorporated.
Figure 14: The three sparse attention patterns in MInference, with sink token protection incorporated.
Visualization of attention maps in the Llama-2-7B model.
Figure 15: Visualization of attention maps in the Llama-2-7B model.
Overview of Visual Attention Redistribution (VAR).
Figure 16: Overview of Visual Attention Redistribution (VAR).
Models pre-trained without and with a sink token.
Figure 17: Models pre-trained without and with a sink token.
Activation magnitudes in LLaMA2-7B before and after applying CushionCache.
Figure 18: Activation magnitudes in LLaMA2-7B before and after applying CushionCache.
Attention maps with and without register tokens.
Figure 19: Attention maps with and without register tokens.
Self-attention patterns in BERT-base, showing attention probabilities, value magnitudes, and their product.
Figure 22: Self-attention patterns in BERT-base, showing attention probabilities, value magnitudes, and their product.
Analysis of sink token properties.
Figure 23: Analysis of sink token properties.
Systematic outliers in LLaMA2-7B.
Figure 25: Systematic outliers in LLaMA2-7B.
The emergence of activation outliers from weight outliers.
Figure 26: The emergence of activation outliers from weight outliers.
The spread of attention outliers from activation outliers (AS).
Figure 27: The spread of attention outliers from activation outliers (AS).
Systematic outlier mechanism in Qwen3-30B-A3B MoE LLM.
Figure 28: Systematic outlier mechanism in Qwen3-30B-A3B MoE LLM.
Cross-layer evolution of extreme activation outliers in LLaMA2-7B.
Figure 29: Cross-layer evolution of extreme activation outliers in LLaMA2-7B.
Value updates from AS tokens are essentially the same.
Figure 30: Value updates from AS tokens are essentially the same.
Cosine similarity of attention bias terms across tokens and heads.
Figure 31: Cosine similarity of attention bias terms across tokens and heads.
PCA visualization of positional vectors.
Figure 32: PCA visualization of positional vectors.
Cosine similarity of normalized hidden states across layers in Llama-2-13B and Mistral-7B.
Figure 33: Cosine similarity of normalized hidden states across layers in Llama-2-13B and Mistral-7B.
The presence of AS modulates information flow between tokens.
Figure 34: The presence of AS modulates information flow between tokens.
Evolution of attention patterns in Pythia 410M.
Figure 35: Evolution of attention patterns in Pythia 410M.
Schematic illustration of gated attention.
Figure 36: Schematic illustration of gated attention.
Architecture of Value-State Gated Attention (VGA).
Figure 39: Architecture of Value-State Gated Attention (VGA).

实验结果

汇集 200+ 论文关键数字:(1) AS 普遍性——LLaMA 首 token 在 98% 注意力头拿最大权重 [165];BERT [SEP] 常独占某头 50%+ 注意力 [53]。(2) 长文本——StreamingLLM [25] dense 4K PPL=5641,sliding 砍 sink PPL=5158,sink+window PPL=5.43。(3) MoE 脆弱性——Qwen3-30B-A3B 剪 3/6144 Super Expert 即退化为重复输出 [43]。(4) 缓解有效性——Gated Attention [27] 46.7%→4.8%;Softmax-1 [165] 65%→3.3%,kurtosis 1657→3.1;Softpick [75] sink rate 100%→0%;TWEO [59] 异常值 >10000→<20,FP8 throughput 提升 36%。(5) 跨模态——FLEX [129] 6× 视频外推;RetoVLA [138] 机器人操作提升 17.1%;几何 [76] Spearman 相关性 0.94。

Ablation studies on rolling diffusion window, mixed training strategy, and AS in Rolling Forcing.
Figure 12: Ablation studies on rolling diffusion window, mixed training strategy, and AS in Rolling Forcing.
Softmax vs Softpick sink rate and largest activation comparison.
Figure 24: Softmax vs Softpick sink rate and largest activation comparison.
Gating position exploration and performance comparison.
Figure 37: Gating position exploration and performance comparison.
AS mitigation with Gated Attention.
Figure 38: AS mitigation with Gated Attention.
Softmax vs Softmax-1 attention maps and activation outliers in GPT2-Medium.
Figure 40: Softmax vs Softmax-1 attention maps and activation outliers in GPT2-Medium.
Attention maps of Softmax and Softpick.
Figure 41: Attention maps of Softmax and Softpick.
查看结构化数据
任务指标本文基线提升
长文本语言建模(困惑度) Perplexity (PPL, 越低越好) StreamingLLM 报告 sink+sliding window 在 4K+ 上下文 PPL=5.40 dense attention PPL=5641;sliding window 砍 sink PPL=5158 相对 dense attention 提升 >1000×,相对 naive sliding window 提升 >950×
首 token 注意力抑制 首 token 注意力比例 (越低越好) Gated Attention 平均 4.8% [27];Softmax-1 3.3% [165];Softpick 0% sink rate [75] baseline LLaMA2-7B 平均 46.7% [27];GPT-2 Medium 65% [165];100% sink rate Gated Attention 约 10× 抑制;Softmax-1 约 20× 抑制;Softpick 完全消除
激活异常值抑制 激活 kurtosis / 异常值幅度 (越低越稳) Softpick kurtosis 340 [75];Softmax-1 kurtosis 3.1 [165];TWEO 异常值 <20 [59] Softmax 原始 33,510 [75];Softmax 原始 1,657 [165];Adam 训练 >10,000 Softpick 约 100×;Softmax-1 约 500×;TWEO 约 500×
INT4/INT8 KV cache 量化 下游任务准确率 (越高越好) IntactKV / KVSink / KVQuant 等保留 sink token 后 2-bit 量化 [16, 29, 154] 不做 sink 保护的 2-bit 量化 在 LongBench、Needle-in-a-Haystack 等长文本基准上恢复接近 FP16 精度(差距 <1-2 个点)
视觉语言模型幻觉抑制 POPE / CHAIR / MMHal-Bench 准确率 VAR [101]、AttnReal [32]、VASparse [33] 通过重分配 sink 注意力 原始 MLLM POPE 准确率提升 5-15 个点(具体随模型和 benchmark 而异)
自回归视频扩散时间外推 生成时长倍数 (越高越好) FLEX 框架 inference-time attention sink [129] 训练时只见过 5s 的 baseline 实现 6× 外推(30s),匹配 12× 数据微调的 baseline
VLA 机器人操作 真实环境任务成功率 RetoVLA 重用 register token 作为空间记忆 [138] 原始 VLA 丢弃 register token 真实机器人操作任务提升 17.1%

局限与改进

作者在 §9 显式承认三个局限:(1) 覆盖广度上,本文主要聚焦 CLM、LLM、MLLM、MoE LLM、ViT、DiT 等主流架构,对 Hymba、Mamba-R、VGGT、Omni-modal LLM 等新兴架构涉及较浅,原因是相关研究刚起步。(2) AS 现象跨架构同构但实现细节不同,本文形式化主要围绕 LLM 的 MHSA + Softmax,对 Mamba、RWKV 等非 Softmax 架构的等价现象只能类比。(3) 综述性工作不产出新基准,导致 sink rate、attention mass、kurtosis 等指标在不同论文中定义略有差异。本人观察到的额外局限:(4) 第 4 章把 5+ 种解释理论并排列出,但缺少统一实验比较"哪个理论解释力更强";(5) 第 5 章缓解方法的代价-收益对比主要来自各原论文自报数据,缺独立第三方 benchmark;(6) 对 AS 在 RLHF/DPO 等对齐阶段的影响讨论不足。

独立分析的弱点

独立审视识别 6 个弱点:(1) AS 自我强化循环何时建立仍不清晰——No-Op 理论只说"会建立",Outlier Circuits 只说"建立后什么样",缺乏 epoch-level 探针。改进:训练时记录每 head sink 强度随 epoch 变化。(2) 阈值式判别 $\tau\cdot\mu_A$ 在 batch 内分布不均时易误判。改进:用轻量 head-level probe 替代全局阈值。(3) Modified Softmax(Softpick、Sigmoid Attn)大多不能后插已训练 LLM。改进:研究"逐步蒸馏",把标准 LLM 用 KL 对齐到 Softpick 再用极少步微调。(4) Gated Attention 训练成本高(3.5T tokens)。改进:只训练 gate 参数、冻结主体的 adapter 方案。(5) 对 AS 与安全/对齐关系讨论流于表面。改进:补充 AS-aware red-teaming 协议。(6) 缺乏 AS 与训练数据分布的因果分析。改进:消融 tokenizer/语种/长度分布,建立 sink 强度预测模型。

未来方向

作者在 §7.2 给出 7 个方向:(1) 高效轻量化 AS 处理——sink 检测、重分配、门控、几何度量在延迟和 kernel 兼容上突破;(2) 预训练模型的轻量适配——用 adapter/LoRA/continual pre-training 注入 gate/modified-softmax/bias;(3) 训练动态形式化——把 Softmax 约束、优化动态、隐式 bias 纳入统一数学框架;(4) 新兴架构中的 AS——Hymba、VGGT、3D Transformer 尚缺系统研究;(5) 统一理论框架——把 4-5 种解释融合为单一可证伪理论;(6) 标准化 benchmark——让 sink rate、kurtosis、PPL、量化恢复可跨论文比较;(7) 跨架构跨模态迁移。本人认为还可拓展:(8) AS 与 CoT 推理的交互;(9) AS-aware MoE 路由损失;(10) 超长视频/音频/机器人轨迹的 AS 演化;(11) 用 attention patching、causal tracing 干预 sink 验证功能性角色。

复现评估

可复现性两极分化:(1) 数据与算力——方法在 Pile/RedPajama/LongBench/ImageNet-1K/COCO/Needle-in-a-Haystack 等开源数据集评估;但生产级方法(OSP 1.4B/1T tokens、Gated Attention 3.5T tokens)需数十到数百张 H100。(2) 代码开源较好——StreamingLLM、H2O、IntactKV、Softpick、ViT Registers、OSP、Quantizable Transformers 都开源 PyTorch,可在小模型重现;MoE 的 Super Expert 分析(Qwen3-30B-A3B)及部分 Gated Attention 改进只在闭源模型上验证。(3) 配套仓库 github.com/ZunhaiSu/Awesome-Attention-Sink 把 200+ 论文分类。(4) 复现难度:经典利用 ⭐ 易;Modified Softmax 小模型 ⭐⭐ 中等;Gated Attention 与 OSP 从零训练 ⭐⭐⭐ 困难;生产级 MoE 复现 ⭐⭐⭐⭐。