English

Sparse Attention as Compact Kernel Regression

Machine Learning 2026-05-11 v3

Abstract

Recent work has revealed a link between self-attention mechanisms in transformers and test-time kernel regression via the Nadaraya-Watson estimator, with standard softmax attention corresponding to a Gaussian kernel. However, a kernel-theoretic understanding of sparse attention mechanisms is currently missing. In this paper, we establish a formal correspondence between sparse attention and compact (bounded support) kernels. We show that normalized ReLU and sparsemax attention arise from Epanechnikov kernel regression under fixed and adaptive normalizations, respectively. More generally, we demonstrate that widely used kernels in nonparametric density estimation -- including Epanechnikov, biweight, and triweight -- correspond to α\alpha-entmax attention with α=1+1n\alpha = 1 + \frac{1}{n} for nNn \in \mathbb{N}, while the softmax/Gaussian relationship emerges in the limit nn \to \infty. This unified perspective explains how sparsity naturally emerges from kernel design and provides principled alternatives to heuristic top-kk attention and other associative memory mechanisms. Experiments with a kernel-regression-based variant of transformers -- Memory Mosaics -- show that kernel-based sparse attention achieves competitive performance on language modeling, in-context learning, and length generalization tasks, offering a principled framework for designing attention mechanisms.

Keywords

Cite

@article{arxiv.2601.22766,
  title  = {Sparse Attention as Compact Kernel Regression},
  author = {Saul Santos and Nuno Gonçalves and Daniel C. McNamee and Marcos Treviso and André F. T Martins},
  journal= {arXiv preprint arXiv:2601.22766},
  year   = {2026}
}

Comments

16 pages, 5 figures

R2 v1 2026-07-01T09:27:27.920Z