SympFormer: Accelerated attention blocks via Inertial Dynamics on Density Manifolds
Authors: Viktor Stein, Wuchen Li, Gabriele Steidl
Organizations: Institute of Mathematics, Technische Universität Berlin, Straße des 17. Juni 136, 10623 Berlin, Germany · Department of Mathematics, University of South Carolina, Columbia. 1523 Greene St, Columbia, SC 29208, USA
Transformers owe much of their empirical success in natural language processing to the self-attention blocks. Recent perspectives interpret attention blocks as interacting particle systems, whose mean-field limits correspond to gradient flows of interaction energy functionals on probability density spaces equipped with Wasserstein-2-type metrics. We extend this viewpoint by introducing accelerated attention blocks derived from inertial Nesterov-type dynamics on density spaces. In our proposed architecture, tokens carry both spatial (feature) and velocity variables. The time discretization and the approximation of accelerated density dynamics yield Hamiltonian momentum attention blocks, which constitute the proposed accelerated attention architectures. In particular, for linear self-attention, we show that the attention blocks approximate a Stein variational gradient flow, using a bilinear kernel, of a potential energy. In this setting, we prove that elliptically contoured probability distributions are preserved by the accelerated attention blocks. We present implementable particle-based algorithms and demonstrate that the proposed accelerated attention blocks converge faster than the classical attention blocks while preserving the number of oracle calls.
Figures & tables
Figure 1: The accelerated attention block followed by an accelerated MLP block as described in Algorithm 1 .
model
last ( ↓ )
best ( ↓ )
wall clock time (seconds) ( ↓ )
Baseline
2.4687
2.4473
2409.4
YuriiFormer-Lie-Trotter
2.4041
2.3872
2835.2
Plain Euler
2.3247
2.3234
5036.1
Presymp Euler
2.4728
2.4592
4979.0
Presymp ExpEuler
2.3579
2.2523
5623.4
Presymp AB2
2.6653
2.6546
5249.4
Table 1: Validation loss on the tinystories data set after 10000 optimization steps.
Figure 2: Validation loss (circles) and training loss (lines) on the tinystories data set after 10000 optimization steps, illustrating the results from Table 1 .
model
last ( ↓ )
best ( ↓ )
wall clock time (seconds) ( ↓ )
Baseline
3.0830
2.961427
486.7
YuriiFormer
2.8783
2.765975
749.6
plain Euler
3.0399
2.920602
809.3
Presymp Euler
2.8467
2.731363
1172.8
Table 2: Validation loss of the SympFormer with linear attention (smaller configuration) on the TinyStories data set after 10000 optimization steps.
model
last ( ↓ )
best ( ↓ )
wall clock time (seconds) ( ↓ )
Baseline
3.0118
2.917168
8956.8
YuriiFormer
2.8486
2.765023
9601.3
plain Euler
2.7483
2.656692
10806.5
Presymp Euler
2.7862
2.690885
12620.0
Table 3: Validation loss of the SympFormer with linear attention (larger configuration) on the TinyStories data set after 10000 optimization steps.
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
architecture
ζ1
ζ2
plain Euler
α
1
Presymp Euler
1−α(tk)hY
1
Presymp ExpEuler
e−Δηk
αeff1−e−Δηk
Appendix
Table 4: Scalar prefactors ζi for the different first-order time discretizations. Here, α∈(0,1) is a freely learned scalar.