cosFormer: Rethinking Softmax in Attention
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
- 2017Attention Is All You Needcited by 59,932
- 2015Deep Residual Learning for Image Recognitioncited by 51,809
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
- 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,266
- 2021Swin Transformer: Hierarchical Vision Transformer using Shifted Windowscited by 12,082
- 2020End-to-End Object Detection with Transformerscited by 7,384
- 2018GLUE: A Multi-Task Benchmark and Analysis Platform for Natural Language Understandingcited by 4,854
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,581
- 2020wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representationscited by 3,853
- 2020Longformer: The Long-Document Transformercited by 3,362
27 more
- 2016Pointer Sentinel Mixture Modelscited by 2,992
- 2016Categorical Reparameterization with Gumbel-Softmaxcited by 2,708
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 1,979
- 2020Big Bird: Transformers for Longer Sequencescited by 1,673
- 2020Reformer: The Efficient Transformercited by 1,658
- 2020Rethinking Attention with Performerscited by 1,584
- 2019Generating Long Sequences with Sparse Transformerscited by 1,523
- 2020Linformer: Self-Attention with Linear Complexitycited by 1,462
- 2015Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs)cited by 1,061
- 2019What Does BERT Look At? An Analysis of BERT's Attentioncited by 994
- 2020Long Range Arena: A Benchmark for Efficient Transformerscited by 696
- 2020Efficient Content-Based Sparse Attention with Routing Transformerscited by 469
- 2021Nystr"omformer: A Nystr"om-Based Algorithm for Approximating Self-Attentioncited by 468
- 2021Random Feature Attentioncited by 350
- 2019Revealing the Dark Secrets of BERTcited by 300
- 2020Sparse Sinkhorn Attentioncited by 250
- 2018Adaptive Input Representations for Neural Language Modelingcited by 226
- 2019Transformer Dissection: A Unified Understanding of Transformer's Attention via the Lens of Kernelcited by 211
- 2020Synthesizer: Rethinking Self-Attention in Transformer Modelscited by 204
- 2017On the Properties of the Softmax Function with Application in Game Theory and Reinforcement Learningcited by 136
- 2018ListOps: A Diagnostic Dataset for Latent Tree Learningcited by 128
- 2020Fast Transformers with Clustered Attentioncited by 123
- 2018Learning long-range spatial dependencies with horizontal gated-recurrent unitscited by 98
- 2021Do Transformer Modifications Transfer Across Implementations and Applications?cited by 87
- 2020SMYRF: Efficient Attention using Asymmetric Clusteringcited by 43
- 2021Relative Positional Encoding for Transformers with Linear Complexitycited by 36
- 2016One-vs-Each Approximation to Softmax for Scalable Estimation of Probabilitiescited by 14
Built on by
Citing papers per year: 2022: 34; 2023: 43; 2024: 42; 2025: 47; 2026: 46.
212 papers.
Sort:
By area:
- 2022Long Range Language Modeling via Gated State Spacescited by 265
- 2022Spikformer: When Spiking Neural Network Meets Transformercited by 263
- 2025MiniMax-M1: Scaling Test-Time Compute Efficiently with Lightning Attentioncited by 248
- 2023FLatten Transformer: Vision Transformer using Focused Linear Attentioncited by 170
- 2023Spike-driven Transformercited by 141
- 2024HGRN2: Gated Linear RNNs with State Expansioncited by 122
- 2024The Hedgehog & the Porcupine: Expressive Linear Attentions with Softmax Mimicrycited by 119
- 2023LongCoder: A Long-Range Pre-trained Language Model for Code Completioncited by 110
- 2024Demystify Mamba in Vision: A Linear Attention Perspectivecited by 101
- 2023Hierarchically Gated Recurrent Neural Network for Sequence Modelingcited by 100
- 2022The Devil in Linear Transformercited by 98
- 2022What Makes Convolutional Models Great on Long Sequence Modeling?cited by 86
38 more
- 2022KERPLE: Kernelized Relative Positional Embedding for Length Extrapolationcited by 84
- 2023MB-TaylorFormer: Multi-branch Efficient Transformer Expanded by Taylor Formula for Image Dehazingcited by 81
- 2024Beyond the Limits: A Survey of Techniques to Extend the Context Length in Large Language Modelscited by 71
- 2024Polynormer: Polynomial-Expressive Graph Transformer in Linear Timecited by 64
- 2024Mamba-360: Survey of State Space Models as Transformer Alternative for Long Sequence Modelling: Methods, Applications, and Challengescited by 63
- 2025Test-time regression: a unifying framework for designing sequence models with associative memorycited by 63
- 2022Implicit Motion Handling for Video Camouflaged Object Detectioncited by 60
- 2025SLA: Beyond Sparsity in Diffusion Transformers via Fine-Tunable Sparse-Linear Attentioncited by 55
- 2024Linearizing Large Language Modelscited by 51
- 2024Bridging the Divide: Reconsidering Softmax and Linear Attentioncited by 48
- 2023How to Capture Higher-order Correlations? Generalizing Matrix Softmax Attention to Kronecker Computationcited by 44
- 2023Toeplitz Neural Network for Sequence Modelingcited by 43
- 2023EGformer: Equirectangular Geometry-biased Transformer for 360 Depth Estimationcited by 42
- 2024Scene Adaptive Sparse Transformer for Event-based Object Detectioncited by 39
- 2025Log-Linear Attentioncited by 39
- 2025Jet-Nemotron: Efficient Language Model with Post Neural Architecture Searchcited by 39
- 2025MB-TaylorFormer V2: Improved Multi-branch Linear Transformer Expanded by Taylor Formula for Image Restorationcited by 36
- 2023A Survey of Techniques for Optimizing Transformer Inferencecited by 35
- 2023TransNormerLLM: A Faster and Better Large Language Model with Improved TransNormercited by 34
- 2022Transforming medical imaging with Transformers? A comparative review of key properties, current progresses, and future perspectivescited by 32
- 2022SimA: Simple Softmax-free Attention for Vision Transformerscited by 32
- 2025PolaFormer: Polarity-aware Linear Attention for Vision Transformerscited by 30
- 2024VSSD: Vision Mamba with Non-Causal State Space Dualitycited by 29
- 2022Castling-ViT: Compressing Self-Attention via Switching Towards Linear-Angular Attention at Vision Transformer Inferencecited by 28
- 2023Primal-Attention: Self-attention through Asymmetric Kernel SVD in Primal Representationcited by 28
- 2024Spikformer V2: Join the High Accuracy Club on ImageNet with an SNN Ticketcited by 28
- 2022Transformers from an Optimization Perspectivecited by 27
- 2023Transformer-VQ: Linear-Time Transformers via Vector Quantizationcited by 26
- 2023Faster Causal Attention Over Large Sequences Through Sparse Flash Attentioncited by 24
- 2023Efficient Attention via Control Variatescited by 23
- 2022Vicinity Vision Transformercited by 22
- 2022EcoFormer: Energy-Saving Attention with Linear Complexitycited by 21
- 2025Efficient Attention Mechanisms for Large Language Models: A Surveycited by 21
- 2022How Much Does Attention Actually Attend? Questioning the Importance of Attention in Pretrained Transformerscited by 20
- 2023SARA-RT: Scaling up Robotics Transformers with Self-Adaptive Robust Attentioncited by 20
- 2024MetaLA: Unified Optimal Linear Approximation to Softmax Attention Mapcited by 20
- 2022MPCViT: Searching for Accurate and Efficient MPC-Friendly Vision Transformer with Heterogeneous Attentioncited by 19
- 2023GAFlow: Incorporating Gaussian Attention into Optical Flowcited by 18
50 most cited of 212 All 212 (JSON)
- 2026Contrastive Attention Mitigates Spectral Bias in Spiking Transformers1 Oct 2026
- 2026Quasi Linear Kernel Attention with Infinite Capacity28 Sep 2026
- 2026Prescriptive SVD-Inspired Attention via Spectral Energy Retention21 Sep 2026
- 2026Conditioned Initialization for Attention7 Sep 2026
- 2026Uncertainty-Guided Adverse Weather Restoration via Gated Transformer Network2 Sep 2026
- 2026Efficient and High-Quality Depth Estimation via Pixel-Space Diffusion with Linear Attention31 Aug 2026
- 2026Sliding-window beats linear attention28 Aug 2026
- 2026DiD It in 87 Minutes: A Label-Free Softmax-to-Linear Adaptation of Vision Transformers for Object Detection23 Aug 2026
- 2026FLARE++: Low-rank attention with dynamic attention routing12 Aug 2026
- 2026Transformer-based Diffusion models for Hydrological Time Series Probabilistic Imputation and Forecasting23 Jul 2026
- 2026Norm or Direction? Decoding Vision Mambas for High-Resolution Vision21 Jul 2026
- 2026Kernelized Linear Attention: Breaking the Capacity Wall with Symmetric Cones19 Jul 2026
38 more
- 2026The Key to Going Linear: Analysis-Driven Transformer Linearization8 Jul 2026
- 2026Generalization Analysis of Transformers in Distribution Regression28 Jun 2026
- 2026Flexformer: Flexible Linear Transformer with Learnable Attention Kernel26 Jun 2026
- 2026Mixtures of Subspaces for Bandwidth Efficient Context Parallel Training15 Jun 2026
- 2026Long-Context Modeling via GSS-Transformer Hybrid Architecture with Learnable Mixing15 Jun 2026
- 2026ATT-CR: Adaptive Triangular Transformer for Cloud Removal4 Jun 2026
- 2026Blurry Window Attention31 May 2026
- 2026Revisiting Neural Processes via Fourier Transform and Volterra Series31 May 2026
- 2026Functional Attention: From Pairwise Affinities to Functional Correspondences29 May 2026
- 2026Activation-Free Backbones for Image Recognition: Polynomial Alternatives within MetaFormer-Style Vision Models20 May 2026
- 2026Representative Attention For Vision Transformers14 May 2026
- 2026Exact Linear Attention13 May 2026
- 2026PhysEDA: Physics-Aware Learning Framework for Efficient EDA With Manhattan Distance Decay11 May 2026
- 2026The Impossibility Triangle of Long-Context Modeling6 May 2026
- 2026LaplacianFormer:Rethinking Linear Attention with Laplacian Kernel22 Apr 2026
- 2026Integrated electro-optic attention nonlinearities for transformers10 Apr 2026
- 2026MICA: Multivariate Infini Compressive Attention for Time Series Forecasting7 Apr 2026
- 2026Preconditioned Attention: Enhancing Efficiency in Transformers28 Mar 2026
- 2026A Boltzmann-machine-enhanced Transformer For DNA Sequence Classification27 Mar 2026
- 2026Comparative analysis of dual-form networks for live land monitoring using multi-modal satellite image time series25 Mar 2026
- 2026ViT-AdaLA: Adapting Vision Transformers with Linear Attention17 Mar 2026
- 2026SketchGraphNet: A Memory-Efficient Hybrid Graph Transformer for Large-Scale Sketch Corpora Recognition8 Mar 2026
- 2026Spectral Conditioning of Attention Improves Transformer Performance7 Mar 2026
- 2026Gradient Flow Polarizes Softmax Outputs towards Low-Entropy Solutions6 Mar 2026
- 20262Mamba2Furious: Linear in Complexity, Competitive in Accuracy19 Feb 2026
- 2026HLA: Hadamard Linear Attention12 Feb 2026
- 2026Interpretable Vision Transformers in Image Classification via SVDA11 Feb 2026
- 2026Free Energy Mixer6 Feb 2026
- 2026ZeroS: Zero-Sum Linear Attention for Efficient Transformers5 Feb 2026
- 2026SLAY: Geometry-Aware Spherical Linearized Attention with Yat-Kernel4 Feb 2026
- 2026MirrorLA: Reflecting Feature Map for Vision Linear Attention4 Feb 2026
- 2026STILL: Selecting Tokens for Intra-Layer Hybrid Attention to Linearize LLMs2 Feb 2026
- 2026Dissecting Outlier Dynamics in LLM NVFP4 Pretraining2 Feb 2026
- 2026S2DiT: Sandwich Diffusion Transformer for Mobile Streaming Video Generation19 Jan 2026
- 2025MS-SSM: A Multi-Scale State Space Model for Efficient Sequence Modeling29 Dec 2025
- 2025Linear Attention for Joint Power Optimization and User-Centric Clustering in Cell-Free Networks19 Dec 2025
- 2025LUNA: Linear Universal Neural Attention with Generalization Guarantees8 Dec 2025
- 2025ViT3: Unlocking Test-Time Training in Vision1 Dec 2025
50 newest of 212 All 212 (JSON)
- 2024Demystify Mamba in Vision: A Linear Attention Perspectivecited by 101
- 2024Mamba-360: Survey of State Space Models as Transformer Alternative for Long Sequence Modelling: Methods, Applications, and Challengescited by 63
- 2024VSSD: Vision Mamba with Non-Causal State Space Dualitycited by 29
- 2024Taipan: Efficient and Expressive State Space Language Models with Selective Attentioncited by 4
- 2025Data Efficient Any Transformer-to-Mamba Distillation via Attention Bridgecited by 4
- 20262Mamba2Furious: Linear in Complexity, Competitive in Accuracycited by 1
- 2026Norm or Direction? Decoding Vision Mambas for High-Resolution Visioncited by 0
- 2026Norm or Direction? Decoding Vision Mambas for High-Resolution Vision21 Jul 2026
- 20262Mamba2Furious: Linear in Complexity, Competitive in Accuracy19 Feb 2026
- 2025Data Efficient Any Transformer-to-Mamba Distillation via Attention Bridge22 Oct 2025
- 2024Taipan: Efficient and Expressive State Space Language Models with Selective Attention24 Oct 2024
- 2024VSSD: Vision Mamba with Non-Causal State Space Duality26 Jul 2024
- 2024Demystify Mamba in Vision: A Linear Attention Perspective26 May 2024
- 2024Mamba-360: Survey of State Space Models as Transformer Alternative for Long Sequence Modelling: Methods, Applications, and Challenges24 Apr 2024
- 2025SLA: Beyond Sparsity in Diffusion Transformers via Fine-Tunable Sparse-Linear Attentioncited by 55
- 2025LiT: Delving into a Simple Linear Diffusion Transformer for Image Generationcited by 9
- 2026S2DiT: Sandwich Diffusion Transformer for Mobile Streaming Video Generationcited by 6
- 2025Attention in Diffusion Model: A Surveycited by 4
- 2026Transformer-based Diffusion models for Hydrological Time Series Probabilistic Imputation and Forecastingcited by 0
- 2026Transformer-based Diffusion models for Hydrological Time Series Probabilistic Imputation and Forecasting23 Jul 2026
- 2026S2DiT: Sandwich Diffusion Transformer for Mobile Streaming Video Generation19 Jan 2026
- 2025SLA: Beyond Sparsity in Diffusion Transformers via Fine-Tunable Sparse-Linear Attention28 Sep 2025
- 2025Attention in Diffusion Model: A Survey1 Apr 2025
- 2025LiT: Delving into a Simple Linear Diffusion Transformer for Image Generation22 Jan 2025
- 2025Representation Shift: Unifying Token Compression with FlashAttentioncited by 5
- 2026Sliding-window beats linear attentioncited by 2
- 2025LLM Inference Acceleration via Efficient Operation Fusioncited by 1
- 2026Blurry Window Attentioncited by 1
- 2026Representative Attention For Vision Transformerscited by 0
- 2026Sliding-window beats linear attention28 Aug 2026
- 2026Blurry Window Attention31 May 2026
- 2026Representative Attention For Vision Transformers14 May 2026
- 2025Representation Shift: Unifying Token Compression with FlashAttention1 Aug 2025
- 2025LLM Inference Acceleration via Efficient Operation Fusion24 Feb 2025
- 2026Exact Linear Attentioncited by 0
- 2026Exact Linear Attention13 May 2026
- 2022Long Range Language Modeling via Gated State Spacescited by 265
- 2022Spikformer: When Spiking Neural Network Meets Transformercited by 263
- 2023FLatten Transformer: Vision Transformer using Focused Linear Attentioncited by 170
- 2023Spike-driven Transformercited by 141
- 2024HGRN2: Gated Linear RNNs with State Expansioncited by 122
- 2024The Hedgehog & the Porcupine: Expressive Linear Attentions with Softmax Mimicrycited by 119
- 2023LongCoder: A Long-Range Pre-trained Language Model for Code Completioncited by 110
- 2023Hierarchically Gated Recurrent Neural Network for Sequence Modelingcited by 100
- 2022The Devil in Linear Transformercited by 98
- 2022What Makes Convolutional Models Great on Long Sequence Modeling?cited by 86
- 2022KERPLE: Kernelized Relative Positional Embedding for Length Extrapolationcited by 84
- 2023MB-TaylorFormer: Multi-branch Efficient Transformer Expanded by Taylor Formula for Image Dehazingcited by 81
12 most cited of 192 All 192 (JSON)
- 2026Contrastive Attention Mitigates Spectral Bias in Spiking Transformers1 Oct 2026
- 2026Quasi Linear Kernel Attention with Infinite Capacity28 Sep 2026
- 2026Prescriptive SVD-Inspired Attention via Spectral Energy Retention21 Sep 2026
- 2026Conditioned Initialization for Attention7 Sep 2026
- 2026Uncertainty-Guided Adverse Weather Restoration via Gated Transformer Network2 Sep 2026
- 2026Efficient and High-Quality Depth Estimation via Pixel-Space Diffusion with Linear Attention31 Aug 2026
- 2026DiD It in 87 Minutes: A Label-Free Softmax-to-Linear Adaptation of Vision Transformers for Object Detection23 Aug 2026
- 2026FLARE++: Low-rank attention with dynamic attention routing12 Aug 2026
- 2026Kernelized Linear Attention: Breaking the Capacity Wall with Symmetric Cones19 Jul 2026
- 2026The Key to Going Linear: Analysis-Driven Transformer Linearization8 Jul 2026
- 2026Generalization Analysis of Transformers in Distribution Regression28 Jun 2026
- 2026Flexformer: Flexible Linear Transformer with Learnable Attention Kernel26 Jun 2026
12 newest of 192 All 192 (JSON)
Similar, not cited
Close in wording, no citation either way
- 2024More Expressive Attention with Negative Weights
- 2024Beyond Linear Approximations: A Novel Pruning Approach for Attention Matrix
- 2022Mega: Moving Average Equipped Gated Attention
- 2026SAS: Simple Attention Sparsification via End-to-End Optimization of Context Ranking
- 2025Forgetting Transformer: Softmax Attention with a Forget Gate
- 2024A Training-free Sub-quadratic Cost Transformer Model Serving Framework With Hierarchically Pruned Attention
- 2025Sliding Window Attention Training for Efficient Large Language Models
- 2025Mixture of Sparse Attention: Content-Based Learnable Sparse Attention via Expert-Choice Routing