Skip to main content
QUICK REVIEW

[Paper Review] ClusTR: Exploring Efficient Self-attention via Clustering for Vision Transformers

Yutong Xie, Jianpeng Zhang|arXiv (Cornell University)|Aug 28, 2022
Multimodal Machine Learning ApplicationsComputer Science6 citations
TL;DR

ClusTR proposes a content-based sparse self-attention mechanism for Vision Transformers that reduces computational complexity by clustering and aggregating key and value tokens based on semantic similarity, enabling efficient long-range modeling. The method achieves state-of-the-art performance with 83.2% Top-1 accuracy on ImageNet using only 22.7M parameters, outperforming dense and grid-based sparse attention methods.

ABSTRACT

Although Transformers have successfully transitioned from their language modelling origins to image-based applications, their quadratic computational complexity remains a challenge, particularly for dense prediction. In this paper we propose a content-based sparse attention method, as an alternative to dense self-attention, aiming to reduce the computation complexity while retaining the ability to model long-range dependencies. Specifically, we cluster and then aggregate key and value tokens, as a content-based method of reducing the total token count. The resulting clustered-token sequence retains the semantic diversity of the original signal, but can be processed at a lower computational cost. Besides, we further extend the clustering-guided attention from single-scale to multi-scale, which is conducive to dense prediction tasks. We label the proposed Transformer architecture ClusTR, and demonstrate that it achieves state-of-the-art performance on various vision tasks but at lower computational cost and with fewer parameters. For instance, our ClusTR small model with 22.7M parameters achieves 83.2\% Top-1 accuracy on ImageNet. Source code and ImageNet models will be made publicly available.

Motivation & Objective

  • To address the quadratic computational complexity of dense self-attention in Vision Transformers, especially for dense prediction tasks.
  • To overcome limitations of grid-based downsampling, such as loss of fine-grained details and inclusion of redundant background tokens.
  • To develop a content-aware token aggregation method that preserves semantic richness while reducing sequence length.
  • To extend the clustering-guided attention to multi-scale modeling for improved performance on dense prediction tasks.
  • To achieve state-of-the-art performance with reduced model size and computation cost.

Proposed method

  • Clustering is applied to key and value tokens based on their content similarity, reducing the number of tokens through aggregation into cluster representatives.
  • The query tokens attend to the clustered key and value tokens, forming a clustering-guided self-attention mechanism that maintains long-range dependency modeling.
  • The number of clusters is flexibly adjustable, allowing dynamic control over sequence length and computational cost, unlike fixed grid-based downsampling.
  • Multi-scale clustering is introduced by applying different cluster counts at different stages, enabling hierarchical feature learning.
  • The method is integrated into a new Transformer architecture named ClusTR, available in small, base, and tiny variants.
  • The model is trained and evaluated on image classification, semantic segmentation, object detection, and pose estimation benchmarks.

Experimental results

Research questions

  • RQ1Can content-based clustering of keys and values reduce computational complexity in Vision Transformers without sacrificing performance?
  • RQ2How does clustering-guided self-attention compare to grid-based or convolutional downsampling in preserving semantic information and accuracy?
  • RQ3Does multi-scale clustering-guided attention improve performance on dense prediction tasks such as semantic segmentation?
  • RQ4Can a sparse attention mechanism based on clustering achieve state-of-the-art results with fewer parameters and FLOPs?
  • RQ5What is the impact of cluster count flexibility on model efficiency and accuracy across different vision tasks?

Key findings

  • ClusTR-S with 22.7M parameters achieves 83.2% Top-1 accuracy on ImageNet, outperforming competitive models with lower FLOPs and parameters.
  • The clustering-guided method reduces parameters by 18% and improves Top-1 accuracy by 0.5 points compared to grid-based token aggregation (77.2% vs. 76.7%).
  • Compared to k-NN and spatial-reduction attention, ClusTR achieves 0.4% higher Top-1 accuracy while reducing parameters by 18% and FLOPs by 5%.
  • Multi-scale clustering improves mIOU on ADE-20K semantic segmentation by 1.4 points (42.6 vs. 41.2) compared to single-scale, despite a small increase in FLOPs and parameters.
  • The model achieves 84.1% Top-1 accuracy on ImageNet with 40.3M parameters, demonstrating strong scalability.
  • Ablation studies confirm that clustering-guided attention is superior to grid-based and k-NN sparse attention in both accuracy and efficiency.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.