[Paper Review] SOFT: Softmax-free Transformer with Linear Complexity
SOFT introduces a softmax-free self-attention mechanism using a Gaussian kernel and Nyström-based low-rank approximation with Moore-Penrose inverse through Newton-Raphson, achieving linear time/space complexity and improved ImageNet accuracy over other linear transformers.
Vision transformers (ViTs) have pushed the state-of-the-art for various visual recognition tasks by patch-wise image tokenization followed by self-attention. However, the employment of self-attention modules results in a quadratic complexity in both computation and memory usage. Various attempts on approximating the self-attention computation with linear complexity have been made in Natural Language Processing. However, an in-depth analysis in this work shows that they are either theoretically flawed or empirically ineffective for visual recognition. We further identify that their limitations are rooted in keeping the softmax self-attention during approximations. Specifically, conventional self-attention is computed by normalizing the scaled dot-product between token feature vectors. Keeping this softmax operation challenges any subsequent linearization efforts. Based on this insight, for the first time, a softmax-free transformer or SOFT is proposed. To remove softmax in self-attention, Gaussian kernel function is used to replace the dot-product similarity without further normalization. This enables a full self-attention matrix to be approximated via a low-rank matrix decomposition. The robustness of the approximation is achieved by calculating its Moore-Penrose inverse using a Newton-Raphson method. Extensive experiments on ImageNet show that our SOFT significantly improves the computational efficiency of existing ViT variants. Crucially, with a linear complexity, much longer token sequences are permitted in SOFT, resulting in superior trade-off between accuracy and complexity.
Motivation & Objective
- Motivate the need for efficient Transformers in vision to handle long token sequences without quadratic complexity.
- Propose a softmax-free self-attention mechanism that enables linear complexity.
- Develop a Nyström-based low-rank approximation with Newton-Raphson computed Moore-Penrose inverse for robust attention.
- Design and evaluate SOFT-based backbones on ImageNet to assess accuracy–complexity trade-offs.
Proposed method
- Replace softmax-based attention with a Gaussian kernel attention S = exp(Q ⊖ K) that is symmetric and in [0,1].
- Use a Nyström decomposition with a small bottleneck m to approximate the full attention matrix with a linear-time/space complexity, Ŝ = Pᵀ A† P.
- Compute the Moore-Penrose inverse A† via Newton–Raphson iterations to ensure numerical robustness (A₀ = αA, A_{k+1} = 2A_k − A_k A A_k).
- Sample bottleneck tokens using convolution, average pooling, or other sampling methods; prefer average pooling for stability and efficiency.
- Instantiate SOFT as a layer within a pyramidal vision Transformer backbone, with specific hyperparameters (e.g., d_e, h, n, m, sp) to build SOFT variants.
Experimental results
Research questions
- RQ1Can a softmax-free Gaussian-kernel attention achieve comparable accuracy to softmax-based attention in Vision Transformers?
- RQ2Does Nyström-based low-rank approximation with Moore-Penrose inverse provide stable training and linear complexity in vision tasks?
- RQ3What design choices (bottleneck size m, sampling strategy) optimize the accuracy–efficiency trade-off for SOFT?
- RQ4How does SOFT perform against other linear/efficient Transformers on ImageNet and NLP benchmarks?
- RQ5What architectural benefits arise from integrating SOFT into pyramidal Transformer backbones for visual recognition?
Key findings
- SOFT achieves linear time and space complexity (O(n)) for attention, enabling longer token sequences.
- Nyström-based decomposition with Moore-Penrose inverse via Newton–Raphson provides robust attention approximation.
- On ImageNet, SOFT-based backbones outperform several CNNs and ViT variants in accuracy–complexity trade-offs.
- SOFT demonstrates competitive or superior accuracy compared to Linformer, Performer, and Nyströmformer under similar settings.
- Ablations show bottleneck size m ≈ 49 offers a good balance of accuracy and compute; average-pooling sampling performs best among tested methods.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.