[Paper Review] Making Vision Transformers Efficient from A Token Sparsification View
This paper proposes Semantic Token ViT (STViT), a token sparsification method that replaces redundant image tokens with a small set of learnable semantic tokens acting as cluster centers. Using multi-head attention to dynamically aggregate and recover these high-level semantic representations, STViT achieves up to 60% FLOPs reduction and over 100% speedup on DeiT models with minimal accuracy drop, while enabling efficient adaptation to downstream tasks via a recoverable backbone design.
The quadratic computational complexity to the number of tokens limits the practical applications of Vision Transformers (ViTs). Several works propose to prune redundant tokens to achieve efficient ViTs. However, these methods generally suffer from (i) dramatic accuracy drops, (ii) application difficulty in the local vision transformer, and (iii) non-general-purpose networks for downstream tasks. In this work, we propose a novel Semantic Token ViT (STViT), for efficient global and local vision transformers, which can also be revised to serve as backbone for downstream tasks. The semantic tokens represent cluster centers, and they are initialized by pooling image tokens in space and recovered by attention, which can adaptively represent global or local semantic information. Due to the cluster properties, a few semantic tokens can attain the same effect as vast image tokens, for both global and local vision transformers. For instance, only 16 semantic tokens on DeiT-(Tiny,Small,Base) can achieve the same accuracy with more than 100% inference speed improvement and nearly 60% FLOPs reduction; on Swin-(Tiny,Small,Base), we can employ 16 semantic tokens in each window to further speed it up by around 20% with slight accuracy increase. Besides great success in image classification, we also extend our method to video recognition. In addition, we design a STViT-R(ecover) network to restore the detailed spatial information based on the STViT, making it work for downstream tasks, which is powerless for previous token sparsification methods. Experiments demonstrate that our method can achieve competitive results compared to the original networks in object detection and instance segmentation, with over 30% FLOPs reduction for backbone. Code is available at http://github.com/changsn/STViT-R
Motivation & Objective
- To address the quadratic computational cost of Vision Transformers (ViTs) due to high token counts.
- To overcome limitations of existing token pruning methods, including accuracy drops, poor spatial distribution, and incompatibility with downstream tasks.
- To develop a general-purpose, efficient ViT architecture that works for both global and local transformers (e.g., DeiT and Swin).
- To enable effective fine-tuning and adaptation to downstream tasks like object detection and instance segmentation through a recoverable backbone.
- To demonstrate that a few semantic tokens can effectively represent global and local semantic information without sacrificing performance.
Proposed method
- Semantic tokens are initialized via spatial and inter-window pooling to ensure uniform, space-aware distribution and local semantic integration.
- A two-layer Transformer-based Semantic Token Generation Module (STGM) uses these tokens as queries to attend to image tokens (keys/values), recovering cluster centers through self-attention.
- The first attention layer uses spatially initialized semantic tokens to aggregate local features, while the second layer enables global semantic clustering.
- Image tokens are discarded after STGM; only semantic tokens are used in subsequent layers, drastically reducing FLOPs and inference time.
- For downstream tasks, STViT-R is introduced with 'dumbbell units' that reuse semantic tokens and recover spatial details via a recovery module.
- The method is plug-and-play, compatible with both global (DeiT) and local (Swin) attention mechanisms.
Experimental results
Research questions
- RQ1Can a small number of learnable semantic tokens effectively replace redundant image tokens in ViTs without significant accuracy drop?
- RQ2How can token sparsification be made robust and generalizable across different ViT architectures, including global and local attention variants?
- RQ3Can a sparsified ViT backbone be effectively fine-tuned for downstream tasks like object detection and instance segmentation?
- RQ4What initialization and attention mechanisms best enable semantic tokens to capture both local and global image representations?
- RQ5How does the integration of a recovery module in STViT-R restore spatial detail for dense prediction tasks?
Key findings
- On DeiT-Tiny, Small, and Base, only 16 semantic tokens achieve comparable accuracy to full models with over 100% inference speed improvement and nearly 60% FLOPs reduction.
- On Swin-Tiny and Swin-Small, using 16 semantic tokens per window increases speed by ~20% and improves accuracy slightly, demonstrating efficiency and robustness.
- STViT-R achieves competitive COCO APb of 51.8 and APm of 44.7 on object detection and instance segmentation with over 30% FLOPs reduction in the backbone.
- Ablation studies show that using both spatial and global initialization improves performance over single initialization, and the dumbbell unit is essential for recovery performance.
- Reusing semantic tokens across dumbbell units causes only a minor drop in performance (e.g., 0.2 APb), confirming the stability of the method.
- The global initialization is distinct from learned positional encoding, as replacing it with learned PE causes a 0.1% accuracy drop, validating its unique role.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.