mlsanityData to 7 Oct 2026

Cottention: Linear Transformers With Cosine Attention

arXiv 2409.18747 ↗First posted 27 Sep 2024cs.LGcited by 5

Not on the map. Why?

Abstract (arXiv)

Attention mechanisms, particularly softmax attention, have been instrumental in the success of transformer-based models such as GPT. However, the quadratic memory complexity of softmax attention with respect to sequence length poses significant challenges for processing longer sequences. We introduce Cottention, a novel attention mechanism that replaces the softmax operation with cosine similarity. By leveraging the properties of cosine similarity and rearranging the attention equation, Cottention achieves native linear memory complexity with respect to sequence length, making it inherently more memory-efficient than softmax attention. We demonstrate that Cottention can be reformulated as a recurrent neural network (RNN) with a finite hidden state, allowing for constant memory usage during inference. We evaluate Cottention on both the bidirectional BERT and causal GPT tasks, demonstrating comparable performance to softmax attention while significantly reducing memory requirements. To ensure efficient computation, we develop a custom CUDA kernel for Cottention. Our results show that Cottention is a promising alternative to softmax attention, enabling the processing of longer sequences without sacrificing performance, due to its native linear memory complexity and ability to maintain a constant memory footprint during inference.

Key facts. Cited by 5 papers in the map (data through 7 Oct 2026). Builds on 35 of its 38 references that are in the map. First posted on arXiv 27 Sep 2024.

Builds on

35 of 38 references.

References · 35

  1. 2017Attention Is All You Needcited by 59,932
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  3. 2020Language Models are Few-Shot Learnerscited by 32,199
  4. 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
  5. 2021High-Resolution Image Synthesis with Latent Diffusion Modelscited by 18,694
  6. 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
  7. 2018GLUE: A Multi-Task Benchmark and Analysis Platform for Natural Language Understandingcited by 4,854
  8. 2014Neural Machine Translation by Jointly Learning to Align and Translatecited by 4,530
  9. 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,611
  10. 2020Longformer: The Long-Document Transformercited by 3,362
  11. 2022Training Compute-Optimal Large Language Modelscited by 2,927
  12. 2021Efficiently Modeling Long Sequences with Structured State Spacescited by 2,424
23 more
  1. 2020The Pile: An 800GB Dataset of Diverse Text for Language Modelingcited by 2,346
  2. 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 1,979
  3. 2020Big Bird: Transformers for Longer Sequencescited by 1,673
  4. 2020Reformer: The Efficient Transformercited by 1,658
  5. 2020Rethinking Attention with Performerscited by 1,584
  6. 2019Generating Long Sequences with Sparse Transformerscited by 1,523
  7. 2020Linformer: Self-Attention with Linear Complexitycited by 1,462
  8. 2021Swin Transformer V2: Scaling Up Capacity and Resolutioncited by 1,215
  9. 2015Aligning Books and Movies: Towards Story-like Visual Explanations by Watching Movies and Reading Bookscited by 1,041
  10. 2015Effective Approaches to Attention-based Neural Machine Translationcited by 1,024
  11. 2020Efficient Transformers: A Surveycited by 784
  12. 2016Language Modeling with Gated Convolutional Networkscited by 688
  13. 2021Combining Recurrent, Convolutional, and Continuous-time Models with Linear State-Space Layerscited by 607
  14. 2023Ring Attention with Blockwise Transformers for Near-Infinite Contextcited by 448
  15. 2021Random Feature Attentioncited by 350
  16. 2022Diagonal State Spaces are as Effective as Structured State Spacescited by 350
  17. 2022cosFormer: Rethinking Softmax in Attentioncited by 212
  18. 2021Self-attention Does Not Need O(n2) Memorycited by 152
  19. 2024Scalable High-Resolution Pixel-Space Image Synthesis with Hourglass Diffusion Transformerscited by 116
  20. 2017Cosine Normalization: Using Cosine Similarity Instead of Dot Product in Neural Networkscited by 58
  21. 2023Striped Attention: Faster Ring Attention for Causal Transformerscited by 52
  22. 2021When Attention Meets Fast Recurrence: Training Language Models with Reduced Computecited by 34
  23. 2022Enhancing Few-shot Image Classification with Cosine Transformercited by 4

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 2; 2026: 3.

5 papers.