arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2410.07799cs.LGstat.ML
收藏

关注差距:注意力层中秩坍缩与信号传播的谱分析

Mind the Gap: a Spectral Analysis of Rank Collapse and Signal Propagation in Attention Layers

Mathematical Institute, University of Oxford(牛津大学数学研究所)

Thiziri Nait Saada, Alireza Naderi, Jared Tanner

AI总结:

该研究针对softmax注意力层的信息传播异常问题,通过随机矩阵理论发现了宽度方向秩坍缩的新问题及谱隙成因,提出移除离群特征值的缓解方案,为相关实证研究提供理论支撑。

摘要:

注意力层是Transformer(当前最先进的神经网络架构)的核心组件。由于基于softmax的注意力存在阻碍有效信息流的倾向,研究人员正在探索其替代方案。即便在初始化阶段,人们仍不甚清楚为何信号和梯度在这些随机网络中的传播会出现异常,进而导致两类已知问题:(i)梯度消失/爆炸,以及(ii)深度方向的秩坍缩,即所有token在逐层传播中收敛为单一表示。尽管深度方向的秩坍缩由重复矩阵乘法自然引发——这是多种架构共有的模式——但我们发现了softmax注意力层独有的、此前未被发现的另一类挑战:(iii)宽度方向的秩坍缩,该问题会随着上下文长度增加而出现。我们利用随机矩阵理论开展了严格分析,揭示出注意力矩阵的两个最大奇异值之间存在的谱隙是导致问题(iii)的原因,而这又会进一步加剧问题(i)和(ii)。基于这一洞见,我们提出了一种新颖且简单的实用解决方案,通过移除离群特征值来缓解宽度方向的秩坍缩。我们的理论框架为近期的实践研究提供了全新视角,例如(Ye等人,2024;Ali等人,2023),他们的特设解决方案现在可被解释为解决谱隙问题的隐性尝试。这项工作为正在进行的大规模实证研究提供了宝贵的理论支撑,让Transformer理解领域的理论与实践更进一步。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑