Unraveling the Gradient Descent Dynamics of Transformers

Bingqing Song, Boran Han, Shuai Zhang, Jie Ding, Mingyi Hong
11/12/2024
cs.LGmath.OC

No confident code implementation found for this paper.

Abstract

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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{song2024unraveling,
  title  = {Unraveling the Gradient Descent Dynamics of Transformers},
  author = {Bingqing Song and Boran Han and Shuai Zhang and Jie Ding and Mingyi Hong},
  year   = {2024},
  eprint = {2411.07538},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2411.07538},
  url    = {http://arxiv.org/abs/2411.07538v1},
  journal = {NEURIPS 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2411.07538.svg)](https://codeofpaper.com/paper/2411.07538)

Discussion