NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Just Shift It: Test-Time Prototype Shifting for Zero-Shot Generalization with Vision-Language Models

Elaine Sui, Xiaohan Wang, Serena Yeung-Levy

TL;DR

The Test-Time Prototype Shifting (TPS) framework introduces a highly efficient method for adapting vision-language models (VLMs) to out-of-distribution data at test time without needing labeled data. Instead of backpropagating through massive text encoders to tune prompts, TPS pre-computes class prototypes and dynamically learns small "shift vectors" directly in the embedding space. This simple tweak delivers state-of-the-art accuracy while slashing memory usage and computational runtime by over 10x compared to existing test-time prompt tuning methods.

What Problem Does This Paper Address?

Vision-language foundation models like CLIP excel at zero-shot classification, but their performance often degrades when encountering real-world domain shifts (e.g., sketch versions of images, adversarial examples, or entirely new datasets).

To fix this, researchers use Test-Time Adaptation (TTA), which tunes the model on-the-fly using unlabeled test samples. A prominent approach is Test-Time Prompt Tuning (TPT), which optimizes the text prompts fed into the VLM. However, TPT requires backpropagating gradients through the entire, massive text encoder for every single test image. This makes it incredibly slow, memory-intensive, and computationally impractical for deployment, especially as the number of target classes grows.

Methods

TPS bypasses the text encoder during the online adaptation phase entirely by shifting the optimization problem directly into the shared embedding space.

Figure 1. Comparison of Test-Time Prompt Tuning (TPT) [47] against our method, Test-Time Prototype Shifting (TPS). TPT re- quires gradients to backpropagate through the large text encoder in order to reach the tuneable prompt, incurring high memory and computational costs. In contrast, TPS only backpropagates gradi- ents to the feature space, in which our class prototype shifts are learned, making it much more efficient.

The framework operates in three distinct stages:

  1. Prototype Generation: Class text prompts (which can range from simple "a photo of a {class}" templates to rich, LLM-generated descriptors) are passed through the text encoder offline. The resulting class embeddings—called "prototypes"—are cached.
  2. Test-Time Shift Tuning: When a new test image arrives, the model generates multiple augmented views of it. These views are processed by a frozen image encoder. TPS then uses a lightweight "Shift Learner" to learn a unique shift vector for each class prototype. The objective is to minimize the entropy of the model's predictions across the augmented views, encouraging high-confidence, consistent predictions.
  3. Test-Time Inference: The learned shift vectors are added to the cached prototypes. The final classification is determined by computing the cosine similarity between these shifted prototypes and the original test image embedding.
Figure 2. We illustrate the three stages of Test-Time Prototype Shifting (TPS). 1) Prototype Generation: pre-computation of class prototypes using different prompt-engineering strategies. We show the computation of k class-conditioned descriptors for a single class. Means are computed and cached. 2) Test-Time Shift Tuning: one iteration of test-time training where we tune the Shift Learner to generate small perturbations to the class prototypes to close the gap between the source and target distributions. Marginal entropy of the CLIP similarities of the shifted prototypes and augmented image embeddings is minimized. 3) Test-Time Inference: Using the tuned Shift Learner, we compute the final prediction for the shifted class prototypes and the original image embedding with CLIP similarity.

Datasets

The authors evaluated TPS across 15 diverse image classification datasets and one visual reasoning benchmark:

  • Natural Distribution Shifts: ImageNet and its variants (ImageNet-V2, ImageNet-A, ImageNet-R, ImageNet-Sketch).
  • Cross-Dataset Generalization: Flowers102, DTD, OxfordPets, StanfordCars, UCF101, Caltech101, Food101, SUN397, FGVC-Aircraft, and EuroSAT.
  • Context-Dependent Visual Reasoning: Bongard-HOI.

Key Insights and Ideas

  • Feature-Space Modulation is Efficient: Directly adjusting vectors in the embedding space preserves the rich structure of the pre-trained VLM while avoiding the massive computational overhead of backpropagating through deep neural network encoders.
  • Per-Class Shifts Matter: Instead of applying a single universal shift to all classes, learning distinct shift vectors for each individual class prototype provides the necessary degrees of freedom to capture complex, class-level distribution shifts.
  • Decoupled Prompt Engineering: Because prototype generation happens offline, TPS acts as a true plug-and-play framework. It seamlessly benefits from advanced prompt engineering techniques (like using GPT-4 to generate detailed visual descriptors) without adding a single millisecond to test-time latency.

Key Results

  • Accuracy Gains: TPS consistently outperformed zero-shot CLIP and existing TTA methods. It achieved a 3.3% average accuracy improvement over vanilla TPT on ImageNet distribution shifts and a 1.9% improvement on cross-dataset generalization.
  • Massive Efficiency Boosts: TPS runs more than 10x faster and consumes less than 1/10th of the GPU memory compared to TPT.
  • O(1) Scalability: Crucially, while TPT's runtime scales linearly with the number of classes in a dataset (due to text encoder processing), TPS's runtime remains virtually constant at around 65 ms per batch, making it highly viable for many-class real-world applications.
Figure 3. Comparison of computational and memory costs on an A6000 GPU on ImageNet. Left: Average runtimes of TPT and TPS across different sized subsets of ImageNet [6] over 3 runs. Note that error bars are depicted but are not visible as they have extremely small standard deviations. Right: Memory consumption of TPT and TPS on ImageNet.

Limitations and Future Work

While TPS demonstrates impressive efficiency and accuracy, it relies heavily on the quality of the underlying VLM's embedding space. Furthermore, because it utilizes GPT-4 to generate advanced class descriptors during the offline phase, the framework risks inheriting or magnifying the inherent biases present in both CLIP and large language models. The authors suggest that future work should explore how to best leverage these foundation models' capabilities without propagating their biases, alongside extending feature-space modulation to other complex vision-language tasks.

Summary updated

BibTeX
@inproceedings{sui2025just,
  author = {Elaine Sui and Xiaohan Wang and Serena Yeung-Levy},
  title = {{Just Shift It: Test-Time Prototype Shifting for Zero-Shot Generalization with Vision-Language Models}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2025},
  doi = {10.1109/wacv61041.2025.00090},
}
Figure