cosFormer: Rethinking Softmax In Attention
Zhen Qin, Weixuan Sun, Hui Deng, Dongxu Li, Yunshen Wei, Baohong Lv, Junjie Yan, Lingpeng Kong, Yiran Zhong
摘要
Transformer has shown great successes in natural language processing, computer vision, and audio processing. As one of its core components, the softmax attention helps to capture long-range dependencies yet prohibits its scale-up due to the quadratic space and time complexity to the sequence length. Kernel methods are often adopted to reduce the complexity by approximating the softmax operator. Nevertheless, due to the approximation errors, their performances vary in different tasks/corpus and suffer crucial performance drops when compared with the vanilla softmax attention. In this paper, we propose a linear transformer called COSFORMER that can achieve comparable or better accuracy to the vanilla transformer in both casual and cross attentions. COSFORMER is based on two key properties of softmax attention: i). non-negativeness of the attention matrix; ii). a non-linear re-weighting scheme that can concentrate the distribution of the attention matrix. As its linear substitute, COSFORMER fulfills these properties with a linear operator and a cosine-based distance re-weighting mechanism. Extensive experiments on language modeling and text understanding tasks demonstrate the effectiveness of our method. We further examine our method on long sequences and achieve state-of-the-art performance on the Long-Range Arena benchmark. The source code is available at COSFORMER .
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 97 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- FLatten Transformer: Vision Transformer using Focused Linear Attention 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- FLatten Transformer: Vision Transformer using Focused Linear Attention 引用了 Reformer: The Efficient Transformer
- FLatten Transformer: Vision Transformer using Focused Linear Attention 引用了 Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Big Bird: Transformers for Longer Sequences 引用了 Reformer: The Efficient Transformer
- Structure-Aware Transformer for Graph Representation Learning 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Demystify Mamba in Vision: A Linear Attention Perspective 引用了 FLatten Transformer: Vision Transformer using Focused Linear Attention
- Demystify Mamba in Vision: A Linear Attention Perspective 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Demystify Mamba in Vision: A Linear Attention Perspective 引用了 Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Spike-driven Transformer 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Spike-driven Transformer 引用了 Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
引用它的顶会 Paper97
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space DualityTri Dao, Albert GuICML 2024 · 1,407 次引用
- Spike-driven TransformerMan Yao, Jiakui Hu, Zhaokun Zhou, Li Yuan 等NeurIPS 2023 · 368 次引用
- FLatten Transformer: Vision Transformer using Focused Linear AttentionDongchen Han, Xuran Pan, Yizeng Han, Shiji Song 等ICCV 2023 · 358 次引用
- Structure-Aware Transformer for Graph Representation LearningDexiong Chen, Leslie O'Bray, Karsten M. BorgwardtICML 2022 · 349 次引用
- Demystify Mamba in Vision: A Linear Attention PerspectiveDongchen Han, Ziyi Wang, Zhuofan Xia, Yizeng Han 等NeurIPS 2024 · 287 次引用
它引用的 Paper14
- 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 次引用
- wav2vec 2.0: A Framework for Self-Supervised Learning of Speech RepresentationsAlexei Baevski, Yuhao Zhou, Abdelrahman Mohamed, Michael AuliNeurIPS 2020 · 9,451 次引用
- Big Bird: Transformers for Longer SequencesManzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie 等NeurIPS 2020 · 3,159 次引用
- Reformer: The Efficient TransformerNikita Kitaev, Lukasz Kaiser, Anselm LevskayaICLR 2020 · 2,878 次引用
相关 Paper
- The Devil in Linear TransformerZhen Qin, Xiaodong Han, Weixuan Sun, Dongxu Li 等EMNLP 2022 · 24 次引用
- NormDirection: Restoring the Missing Query Norm in Vision Linear AttentionWeikang Meng, Yadan Luo, Liangyu Huo, Yingjian Li 等ICML 2026 · 2 次引用
- Skyformer: Remodel Self-Attention with Gaussian Kernel and Nyström MethodYifan Chen, Qi Zeng, Heng Ji, Yun YangNeurIPS 2021 · 74 次引用
- Nyströmformer: A Nyström-based Algorithm for Approximating Self-AttentionYunyang Xiong, Zhanpeng Zeng, Rudrasis Chakraborty, Mingxing Tan 等AAAI 2021 · 675 次引用
- Bridging the Divide: Reconsidering Softmax and Linear AttentionDongchen Han, Yifan Pu, Zhuofan Xia, Yizeng Han 等NeurIPS 2024 · 69 次引用
