mlsanityData to 7 Oct 2026

cosFormer: Rethinking Softmax in Attention

arXiv 2202.08791 ↗First posted 17 Feb 2022cs.CLcited by 212

On the map: LLM reasoning → Test-time compute and efficient thinking

Abstract (arXiv)

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 https://github.com/OpenNLPLab/cosFormer.

Key facts. Cited by 212 papers in the map (data through 7 Oct 2026). Placed in Test-time compute and efficient thinking, one of 17 directions in LLM reasoning. Builds on 39 of its 52 references that are in the map. First posted on arXiv 17 Feb 2022.

Builds on

39 of 52 references.

References · 39

  1. 2017Attention Is All You Needcited by 59,932
  2. 2015Deep Residual Learning for Image Recognitioncited by 51,809
  3. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  4. 2020Language Models are Few-Shot Learnerscited by 32,199
  5. 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
  6. 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,266
  7. 2021Swin Transformer: Hierarchical Vision Transformer using Shifted Windowscited by 12,082
  8. 2020End-to-End Object Detection with Transformerscited by 7,384
  9. 2018GLUE: A Multi-Task Benchmark and Analysis Platform for Natural Language Understandingcited by 4,854
  10. 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,581
  11. 2020wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representationscited by 3,853
  12. 2020Longformer: The Long-Document Transformercited by 3,362
27 more
  1. 2016Pointer Sentinel Mixture Modelscited by 2,992
  2. 2016Categorical Reparameterization with Gumbel-Softmaxcited by 2,708
  3. 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 1,979
  4. 2020Big Bird: Transformers for Longer Sequencescited by 1,673
  5. 2020Reformer: The Efficient Transformercited by 1,658
  6. 2020Rethinking Attention with Performerscited by 1,584
  7. 2019Generating Long Sequences with Sparse Transformerscited by 1,523
  8. 2020Linformer: Self-Attention with Linear Complexitycited by 1,462
  9. 2015Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs)cited by 1,061
  10. 2019What Does BERT Look At? An Analysis of BERT's Attentioncited by 994
  11. 2020Long Range Arena: A Benchmark for Efficient Transformerscited by 696
  12. 2020Efficient Content-Based Sparse Attention with Routing Transformerscited by 469
  13. 2021Nystr"omformer: A Nystr"om-Based Algorithm for Approximating Self-Attentioncited by 468
  14. 2021Random Feature Attentioncited by 350
  15. 2019Revealing the Dark Secrets of BERTcited by 300
  16. 2020Sparse Sinkhorn Attentioncited by 250
  17. 2018Adaptive Input Representations for Neural Language Modelingcited by 226
  18. 2019Transformer Dissection: A Unified Understanding of Transformer's Attention via the Lens of Kernelcited by 211
  19. 2020Synthesizer: Rethinking Self-Attention in Transformer Modelscited by 204
  20. 2017On the Properties of the Softmax Function with Application in Game Theory and Reinforcement Learningcited by 136
  21. 2018ListOps: A Diagnostic Dataset for Latent Tree Learningcited by 128
  22. 2020Fast Transformers with Clustered Attentioncited by 123
  23. 2018Learning long-range spatial dependencies with horizontal gated-recurrent unitscited by 98
  24. 2021Do Transformer Modifications Transfer Across Implementations and Applications?cited by 87
  25. 2020SMYRF: Efficient Attention using Asymmetric Clusteringcited by 43
  26. 2021Relative Positional Encoding for Transformers with Linear Complexitycited by 36
  27. 2016One-vs-Each Approximation to Softmax for Scalable Estimation of Probabilitiescited by 14

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2022: 34; 2023: 43; 2024: 42; 2025: 47; 2026: 46.

212 papers.

Sort:

By area:

  1. 2022Long Range Language Modeling via Gated State Spacescited by 265
  2. 2022Spikformer: When Spiking Neural Network Meets Transformercited by 263
  3. 2025MiniMax-M1: Scaling Test-Time Compute Efficiently with Lightning Attentioncited by 248
  4. 2023FLatten Transformer: Vision Transformer using Focused Linear Attentioncited by 170
  5. 2023Spike-driven Transformercited by 141
  6. 2024HGRN2: Gated Linear RNNs with State Expansioncited by 122
  7. 2024The Hedgehog & the Porcupine: Expressive Linear Attentions with Softmax Mimicrycited by 119
  8. 2023LongCoder: A Long-Range Pre-trained Language Model for Code Completioncited by 110
  9. 2024Demystify Mamba in Vision: A Linear Attention Perspectivecited by 101
  10. 2023Hierarchically Gated Recurrent Neural Network for Sequence Modelingcited by 100
  11. 2022The Devil in Linear Transformercited by 98
  12. 2022What Makes Convolutional Models Great on Long Sequence Modeling?cited by 86
38 more
  1. 2022KERPLE: Kernelized Relative Positional Embedding for Length Extrapolationcited by 84
  2. 2023MB-TaylorFormer: Multi-branch Efficient Transformer Expanded by Taylor Formula for Image Dehazingcited by 81
  3. 2024Beyond the Limits: A Survey of Techniques to Extend the Context Length in Large Language Modelscited by 71
  4. 2024Polynormer: Polynomial-Expressive Graph Transformer in Linear Timecited by 64
  5. 2024Mamba-360: Survey of State Space Models as Transformer Alternative for Long Sequence Modelling: Methods, Applications, and Challengescited by 63
  6. 2025Test-time regression: a unifying framework for designing sequence models with associative memorycited by 63
  7. 2022Implicit Motion Handling for Video Camouflaged Object Detectioncited by 60
  8. 2025SLA: Beyond Sparsity in Diffusion Transformers via Fine-Tunable Sparse-Linear Attentioncited by 55
  9. 2024Linearizing Large Language Modelscited by 51
  10. 2024Bridging the Divide: Reconsidering Softmax and Linear Attentioncited by 48
  11. 2023How to Capture Higher-order Correlations? Generalizing Matrix Softmax Attention to Kronecker Computationcited by 44
  12. 2023Toeplitz Neural Network for Sequence Modelingcited by 43
  13. 2023EGformer: Equirectangular Geometry-biased Transformer for 360 Depth Estimationcited by 42
  14. 2024Scene Adaptive Sparse Transformer for Event-based Object Detectioncited by 39
  15. 2025Log-Linear Attentioncited by 39
  16. 2025Jet-Nemotron: Efficient Language Model with Post Neural Architecture Searchcited by 39
  17. 2025MB-TaylorFormer V2: Improved Multi-branch Linear Transformer Expanded by Taylor Formula for Image Restorationcited by 36
  18. 2023A Survey of Techniques for Optimizing Transformer Inferencecited by 35
  19. 2023TransNormerLLM: A Faster and Better Large Language Model with Improved TransNormercited by 34
  20. 2022Transforming medical imaging with Transformers? A comparative review of key properties, current progresses, and future perspectivescited by 32
  21. 2022SimA: Simple Softmax-free Attention for Vision Transformerscited by 32
  22. 2025PolaFormer: Polarity-aware Linear Attention for Vision Transformerscited by 30
  23. 2024VSSD: Vision Mamba with Non-Causal State Space Dualitycited by 29
  24. 2022Castling-ViT: Compressing Self-Attention via Switching Towards Linear-Angular Attention at Vision Transformer Inferencecited by 28
  25. 2023Primal-Attention: Self-attention through Asymmetric Kernel SVD in Primal Representationcited by 28
  26. 2024Spikformer V2: Join the High Accuracy Club on ImageNet with an SNN Ticketcited by 28
  27. 2022Transformers from an Optimization Perspectivecited by 27
  28. 2023Transformer-VQ: Linear-Time Transformers via Vector Quantizationcited by 26
  29. 2023Faster Causal Attention Over Large Sequences Through Sparse Flash Attentioncited by 24
  30. 2023Efficient Attention via Control Variatescited by 23
  31. 2022Vicinity Vision Transformercited by 22
  32. 2022EcoFormer: Energy-Saving Attention with Linear Complexitycited by 21
  33. 2025Efficient Attention Mechanisms for Large Language Models: A Surveycited by 21
  34. 2022How Much Does Attention Actually Attend? Questioning the Importance of Attention in Pretrained Transformerscited by 20
  35. 2023SARA-RT: Scaling up Robotics Transformers with Self-Adaptive Robust Attentioncited by 20
  36. 2024MetaLA: Unified Optimal Linear Approximation to Softmax Attention Mapcited by 20
  37. 2022MPCViT: Searching for Accurate and Efficient MPC-Friendly Vision Transformer with Heterogeneous Attentioncited by 19
  38. 2023GAFlow: Incorporating Gaussian Attention into Optical Flowcited by 18

50 most cited of 212 All 212 (JSON)

Similar, not cited

Close in wording, no citation either way

  1. 2024More Expressive Attention with Negative Weights
  2. 2024Beyond Linear Approximations: A Novel Pruning Approach for Attention Matrix
  3. 2022Mega: Moving Average Equipped Gated Attention
  4. 2026SAS: Simple Attention Sparsification via End-to-End Optimization of Context Ranking
  5. 2025Forgetting Transformer: Softmax Attention with a Forget Gate
  6. 2024A Training-free Sub-quadratic Cost Transformer Model Serving Framework With Hierarchically Pruned Attention
  7. 2025Sliding Window Attention Training for Efficient Large Language Models
  8. 2025Mixture of Sparse Attention: Content-Based Learnable Sparse Attention via Expert-Choice Routing