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

关于Transformer中注意力掩码与LayerNorm的作用研究

On the Role of Attention Masks and LayerNorm in Transformers

MIT LIDS(麻省理工学院信息与决策系统实验室);MIT CSAIL(麻省理工学院计算机科学与人工智能实验室);TU Munich(慕尼黑工业大学)

Xinyi Wu, Amir Ajorlou, Yifei Wang, Stefanie Jegelka, Ali Jadbabaie

AI总结:

该研究分析Transformer中注意力掩码与LayerNorm对自注意力秩坍缩的影响,发现稀疏/局部掩码可减缓坍缩,合适值矩阵下带LayerNorm的自注意力不会坍缩至秩1子空间,推翻了LayerNorm无作用的假设,揭示其更强的表达能力。

摘要:

自注意力是Transformer的核心机制,而Transformer是现代基础模型的关键构建模块。近期研究表明,纯自注意力会随着网络深度增加出现日益严重的秩坍缩问题,限制了模型的表达能力以及模型深度的进一步利用。然而,现有关于秩坍缩的研究大多忽略了Transformer中其他可能缓解秩坍缩问题的关键组件。\n本文对自注意力机制下的秩坍缩现象展开了一般性分析,同时纳入了注意力掩码与层归一化(LayerNorm)的影响。具体而言,我们发现尽管纯掩码注意力仍会出现向秩为1的子空间的指数式坍缩,但稀疏或局部掩码注意力可被证明能够减缓坍缩速率。\n在结合LayerNorm的自注意力场景中,我们首先证明对于特定类别的值矩阵,系统仍会指数式坍缩至秩为1的子空间。但随后我们通过构造非平凡反例证实,若选择合适的值矩阵,一类通用序列可能不会收敛到秩为1的子空间,且带LayerNorm的自注意力动力学可同时拥有丰富的均衡态集合,其秩可覆盖从1到满秩之间的所有可能取值。\n我们的研究结果反驳了此前“LayerNorm对自注意力的秩坍缩无影响”的假设,表明带LayerNorm的自注意力构成了一个远比此前认知更具表达力、更多样化的非线性动力学系统。

英文摘要:

Self-attention is the key mechanism of transformers, which are the essential building blocks of modern foundation models. Recent studies have shown that pure self-attention suffers from an increasing degree of rank collapse as depth increases, limiting model expressivity and further utilization of model depth. The existing literature on rank collapse, however, has mostly overlooked other critical components in transformers that may alleviate the rank collapse issue. In this paper, we provide a general analysis of rank collapse under self-attention, taking into account the effects of attention masks and layer normalization (LayerNorm). In particular, we find that although pure masked attention still suffers from exponential collapse to a rank one subspace, sparse or local masked attention can provably slow down the collapse rate. In the case of self-attention with LayerNorm, we first show that for certain classes of value matrices, collapse to a rank one subspace still happens exponentially. However, through construction of nontrivial counterexamples, we then establish that with proper choice of value matrices, a general class of sequences may not converge to a rank one subspace, and the self-attention dynamics with LayerNorm can simultaneously possess a rich set of equilibria with any possible rank between one and full. Our result refutes the previous hypothesis that LayerNorm plays no role in the rank collapse of self-attention and suggests that self-attention with LayerNorm constitutes a much more expressive, versatile nonlinear dynamical system than what was originally thought.

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

↑