Semantic Equitable Clustering: A Simple, Fast and Effective Strategy for Vision Transformer

Qihang Fan, Huaibo Huang, Mingrui Chen, Ran He · DOI

Abstract

Vision Transformers (ViTs) have revolutionized computer vision but suffer from quadratic computational complexity relative to token count. Existing mitigation strategies, such as spatial window partitioning or iterative k-means clustering, often compromise between semantic context and hardware efficiency. We present Semantic Equitable Clustering (SEC), a novel strategy that groups tokens based on semantic similarity into equal-sized partitions in a single pass. SEC ensures high GPU utilization while preserving long-range semantic relationships. Our resulting backbone, SECViT, and its application as a vision-language connector for Multimodal Large Language Models (MLLMs), demonstrate superior performance-efficiency trade-offs across ImageNet-1K, COCO, and multimodal benchmarks.

Introduction: Beyond Spatial Partitioning

The primary bottleneck in Vision Transformers is the global self-attention mechanism. To address this, models like the Swin Transformer utilize Window Partitioning, which restricts attention to local spatial windows. However, this approach often severs semantic links between related objects located in different windows. Alternatively, k-means clustering can group tokens by meaning, but its iterative nature is computationally expensive, and it produces clusters of varying sizes. Uneven clusters lead to "idle" GPU threads, significantly hindering parallel processing efficiency.

Comparison of partitioning strategies: Window Partition (spatial but non-semantic), k-means (semantic but non-equitable), and SEC (both semantic and equitable).

Methodology: Semantic and Equitable

SEC is designed to be both "semantic" (grouping by content) and "equitable" (ensuring equal group sizes for hardware efficiency). The process involves three main steps:

  1. Global Anchor Generation: A "global semantic token" is created by average-pooling all image tokens, capturing the overall context.
  2. Similarity-Based Sorting: The cosine similarity between every token and this global anchor is calculated.
  3. Equi-partitioning: Tokens are sorted by these similarity scores and divided into equal-sized groups. This ensures that tokens with similar relevance to the global scene are processed together, regardless of their spatial distance.
Illustration of SECViT architecture and the Semantic Equitable Clustering process.

SECViT and MLLM Integration

The authors implement this strategy in SECViT, a hierarchical backbone. Furthermore, SEC is utilized as a vision-language connector for models like LLaVA-1.5. In this context, SEC clusters tokens and merges them via attentive pooling, drastically reducing the token count sent to the Large Language Model (LLM) without losing critical information.

Key Insights

  • Hardware-First Design: By enforcing equal cluster sizes, SEC avoids the need for specialized CUDA kernels and ensures maximum GPU throughput.
  • Semantic Anchoring: The use of an average-pooled global token as an anchor is a computationally cheap yet effective way to capture image-wide semantics.
  • Interleaved Merging: For multimodal tasks, the researchers found that "interleaved" merging—grouping tokens with varying similarity levels—preserves more diverse information than merging only the most similar tokens.

Experimental Results

The SEC strategy was validated across multiple standard benchmarks:

  • ImageNet-1K: SECViT-S achieved 84.3% Top-1 accuracy with only 4.6 GFLOPs, outperforming more computationally intensive models.
  • Object Detection & Segmentation: On MS COCO and ADE20K, SECViT showed consistent improvements over baseline models like Swin and ResNet.
  • Multimodal Performance: When integrated into LLaVA-1.5, SEC reduced vision tokens from 576 to 144. This led to a 2.2x inference speedup and improved scores on benchmarks like MMBench (+4.9 points) and TextVQA.

Conclusion

Semantic Equitable Clustering provides a simple yet powerful alternative to spatial partitioning. By aligning clustering logic with both semantic content and hardware architecture, SEC enables Vision Transformers to be both faster and more accurate. Future work will explore dynamic cluster sizing and scaling SEC to even larger multimodal architectures.

Summary updated

BibTeX
@misc{fan2024semantic,
  author = {Qihang Fan and Huaibo Huang and Mingrui Chen and Ran He},
  title = {{Semantic Equitable Clustering: A Simple, Fast and Effective Strategy for Vision Transformer}},
  year = {2024},
  eprint = {2405.13337},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.13337},
}
Figure