DeCoOp: Robust Prompt Tuning with Out-of-Distribution Detection

Zhi Zhou, Ming Yang, Jiang-Xin Shi, Lan-Zhe Guo, Yu-Feng Li · DOI · OpenReview

DeCoOp: Robust Prompt Tuning with Out-of-Distribution Detection

Abstract

Vision-language models (VLMs) like CLIP excel at zero-shot classification but often suffer from performance degradation on unseen classes after prompt tuning on a specific set of base classes. This paper introduces DeCoOp, a framework designed for "Open-world Prompt Tuning" (OPT). By decomposing the classification task into Out-of-Distribution (OOD) detection and specialized sub-classification, DeCoOp effectively bridges the gap between base-class optimization and new-class generalization. Experimental results across 11 benchmarks demonstrate a 2% average accuracy improvement and a significant boost in base-to-new discriminability.

The Open-world Prompt Tuning Challenge

Prompt tuning methods, such as Context Optimization (CoOp), have become a standard way to adapt large-scale pre-trained VLMs to downstream tasks using only a few labeled examples. While these methods significantly improve performance on "base classes" (those seen during tuning), they frequently compromise the model's original "zero-shot" capabilities on "new classes" (those unseen during tuning).

Overview of the Training and Testing stages in prompt tuning, highlighting the introduction of new classes during deployment.

In real-world applications, a model cannot assume that all inputs belong to the classes it was tuned on. This paper formalizes this as Open-world Prompt Tuning (OPT), where the model must simultaneously handle base and new classes. The fundamental challenge is "base-to-new discriminability"—the ability to distinguish whether an image belongs to the tuned distribution or is a novel category that should be handled by the original zero-shot weights.

Methodology: Decomposed Context Optimization (DeCoOp)

The authors propose a two-tiered solution starting with a theoretical framework called Decomposed Prompt Tuning (DePT). DePT mathematically proves that if a model can accurately detect when an image belongs to a new class, it can minimize total error by routing those images to the original frozen VLM weights while using tuned prompts only for base classes.

DeCoOp is the practical implementation of this theory, consisting of three main components:

  1. New-class Detectors ($M_D$): An ensemble of detectors trained using a "leave-out" strategy. During training, certain base classes are withheld to simulate "new" classes, teaching the model to recognize the characteristics of unknown data.
  2. Sub-classifiers ($M_C$): Specialized classifiers that focus on subsets of base classes to maximize fine-grained accuracy.
  3. The Router: At inference time, the detectors act as a gate. If an image is flagged as "new," the system defaults to standard zero-shot CLIP. If flagged as "base," the specialized sub-classifier takes over.

Key Insights: The H-Metric Trap

A critical contribution of this work is the critique of the standard "Harmonic Mean" (H-metric) used to evaluate base-to-new generalization. The H-metric calculates the harmonic mean of base and new class accuracies, but it assumes the model knows which distribution the image comes from in advance.

Comparison of changes in the Harmonic Mean (H) metric versus actual accuracy, illustrating the potential for the H-metric to be misleading in open-world scenarios.

As shown in the figure above, an improvement in the H-metric does not always translate to better real-world accuracy. In OPT scenarios, a model might have high separate accuracies but fail to distinguish between the two distributions, leading to poor overall performance when classes are mixed. DeCoOp addresses this by treating the performance drop as an OOD problem rather than just a prompt-tuning problem.

Results and Performance

DeCoOp was evaluated on 11 diverse datasets, ranging from general objects (ImageNet) to specialized satellite imagery (EuroSAT).

  • Accuracy Gains: DeCoOp achieved a 2% average accuracy boost over state-of-the-art methods like CoCoOp and SHIP in the open-world setting.
  • Discriminability: The method showed a massive leap in AUROC (Area Under the Receiver Operating Characteristic), averaging 91.57% compared to CoCoOp’s 78.72%, proving its superior ability to tell base and new classes apart.
  • Efficiency: Despite using an ensemble, DeCoOp is computationally efficient. It avoids the per-image neural network pass required by CoCoOp, making it nearly twice as fast during inference on certain benchmarks.

Conclusion and Future Directions

DeCoOp represents a significant step toward making prompt tuning viable for real-world, open-world applications. By integrating OOD detection, it preserves the zero-shot strengths of VLMs while reaping the benefits of fine-tuning. Future work may look into more tightly integrating the detection and classification stages during the training process to further reduce overhead and improve robustness across even more diverse domains.

Summary updated

BibTeX
@inproceedings{zhou2024decoop,
  author = {Zhi Zhou and Ming Yang and Jiang-Xin Shi and Lan-Zhe Guo and Yu-Feng Li},
  title = {{DeCoOp: Robust Prompt Tuning with Out-of-Distribution Detection}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=MoTUdh9ZCc},
}
Figure