在Transformer统计力学理论中剖析注意力路径的相互作用
Dissecting the Interplay of Attention Paths in a Statistical Mechanics Theory of Transformers
AI总结:
该研究构建了深度多头自注意力网络贝叶斯学习的统计力学理论,揭示注意力路径相互作用提升泛化的机制,经实验验证并可用于梯度下降模型的网络剪枝。
摘要:
尽管Transformer在实证中表现出色,但人们对其的理论理解仍较为匮乏。本文研究了一种深度多头自注意力网络,该网络与Transformer密切相关且具备解析可处理性。我们构建了该模型下贝叶斯学习的统计力学理论,推导了有限宽度热力学极限(即$N,P\rightarrow\finity$,$P/N=\bigO(1)$,其中$N$为网络宽度,$P$为训练样本数量)下网络预测统计量的精确方程。我们的理论表明,预测统计量可表示为多个独立核的和,每个核对不同的“注意力路径”配对,注意力路径定义为跨层经由不同注意力头的信息通路。这些核依据“任务相关核组合”机制进行加权,使总核与任务标签对齐。由此,注意力路径间的这种相互作用提升了泛化性能。我们在合成序列分类任务和真实世界序列分类任务上开展的实验均验证了上述发现。最后,我们的理论明确将核组合机制与所学习权重的性质关联起来,可将其见解定性迁移至通过梯度下降训练的模型。作为示例,我们通过剪去理论判定相关性较低的注意力头,实现了高效的网络规模缩减。
英文摘要:
Despite the remarkable empirical performance of Transformers, their theoretical understanding remains elusive. Here, we consider a deep multi-head self-attention network, that is closely related to Transformers yet analytically tractable. We develop a statistical mechanics theory of Bayesian learning in this model, deriving exact equations for the network's predictor statistics under the finite-width thermodynamic limit, i.e., $N,P\rightarrow\infty$, $P/N=\mathcal{O}(1)$, where $N$ is the network width and $P$ is the number of training examples. Our theory shows that the predictor statistics are expressed as a sum of independent kernels, each one pairing different 'attention paths', defined as information pathways through different attention heads across layers. The kernels are weighted according to a 'task-relevant kernel combination' mechanism that aligns the total kernel with the task labels. As a consequence, this interplay between attention paths enhances generalization performance. Experiments confirm our findings on both synthetic and real-world sequence classification tasks. Finally, our theory explicitly relates the kernel combination mechanism to properties of the learned weights, allowing for a qualitative transfer of its insights to models trained via gradient descent. As an illustration, we demonstrate an efficient size reduction of the network, by pruning those attention heads that are deemed less relevant by our theory.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。