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

使用符号梯度下降的两层 Transformer 的优化与泛化

On the Optimization and Generalization of Two-layer Transformers with Sign Gradient Descent

Tsinghua University(清华大学);RIKEN AIP(理化学研究所人工智能项目);University of Tokyo(东京大学);Shanghai Jiao Tong University(上海交通大学)

Bingrui Li, Wei Huang, Andi Han, Zhanpeng Zhou, Taiji Suzuki, Jun Zhu, Jianfei Chen

AI总结:

研究符号梯度下降优化两层 Transformer 的训练动态,证明其在有噪数据集上收敛快但泛化差,并指出 Adam 表现类似且均需高质量数据。

摘要:

Adam 优化器在实践中被广泛用于 Transformer 的优化,这使得理解其底层优化机制成为一个重要问题。然而,由于 Adam 的复杂性,从理论上分析它如何优化 Transformer 仍然是一项具有挑战性的任务。幸运的是,符号梯度下降(SignGD)作为 Adam 的有效替代方法。尽管 SignGD 很简单,但关于它如何优化 Transformer 的理论理解仍然滞后。在本研究中,我们探讨了 SignGD 如何优化一个两层 Transformer——该 Transformer 由一个带有可训练 query-key 参数化的 softmax attention 层以及随后的一个线性层组成——训练数据为线性可分的有噪数据集。我们在训练动态中识别出四个阶段,每个阶段都展现出有趣的行为。基于这些训练动态,我们证明了学习到的 Transformer 在有噪数据集上具有快速收敛性但泛化能力较差。我们还表明,在此设定下,Adam 在优化和泛化方面的行为与 SignGD 类似。此外,我们发现 SignGD 泛化能力差并非仅仅由于数据噪声,这表明 SignGD 和 Adam 在实际任务中都需要高质量数据。最后,在合成数据集和真实世界数据集上的实验从经验上支持了我们的理论结果。

英文摘要:

The Adam optimizer is widely used for transformer optimization in practice, which makes understanding the underlying optimization mechanisms an important problem. However, due to the Adam's complexity, theoretical analysis of how it optimizes transformers remains a challenging task. Fortunately, Sign Gradient Descent (SignGD) serves as an effective surrogate for Adam. Despite its simplicity, theoretical understanding of how SignGD optimizes transformers still lags behind. In this work, we study how SignGD optimizes a two-layer transformer -- consisting of a softmax attention layer with trainable query-key parameterization followed by a linear layer -- on a linearly separable noisy dataset. We identify four stages in the training dynamics, each exhibiting intriguing behaviors. Based on the training dynamics, we prove the fast convergence but poor generalization of the learned transformer on the noisy dataset. We also show that Adam behaves similarly to SignGD in terms of both optimization and generalization in this setting. Additionally, we find that the poor generalization of SignGD is not solely due to data noise, suggesting that both SignGD and Adam requires high-quality data for real-world tasks. Finally, experiments on synthetic and real-world datasets empirically support our theoretical results.

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

↑