Abstract
Vision Transformers (ViTs) have achieved state-of-the-art performance in computer vision but suffer from high computational costs due to the quadratic complexity of self-attention. We present STViT (Semantic Token ViT), a framework that improves efficiency by clustering redundant image tokens into a compact set of "semantic tokens." Unlike traditional pruning, STViT preserves essential information and maintains spatial compatibility for local-attention models like Swin. Our proposed STViT-R architecture further enables efficient performance on dense downstream tasks through a recovery mechanism that reconstructs spatial resolution from condensed semantic representations.
Introduction
The standard Vision Transformer treats images as sequences of patches, leading to a computational bottleneck where self-attention costs scale quadratically with the number of tokens. Previous attempts to mitigate this via token pruning often suffer from three major flaws: imprecise scoring of token importance, spatial disruption of feature maps (creating a "Swiss cheese" effect incompatible with local-window models), and the loss of fine-grained geometry necessary for downstream tasks like object detection.
Methodology: Semantic Token Generation
The core of our approach is the Semantic Token Generation Module (STGM). Rather than discarding tokens, STGM clusters them to condense information into a small set of "semantic tokens."
Semantic Token Generation
The process begins with standard transformer layers for low-level feature extraction. The STGM then performs:
- Initialization: Lightweight spatial pooling (intra- and inter-window) creates initial cluster centers.
- Aggregation: Self-attention is used where cluster centers act as queries to adaptively "absorb" information from the original image tokens (keys and values).
- Global Context: Global cluster centers, initialized with noise, are added to ensure the tokens capture high-level, image-wide semantics similar to a
[CLS]token.
The STViT-R Architecture
To support downstream tasks, we introduce STViT-R (Recover). This "dumbbell" architecture condenses tokens in middle layers to save massive computation and uses a Recovery Module (the inverse of STGM) to map semantic information back onto a full-resolution spatial grid for dense prediction tasks.
Experimental Results
STViT demonstrates significant efficiency gains across multiple benchmarks:
- Image Classification: On DeiT-Small, using only 16 semantic tokens achieved the same accuracy as the 196-token baseline while reducing FLOPs by nearly 60% and doubling inference throughput (+105%).
- Local Attention Models: STViT achieved a 20% speedup on Swin-T with a slight increase in accuracy, proving its compatibility with window-based attention.
- Downstream Tasks: Using STViT-R as a backbone for Cascade Mask R-CNN on COCO, we achieved comparable results to the original Swin-S while reducing backbone FLOPs by over 30%.
- Video Recognition: On Video Swin-S, the method saved 27% FLOPs with a negligible (0.3%) drop in accuracy.
Discussion and Conclusion
STViT highlights that image token redundancy is a feature that can be leveraged through clustering rather than simple pruning. By aggregating information, the model avoids the pitfalls of imprecise token scoring and maintains the spatial awareness required for modern transformer architectures.
While the framework excels in classification and detection, semantic segmentation remains a challenge. The STGM acts as a low-frequency filter, which can smooth out the high-frequency, pixel-level details required for segmentation. Future work will focus on better preserving these details during the recovery phase to improve performance on dense, pixel-perfect prediction tasks.
Summary updated