Spurious Feature Eraser: Stabilizing Test-Time Adaptation for Vision-Language Foundation Model

Huan Ma, Yan Zhu, Changqing Zhang, Peilin Zhao, Baoyuan Wu, Long-Kai Huang, Qinghua Hu, Bingzhe Wu

Introduction

Vision-Language Foundation Models (VLFMs) like CLIP have demonstrated remarkable zero-shot capabilities across diverse tasks. However, these models often rely on "decision shortcuts"—spurious correlations between background features and class labels—which leads to significant performance degradation on out-of-distribution data. For instance, a model might incorrectly classify a spider as a crab simply because it appears on a beach. This paper introduces Spurious Feature Eraser (SEraser), a test-time prompt tuning method designed to mitigate these shortcuts by forcing the model to ignore non-essential features.

The Problem: Decision Shortcuts in VLFMs

VLFMs are highly susceptible to spurious correlations. If a training set frequently pairs waterbirds with water, the model may learn to associate the "water" background with the "waterbird" label, ignoring the actual bird's features.

Visualizing how a beach background causes CLIP to misclassify a spider as a crab, and how focusing on the masked object corrects the prediction.

Existing solutions like fine-tuning or architectural changes (e.g., Alpha-CLIP) are computationally expensive. Standard Test-Time Prompt Tuning (TPT) often fails because it reinforces high-confidence predictions, which may be based on the very spurious features we want to avoid. Furthermore, traditional benchmarks are increasingly compromised by test data leakage, as VLFMs are trained on internet-scale datasets.

SEraser: Test-Time Prompt Tuning via Entropy Maximization

The authors propose SEraser, an out-of-the-box paradigm that optimizes a continuous, learnable text prompt at inference time. Instead of updating model weights, SEraser tunes the prompt to maximize the entropy of predictions on auxiliary images that isolate spurious features.

The SEraser architecture: Auxiliary images (annotations, patches, or reference images) are used to tune a prompt by maximizing prediction entropy, effectively 'erasing' the influence of spurious features.

By forcing a uniform distribution (high uncertainty) on images containing only the background or non-essential patches, the model is effectively taught to "erase" these shortcuts. This compels the model to rely on the invariant features of the core object in the original image. Auxiliary images are generated via:

  1. Annotations: Masking the foreground using tools like Segment Anything (SAM).
  2. Patches: Utilizing corner patches where the main object is unlikely to be present.
  3. Reference Images: Retrieving visually similar images from external out-of-distribution datasets.

The S2E Paradigm: Generative Robustness Evaluation

To address the issue of data leakage in foundation models, the authors introduce the Shortcut-to-Evaluate (S2E) paradigm. Using generative AI (DALL-E, Midjourney), they created synthetic datasets like CamelDeer (camels in grasslands, deer in deserts) and SpiderCrab (spiders on beaches). These counter-contextual images provide a rigorous test of a model's reliance on shortcuts without the risk of the model having seen the test images during pre-training.

Key Results and Insights

SEraser demonstrates significant improvements across various benchmarks:

  • Waterbirds: Improved worst-group accuracy by over 25% (from 40.04% to 65.25%) compared to vanilla CLIP.
  • SpiderCrab (S2E): Boosted worst-group accuracy from 42.00% to 94.67%, a massive 52.6% absolute improvement.
  • Real-world Datasets: On Tiny-ImageNet, CUB-200, and ImageNetA, combining patch and reference-based strategies increased average accuracy from 25.8% to 40.5%.

Visualization via Grad-CAM reveals that CLIP often "knows" the correct features, but the background shortcut overrides them. SEraser acts as a soft constraint, preventing hasty decisions based on partial or spurious information.

Conclusion

SEraser provides a robust, computationally efficient way to stabilize VLFM performance at test time. By shifting the focus from static benchmarks to generative evaluation (S2E), the authors also provide a path forward for testing increasingly powerful foundation models in a leakage-free manner. While test-time adaptation adds some inference overhead, the gains in reliability and accuracy on out-of-distribution data are substantial.

Summary updated

BibTeX
@inproceedings{ma2025spurious,
  author = {Huan Ma and Yan Zhu and Changqing Zhang and Peilin Zhao and Baoyuan Wu and Long-Kai Huang and Qinghua Hu and Bingzhe Wu},
  title = {{Spurious Feature Eraser: Stabilizing Test-Time Adaptation for Vision-Language Foundation Model}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i18.34124},
}
Figure