Linformer: Self-Attention with Linear Complexity
Sinong WangBelinda Z. LiMadian KhabsaHan FangHao Ma
Proposes Linformer, an attention architecture that reduces Transformer computational and memory complexity from quadratic to linear via low-rank matrix approximation without sacrificing accuracy.
Modern natural language processing relies heavily on Transformer models, but their core self-attention mechanism scales quadratically with sequence length in both computation time and memory. This computational bottleneck makes processing long texts prohibitively expensive for training and deployment. The article addresses this limitation by investigating whether Transformer self-attention can be mathematically simplified without sacrificing model accuracy.
The article demonstrates that self-attention matrices can be effectively approximated using low-rank representations and introduces the Linformer, an architecture that reduces self-attention complexity from quadratic to linear with respect to sequence length. The authors evaluated their design by pretraining models on large text corpora (BookCorpus and English Wikipedia) and benchmarking downstream performance across multiple standard language understanding and sentiment analysis tasks, alongside empirical speed and memory tests on high-performance GPUs.
The findings confirm three critical results. First, spectrum analysis shows that attention matrices are inherently low rank, with information concentrated in the top singular values. Second, the Linformer matches standard Transformer models in validation perplexity and downstream accuracy, scoring 92.30 on benchmark tasks compared to 92.25 for standard RoBERTa baselines, while outperforming distilled models. Third, the Linformer provides dramatic efficiency gains that scale with sequence length, achieving up to a 20-fold speedup in inference and a 60-fold reduction in memory consumption at long sequence lengths.
These results demonstrate that organizations can significantly lower computing costs, decrease power consumption, and deploy high-performance Transformer architectures on longer documents and resource-constrained environments. Practitioners should consider adopting linear projection techniques, particularly layerwise parameter sharing, for long-sequence tasks. Future work should explore extending this linear attention design to image processing and evaluating non-uniform projections across different layers.
- Paper: Attention Is All You Need, Ashish Vaswani et al. (2017). Mastering the foundational Transformer architecture introduced here is essential for understanding how the Linformer modifies the self-attention mechanism to reduce complexity.
- Paper: Reformer: The Efficient Transformer, Nikita Kitaev et al. (2020). Reading this work on locality-sensitive hashing provides crucial context on prior efficient Transformer designs that directly motivated the low-rank approximation approach of the Linformer.
- Paper: Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention, Angelos Katharopoulos et al. (2020). This paper builds directly upon linear attention concepts to formulate linear transformers with recurrent inference properties.
- Paper: Rethinking Attention with Performers, Krzysztof Choromanski et al. (2021). This work extends linear complexity ideas to the full softmax kernel using random feature maps, offering an alternative approach to efficient attention.
- Paper: Longformer: The Long-Document Transformer, Iz Beltagy et al. (2020). This paper generalizes efficient long-context modeling by combining local windowed attention with task-specific global attention.
- Paper: Synthesizer: Rethinking Self-Attention for Transformer Models, Yi Tay et al. (2021). This research continues the investigation into whether dot-product self-attention is truly necessary by proposing synthetic attention mechanisms.
- Paper: FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness, Tri Dao et al. (2022). This work tackles the quadratic memory bottleneck from an IO-aware exact-attention perspective, complementing low-rank approximation methods.
