解析带残差连接的Transformer梯度下降收敛性,揭示其稳定训练机制。
On the Convergence of Gradient Descent on Learning Transformers with Residual Connections
- 构建单层完整Transformer模型,分析梯度下降收敛过程。
- 证明在合适初始化下收敛速度由注意力输出矩阵的奇异值决定。
- 发现残差连接能缓解softmax导致的病态问题,提升优化稳定性。
Transformer模型因其在多个科学与工程领域的卓越表现已成为基础工具。尽管其实证成功显著,但其理论基础仍相对薄弱,尤其对训练动态的理解不足。现有研究多聚焦于孤立组件(如自注意力机制和前馈网络),未充分探讨组件间相互作用,特别是残差连接的影响。本文通过分析包含自注意力、前馈网络及残差连接的单层完整Transformer,揭示在适当初始化下,梯度下降呈现线性收敛率,收敛速度取决于注意力输出矩阵的最小与最大奇异值。分析还表明,残差连接可缓解由softmax操作带来的低秩结构所引发的病态问题,从而增强优化稳定性。我们将理论扩展至多层Transformer架构,在合适初始化下同样验证了线性收敛性。实验结果支持理论发现,证实残差连接对促进收敛稳定性具有积极作用。
原文摘要 · Abstract (English)
Transformer models have emerged as fundamental tools across various scientific and engineering disciplines, owing to their outstanding performance in diverse applications. Despite this empirical success, the theoretical foundations of Transformers remain relatively underdeveloped, particularly in understanding their training dynamics. Existing research predominantly examines isolated components--such as self-attention mechanisms and feedforward networks--without thoroughly investigating the interdependencies between these components, especially when residual connections are present. In this paper, we aim to bridge this gap by analyzing the convergence behavior of a structurally complete yet single-layer Transformer, comprising self-attention, a feedforward network, and residual connections. We demonstrate that, under appropriate initialization, gradient descent exhibits a linear convergence rate, where the convergence speed is determined by the minimum and maximum singular values of the output matrix from the attention layer. Moreover, our analysis reveals that residual connections serve to ameliorate the ill-conditioning of this output matrix, an issue stemming from the low-rank structure imposed by the softmax operation, thereby promoting enhanced optimization stability. We also extend our theoretical findings to a multi-layer Transformer architecture, confirming the linear convergence rate of gradient descent under suitable initialization. Empirical results corroborate our theoretical insights, illustrating the beneficial role of residual connections in promoting convergence stability.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。