Transformers from an Optimization Perspective
Yongyi Yang, Zengfeng Huang, David P. Wipf
Abstract
Deep learning models such as the Transformer are often constructed by heuristics and experience. To provide a complementary foundation, in this work we study the following problem: Is it possible to find an energy function underlying the Transformer model, such that descent steps along this energy correspond with the Transformer forward pass? By finding such a function, we can view Transformers as the unfolding of an interpretable optimization process across iterations. This unfolding perspective has been frequently adopted in the past to elucidate more straightforward deep models such as MLPs and CNNs; however, it has thus far remained elusive obtaining a similar equivalence for more complex models with self-attention mechanisms like the Transformer. To this end, we first outline several major obstacles before providing companion techniques to at least partially address them, demonstrating for the first time a close association between energy function minimization and deep layers with self-attention. This interpretation contributes to our intuition and understanding of Transformers, while potentially laying the ground-work for new model designs.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Cited by top-tier papers11
- On Sparse Modern Hopfield ModelJerry Yao-Chieh Hu, Donglin Yang, Dennis Wu, Chenwei Xu et al.NeurIPS 2023 · 52 citations
- On the Convergence of Encoder-only Shallow TransformersYongtao Wu, Fanghui Liu, Grigorios Chrysos, Volkan CevherNeurIPS 2023 · 17 citations
- Attention as Implicit Structural InferenceRyan Singh, Christopher L. BuckleyNeurIPS 2023 · 12 citations
- ContraNorm: A Contrastive Learning Perspective on Oversmoothing and BeyondXiaojun Guo, Yifei Wang, Tianqi Du, Yisen WangICLR 2023 · 10 citations
- Optimization-Derived Learning with Essential Convergence Analysis of Training and Hyper-trainingRisheng Liu, Xuan Liu, Shangzhi Zeng, Jin Zhang et al.ICML 2022 · 8 citations
Builds on14
- Reformer: The Efficient TransformerNikita Kitaev, Lukasz Kaiser, Anselm LevskayaICLR 2020 · 2,878 citations
- Simple and Deep Graph Convolutional NetworksMing Chen, Zhewei Wei, Zengfeng Huang, Bolin Ding et al.ICML 2020 · 1,910 citations
- Pay Attention to MLPsHanxiao Liu, Zihang Dai, David R. So, Quoc V. LeNeurIPS 2021 · 912 citations
- Hopfield Networks is All You NeedHubert Ramsauer, Bernhard Schäfl, Johannes Lehner, Philipp Seidl et al.ICLR 2021 · 620 citations
- cosFormer: Rethinking Softmax In AttentionZhen Qin, Weixuan Sun, Hui Deng, Dongxu Li et al.ICLR 2022 · 303 citations
Related papers
- TransforLearn: Interactive Visual Tutorial for the Transformer ModelLin Gao, Zekai Shao, Ziqin Luo, Haibo Hu et al.IEEE VIS 2023 · 13 citations
- Hyper-SET: Designing Transformers via Hyperspherical Energy MinimizationYunzhe Hu, Difan Zou, Dong XuICLR 2026 · 2 citations
- Transformers learn to implement preconditioned gradient descent for in-context learningKwangjun Ahn, Xiang Cheng, Hadi Daneshmand, Suvrit SraNeurIPS 2023 · 324 citations
- In-Context Deep Learning via Transformer ModelsWeimin Wu, Maojiang Su, Jerry Yao-Chieh Hu, Zhao Song et al.ICML 2025
- Transformers Implement Functional Gradient Descent to Learn Non-Linear Functions In ContextXiang Cheng, Yuxin Chen, Suvrit SraICML 2024 · 64 citations
