Abstract
Vision Transformers (ViTs) face significant computational challenges due to the quadratic complexity of self-attention relative to input token counts. This paper introduces Agglomerative Token Clustering (ATC), a parameter-free method for token reduction that employs bottom-up hierarchical clustering to merge redundant tokens. Unlike existing global partitioning strategies, ATC iteratively identifies and combines the most similar features, preserving informative content across diverse tasks. Experimental results demonstrate that ATC significantly outperforms current state-of-the-art methods in image classification, object detection, and image synthesis, particularly at high compression rates without requiring fine-tuning.
Introduction
While Vision Transformers (ViTs) have revolutionized computer vision, their computational cost scales poorly with image resolution. To address this "quadratic tax," researchers utilize token reduction techniques, typically categorized as pruning (deleting tokens) or merging (combining tokens). Pruning is often lossy, as discarded information cannot be recovered. Conversely, existing merging methods like Token Merging (ToMe) often rely on rigid global partitioning or bipartite matching, which can limit flexibility and lead to suboptimal grouping.
Agglomerative Token Clustering (ATC) offers a more flexible, "bottom-up" alternative. By merging the most redundant observations first, ATC preserves a more diverse set of features throughout the network. This local approach is vital for complex tasks where maintaining fine-grained detail is essential.
Methods
ATC implements a classical hierarchical clustering approach to reduce token density. The process follows three primary steps:
- Similarity Measurement: The algorithm calculates the cosine distance between all tokens, specifically utilizing the "keys" from the self-attention layer.
- Iterative Merging: It identifies the two most similar tokens or clusters and merges them. This cycle repeats until the target token count is reached.
- Weighted Representation: Merged tokens are represented as a weighted average of the originals. This ensures that clusters representing larger spatial areas carry appropriate weight in subsequent attention layers.
ATC is entirely parameter-free, requiring no additional layers or training. The authors evaluated three linkage functions—single, complete, and average—to determine optimal cluster distance metrics, finding that "average" and "complete" linkages generally prevent the "chaining" effect seen in single linkage.
Key Results
ATC was evaluated across a wide range of benchmarks, including ImageNet-1K, NABirds (fine-grained classification), and COCO (object detection). The method demonstrates remarkable robustness at low "keep rates" (high compression).
- Classification Performance: On a ViT-Base model, ATC outperformed ToMe by 10.5 percentage points in accuracy without any fine-tuning. On the fine-grained NABirds dataset with a 25% keep rate, ATC achieved a 9.6 percentage point lead over previous state-of-the-art merging techniques.
- Detection and Synthesis: In COCO object detection, ATC provided a 4-point improvement in mAP over ToMe at a 50% keep rate. In image synthesis via Stable Diffusion, ATC maintained higher image quality and structural integrity, reflected in superior FID scores.
Discussion and Future Work
ATC provides a powerful, off-the-shelf solution for enhancing ViT efficiency. Its primary advantage lies in its ability to preserve diverse features through local merging, making it suitable for a broader array of tasks than previous global methods.
However, a current limitation is the computational overhead of the clustering process itself during inference, as current implementations are often CPU-bound. Future work will focus on developing GPU-optimized, batched versions of agglomerative clustering to fully realize the theoretical speedups offered by token reduction. Additionally, exploring adaptive linkage selection based on specific task requirements remains a promising avenue for further optimization.
Summary updated