paper-with-me

Papers

$k$NN Attention Demystified: A Theoretical Exploration for Scalable Transformers

2024-11-06 · Themistoklis Haris

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 ($k$NN) attention have been introduced [Roy, Saffar, Vaswani, Grangier, 2021] enabling each token to attend to only its $k$ closest tokens. While $k$NN 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 $k$NN attention, reformulating self-attention as expectations over softmax distributions and leveraging lazy Gumbel sampling [Mussmann, Levy, Ermon, 2017] with $k$NN 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.

📄 PDF Abstract BibTeX arXiv:2411.04013

Code (1)

sansui-123/knn_attention 공식 구현 pytorch

Methods 이 논문이 사용한 방법론

Attention 설명 없음
Softmax The Softmax output function transforms a previous layer's output into a vector of probabilities. It is commonly used for multiclass classification. Given an input vector $x$…

Similar Papers 제목 키워드 기반

Masked Language Modeling for Proteins via Linearly Scalable Long-Context Transformers

2020-06-05 · Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song 외

Transformer models have achieved state-of-the-art results across a diverse range of domains. However, concern over the cost of training the attention mechanism to learn complex dependencies between distant inputs continu…

Language ModelingLanguage ModellingMasked Language Modeling

In-Context Linear Regression Demystified: Training Dynamics and Mechanistic Interpretability of Multi-Head Softmax Attention

2025-03-17 · Jianliang He, Xintian Pan, Siyu Chen, Zhuoran Yang

We study how multi-head softmax attention models are trained to perform in-context learning on linear data. Through extensive empirical experiments and rigorous theoretical analysis, we demystify the emergence of elegant…

In-Context Learning

Strassen Attention: Unlocking Compositional Abilities in Transformers Based on a New Lower Bound Method

2025-01-31 · Alexander Kozachinskiy, Felipe Urrutia, Hector Jimenez, Tomasz Steifer 외

We propose a novel method to evaluate the theoretical limits of Transformers, allowing us to prove the first lower bounds against one-layer softmax Transformers with infinite precision. We establish those bounds for thre…

All

On the Theoretical Expressive Power and the Design Space of Higher-Order Graph Transformers

2024-04-04 · Cai Zhou, Rose Yu, Yusu Wang

Graph transformers have recently received significant attention in graph learning, partly due to their ability to capture more global interaction via self-attention. Nevertheless, while higher-order graph neural networks…

Graph AttentionGraph Learning

SWAT: Scalable and Efficient Window Attention-based Transformers Acceleration on FPGAs

2024-05-27 · Zhenyu Bai, Pranav Dangi, Huize Li, Tulika Mitra

Efficiently supporting long context length is crucial for Transformer models. The quadratic complexity of the self-attention computation plagues traditional Transformers. Sliding window-based static sparse attention miti…

GPU