Enhancing Outlier Knowledge for Few-Shot Out-of-Distribution Detection with Extensible Local Prompts

Fanhu Zeng, Zhen Cheng, Fei Zhu, Xu-Yao Zhang

Abstract

Out-of-Distribution (OOD) detection, aiming to distinguish outliers from known categories, has gained prominence in practical scenarios. Recently, the advent of vision-language models (VLM) has heightened interest in enhancing OOD detection for VLM through few-shot tuning. However, existing methods mainly focus on optimizing global prompts, ignoring refined utilization of local information with regard to outliers. Motivated by this, we freeze global prompts and introduce a novel coarse-to-fine tuning paradigm to emphasize regional enhancement with local prompts. Our method comprises two integral components: global prompt guided negative augmentation and local prompt enhanced regional regularization. The former utilizes frozen, coarse global prompts as guiding cues to incorporate negative augmentation, thereby leveraging local outlier knowledge. The latter employs trainable local prompts and a regional regularization to capture local information effectively, aiding in outlier identification. We also propose regional-related metric to empower the enrichment of OOD detection. Moreover, since our approach explores enhancing local prompts only, it can be seamlessly integrated with trained global prompts during inference to boost the performance. Comprehensive experiments demonstrate the effectiveness and potential of our method. Notably, our method reduces average FPR95 by 5.17% against state-of-the-art method in 4-shot tuning on challenging ImageNet-1k dataset, even outperforming 16-shot results of previous methods.

Introduction

Out-of-Distribution (OOD) detection is a critical capability for safety-sensitive AI applications, such as autonomous driving and medical diagnosis, where the model must recognize when an input does not belong to any of its trained classes. While Vision-Language Models (VLMs) like CLIP have demonstrated impressive zero-shot and few-shot capabilities, current OOD detection methods primarily rely on global prompts (e.g., "a photo of a [class]").

Conceptual comparison between existing global optimization methods and the proposed local prompt enhancement.

As illustrated in Figure 1, global prompts often fail in "near-OOD" scenarios. For instance, a model might correctly identify a tiger as In-Distribution (ID) based on its overall silhouette but fail to distinguish a visually similar cat as OOD. This failure occurs because global features overlook subtle regional differences, such as the specific stripe patterns on a tiger's forehead. To address this, we propose Local-Prompt, a "coarse-to-fine" tuning paradigm that focuses on regional details to refine the decision boundary between ID and OOD samples.

Methodology

The Local-Prompt framework decomposes the tuning process into global and local components. By freezing the global prompts, we ensure the model retains its general semantic knowledge while we optimize specialized local prompts through two primary modules.

The Local-Prompt framework: (a) Global Prompt Guided Negative Augmentation and (b) Local Prompt Enhanced Regional Regularization.

1. Global Prompt Guided Negative Augmentation

In few-shot settings, real OOD data is typically unavailable. We simulate outliers by taking random crops of ID images and using frozen global prompts to rank them. Crops that exhibit the lowest similarity to the class label are treated as "hard negatives." These simulated outliers provide the model with essential local outlier knowledge, teaching it what specific regions do not belong to the target class.

2. Local Prompt Enhanced Regional Regularization

We train local prompts using a contrastive loss that encourages the model to focus on ID-relevant regions while distancing itself from the outlier-related regions identified during negative augmentation. To prevent the local negative prompts from collapsing into redundant features, we incorporate a "diversity regularization" term. This ensures the model learns a broad spectrum of local characteristics that distinguish ID from OOD.

3. Regional-MCM Score

During inference, we introduce the Regional-MCM score. This metric combines global similarity with the mean similarity of the $k$ most relevant local regions. By integrating both coarse and fine-grained information, the Regional-MCM score provides a more robust measure of confidence for OOD detection.

Experimental Results

We evaluated Local-Prompt across several benchmarks, including ImageNet-1k (ID) and datasets like iNaturalist, SUN, and Places (OOD).

  • State-of-the-Art Performance: In a 4-shot setting, Local-Prompt achieved a 5.17% reduction in average FPR95 compared to previous leading methods on ImageNet-1k. Remarkably, our 4-shot results outperformed the 16-shot results of existing state-of-the-art approaches, demonstrating superior data efficiency.
  • Near-OOD Robustness: On the challenging ImageNet-10 vs. ImageNet-20 task, Local-Prompt achieved an average FPR95 of 5.05%, significantly outperforming standard MCM (8.75%) and LoCoOp (11.60%).
  • ID Accuracy Preservation: Unlike many OOD methods that sacrifice classification performance, Local-Prompt improved ID accuracy by approximately 1.02% on ImageNet-1k.

Conclusion

Local-Prompt introduces an extensible, coarse-to-fine paradigm for OOD detection in VLMs. By focusing on regional enhancement through local prompts, our method captures the fine-grained differences necessary to distinguish between visually similar ID and OOD samples. Because the local prompts are optimized orthogonally to global prompts, our method can be seamlessly integrated with existing global-tuning techniques to further boost performance. Future work will explore the joint optimization of global and local prompts and the application of this framework to complex tasks like open-world object detection.

Summary updated

Abstract

Out-of-Distribution (OOD) detection, aiming to distinguish outliers from known categories, has gained prominence in practical scenarios. Recently, the advent of vision-language models (VLM) has heightened interest in enhancing OOD detection for VLM through few-shot tuning. However, existing methods mainly focus on optimizing global prompts, ignoring refined utilization of local information with regard to outliers. Motivated by this, we freeze global prompts and introduce a novel coarse-to-fine tuning paradigm to emphasize regional enhancement with local prompts. Our method comprises two integral components: global prompt guided negative augmentation and local prompt enhanced regional regularization. The former utilizes frozen, coarse global prompts as guiding cues to incorporate negative augmentation, thereby leveraging local outlier knowledge. The latter employs trainable local prompts and a regional regularization to capture local information effectively, aiding in outlier identification. We also propose regional-related metric to empower the enrichment of OOD detection. Moreover, since our approach explores enhancing local prompts only, it can be seamlessly integrated with trained global prompts during inference to boost the performance. Comprehensive experiments demonstrate the effectiveness and potential of our method. Notably, our method reduces average FPR95 by 5.17% against state-of-the-art method in 4-shot tuning on challenging ImageNet-1k dataset, even outperforming 16-shot results of previous methods.
BibTeX
@inproceedings{zeng2025enhancing,
  author = {Fanhu Zeng and Zhen Cheng and Fei Zhu and Xu-Yao Zhang},
  title = {{Enhancing Outlier Knowledge for Few-Shot Out-of-Distribution Detection with Extensible Local Prompts}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=Ew3VifXaxZ},
}
Figure