AttentionLite: Towards Efficient Self-Attention Models for Vision

Souvik Kundu, Sairam Sundaresan

TL;DR

AttentionLite is a novel framework that creates ultra-efficient vision models by combining self-attention, knowledge distillation, and pruning into a single, unified training pass. By distilling knowledge from a heavy CNN teacher into a sparse self-attention student, the authors achieve up to 30x parameter reduction and 2x compute savings with negligible loss in accuracy.

What Problem Does This Paper Address?

Convolutional Neural Networks (CNNs) have long been the gold standard for vision, but they have two inherent flaws: they are content-agnostic (applying the same weights regardless of pixel content) and they scale poorly when trying to capture long-range dependencies (increasing the receptive field makes them computationally expensive).

While self-attention (SA) mechanisms solve these issues by being content-aware and efficient at scale, they often lack the "spatial context" that convolutions naturally possess. Furthermore, traditional model optimization—like pruning (removing weights) and distillation (teaching a small model using a large one)—is typically a multi-stage, iterative process that is time-consuming and computationally heavy. AttentionLite seeks to solve all these problems at once by fusing these techniques into a "sparse distillation" framework.

Methods

The core of the paper is the Sparse Distillation framework, which optimizes a model across three dimensions simultaneously:

  1. Architecture Substitution: The authors replace standard $k \times k$ convolutions with local self-attention layers. These layers use relative positional embeddings to help the model learn spatial context while keeping parameter counts low.
  2. Joint Optimization: Instead of pruning a pre-trained model, the framework starts with a student model that has a random pruning mask. During a single training pass, it simultaneously distills knowledge from a heavy CNN teacher (ResNet50) and updates the pruning mask.
  3. Multi-Faceted Loss: The training uses a composite loss function:
  4. Cross-Entropy: Standard classification loss.
  5. KL-Divergence (Logit Distillation): Matching the output probabilities of the teacher.
  6. Attention Transfer (Feature Distillation): Forcing the student's activation maps to match the teacher's, which helps the self-attention student "inherit" the teacher's spatial awareness.

The framework supports both irregular pruning (removing individual weights for maximum compression) and structured column pruning (removing entire columns of weights to better suit standard hardware acceleration).

Fig. 1: (a) Three orthogonal prior art to generate reduced parameter models, namely distillation, pruning (through training) and use of self-attention models. Proposed approach: A joint optimization strategy where distillation extracts the positional context and richer knowledge from the convolutional teacher, and pruning keeps the parameter budget of the student extremely limited. (b) Internal attention layer computation mechanics of the student ΦS, with only a fraction of the weights being non-zero. Note that we replace all k × k (k > 1) convolutions with self-attention.

Datasets

The authors evaluated AttentionLite on three standard computer vision benchmarks:

  • CIFAR-10: 10 classes of small images.
  • CIFAR-100: 100 classes of small images.
  • Tiny-ImageNet: A subset of ImageNet with 200 classes at $64 \times 64$ resolution.

For all experiments, a ResNet50 was used as the convolutional teacher model.

Key Insights and Ideas

  • CNNs make great teachers for SA students: The "inductive bias" of a CNN (its innate understanding of spatial locality) can be transferred to a self-attention model through distillation. This effectively gives the SA student the "best of both worlds."
  • Single-Pass Efficiency: By performing pruning and distillation at the same time, the authors eliminate the need for the expensive "train-prune-finetune" cycles common in deep learning optimization.
  • Attention Transfer is the "Secret Sauce": The authors found that transferring feature-level attention maps (AT-loss) consistently improved accuracy by up to 2.33%. This suggests that matching how the teacher looks at an image is just as important as matching what it predicts.
  • Hybrid vs. Homogeneous: The paper explores "Hybrid" models (using a CNN stem at the start) and "Homogeneous" models (pure self-attention). While Hybrid models are slightly more accurate, Homogeneous models offer better potential for parallel execution on specialized hardware.

Key Results

The AttentionLite models achieved remarkable efficiency gains compared to their ResNet50 teacher:

  • Parameter Reduction: Achieved up to 30.26x reduction on CIFAR-10 and 11x on Tiny-ImageNet using irregular pruning.
  • Compute Efficiency: Consistently achieved ~2x reduction in FLOPs (Floating Point Operations).
  • Accuracy: Despite the massive compression, the models remained highly competitive. For example, a Hybrid SA-ResNet26 on CIFAR-10 achieved 94.7% accuracy (only a 0.64% drop from the teacher) while being 30x smaller.
  • Baseline Improvement: Optimized AttentionLite models significantly outperformed their unoptimized student counterparts, proving that the joint optimization framework is highly effective.

Limitations and Future Work

While the results are promising, the authors note a few areas for further exploration:

  • Hardware Benchmarking: Although the models are theoretically more efficient, the authors have not yet benchmarked them on custom hardware to measure real-world latency gains.
  • Task Variety: The current study focuses on image classification. Future work is needed to see if these gains translate to more complex tasks like object detection or image segmentation.
  • Transformer Scaling: The authors suggest that applying this sparse distillation approach to full-scale Transformer architectures (like ViT) is a logical and exciting next step.

Summary updated

BibTeX
@misc{kundu2021attentionlite,
  author = {Souvik Kundu and Sairam Sundaresan},
  title = {{AttentionLite: Towards Efficient Self-Attention Models for Vision}},
  year = {2021},
  eprint = {2101.05216},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2101.05216},
}
Figure