# NearFormer: Linear-Size Sparse Attention via Randomized Near Neighbors

DevFeed: [NearFormer: Linear-Size Sparse Attention via Randomized Near Neighbors](<https://devfeed.tech/articles/nearformer-linear-size-sparse-attention-via-randomized-near-neighbors-125527.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2611.12186>)

Author: Ali Parviz, Alex Cloninger, Gal Mishne

Published: 2026-11-10T05:00:00Z

Content type: article

Language: en

Sources: [arXiv: Artificial Intelligence](<https://devfeed.tech/sources/arxiv-artificial-intelligence.md>), [arXiv: Machine Learning](<https://devfeed.tech/sources/arxiv-machine-learning.md>)

Topics: [Machine learning](<https://devfeed.tech/topics/machine-learning.md>), [Transformer](<https://devfeed.tech/topics/transformer.md>), [graph theory](<https://devfeed.tech/topics/graph-theory.md>)

Tags: [abstract](<https://devfeed.tech/tags/abstract.md>), [arxiv](<https://devfeed.tech/tags/arxiv.md>), [attention](<https://devfeed.tech/tags/attention.md>), [benchmarks](<https://devfeed.tech/tags/benchmarks.md>), [budget](<https://devfeed.tech/tags/budget.md>), [but](<https://devfeed.tech/tags/but.md>), [can](<https://devfeed.tech/tags/can.md>), [capture](<https://devfeed.tech/tags/capture.md>), [connect](<https://devfeed.tech/tags/connect.md>), [construction](<https://devfeed.tech/tags/construction.md>), [cost](<https://devfeed.tech/tags/cost.md>), [cs-ai](<https://devfeed.tech/tags/cs-ai.md>), [cs-lg](<https://devfeed.tech/tags/cs-lg.md>), [experiments](<https://devfeed.tech/tags/experiments.md>), [feature](<https://devfeed.tech/tags/feature.md>), [fixed](<https://devfeed.tech/tags/fixed.md>), [global](<https://devfeed.tech/tags/global.md>), [graph](<https://devfeed.tech/tags/graph.md>), [graphs](<https://devfeed.tech/tags/graphs.md>), [linear](<https://devfeed.tech/tags/linear.md>), [size](<https://devfeed.tech/tags/size.md>), [sparse-attention](<https://devfeed.tech/tags/sparse-attention.md>)

## AI overview

NearFormer reduces graph-transformer global-attention support to linear size, O(|E| + nk), by connecting each node to a fixed budget k of randomized near neighbors. The neighbors come from broader neighborhoods defined by label-independent feature or spectral geometry; the graph is built once with within-bin search and held fixed. These edges support sparse global attention, optionally with learned attention biases, while the original graph remains available for local message passing. Experiments on long-range graph benchmarks and synthetic structural tasks report a favorable accuracy-scalability trade-off against local message passing, dense attention, and sparse attention. The abstract does not provide specific benchmark results or construction details.

## Source excerpt

arXiv:2611.12186v1 Announce Type: new 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. 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.