Concept Matching with Agent for Out-of-Distribution Detection

Yuxiao Lee, Xiaofeng Cao, Jingcai Guo, Wei Ye, Qing Guo, Yi Chang · DOI

TL;DR

This paper introduces Concept Matching with Agent (CMA), a novel zero-shot OOD detection method that leverages the power of Large Language Models (LLMs) by employing "agents" (neutral text prompts) to enhance the separation between in-distribution (ID) and out-of-distribution (OOD) data. CMA achieves superior performance by forming a "vector triangle relationship" between data, labels, and agents, outperforming existing methods without requiring additional training data.

What Problem Does This Paper Address?

Out-of-distribution (OOD) detection is crucial for ensuring the reliability of AI systems when encountering data that deviates from their training distribution. Traditional OOD detection methods, including those based on CLIP, often rely on a binary relationship between ID and OOD data. While effective to some extent, these methods lack the flexibility to handle the dynamic complexity of real-world data distributions. The authors aim to improve the robustness and adaptability of OOD detection by incorporating external information, specifically through the "agent paradigm" popularized by LLMs, to create a more nuanced approach to distinguishing between ID and OOD inputs.

Methods

The core of the proposed method, Concept Matching with Agent (CMA), is the introduction of "agents" in the form of neutral textual concept prompts. These agents interact with both ID labels and data inputs, forming a "vector triangle relationship." This is a departure from traditional binary relationships. The authors hypothesize that neutral prompts have a minimal impact on ID data but can significantly reduce the score of OOD data, effectively widening the gap between ID and OOD scores.

Specifically, CMA uses a CLIP model with an image encoder and a text encoder. Neutral prompts are concatenated with ID labels and fed into the text encoder to generate text embeddings. The similarity between image embeddings and these combined text embeddings is then computed. The CMA score is derived from this similarity, with the triangular framework designed to minimize the maximum score, thereby enhancing OOD detection. A key advantage is that CMA is a zero-shot method, requiring no additional training data.

Datasets

The paper evaluates CMA on a variety of datasets:

  • Large-scale OOD Benchmark: ImageNet-1k (ID) paired with four OOD datasets: iNaturalist, SUN, Places, and Textures.
  • Small-scale Datasets: FashionMNIST, STL10, OxfordIIIPet, Food-101, CUB-200, PlantVillage, LFW, Stanford-dogs, FGVC-Aircraft, Grocery Store, and CIFAR-10.
  • Hard OOD Tasks: ImageNet-10, ImageNet-20 (with similar semantic content to ImageNet-10 but different classes), and the Spurious OOD detection benchmark (Waterbirds dataset).

Key Insights and Ideas

  • The "Agent" Paradigm for OOD: The paper successfully adapts the agent paradigm, common in LLMs, to the OOD detection task. This involves using neutral text prompts as active participants in the detection process.
  • Vector Triangle Relationship: Moving beyond binary classification, the "vector triangle relationship" formed by ID labels, data inputs, and agents provides a more sophisticated way to discriminate between ID and OOD data.
  • Neutral Prompts as Discriminators: The finding that neutral prompts have a differential impact on ID vs. OOD data is crucial. They minimally affect ID data but significantly suppress OOD data scores, creating a clear separation.
  • Zero-Shot Capability: CMA's ability to perform OOD detection without requiring any training on OOD data or even fine-tuning on ID data makes it highly practical and versatile.
  • Scalability and Flexibility: The method's performance scales with the underlying CLIP model, and the concept of agents allows for tailoring to specific scenarios.

Key Results

  • Superior Performance: CMA consistently outperforms existing zero-shot and training-required OOD detection methods across various benchmarks, including ImageNet-1k, small-scale datasets, and hard OOD tasks.
  • ImageNet-1k Benchmark: CMA achieves significant improvements over average zero-shot methods (2.22% in AUROC, 2.68% in FPR95) and require-training methods (0.79% in AUROC, 3.13% in FPR95) on the ImageNet-1k OOD benchmark.
  • ID Classification Accuracy: CMA does not compromise the model's accuracy on the original classification task, as shown in Table 7.
  • Impact of Agents: Experiments demonstrate that the number and type of agents significantly impact performance, with an optimal number of agents found to be crucial.
  • Softmax Scaling Importance: The paper highlights that softmax scaling is essential for CMA's effectiveness, as it allows agents to influence the final score calculation.

Limitations and Future Work

  • Agent Sensitivity: The performance of CMA can be sensitive to the choice of neutral prompts. If prompts share semantic similarities with ID labels, it can compromise ID detection.
  • OOD Similarity: The method struggles with OOD images that are too similar to ID labels, as external information may not fully mitigate this.
  • Future Research: The authors suggest further research into obtaining neutral prompts that better align with ID label requirements without explicit training. They also emphasize the need for more in-depth research into the interaction between external information and OOD detection.

Summary updated

BibTeX
@inproceedings{lee2025concept,
  author = {Yuxiao Lee and Xiaofeng Cao and Jingcai Guo and Wei Ye and Qing Guo and Yi Chang},
  title = {{Concept Matching with Agent for Out-of-Distribution Detection}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i5.32481},
}
Figure