解析Transformer梯度下降动态,揭示收敛条件与初始化关键作用。
Unraveling the Gradient Descent Dynamics of Transformers
- 分析单层Transformer损失曲面,对比Softmax与Gaussian注意力核
- 大输入维度下,恰当初始化可保证全局最优,但Softmax可能陷入局部最优
- 理论结合实验验证,适合研究优化机制的学者参考
尽管Transformer架构在多个领域取得显著成功,但其优化动态的完整理论基础仍不充分。本文旨在填补这一空白,回答两个核心问题:(1) 哪类Transformer结构能保证梯度下降(GD)的收敛性?(2) 在何种初始条件和结构特性下,Transformer能实现快速收敛?通过分析单层Transformer在Softmax与Gaussian注意力核下的损失景观,研究给出明确答案。结果表明,在适当权重初始化下,无论采用哪种核函数,梯度下降均可使模型达到全局最优解,尤其当输入嵌入维度较大时。然而,部分情形显示使用Softmax注意力核可能陷入次优局部解;相比之下,Gaussian注意力核表现更优。实证研究进一步验证了理论发现。
原文摘要 · Abstract (English)
While the Transformer architecture has achieved remarkable success across various domains, a thorough theoretical foundation explaining its optimization dynamics is yet to be fully developed. In this study, we aim to bridge this understanding gap by answering the following two core questions: (1) Which types of Transformer architectures allow Gradient Descent (GD) to achieve guaranteed convergence? and (2) Under what initial conditions and architectural specifics does the Transformer achieve rapid convergence during training? By analyzing the loss landscape of a single Transformer layer using Softmax and Gaussian attention kernels, our work provides concrete answers to these questions. Our findings demonstrate that, with appropriate weight initialization, GD can train a Transformer model (with either kernel type) to achieve a global optimal solution, especially when the input embedding dimension is large. Nonetheless, certain scenarios highlight potential pitfalls: training a Transformer using the Softmax attention kernel may sometimes lead to suboptimal local solutions. In contrast, the Gaussian attention kernel exhibits a much favorable behavior. Our empirical study further validate the theoretical findings.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。