Introduction
Vision-Language Models (VLMs) like CLIP have set new benchmarks in zero-shot classification. However, these models often struggle with "domain gaps"—performance declines when the model encounters data distributions significantly different from its training set (e.g., sketches, medical images, or adversarial examples). Test-Time Adaptation (TTA) aims to mitigate this by adjusting the model using unlabeled test data at runtime.
The Efficiency Bottleneck of Prompt Tuning
The current state-of-the-art for TTA is Test-Time Prompt Tuning (TPT). TPT optimizes text prompts to better align with the test image distribution. While effective, TPT is computationally expensive. It requires backpropagating gradients through a massive text encoder for every test instance, leading to high latency and memory consumption. This overhead makes TPT impractical for real-time or resource-constrained applications like mobile devices or robotics.
Proposed Method: Test-Time Prototype Shifting (TPS)
To address these limitations, we introduce Test-Time Prototype Shifting (TPS). Instead of indirectly modulating class representations by tuning text prompts, TPS directly "shifts" class prototypes within the model's internal embedding space.
As shown in the workflow below, the TPS framework operates in three distinct stages:
- Prototype Generation: Class prototypes are pre-computed and cached using the text encoder before inference. These can be derived from simple manual templates or complex LLM-generated descriptors.
- Test-Time Shift Tuning: For each test image, multiple augmented views are generated. TPS learns a small, sample-specific shift vector for the cached prototypes by minimizing prediction entropy across these views. Crucially, the image and text encoders remain frozen, and gradients are only applied to the shift vectors.
- Test-Time Inference: The final classification is performed using the original image and the updated, shifted prototypes.
By bypassing the text encoder during the optimization loop, TPS achieves massive efficiency gains while remaining agnostic to how the initial prototypes were generated.
Experimental Results
TPS was evaluated across 15 datasets, including ImageNet variants for distribution shifts and specialized datasets for cross-dataset generalization.
Accuracy and Robustness
TPS consistently outperformed TPT, achieving a 3.3% improvement on natural distribution shifts and a 1.9% gain on cross-dataset benchmarks. It also showed superior performance on the Bongard-HOI visual reasoning task, demonstrating its ability to handle complex semantic relationships beyond simple labeling.
Efficiency Gains
The primary advantage of TPS is its efficiency. On an NVIDIA A6000 GPU:
- Speed: TPS is 10x faster than TPT. Its runtime is nearly independent of the number of classes, whereas TPT's runtime increases linearly with class count.
- Memory: TPS requires less than 1/10th of the GPU memory (approx. 1.7GB vs. 19GB for ImageNet), making it accessible for standard consumer hardware.
Conclusion
Test-Time Prototype Shifting (TPS) offers a practical and powerful alternative to prompt tuning for VLM adaptation. By shifting prototypes directly in the embedding space, TPS provides a "plug-and-play" solution that is faster, more memory-efficient, and more accurate than previous methods. This efficiency paves the way for deploying adaptive VLMs on edge devices and in real-time systems.
Summary updated