Linear Attention via Positive Kernel Feature Maps

This direction is merged into another direction: linear complexity attention. Its last version stays readable and citable here.

Version 1 of 113 papers21 conceptsfrozen 2026-10-04

Standard Transformers are computationally expensive because their attention mechanism scales quadratically ($O(L^2)$) with the sequence length $L$. This "quadratic bottleneck" makes processing long documents, high-resolution images, or extended histories in recommendation systems prohibitively slow.

The research direction explored here seeks to "linearize" attention, reducing complexity to $O(L)$ by rethinking the fundamental way we compute similarity between queries and keys.

The Associative Property Trick

The core insight behind linear attention is a simple change in the order of operations. In standard attention, we compute a similarity matrix $A = \text{softmax}(QK^T)$ and then multiply it by the values $V$. This $QK^T$ step creates an $L \times L$ matrix, which is the source of the quadratic cost.

As Angelos Katharopoulos, Apoorv Vyas, and their colleagues demonstrate in Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention, if we can decompose the similarity function into a product of feature maps—such that $\text{Sim}(Q, K) = \phi(Q)\phi(K)^T$—we can use the associative property of matrix multiplication:

$$(\phi(Q)\phi(K)^T)V = \phi(Q)(\phi(K)^TV)$$

By computing $(\phi(K)^TV)$ first, we create a matrix of size $d \times d$ (where $d$ is the head dimension) instead of $L \times L$. Since $d$ is usually much smaller than $L$, the computation becomes linear with respect to the sequence length.

The Challenge of Non-Negativity

The difficulty lies in the $\text{softmax}$ function. Softmax ensures that all attention weights are positive and sum to one. When we replace softmax with a kernel approximation $\phi(x)$, we must ensure that the resulting similarity scores remain non-negative.

If the similarity scores can be negative, the denominator used for normalization (the sum of similarities) could approach zero, leading to numerical instability, exploding gradients, and training crashes. Jose Miguel Luna and Taha Bouhsine identify this "denominator problem" in SLAY: Geometry-Aware Spherical Linearized Attention with Yat-Kernel as a primary reason why many linear attention variants fail during training.

Evolving Feature Maps

Researchers have proposed several ways to design the feature map $\phi(x)$ to maintain stability and accuracy:

  1. Simple Activations: Angelos Katharopoulos originally proposed using an ELU-based mapping. Similarly, Chuanyang Zheng shows in The Linear Attention Resurrection in Vision Transformer that a simple ReLU function can serve as an effective and stable feature map for vision tasks, helping the model focus on salient objects.
  2. Random Features: To more closely approximate the original Gaussian kernel of softmax, Valerii Likhosherstov, Krzysztof Marcin Choromanski, and others developed specialized random feature mappings. In Chefs' Random Tables: Non-Trigonometric Random Features, they introduce non-trigonometric features that are guaranteed to be positive and bounded, avoiding the instabilities of earlier trigonometric approximations. Their subsequent work on Dense-Exponential Random Features (FAVOR#) further reduces approximation variance by orders of magnitude.
  3. Normalization Strategies: In the context of recommendation systems, Langming Liu and Liu Cai suggest in LinRec that combining L2-normalization with ELU activation can prevent vanishing gradients while maintaining the necessary properties of attention.
  4. Optimal Transport: Pourya Shamsolmoali and colleagues take a different path in SeTformer Is What You Need for Vision and Language, using positive definite kernels within a Reproducing Kernel Hilbert Space (RKHS) combined with Optimal Transport to ensure non-negativity and high performance with fewer parameters.

Transformers as Recurrent Networks

A powerful consequence of linear attention is that it mathematically transforms the Transformer into a Recurrent Neural Network (RNN).

In a standard Transformer, we need the entire sequence to compute attention for the next token. In a Linear Transformer, the term $(\phi(K)^TV)$ acts as a fixed-size "state" or "memory" that can be updated incrementally as new tokens arrive. As Katharopoulos et al. point out, this allows for autoregressive inference that is thousands of times faster, as the model no longer needs to re-scan the entire history for every new word generated.

By replacing the $O(L^2)$ global search with an $O(L)$ state update, these models bridge the gap between the expressive power of Transformers and the efficiency of RNNs.

Papers in this version

History & citationVersion 1 · 2026-10-04

Merged into another direction · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_linear_attention_via_positive_kernel_fea_72cdcefb,
  title = {Linear Attention via Positive Kernel Feature Maps},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/linear-attention-via-positive-kernel-feature-maps/rdr_72cdcefbbd84496cab40f3a24c178ab6},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-23},
}

This exact version (version 1, frozen text):

@misc{lacuna_linear_attention_via_positive_kernel_fea_72cdcefb_v1,
  title = {Linear Attention via Positive Kernel Feature Maps},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/linear-attention-via-positive-kernel-feature-maps/rdr_72cdcefbbd84496cab40f3a24c178ab6/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-23},
}