揭示注意力层中信号传播的奇异值缺口问题,提出简单修复方案。
Mind the Gap: a Spectral Analysis of Rank Collapse and Signal Propagation in Attention Layers
- 通过随机矩阵理论分析注意力矩阵奇异值分布
- 发现上下文长度增大时出现宽度方向秩坍塌,导致信号衰减
- 提出移除异常特征值的轻量级修复方法,适配实际模型优化
注意力层是当前主流神经网络架构Transformer的核心组件。尽管软最大注意力存在信息流动受阻的问题,其在初始化阶段的信号与梯度传播机制仍不清晰,常引发(i)梯度消失/爆炸和(ii)深度方向秩坍塌——即所有标记沿层收敛为单一表示。我们发现,软最大注意力还存在此前未知的(iii)宽度方向秩坍塌,随上下文长度增加而加剧。基于随机矩阵理论,我们揭示了注意力矩阵前两个最大奇异值间存在谱隙,是导致(iii)的根本原因,并进一步恶化(i)和(ii)。基于此,我们提出一种简单有效的方法:移除异常特征值以缓解宽度方向秩坍塌。该理论框架为近期若干经验性工作(如Ye et al., 2024;Ali et al., 2023)提供了统一解释,表明它们的启发式方案实质上是隐式应对谱隙问题。本研究为大规模实证研究提供理论支撑,推动了对Transformer的理解向理论与实践融合迈进。
原文摘要 · Abstract (English)
Attention layers are the core component of transformers, the current state-of-the-art neural network architecture. Alternatives to softmax-based attention are being explored due to its tendency to hinder effective information flow. Even at initialisation, it remains poorly understood why the propagation of signals and gradients through these random networks can be pathological, resulting in issues known as (i) vanishing/exploding gradients and (ii) rank collapse $\textit{in depth}$, i.e. when all tokens converge to a single representation along layers. While rank collapse in depth naturally arises from repeated matrix multiplications$\unicode{x2013}$a common pattern across various architectures$\unicode{x2013}$we identify an additional and previously unknown challenge unique to softmax attention layers: (iii) rank collapse $\textit{in width}$, which occurs as the context length increases. Using Random Matrix Theory, we conduct a rigorous analysis that uncovers a spectral gap between the two largest singular values of the attention matrix as the cause of (iii), which in turn exacerbates (i) and (ii). Building on this insight, we propose a novel yet simple practical solution to mitigate rank collapse in width by removing the outlier eigenvalue(s). Our theoretical framework offers a fresh perspective on recent practical studies, such as (Ye et al., 2024; Ali et al., 2023), whose ad hoc solutions can now be interpreted as implicit efforts to address the spectral gap issue. This work provides valuable theoretical support for ongoing large-scale empirical research, bringing theory and practice one step closer in the understanding of transformers.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。