Abstract
Contrastive Language-Image Pretraining (CLIP) models have revolutionized computer vision by enabling natural language understanding of images. However, the Vision Transformer (ViT) backbones typically used in CLIP are computationally expensive due to the quadratic complexity of self-attention. This paper presents Patch Ranking, a novel framework that treats token pruning as a ranking prediction problem. By identifying a "Golden Ranking" of token importance and training a lightweight predictor to approximate it, the method achieves a ~50% reduction in inference time. When combined with learnable visual and text prompts, the framework can prune up to 40% of image tokens with a negligible accuracy loss of approximately 0.3%.
Introduction
The success of CLIP in zero-shot transfer and multimodal tasks is tempered by its high computational cost. Token pruning—the removal of redundant or less informative image patches—is a standard technique to improve ViT efficiency. However, traditional pruning heuristics, such as those based on CLS token attention, often struggle to identify the optimal subset of tokens for multimodal alignment, leading to significant performance degradation at high pruning rates.
Methodology: The Patch Ranking Framework
The proposed Patch Ranking framework operates in three distinct phases to ensure both efficiency and accuracy.
Phase I: Establishing a Golden Ranking
To determine which tokens are truly essential, the authors define a "Golden Ranking" using a greedy search strategy. Tokens are scored based on three primary metrics:
- Label-Driven: Impact on the probability of the ground-truth class.
- Maximum Confidence: Impact on the model's overall prediction certainty.
- Feature Preservation: The degree to which the global image representation changes upon token removal.
Phase II: Predicting the Ranking
Calculating the Golden Ranking for every image is computationally prohibitive. To solve this, a lightweight Mix-MLP predictor is trained to estimate token importance based on intermediate representations from early ViT layers. The authors found that the Feature Preservation score is particularly effective as it generalizes well across different datasets.
Phase III: Model Tuning via Learnable Tokens
Pruning tokens alters the input distribution, which can degrade performance. Rather than performing full-model fine-tuning, the framework employs Prompt Tuning. By introducing a small set of learnable visual and text prompts, the model can adapt to the reduced token sequences and maintain high alignment between modalities.
Experimental Results
The framework was evaluated across seven diverse benchmarks, including ImageNet, Caltech101, and fine-grained datasets like OxfordPets and Flowers102.
Efficiency and Accuracy
The Patch Ranking approach significantly outperforms baseline methods like CLS Attention and existing pruning techniques such as EViT and ToMe. On average, the method achieved 65.4% accuracy compared to EViT's 64.3% at equivalent computational costs. In terms of raw speed, inference time was reduced from 3.5ms to 1.6ms per image on an NVIDIA A4500, representing a substantial gain for real-world applications.
The Role of Dual Prompts
A key finding is the necessity of dual-modality prompt tuning. While visual prompts help the image encoder process pruned sequences, text prompts are crucial for realigning the language model to the modified visual features. As shown in the results, the combination of Visual and Text (V+T) prompt tuning yields the best trade-off between efficiency and accuracy.
Conclusion
Patch Ranking offers a robust solution for deploying CLIP models in resource-constrained environments. By reframing pruning as a learnable ranking task and utilizing prompt tuning for recovery, the method achieves significant speedups with minimal impact on zero-shot performance. Future research will explore dynamic pruning rates and the application of this framework to generative multimodal models.
Summary updated