Class-Aware Prototype Learning with Negative Contrast for Test-Time Adaptation of Vision-Language Models

Xiaozhen Qiao, Jingkai Zhao, Yuqiu Jiang, Xianda Guo, Zhe Sun, Hongyuan Zhang, Xuelong LiarXiv 2025 · DOI

Abstract

Vision-Language Models (VLMs) like CLIP demonstrate impressive zero-shot capabilities but often struggle with distribution shifts encountered during deployment. Test-Time Adaptation (TTA) offers a solution by updating models using unlabeled data streams. However, current TTA approaches face two major hurdles: prototype degradation in long-tailed data distributions and semantic confusion between visually similar categories. We present CPL-NC (Class-Aware Prototype Learning with Negative Contrast), a framework designed to address these issues through a dynamic frequency-aware cache and explicit negative contrastive learning. Our method achieves state-of-the-art performance across 15 diverse benchmarks while maintaining high computational efficiency.

Introduction

Deploying VLMs in real-world scenarios often involves data that differs significantly from the training distribution. While TTA aims to bridge this gap, existing methods are limited by the "dead class" problem—where frequent classes overwrite rare ones in fixed-size caches—and a lack of clear decision boundaries between semantically related classes.

Figure 4: Illustration of the core challenges in TTA. (c) shows the long-tailed distribution leading to sample count imbalances. (d) demonstrates semantic confusion among 'fish' categories despite visual dissimilarities.

Methodology

CPL-NC introduces several innovations to stabilize and enhance test-time adaptation:

Class-Aware Prototype Cache (CAPC)

Unlike standard caches, CAPC dynamically manages storage based on class frequency and recency. A nonlinear suppression function prevents dominant classes from monopolizing memory, ensuring that rare "tail" classes remain represented.

Dead-Class Rejuvenation

To prevent infrequent classes from becoming "dead," the framework monitors activation levels. Inactive classes receive temporary capacity boosts and synthetic feature injections derived from semantically similar categories to maintain prototype readiness.

Negative Contrastive Learning (NCL)

To resolve semantic confusion, CPL-NC identifies "hard negatives"—the most similar but incorrect visual-textual pairs. An InfoNCE loss is applied to push these representations apart, sharpening decision boundaries between confusing classes like "goldfish" and "starfish."

Asymmetric Optimization

To ensure stability and efficiency, CPL-NC performs parametric updates only on textual prototypes. Visual prototypes serve as stable anchors in the cache and are updated incrementally, preventing the "semantic drift" often seen when updating both encoders.

Evaluation and Results

The framework was evaluated on 15 benchmarks, including ImageNet robustness variants (OOD) and 10 cross-domain datasets (e.g., Aircraft, Flowers, EuroSAT).

Figure 1: Performance comparison of CPL-NC against state-of-the-art methods. (a) Radar chart for OOD robustness on ImageNet variants. (b) Radar chart for cross-dataset generalization. CPL-NC (orange line) consistently forms the outer boundary.

Key Findings

  • State-of-the-Art Accuracy: CPL-NC achieved 31.09% accuracy on ImageNet-A (ResNet-50) and an average of 70.36% across 10 cross-domain datasets (ViT-B/16), outperforming methods like DPE and TDA.
  • Efficiency: CPL-NC adapted to ImageNet in 2 hours and 44 minutes, significantly faster than prompt-tuning methods like TPT, which can take over 10 hours.
  • Robustness: The asymmetric optimization and CAPC mechanisms provide superior stability against noisy data and long-tailed distributions.

Conclusion

CPL-NC addresses fundamental weaknesses in VLM adaptation by prioritizing memory equity and contrastive clarity. By managing prototypes more intelligently, it allows models to adapt to diverse and challenging environments without the need for labeled data. Future work will focus on further reducing computational latency for real-time edge applications.

Summary updated

BibTeX
@misc{qiao2025class,
  author = {Xiaozhen Qiao and Jingkai Zhao and Yuqiu Jiang and Xianda Guo and Zhe Sun and Hongyuan Zhang and Xuelong Li},
  title = {{Class-Aware Prototype Learning with Negative Contrast for Test-Time Adaptation of Vision-Language Models}},
  year = {2025},
  eprint = {2510.19802},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.19802},
}
Figure