Home Knowledge Base Linformer

Linformer is the low-rank projection wrapper that compresses the attention matrix so Vision Transformers run in linear time with negligible accuracy drop — by projecting keys and values from length N down to rank k using learned linear layers, the model preserves essential dependency structure while avoiding the O(N^2) attention costs that overwhelm high-resolution inputs.

What Is Linformer?

Why Linformer Matters

Compression Modes

Global Projection:

Axis-Aware Projection:

Adaptive k:

How It Works / Technical Details

Step 1: Keys and values are multiplied by projection matrices P_k and P_v of shape (N, k) during the forward pass, producing compressed summaries while queries remain full length.

Step 2: Attention scores are computed between queries and compressed keys, followed by standard softmax and a dot product with the compressed values; the result is then projected back to the model dimension and passed through the feed-forward block.

Comparison / Alternatives

AspectLinformerPerformerAxial/Windowed
ComplexityO(Nk)O(N) with kernelO(N(H+W)) or O(Nw^2)
ApproximationLow-rankKernel feature mapAxis decomposition
Accuracy DropMinimal with proper kVery small with enough featuresNone for small windows
Best Use CaseLow-rank attention mapsStreaming sequencesSpatially structured scenes

Tools & Platforms

Linformer is the practical low-rank compression that lets ViTs eat long image sequences without fracturing memory budgets — it retains the interpretability of softmax attention while turning an O(N^2) bottleneck into a linearly growing helper.

linformer 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.