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 outlier 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.
翻译:现有的提示学习方法在分布外检测中已展现出一定能力,但其训练过程中缺乏目标数据集中的分布外图像,可能导致分布外图像与分布内类别之间的不匹配,从而产生较高的误报率。为解决这一问题,我们提出了一种新颖的分布外检测方法"NegPrompt",通过学习一组负向提示(每个提示代表给定类别标签的负面含义)来界定分布内与分布外图像的边界。该方法仅利用分布内数据学习负向提示,无需依赖任何外部异常数据。此外,现有方法假设所有分布内类别的样本均可获得,这使得它们在开放词汇学习场景中失效——在该场景下,推理阶段可能包含训练中未出现的新分布内类别。相比之下,我们学习的负向提示可迁移至新类别标签。在多个ImageNet基准上的实验表明,NegPrompt超越了基于提示学习的最先进分布外检测方法,并在封闭词汇和开放词汇分类场景的困难分布外检测中保持持续领先优势。代码已开源至 https://github.com/mala-lab/negprompt。