Stable, Fast and Accurate: Kernelized Attention with Relative Positional Encoding
Shengjie Luo, Shanda Li, Tianle Cai, Di He, Dinglan Peng, Shuxin Zheng, Guolin Ke, Liwei Wang, Tie-Yan Liu
摘要
The attention module, which is a crucial component in Transformer, cannot scale efficiently to long sequences due to its quadratic complexity. Many works focus on approximating the dot-then-exponentiate softmax function in the original attention, leading to sub-quadratic or even linear-complexity Transformer architectures. However, we show that these methods cannot be applied to more powerful attention modules that go beyond the dot-then-exponentiate style, e.g., Transformers with relative positional encoding (RPE). Since in many state-of-the-art models, relative positional encoding is used as default, designing efficient Transformers that can incorporate RPE is appealing. In this paper, we propose a novel way to accelerate attention calculation for Transformers with RPE on top of the kernelized attention. Based upon the observation that relative positional encoding forms a Toeplitz matrix, we mathematically show that kernelized attention with RPE can be calculated efficiently using Fast Fourier Transform (FFT). With FFT, our method achieves time complexity. Interestingly, we further demonstrate that properly using relative positional encoding can mitigate the training instability problem of vanilla kernelized attention. On a wide range of tasks, we empirically show that our models can be trained from scratch without any optimization issues. The learned model performs better than many efficient Transformer variants and is faster than standard Transformer in the long-sequence regime.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 22 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Deberta: decoding-Enhanced Bert with Disentangled Attention 引用了 Reformer: The Efficient Transformer
- Functional Interpolation for Relative Positions improves Long Context Transformers 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Functional Interpolation for Relative Positions improves Long Context Transformers 引用了 Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Functional Interpolation for Relative Positions improves Long Context Transformers 引用了 Your Transformer May Not be as Powerful as You Expect
- Functional Interpolation for Relative Positions improves Long Context Transformers 引用了 KERPLE: Kernelized Relative Positional Embedding for Length Extrapolation
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows 引用了 Training data-efficient image transformers & distillation through attention
- ESSAformer: Efficient Transformer for Hyperspectral Image Super-resolution 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- ESSAformer: Efficient Transformer for Hyperspectral Image Super-resolution 引用了 Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Your Transformer May Not be as Powerful as You Expect 引用了 Deberta: decoding-Enhanced Bert with Disentangled Attention
- Your Transformer May Not be as Powerful as You Expect 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Your Transformer May Not be as Powerful as You Expect 引用了 Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Training data-efficient image transformers & distillation through attention 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Hungry Hungry Hippos: Towards Language Modeling with State Space Models 引用了 Reformer: The Efficient Transformer
- KERPLE: Kernelized Relative Positional Embedding for Length Extrapolation 引用了 Deberta: decoding-Enhanced Bert with Disentangled Attention
引用它的顶会 Paper22
- Hungry Hungry Hippos: Towards Language Modeling with State Space ModelsDaniel Y. Fu, Tri Dao, Khaled Kamal Saab, Armin W. Thomas 等ICLR 2023 · 117 次引用
- KERPLE: Kernelized Relative Positional Embedding for Length ExtrapolationTa-Chung Chi, Ting-Han Fan, Peter J. Ramadge, Alexander RudnickyNeurIPS 2022 · 112 次引用
- ESSAformer: Efficient Transformer for Hyperspectral Image Super-resolutionMingjin Zhang, Chi Zhang, Qiming Zhang, Jie Guo 等ICCV 2023 · 73 次引用
- Your Transformer May Not be as Powerful as You ExpectShengjie Luo, Shanda Li, Shuxin Zheng, Tie-Yan Liu 等NeurIPS 2022 · 69 次引用
- Functional Interpolation for Relative Positions improves Long Context TransformersShanda Li, Chong You, Guru Guruganesh, Joshua Ainslie 等ICLR 2024 · 66 次引用
它引用的 Paper16
- Swin Transformer: Hierarchical Vision Transformer using Shifted WindowsZe Liu, Yutong Lin, Yue Cao, Han Hu 等ICCV 2021 · 31,683 次引用
- An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn 等ICLR 2021 · 21,477 次引用
- Training data-efficient image transformers & distillation through attentionHugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa 等ICML 2021 · 8,974 次引用
- Deberta: decoding-Enhanced Bert with Disentangled AttentionPengcheng He, Xiaodong Liu, Jianfeng Gao, Weizhu ChenICLR 2021 · 3,729 次引用
- Reformer: The Efficient TransformerNikita Kitaev, Lukasz Kaiser, Anselm LevskayaICLR 2020 · 2,878 次引用
相关 Paper
- Conv-Basis: A New Paradigm for Efficient Attention Inference and Gradient Computation in TransformersYingyu Liang, Heshan Liu, Zhenmei Shi, Zhao Song 等EMNLP Findings 2025
- Long-range Sequence Modeling with Predictable Sparse AttentionYimeng Zhuang, Jing Zhang, Mei TuACL 2022 · 11 次引用
- Learnable Fourier Features for Multi-dimensional Spatial Positional EncodingYang Li, Si Si, Gang Li, Cho-Jui Hsieh 等NeurIPS 2021 · 171 次引用
- Toeplitz Neural Network for Sequence ModelingZhen Qin, Xiaodong Han, Weixuan Sun, Bowen He 等ICLR 2023 · 5 次引用
- Fourier Transformer: Fast Long Range Modeling by Removing Sequence Redundancy with FFT OperatorZiwei He, Meng Yang, Minwei Feng, Jingcheng Yin 等ACL Findings 2023 · 13 次引用
