NearFormer: Linear-Size Sparse Attention via Randomized Near Neighbors

Ali Parviz, Alex Cloninger, Gal Mishne
11/9/2026
cs.LGcs.AI
transformer-attentiongnn

No confident code implementation found for this paper.

Abstract

Graph transformers can capture long-range interactions, but their quadratic attention cost limits their use on large graphs. We introduce \emph{NearFormer}, a graph transformer whose global attention is restricted to a randomized near-neighbor (NN) graph.

Show full abstract

NearFormer uses an efficient randomized construction to connect each node to a small number of near neighbors from a broader neighborhood defined by a label-independent feature or spectral geometry. For a fixed retained budget \(k\), the resulting attention support has linear size \(\mathcal{O}(|E|+nk)\). The NN graph is built once by within-bin search and then held fixed. We use these edges as sparse global-attention supports, with optional learned attention biases, while preserving the original graph for local message passing. Experiments on long-range graph benchmarks and synthetic structural tasks show that NearFormer provides a favorable accuracy--scalability trade-off relative to local message passing, dense and sparse attention.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{parviz2026nearformer,
  title  = {NearFormer: Linear-Size Sparse Attention via Randomized Near Neighbors},
  author = {Ali Parviz and Alex Cloninger and Gal Mishne},
  year   = {2026},
  eprint = {2611.12186},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2611.12186v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2611.12186.svg)](https://codeofpaper.com/paper/2611.12186)

Discussion