Local-Prompt: Extensible Local Prompts for Few-Shot Out-of-Distribution Detection

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

TL;DR

Local-Prompt is a novel coarse-to-fine prompt tuning paradigm that significantly boosts few-shot Out-of-Distribution (OOD) detection in vision-language models like CLIP. By freezing global prompts and optimizing trainable local prompts to capture fine-grained regional differences, it achieves state-of-the-art performance—reducing average FPR95 by 5.17% on ImageNet-1k with just 4 training examples per class.

What Problem Does This Paper Address?

Out-of-Distribution (OOD) detection ensures that machine learning systems can safely flag unknown objects or anomalies rather than confidently misclassifying them. Recently, researchers have turned to Vision-Language Models (VLMs) like CLIP for this task, using "few-shot prompt tuning" to adapt the model using only a handful of In-Distribution (ID) images.

However, existing methods focus almost entirely on optimizing global prompts (e.g., describing the whole image). This creates a massive blind spot: the most challenging OOD cases often look identical to ID classes on a macro level and only differ in subtle, localized regions. For instance, a cat and a tiger share massive global similarities, differing primarily in local textures or facial markings. Global prompt tuning fails to capture these fine-grained regional nuances, leading to high false-positive rates.

Figure 1: Comparison of prompt learning for OOD detection task. Prompts with global optimization may fail in challenging OOD samples as they are overall similar to ID samples and only have subtle regional differences. For example, cat and tiger are generally similar (blue boxes) and only differ in forehead (red box). Our approach with local outlier knowledge cares about region difference and tackles the issue to some extent.

Methods

To bridge this gap, the authors propose Local-Prompt, a coarse-to-fine tuning paradigm that decouples global and local prompt optimization. They freeze the global prompts and introduce trainable local prompts designed to interact specifically with patch-wise regional image features.

The framework consists of two core components:

  1. Global Prompt Guided Negative Augmentation: Since real OOD data isn't available during few-shot training, the method generates "imaginary" local outliers. It takes random crops of an ID image and uses the frozen, coarse global prompts to rank them. Crops with the highest similarity serve as positive ID regions, while crops with the lowest similarity are treated as "hard negative" (outlier) regions.
  2. Local Prompt Enhanced Regional Regularization: The model trains local prompts for known classes alongside a set of "local negative prompts" to capture outlier semantics. It optimizes these using a regional contrastive loss (forcing the model to highlight ID regions and push away negative regions) and a diversity regularization loss to prevent the negative prompts from collapsing into identical representations.

An elegant advantage of this approach is its extensibility. Because it focuses purely on local prompts, it is fully orthogonal to existing global prompt tuning methods (like LoCoOp). At inference time, users can seamlessly pair these trained local prompts with any optimized global prompts to get a synergistic performance boost.

Figure 2: Detailed structure of the proposed Local-Prompt. Our method consists of global prompt guided negative augmentation and local prompt enhanced regional regularization. We froze global prompts to select regional augmented samples and enhance local prompts to learn regional-related representation that helps im- prove both ID accuracy and OOD detection.

Datasets

The authors evaluated their method using large-scale benchmarks:

  • In-Distribution (ID) Datasets: ImageNet-1k and ImageNet-100.
  • Out-of-Distribution (OOD) Datasets: A standard evaluation suite combining iNaturalist, SUN, Places, and Texture.
  • Near-OOD Benchmarks: ImageNet-10 and ImageNet-20 subsets, specifically used to evaluate performance on highly semantically similar ID/OOD pairs.

Key Insights and Ideas

  • The Power of Prompt Decoupling: Using the same prompt template for both global image tokens and local patch tokens introduces a domain gap. Separating them allows local prompts to specialize in fine-grained textures and regional boundaries.
  • Sensing Outliers via Space Translation: Simple random cropping, when guided by a frozen global model, is surprisingly effective at isolating background noise, context, and non-class features to simulate local outlier knowledge.
  • No Trade-off Between Safety and Accuracy: Traditionally, tuning a model to aggressively reject OOD samples can compress the feature space and harm standard classification accuracy. Local-Prompt avoids this, actually improving ID classification accuracy by refining the model's understanding of local class-specific features.

Key Results

  • State-of-the-Art OOD Rejection: In 4-shot tuning on ImageNet-1k, combining Local-Prompt with LoCoOp reduced the average False Positive Rate at 95% recall (FPR95) by 5.17% compared to the previous best method. Remarkably, its 4-shot performance outperformed the 16-shot performance of prior methods.
  • Conquering Near-OOD Tasks: On the difficult ImageNet-10 vs. ImageNet-20 task (where categories are highly similar), Local-Prompt slashed the average FPR95 from 11.60% (LoCoOp) down to 5.05%.
  • Simultaneous Accuracy Boost: Local-Prompt achieved a 1.02% improvement in ID classification accuracy under the 4-shot setting and a 2.38% boost in the 16-shot setting, proving that local feature refinement aids standard classification.

Limitations and Future Work

  • Training Time Overhead: The negative augmentation step requires processing multiple random crops per image, which increases computational overhead during training. However, the authors note it is still highly practical, requiring only about 4 hours for a 4-shot training run on a single NVIDIA A6000 GPU.
  • Frozen Global Constraints: In this work, global prompts are kept strictly frozen during the training of local prompts. Jointly optimizing both in a unified, end-to-end framework remains an open challenge.
  • Expansion Beyond Classification: The current iteration is tailored for image classification. Extending local prompts to dense open-world vision tasks, such as object detection and semantic segmentation, is a promising direction for future research.

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 Local-Prompt, 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. Code is released at https://github.com/AuroraZengfh/Local-Prompt.
BibTeX
@inproceedings{zeng2025local,
  author = {Fanhu Zeng and Zhen Cheng and Fei Zhu and Hongxin Wei and Xu-Yao Zhang},
  title = {{Local-Prompt: Extensible Local Prompts for Few-Shot Out-of-Distribution Detection}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=Ew3VifXaxZ},
}
Figure