Abstract
We propose a novel framework for producing a class of parameter and compute efficient models called AttentionLite, suitable for resource-constrained applications. Prior work has primarily focused on optimizing models either via knowledge distillation or pruning. In addition to fusing these two mechanisms, our joint optimization framework also leverages recent advances in self-attention as a substitute for convolutions. We can simultaneously distill knowledge from a compute-heavy teacher while also pruning the student model in a single pass of training, thereby reducing training and fine-tuning times considerably. We evaluate the merits of our proposed approach on the CIFAR-10, CIFAR-100, and Tiny-ImageNet datasets. Not only do our AttentionLite models significantly outperform their unoptimized counterparts in accuracy, we find that in some cases, they perform almost as well as their compute-heavy teachers while consuming only a fraction of the parameters and FLOPs. Concretely, AttentionLite models can achieve up to 30x parameter efficiency and 2x computation efficiency with no significant accuracy drop compared to their teacher.
The Efficiency Challenge in Computer Vision
Deep learning in computer vision has long been dominated by Convolutional Neural Networks (CNNs). While effective, CNNs suffer from content agnosticism—applying the same weights regardless of pixel content—and poor scaling when increasing receptive fields. Self-attention (SA) mechanisms solve these issues by being content-aware, yet they often lack the natural spatial context of convolutions and can be too large for edge devices.
Existing optimization methods typically treat pruning and distillation as separate, iterative steps. This "train-prune-retrain" cycle is computationally expensive and time-consuming. AttentionLite addresses this by unifying these processes into a single, efficient training pass.
The AttentionLite Framework
The core of the AttentionLite approach is a joint optimization strategy termed Sparse Distillation. This framework rests on three pillars:
- Self-Attention Substitution: Standard $k \times k$ convolutions are replaced with local self-attention layers. The authors explore both Hybrid architectures (CNN stem with SA layers) and Homogeneous architectures (pure SA).
- Dual-Path Distillation: To compensate for the lack of inductive bias in self-attention, knowledge is distilled from a heavy ResNet50 teacher at both the Logit level and the Attention Map level.
- Single-Pass Sparse Learning: Instead of iterative pruning, the framework uses a dynamic pruning mask during training. The model identifies unimportant weights and "regrows" others based on momentum, maintaining a target parameter density from the start.
Sparse Weight Tensors
The framework supports both irregular pruning for maximum compression and structured column pruning for hardware compatibility. By integrating sparsity directly into the learnable transformation of the self-attention mechanism, the model achieves high efficiency without sacrificing the representational power of the attention maps.
Key Insights and Results
Distillation Bridges the Spatial Gap
Self-attention layers often struggle to learn spatial relationships from scratch. By using a CNN teacher, AttentionLite models "inherit" spatial context through distillation loss. Combining Knowledge Distillation (KD) with Attention Transfer (AT) consistently yielded up to a 2.33% accuracy boost, proving that showing the student how the teacher looks at an image is as vital as the final prediction.
Benchmarking Performance
Evaluated on CIFAR-10, CIFAR-100, and Tiny-ImageNet, the AttentionLite models (specifically SA-ResNet26 and SA-ResNet38 variants) demonstrated remarkable efficiency:
- Parameter Efficiency: Achieved up to 30.26x reduction in parameters compared to the ResNet50 teacher.
- Computational Speed: Achieved a 2x reduction in FLOPs.
- Accuracy: On CIFAR-10, AttentionLite reached 94.88% accuracy, nearly matching the heavy ResNet50 teacher (95.34%) despite the massive size reduction.
Conclusion and Future Work
AttentionLite demonstrates that joint optimization of architecture (SA), distillation, and sparsity can produce ultra-lightweight models in a single training pass. While irregular pruning offers the best theoretical compression, future work will focus on optimizing these models for standard hardware and extending the framework to more complex tasks like object detection and pure Vision Transformer (ViT) architectures.
Summary updated