Delving into Out-of-Distribution Detection with Vision-Language Representations

Yifei Ming, Ziyang Cai, Jiuxiang Gu, Yiyou Sun, Wei Li, Yixuan Li

Abstract

Recognizing out-of-distribution (OOD) samples is critical for machine learning systems deployed in the open world. The vast majority of OOD detection methods are driven by a single modality (e.g., either vision or language), leaving the rich information in multi-modal representations untapped. Inspired by the recent success of vision-language pre-training, this paper enriches the landscape of OOD detection from a single-modal to a multi-modal regime. Particularly, we propose Maximum Concept Matching (MCM), a simple yet effective zero-shot OOD detection method based on aligning visual features with textual concepts. We contribute in-depth analysis and theoretical insights to understand the effectiveness of MCM. Extensive experiments demonstrate that MCM achieves superior performance on a wide variety of real-world tasks. MCM with vision-language features outperforms a common baseline with pure visual features on a hard OOD task with semantically similar classes by 13.1% (AUROC).

Introduction

Machine learning models deployed in real-world environments frequently encounter "unknown unknowns"—samples belonging to classes not present during training. Detecting these Out-of-Distribution (OOD) samples is essential for ensuring the safety and reliability of autonomous systems. Traditionally, OOD detection has been treated as a single-modal problem, primarily focusing on visual feature extraction. However, visual similarity does not always equate to semantic similarity. For instance, a vision-only model might struggle to distinguish a wolf (OOD) from a dog (In-Distribution) due to shared visual characteristics, ignoring their distinct semantic categories.

This research introduces Maximum Concept Matching (MCM), a framework that leverages the rich semantic information available in joint vision-language representations, such as CLIP, to bridge this gap. By aligning visual features with textual concepts, MCM provides a more robust mechanism for identifying samples that fall outside the known semantic space.

Methodology: Maximum Concept Matching (MCM)

MCM is a zero-shot OOD detection method that utilizes pre-trained vision-language models without requiring additional training or fine-tuning on in-distribution (ID) data. The method operates through three primary stages:

  1. Concept Prototypes: For every ID class, the method generates a textual embedding (e.g., the vector for "a photo of a [dog]"). These embeddings serve as semantic anchors in a shared feature space.
  2. Feature Alignment: When a new image is processed, the model calculates the cosine similarity between the image's visual features and all predefined textual concept prototypes.
  3. Softmax Scaling: Unlike standard visual models where softmax can lead to problematic overconfidence, MCM applies softmax to these similarity scores with a specific scaling factor. The authors demonstrate that for vision-language models, this operation actually increases the separability between ID and OOD data.

Because MCM relies on pre-trained representations, it is inherently "OOD-agnostic," meaning it does not require prior knowledge of what the OOD samples might look like.

Theoretical Insights

A key contribution of this work is the theoretical analysis of why MCM succeeds. The researchers identify two critical factors:

  • Language as a Semantic Anchor: Textual descriptions provide a more stable "ground truth" for category representation than visual features alone, which are often susceptible to environmental noise like lighting or background changes.
  • The Uniformity of OOD: In the CLIP feature space, OOD samples tend to exhibit a relatively uniform (low) similarity across all ID textual concepts.
  • Softmax as a Magnifier: Due to this uniformity, softmax scaling acts as a mathematical magnifier. It sharpens the probability peak for ID samples (which match one concept strongly) while keeping the scores for OOD samples low and distributed, significantly improving the detector's ability to distinguish between the two.

Experimental Evaluation

The researchers evaluated MCM across a diverse array of benchmarks, including ImageNet-1k, CUB-200, Stanford Cars, and Food-101. To test the limits of the method, they curated ImageNet-10 (ID) and ImageNet-20 (OOD), a "hard" benchmark where OOD classes are semantically similar to ID classes (e.g., different species of canines).

Key Results

  • State-of-the-Art Performance: On the ImageNet-1k benchmark, MCM achieved an average AUROC of 91.49%, outperforming strong supervised baselines such as MOS.
  • Fine-Grained Discrimination: On the semantically challenging ImageNet-10 vs. ImageNet-20 task, MCM outperformed pure visual distance-based methods (like Mahalanobis distance) by 13.1% in AUROC.
  • Robustness to Spurious Correlations: MCM demonstrated superior robustness on tasks like the Waterbirds dataset, where models are often misled by backgrounds (e.g., water vs. land) rather than the primary object. By anchoring to the textual concept of the object, MCM avoids these common pitfalls.

Limitations and Future Work

While MCM represents a significant step forward, it is not without limitations. The method's performance is sensitive to the quality of text prompts; while "prompt ensembling" helps mitigate this, the reliance on manual or semi-manual prompt engineering remains. Furthermore, MCM is dependent on the underlying vision-language model (e.g., CLIP or ALIGN). As these foundational models evolve, MCM is expected to improve, but it also inherits any biases present in the pre-training data.

Future research directions include exploring more complex vision-language architectures beyond dual-stream models and developing methods to automatically generate optimized concept prototypes for OOD detection.

Conclusion

Maximum Concept Matching (MCM) demonstrates that the integration of linguistic semantics into visual recognition tasks significantly enhances OOD detection. By treating language as a stable anchor and utilizing the unique properties of vision-language feature spaces, MCM provides a highly efficient, training-free solution for building safer and more reliable machine learning systems.

Summary updated

BibTeX
@inproceedings{ming2022delving,
  author = {Yifei Ming and Ziyang Cai and Jiuxiang Gu and Yiyou Sun and Wei Li and Yixuan Li},
  title = {{Delving into Out-of-Distribution Detection with Vision-Language Representations}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=KnCS9390Va},
}
Figure