mlsanityData to 14 Oct 2026

kNN Attention Demystified: A Theoretical Exploration for Scalable Transformers

arXiv 2411.04013 ↗First posted 6 Nov 2024cs.LG cs.DScited by 1

Not on the map. Why?

Abstract (arXiv)

Despite their power, Transformers face challenges with long sequences due to the quadratic complexity of self-attention. To address this limitation, methods like k-Nearest-Neighbor (kNN) attention have been introduced [Roy, Saffar, Vaswani, Grangier, 2021] enabling each token to attend to only its k closest tokens. While kNN attention has shown empirical success in making Transformers more efficient, its exact approximation guarantees have not been theoretically analyzed. In this work, we establish a theoretical framework for kNN attention, reformulating self-attention as expectations over softmax distributions and leveraging lazy Gumbel sampling [Mussmann, Levy, Ermon, 2017] with kNN indices for efficient approximation. Building on this framework, we also propose novel sub-quadratic algorithms that approximate self-attention gradients by leveraging efficient sampling techniques, such as Markov Chain-based estimation. Finally, we demonstrate the practical effectiveness of these algorithms through empirical experiments, showcasing their benefits in both training and inference.

Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Builds on 30 of its 47 references that are in the map. First posted on arXiv 6 Nov 2024.

Builds on

30 of 47 references.

References · 30

  1. 2017Attention Is All You Needcited by 60,361
  2. 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 30,186
  3. 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,673
  4. 2020Longformer: The Long-Document Transformercited by 3,413
  5. 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 2,022
  6. 2020Reformer: The Efficient Transformercited by 1,668
  7. 2020Rethinking Attention with Performerscited by 1,601
  8. 2019Generating Long Sequences with Sparse Transformerscited by 1,546
  9. 2020Linformer: Self-Attention with Linear Complexitycited by 1,474
  10. 2020Long Range Arena: A Benchmark for Efficient Transformerscited by 700
  11. 2019Enhancing the Locality and Breaking the Memory Bottleneck of Transformer on Time Series Forecastingcited by 607
  12. 2022Transformers in Time Series: A Surveycited by 497
18 more
  1. 2022Memorizing Transformerscited by 226
  2. 2021BookSum: A Collection of Datasets for Long-form Narrative Summarizationcited by 184
  3. 2019Blockwise Self-Attention for Long Document Understandingcited by 159
  4. 2019Adaptively Sparse Transformerscited by 155
  5. 2022On The Computational Complexity of Self-Attentioncited by 139
  6. 2023Unlimiformer: Long-Range Transformers with Unlimited Length Inputcited by 128
  7. 2014Asymmetric LSH (ALSH) for Sublinear Time Maximum Inner Product Search (MIPS)cited by 109
  8. 2023Fast Attention Requires Bounded Entriescited by 102
  9. 2019Star-Transformercited by 94
  10. 2023HyperAttention: Long-context Attention in Near-Linear Timecited by 85
  11. 2020The De-democratization of AI: Deep Learning and the Compute Divide in Artificial Intelligence Researchcited by 67
  12. 2021Memory-efficient Transformers via Top-k Attentioncited by 60
  13. 2023KDEformer: Accelerating Transformers via Kernel Density Estimationcited by 58
  14. 2021Is Sparse Attention more Interpretable?cited by 31
  15. 2024The Fine-Grained Complexity of Gradient Computation for Training Large Language Modelscited by 30
  16. 2020The Cascade Transformer: an Application for Efficient Answer Sentence Selectioncited by 20
  17. 2017Fast Amortized Inference and Learning in Log-linear Models with Randomly Perturbed Nearest Neighbor Searchcited by 8
  18. 2024The I/O Complexity of Attention, or How Optimal is Flash Attention?cited by 6

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 1.

1 paper.