Learning Transferable Negative Prompts for Out-of-Distribution Detection

Tianqi Li, Guansong Pang, Xiaolong Bai, Wenjun Miao, Jingyi Zheng
2/9/2026

No official code found. Best implementation: mala-lab/NegPrompt (62 stars, MIT, last commit 2024-04-08).

Abstract

Existing prompt learning methods have shown certain capabilities in Out-of-Distribution (OOD) detection, but the lack of OOD images in the target dataset in their training can lead to mismatches between OOD images and In-Distribution (ID) categories, resulting in a high false positive rate. To address this issue, we introduce a novel OOD detection method, named ‘NegPrompt’, to learn a set of negative prompts, each representing a negative connotation of a given class label, for delineating the boundaries between ID and OOD images. It learns such negative prompts with ID data only, without any reliance on external out-lier data. Further, current methods assume the availability of samples of all ID classes, rendering them ineffective in open-vocabulary learning scenarios where the inference stage can contain novel ID classes not present during training. In contrast, our learned negative prompts are transferable to novel class labels. Experiments on various ImageNet benchmarks show that NegPrompt surpasses state-of-the-art prompt-learning-based OOD detection methods and maintains a consistent lead in hard OOD detection in closed- and open-vocabulary classification scenarios. Code is available at https://github.com/mala-lab/negprompt.

View on arXivView PDF

Code Implementations(1)

mala-lab/NegPromptCommunity100%
MIT

The official implementation of CVPR 24' Paper "Learning Transferable Negative Prompts for Out-of-Distribution Detection"

627Python, Jupyter NotebookMar 15, 20242 years agoMIT
foundation-modelsout-of-distribution-detectionprompt-engineeringprompt-learningvision-language-model

Similar Papers

Cite this paper

@article{li2026learning,
  title  = {Learning Transferable Negative Prompts for Out-of-Distribution Detection},
  author = {Tianqi Li and Guansong Pang and Xiaolong Bai and Wenjun Miao and Jingyi Zheng},
  year   = {2026},
  eprint = {2404.03248},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/pdf/2404.03248},
  journal = {CVPR 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2404.03248.svg)](https://codeofpaper.com/paper/2404.03248)

Discussion