The Devil in Linear Transformer
Zhen Qin, Xiaodong Han, Weixuan Sun, Dongxu Li, Lingpeng Kong, Nick Barnes, Yiran Zhong
Abstract
Linear transformers aim to reduce the quadratic space-time complexity of vanilla transformers. However, they usually suffer from degraded performances on various tasks and corpus. In this paper, we examine existing kernel-based linear transformers and identify two key issues that lead to such performance gaps: 1) unbounded gradients in the attention computation adversely impact the convergence of linear transformer models; 2) attention dilution which trivially distributes attention scores over long sequences while neglecting neighbouring structures. To address these issues, we first identify that the scaling of attention matrices is the devil in unbounded gradients, which turns out unnecessary in linear attention as we show theoretically and empirically. To this end, we propose a new linear attention that replaces the scaling operation with a normalization to stabilize gradients. For the issue of attention dilution, we leverage a diagonal attention to confine attention to only neighbouring tokens in early layers. Benefiting from the stable gradients and improved attention, our new linear transformer model, transNormer, demonstrates superior performance on text classification and language modeling tasks, as well as on the challenging Long-Range Arena benchmark, surpassing vanilla transformer and existing linear variants by a clear margin while being significantly more space-time efficient. The code is available at https://github.com/OpenNLPLab/Transnormer .
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
54 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention cites Reformer: The Efficient Transformer
- Long Range Arena : A Benchmark for Efficient Transformers cites Big Bird: Transformers for Longer Sequences
- Long Range Arena : A Benchmark for Efficient Transformers cites Reformer: The Efficient Transformer
- Big Bird: Transformers for Longer Sequences cites Reformer: The Efficient Transformer
- Random Feature Attention cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- Random Feature Attention cites Long Range Arena : A Benchmark for Efficient Transformers
- Random Feature Attention cites Big Bird: Transformers for Longer Sequences
- Random Feature Attention cites Reformer: The Efficient Transformer
- Simple linear attention language models balance the recall-throughput tradeoff cites Reformer: The Efficient Transformer
- Simple linear attention language models balance the recall-throughput tradeoff cites Gated Linear Attention Transformers with Hardware-Efficient Training
- Gated Linear Attention Transformers with Hardware-Efficient Training cites Simple linear attention language models balance the recall-throughput tradeoff
- Parallelizing Linear Transformers with the Delta Rule over Sequence Length cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- Parallelizing Linear Transformers with the Delta Rule over Sequence Length cites Big Bird: Transformers for Longer Sequences
- Parallelizing Linear Transformers with the Delta Rule over Sequence Length cites Random Feature Attention
- Parallelizing Linear Transformers with the Delta Rule over Sequence Length cites Simple linear attention language models balance the recall-throughput tradeoff
- Parallelizing Linear Transformers with the Delta Rule over Sequence Length cites Reformer: The Efficient Transformer
- Parallelizing Linear Transformers with the Delta Rule over Sequence Length cites Hierarchically Gated Recurrent Neural Network for Sequence Modeling
- Parallelizing Linear Transformers with the Delta Rule over Sequence Length cites Gated Linear Attention Transformers with Hardware-Efficient Training
- Parallelizing Linear Transformers with the Delta Rule over Sequence Length cites Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality
- Hierarchically Gated Recurrent Neural Network for Sequence Modeling cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- Hierarchically Gated Recurrent Neural Network for Sequence Modeling cites Long Range Arena : A Benchmark for Efficient Transformers
- Hierarchically Gated Recurrent Neural Network for Sequence Modeling cites Random Feature Attention
- Gated Linear Attention Transformers with Hardware-Efficient Training cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- Gated Linear Attention Transformers with Hardware-Efficient Training cites Big Bird: Transformers for Longer Sequences
- Gated Linear Attention Transformers with Hardware-Efficient Training cites Reformer: The Efficient Transformer
- Gated Linear Attention Transformers with Hardware-Efficient Training cites Hierarchically Gated Recurrent Neural Network for Sequence Modeling
- Gated Linear Attention Transformers with Hardware-Efficient Training cites Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality cites Gated Linear Attention Transformers with Hardware-Efficient Training
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality cites Random Feature Attention
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality cites Simple linear attention language models balance the recall-throughput tradeoff
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality cites Hierarchically Gated Recurrent Neural Network for Sequence Modeling
Cited by top-tier papers54
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space DualityTri Dao, Albert GuICML 2024 · 1,407 citations
- Parallelizing Linear Transformers with the Delta Rule over Sequence LengthSonglin Yang, Bailin Wang, Yu Zhang, Yikang Shen et al.NeurIPS 2024 · 412 citations
- Gated Linear Attention Transformers with Hardware-Efficient TrainingSonglin Yang, Bailin Wang, Yikang Shen, Rameswar Panda et al.ICML 2024 · 390 citations
- Simple linear attention language models balance the recall-throughput tradeoffSimran Arora, Sabri Eyuboglu, Michael Zhang, Aman Timalsina et al.ICML 2024 · 154 citations
- Hierarchically Gated Recurrent Neural Network for Sequence ModelingZhen Qin, Songlin Yang, Yiran ZhongNeurIPS 2023 · 152 citations
Builds on11
- Big Bird: Transformers for Longer SequencesManzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie et al.NeurIPS 2020 · 3,159 citations
- Reformer: The Efficient TransformerNikita Kitaev, Lukasz Kaiser, Anselm LevskayaICLR 2020 · 2,878 citations
- Transformers are RNNs: Fast Autoregressive Transformers with Linear AttentionAngelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François FleuretICML 2020 · 2,665 citations
- Long Range Arena : A Benchmark for Efficient TransformersYi Tay, Mostafa Dehghani, Samira Abnar, Yikang Shen et al.ICLR 2021 · 881 citations
- Random Feature AttentionHao Peng, Nikolaos Pappas, Dani Yogatama, Roy Schwartz et al.ICLR 2021 · 425 citations
Related papers
- cosFormer: Rethinking Softmax In AttentionZhen Qin, Weixuan Sun, Hui Deng, Dongxu Li et al.ICLR 2022 · 303 citations
- Various Lengths, Constant Speed: Efficient Language Modeling with Lightning AttentionZhen Qin, Weigao Sun, Dong Li, Xuyang Shen et al.ICML 2024 · 26 citations
- Linear Log-Normal Attention with Unbiased ConcentrationYury Nahshan, Joseph Kampeas, Emir HalevaICLR 2024 · 13 citations
- Long-Short Transformer: Efficient Transformers for Language and VisionChen Zhu, Wei Ping, Chaowei Xiao, Mohammad Shoeybi et al.NeurIPS 2021 · 180 citations
- Luna: Linear Unified Nested AttentionXuezhe Ma, Xiang Kong, Sinong Wang, Chunting Zhou et al.NeurIPS 2021 · 145 citations
