Home Knowledge Base Linear Attention

Linear Attention is the kernel-based trick that rewrites attention as a sequence of associative matrix products so complexity grows linearly with token count — it replaces the softmax with a positive-definite kernel, enabling ViTs to process extremely long sequences without quadratic memory while still capturing contextual dependencies.

What Is Linear Attention?

Why Linear Attention Matters

Kernel Choices

Positive Random Features:

Quadratic Polynomial Features:

Learnable Kernels:

How It Works / Technical Details

Step 1: Transform queries and keys through φ to obtain features of dimension m, then compute the context numerator as (φ(K)^T V) and denominator as sum(φ(K)) per position.

Step 2: Multiply φ(Q) with the numerator, divide by the denominator (ensuring positivity), and apply softmax-like normalization before projecting back to the model space.

Comparison / Alternatives

AspectLinear AttentionSoftmax AttentionSparse Attention
ComplexityO(N)O(N^2)
BiasNone if kernel properNone
Long SequenceExcellentPoor
ImplementationSlightly complexStandard

Tools & Platforms

Linear attention is the linear pathway that lets transformers remain faithful to every token without blowing up compute for massive images — it achieves the same context mixing as softmax but with a tame resource profile.

linear attention for visioncomputer vision

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.