Self-Calibrated Tuning of Vision-Language Models for Out-of-Distribution Detection

Geng Yu, Jianing Zhu, Jiangchao Yao, Bo Han

TL;DR

This paper introduces Self-Calibrated Tuning (SCT), a novel framework to improve Out-of-Distribution (OOD) detection in vision-language models (VLMs) like CLIP. SCT adaptively adjusts the influence of OOD regularization based on the model's prediction uncertainty on in-distribution data, effectively mitigating issues caused by noisy OOD features. This leads to more robust and accurate OOD detection, crucial for real-world AI deployments.

What Problem Does This Paper Address?

Deploying AI models in the real world means they'll encounter data they weren't explicitly trained on – this is known as Out-of-Distribution (OOD) data. Accurately identifying OOD data is critical for safety and reliability, especially in sensitive applications like autonomous driving or medical diagnosis. Recent methods leverage powerful Vision-Language Models (VLMs) like CLIP and prompt tuning to achieve impressive OOD detection. These methods often use "in-distribution irrelevant context" (features from training data that shouldn't be related to the target classes) as a proxy for OOD data to regularize the model. However, VLMs can struggle with accurately separating foregrounds from backgrounds, leading to "spurious" OOD features that actually contain information from the target classes. This noise degrades OOD detection performance. The authors aim to address this by making the OOD regularization process smarter, adapting to the quality of these extracted features.

Methods

The core innovation is Self-Calibrated Tuning (SCT). Instead of a fixed OOD regularization, SCT dynamically adjusts the learning objective. It introduces two "modulating factors" that control the balance between the primary classification task and the OOD regularization task.

Here's how it works:

  • Adaptive Weighting: For data points where the VLM is uncertain about its prediction (low confidence), SCT increases the focus on the classification task. This helps the model learn better from potentially noisy OOD features and avoid overfitting to spurious information.
  • Prioritizing Reliable Features: For data points where the VLM is confident, SCT shifts more attention to OOD regularization. This allows the model to leverage more reliable OOD features for better discrimination.

This adaptive redirection is achieved by modifying the standard prompt tuning loss function. The specific implementation uses linear functions for the modulating factors, which are designed to be monotonically decreasing for the classification loss and monotonically increasing for the OOD regularization loss, based on the prediction uncertainty. This approach is designed to be compatible with existing prompt tuning methods.

Datasets

The paper uses the following datasets:

  • In-Distribution (ID) Data: ImageNet-1K is used as the primary ID dataset for training.
  • Out-of-Distribution (OOD) Datasets:
    • iNaturalist
    • SUN
    • Places365
    • Textures
    • CIFAR-10
    • CIFAR-100

These are standard benchmarks in OOD detection research.

Key Insights and Ideas

  • Uncertainty is Key: The quality of OOD features extracted from ID data is directly correlated with the model's confidence in its predictions for those ID data points. When the model is uncertain, the extracted OOD features are less reliable.
  • SCT Adapts to Feature Quality: By adaptively adjusting the learning objective based on prediction uncertainty, SCT effectively "calibrates" the influence of OOD regularization. It down-weights the impact of noisy OOD features when the model is uncertain and leverages more reliable features when the model is confident.
  • Balancing Act: SCT intelligently balances the classification task and OOD regularization. This prevents the model from becoming overly reliant on potentially flawed OOD features while still benefiting from their discriminative power.
  • Compatibility is a Plus: SCT is designed to be a general framework that can be integrated with various prompt tuning methods, enhancing their OOD detection capabilities without requiring significant architectural changes.

Key Results

  • Improved OOD Detection: SCT consistently outperforms existing prompt tuning methods like LoCoOp, particularly in reducing the False Positive Rate (FPR95), a key metric for OOD detection. For example, on ImageNet-1K, SCT achieves a 3% improvement in FPR95 compared to the previous best method.
  • Robust Performance: SCT demonstrates strong performance across various few-shot settings (1, 2, 4, and 16 shots) and different OOD datasets.
  • Maintained Classification Accuracy: Crucially, SCT achieves these OOD detection gains without sacrificing performance on the original in-distribution classification task. Table 6 shows comparable ID Accuracy across methods.
  • Effective Calibration: SCT also shows improvements in confidence calibration, as measured by Expected Calibration Error (ECE), indicating that the model's confidence scores are more aligned with its actual accuracy.

Limitations and Future Work

  • Theoretical Justification: While the linear modulation functions are effective, the paper acknowledges that a deeper theoretical analysis of the relationship between sample uncertainty and OOD detection performance would be beneficial.
  • Sensitivity to Training Data: In few-shot settings, the performance of prompt tuning methods, including SCT, can be sensitive to the quality and quantity of limited ID training data. Future work could explore strategies for selecting more suitable training data or mitigating this sensitivity.
  • AUROC Improvement: While SCT shows significant gains in FPR95, the improvements in AUROC are less pronounced. Further research could focus on enhancing AUROC performance.
  • Exploring Other Modulation Functions: The paper briefly explores other modulation functions (logarithmic, trigonometric) and finds them effective, suggesting that the framework's generality allows for further optimization.

Summary updated

Abstract

Out-of-distribution (OOD) detection is crucial for deploying reliable machine learning models in open-world applications. Recent advances in CLIP-based OOD detection have shown promising results via regularizing prompt tuning with OOD features extracted from ID data. However, the irrelevant context mined from ID data can be spurious due to the inaccurate foreground-background decomposition, thus limiting the OOD detection performance. In this work, we propose a novel framework, namely, Self-Calibrated Tuning (SCT), to mitigate this problem for effective OOD detection with only the given few-shot ID data. Specifically, SCT introduces modulating factors respectively on the two components of the original learning objective. It adaptively directs the optimization process between the two tasks during training on data with different prediction uncertainty to calibrate the influence of OOD regularization, which is compatible with many prompt tuning based OOD detection methods. Extensive experiments and analyses have been conducted to characterize and demonstrate the effectiveness of the proposed SCT. The code is publicly available.
BibTeX
@inproceedings{yu2024self,
  author = {Geng Yu and Jianing Zhu and Jiangchao Yao and Bo Han},
  title = {{Self-Calibrated Tuning of Vision-Language Models for Out-of-Distribution Detection}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=w6vbfSC1y0},
}
Figure