Refiner: Refining Self-attention for Vision Transformers

Daquan Zhou, Yujun Shi, Bingyi Kang, Weihao Yu, Zihang Jiang, Yuan Li, Xiaojie Jin, Qibin Hou, Jiashi FengarXiv 2021

Introduction: The Challenge of Over-smoothing

Vision Transformers (ViTs) have emerged as powerful alternatives to Convolutional Neural Networks (CNNs). However, they face two significant hurdles: extreme data hunger and the "over-smoothing" phenomenon. As ViTs increase in depth, token representations tend to collapse into a uniform state, where global self-attention causes every patch to lose its discriminative detail. This results in "blurry" attention maps in deeper layers, limiting the model's ability to capture fine-grained features.

Comparison of standard self-attention maps (over-smoothed) versus Refiner-attention maps (refined).

The Refiner Module

To address these issues, the authors propose Refiner, a drop-in replacement for the standard self-attention block. Unlike previous methods that add convolutions to token features, Refiner directly enhances the attention maps themselves.

The architecture of the Refiner Attention Block (a) and its integration into the overall Refiner Block (b).

The Refiner module operates in three distinct stages:

  1. Attention Expansion: Standard ViTs often trade off the number of heads for embedding dimension. Refiner breaks this zero-sum game by linearly projecting multi-head attention maps into a higher-dimensional space ($H'$ heads), allowing for more diverse relational modeling.
  2. Distributed Local Attention (DLA): A $3 \times 3$ convolution is applied directly to the expanded attention maps. This effectively injects local inductive biases—the hallmark of CNNs—into the global Transformer architecture.
  3. Attention Reduction: The refined maps are projected back to the original head count to maintain efficiency.

Key Insights

  • Map-Centric Refinement: By focusing on the attention maps rather than just the features, Refiner provides a more direct solution to the over-smoothing problem.
  • Feature Evolution: Analysis using Centered Kernel Alignment (CKA) demonstrates that Refiner-equipped models exhibit more significant feature changes across layers, avoiding the stagnation typical of vanilla ViTs.
  • Efficiency and Robustness: Refined attention maps are robust enough to be shared across adjacent blocks, a feat impossible with standard attention maps.

Results and Performance

Refiner achieves state-of-the-art results with remarkable efficiency. Refined-ViT-L reached 86% top-1 accuracy on ImageNet with 81M parameters, outperforming models three times its size. On smaller scales, Refined-ViT-S (25M params) achieved 83.6%, a 3.7% improvement over the DeiT-S baseline. Furthermore, the module's benefits extend to Natural Language Processing, where it improved GLUE scores for BERT-small models by 1%.

Conclusion

Refiner demonstrates that refining attention maps is a powerful strategy for improving ViT performance and data efficiency. By combining the global reach of Transformers with the local strengths of convolutions, Refiner provides a sharper, more discriminative "eye" for vision models.

Summary updated

BibTeX
@misc{zhou2021refiner,
  author = {Daquan Zhou and Yujun Shi and Bingyi Kang and Weihao Yu and Zihang Jiang and Yuan Li and Xiaojie Jin and Qibin Hou and Jiashi Feng},
  title = {{Refiner: Refining Self-attention for Vision Transformers}},
  year = {2021},
  eprint = {2106.03714},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2106.03714},
}
Figure