TL;DR
This paper introduces LiSA, a novel attention mechanism for visual understanding that significantly improves performance and efficiency over standard self-attention. By learning structural patterns within attention kernels and approximating them with Fast Fourier Transforms (FFTs), LiSA achieves state-of-the-art results on various vision tasks with reduced computational cost.
What Problem Does This Paper Address?
Vision Transformers (ViTs) have become dominant in visual understanding due to their ability to capture long-range dependencies. However, standard self-attention in ViTs suffers from two main limitations: (1) it struggles to learn discriminative features due to a lack of inductive biases, leading to high redundancy and requiring large datasets, and (2) its quadratic complexity with respect to sequence length makes it impractical for high-resolution images and hierarchical models. Existing solutions often compromise accuracy for efficiency or fail to fully leverage structural information.
Methods
The authors propose Lightweight Structure-aware Attention (LiSA), which addresses the limitations of self-attention by:
- Learning Structural Patterns: Instead of just using relative position embeddings (RPEs) additively, LiSA uses them as multiplicative weights to encode structural patterns within the query-key correlation. This allows the attention kernel to be more discriminative.
- Structure-Aware Attention (SA): The initial formulation of SA (Eq. 4 & 5) incorporates RPEs multiplicatively and removes the softmax function to allow negative values, which can better capture structural information. It also introduces learnable projection matrices to extract structural patterns.
- Log-Linear Complexity via FFTs: To overcome the quadratic complexity of RPEs and global convolutions, LiSA approximates them using Fast Fourier Transforms (FFTs). This reduces the computational complexity to log-linear with respect to the sequence length, making it efficient for high-resolution inputs.
- Hadamard Product Correlation: For improved expressivity, the authors also explore using Hadamard product correlation, which captures channel-wise structural patterns.
Datasets
The paper evaluates LiSA on several standard benchmarks:
- ImageNet-1K: For image classification.
- Kinetics-400: For video action recognition.
- COCO: For object detection and instance segmentation.
- ADE-20K: For semantic segmentation.
- ImageNet-21K: For large-scale pre-training.
Key Insights and Ideas
- Multiplicative RPEs are Key: Using RPEs as multiplicative weights, rather than additive ones, is crucial for LiSA to effectively learn structural patterns. This allows the RPEs to actively shape the attention kernel.
- Negative Attention Values Help: Removing the softmax function and allowing negative attention values seems to improve the ability to capture structural information, which is a limitation of standard softmax attention.
- FFTs are a Game-Changer for Efficiency: The application of FFTs to approximate global convolutions is the core innovation that makes LiSA computationally feasible for high-resolution inputs and large models, achieving log-linear complexity.
- Structure Matters Early On: Visualizations show that LiSA kernels capture local features in early layers, similar to learned filters, while self-attention kernels are less informative at this stage. This suggests LiSA's structural awareness is beneficial from the start.
Key Results
- State-of-the-Art Performance: LiSA-based models (LiSANets) achieve state-of-the-art results on ImageNet-1K, Kinetics-400, COCO, and ADE-20K. For example, on ImageNet-1K, LiSA achieves 74.9% top-1 accuracy with competitive FLOPs.
- Improved Efficiency: LiSA significantly reduces computational complexity. For instance, LiSA achieves log-linear complexity in computation and linear complexity in memory, outperforming standard self-attention and other efficient variants.
- Better Accuracy-Efficiency Trade-off: LiSA offers a superior trade-off between accuracy and computational cost compared to existing methods, including those that use convolutional attention or RSA.
- Scalability: LiSA demonstrates strong performance and scalability on larger models and datasets like ImageNet-21K.
Limitations and Future Work
- Fixed Structural Pattern Size (D): The current LiSA formulation uses a fixed size
Dfor encoded structural patterns. The authors suggest investigating methods to dynamically change this size based on visual context. - Handling High Resolutions: While LiSA is more efficient than standard attention for high resolutions, processing multiple layers for very high-resolution inputs can still be computationally demanding. The authors propose exploring LiSA with local or sparse attention mechanisms.
- Cross-Attention: The authors believe LiSA could be a valuable component for cross-attention mechanisms, particularly for multi-modal tasks (e.g., image-text, video-text).
Summary updated