Negative Label Guided OOD Detection with Pretrained Vision-Language Models

2403.20078

YC

0

Reddit

0

Published 4/1/2024 by Xue Jiang, Feng Liu, Zhen Fang, Hong Chen, Tongliang Liu, Feng Zheng, Bo Han
Negative Label Guided OOD Detection with Pretrained Vision-Language Models

Abstract

Out-of-distribution (OOD) detection aims at identifying samples from unknown classes, playing a crucial role in trustworthy models against errors on unexpected inputs. Extensive research has been dedicated to exploring OOD detection in the vision modality. Vision-language models (VLMs) can leverage both textual and visual information for various multi-modal applications, whereas few OOD detection methods take into account information from the text modality. In this paper, we propose a novel post hoc OOD detection method, called NegLabel, which takes a vast number of negative labels from extensive corpus databases. We design a novel scheme for the OOD score collaborated with negative labels. Theoretical analysis helps to understand the mechanism of negative labels. Extensive experiments demonstrate that our method NegLabel achieves state-of-the-art performance on various OOD detection benchmarks and generalizes well on multiple VLM architectures. Furthermore, our method NegLabel exhibits remarkable robustness against diverse domain shifts. The codes are available at https://github.com/tmlr-group/NegLabel.

Create account to get full access

or

If you already have an account, we'll log you in

Introduction

The provided text discusses a critical challenge in open-world machine learning scenarios - handling data from unknown classes, referred to as out-of-distribution (OOD) data. This issue can lead to models exhibiting overconfidence and causing severe errors or security risks, particularly in critical applications.

Traditional visual OOD detection methods rely solely on image information, ignoring the rich textual information carried by labels. Vision-language models (VLMs) can leverage multimodal information, which is also beneficial for OOD detection. Some recently proposed methods, like ZOC and MCM, attempt to design dedicated OOD detectors for VLMs, but they have limitations.

The proposed method, NegLabel, aims to leverage the knowledge carried by VLMs for OOD detection more effectively. It introduces a large number of negative labels to enable the model to distinguish OOD samples in a more nuanced and detailed manner. The NegMining algorithm is used to select high-quality negative labels based on their semantic divergence from in-distribution (ID) labels, enhancing the separability between ID and OOD samples.

Additionally, a novel scheme for the OOD score is introduced, which combines the knowledge from the ID and negative label space to better leverage the VLMs' text comprehension capabilities. Extensive experiments demonstrate that NegLabel achieves state-of-the-art performance on various zero-shot OOD detection benchmarks and exhibits remarkable robustness against diverse domain shifts.

Figure 1: Overview of NegLabel. The image encoder extracts input images into image embeddings 𝒉𝒉\bm{\mathit{h}}bold_italic_h. The text encoder extracts ID and negative labels into text embeddings 𝒆𝒆\bm{\mathit{e}}bold_italic_e. All encoders are frozen in the inference time. The negative labels are selected by NegMining (see SectionΒ 3.1) from a large-scale corpus. The image-text similarities are quantified through 𝒉⋅𝒆⋅𝒉𝒆\bm{\mathit{h}}\cdot\bm{\mathit{e}}bold_italic_h β‹… bold_italic_e, represented by purple blocks (darker shades indicating higher similarity). The right part illustrates that ID images tend to produce lower similarities with neagative labels than OOD images. Our NegLabel score (see SectionΒ 3.2) fuses the similarities of image-ID labels (green) and image-negative labels (blue).

Figure 1: Overview of NegLabel. The image encoder extracts input images into image embeddings 𝒉𝒉\bm{\mathit{h}}bold_italic_h. The text encoder extracts ID and negative labels into text embeddings 𝒆𝒆\bm{\mathit{e}}bold_italic_e. All encoders are frozen in the inference time. The negative labels are selected by NegMining (see SectionΒ 3.1) from a large-scale corpus. The image-text similarities are quantified through 𝒉⋅𝒆⋅𝒉𝒆\bm{\mathit{h}}\cdot\bm{\mathit{e}}bold_italic_h β‹… bold_italic_e, represented by purple blocks (darker shades indicating higher similarity). The right part illustrates that ID images tend to produce lower similarities with neagative labels than OOD images. Our NegLabel score (see SectionΒ 3.2) fuses the similarities of image-ID labels (green) and image-negative labels (blue).

Preliminaries

Summary:

The paper discusses zero-shot classification using CLIP-like models. The image space is denoted as 𝒳 and the ID label space is denoted as 𝒴, which is a set of words representing the classes. The ID and OOD feature distributions are represented as β„™Xin and β„™Xout, respectively.

The CLIP-like model extracts image features 𝒉 and text features 𝒆j for each label yj. Zero-shot classification is then performed by predicting the label with the highest cosine similarity between the image and text features.

The paper also discusses out-of-distribution (OOD) detection. A score function S(𝐱) is used to determine if an input 𝐱 is ID or OOD based on a threshold Ξ³. If S(𝐱) β‰₯ Ξ³, then 𝐱 is classified as ID, otherwise it is OOD.

The primary objective is to identify OOD samples without sacrificing ID classification accuracy using the pre-trained CLIP-like model.

Methodology

The text discusses the challenges of zero-shot image classification, where models are trained on large datasets to gain a broader understanding of the training data. However, the limited label space of in-distribution (ID) samples can weaken the model's ability to detect out-of-distribution (OOD) samples, as the differences between ID and OOD samples may not be fully captured.

The central idea of the "NegLabel" approach is to expand the label space of the zero-shot classifier, leveraging the scalability of the model's label space and the text comprehension capabilities of Vision-Language Models (VLMs) to improve zero-shot OOD detection.

Figure 2: Illustration of NegMining. The algorithm selects negative labels with larger distances (lower similarities) from the ID labels. Darker blue squares represent the higher priorities to be picked. Dashed squares represent negative labels that are impossible to be selected.

Figure 2: Illustration of NegMining. The algorithm selects negative labels with larger distances (lower similarities) from the ID labels. Darker blue squares represent the higher priorities to be picked. Dashed squares represent negative labels that are impossible to be selected.

The provided section discusses the selection of negative labels and how they can be used for out-of-distribution (OOD) detection. Key points:

  • Negative labels are labels that have lower affinities with in-distribution (ID) images compared to OOD images. They can provide hints for detecting OOD samples.

  • The NegMining algorithm is proposed to select suitable negative labels by calculating the negative cosine similarities between candidate labels and the whole ID label space.

  • The NegLabel score combines the similarity of the sample with ID labels and negative labels to detect OOD samples. It is designed to be positively correlated with ID label similarity and negatively correlated with negative label similarity.

  • A grouping strategy is introduced to divide the negative labels into multiple groups and calculate the NegLabel score for each group, then take the average. This helps balance the trade-off between the additional knowledge from negative labels and the risk of false positives.

  • The paper provides theoretical analysis from the perspective of multi-label classification, showing that negative labels can improve the separability between ID and OOD samples by increasing the difference in the probabilities that ID and OOD samples are positively classified with respect to the negative labels.

Experiments

This section describes the experimental setup and results for the proposed NegLabel method for zero-shot out-of-distribution (OOD) detection. The key points are:

Datasets and benchmarks: The method is evaluated on the ImageNet-1k OOD benchmark, which uses ImageNet-1k as in-distribution (ID) data and several other datasets as OOD data. The authors also use smaller subsets of ImageNet-1k as ID data, following the settings of the MCM method.

Implementation details: NegLabel is implemented on various vision-language model (VLM) architectures, including CLIP, ALIGN, GroupViT, and AltCLIP. The authors use default hyperparameter settings, such as the number of negative labels, temperature, and grouping strategy.

Computational cost: NegLabel adds a small computational overhead of less than 1% to the model's forward latency for OOD detection.

Experimental results: NegLabel achieves state-of-the-art performance on the ImageNet-1k OOD benchmark, outperforming existing methods like MCM. It also shows strong performance on semantically hard OOD detection tasks and robustness to domain shifts.

Ablation studies: The authors analyze the impact of different components of NegLabel, such as negative label selection and grouping strategy, as well as its performance on various VLM architectures.

Related works

The text summarizes the two major categories of visual Out-of-Distribution (OOD) detection methods: training-time regularization and post hoc methods. Training-time regularization methods assume access to some OOD data during model training, and use techniques like constructing additional branches, decomposing priors, contrastive learning, and logit normalization to improve OOD detection. Post hoc methods do not modify the model parameters, and instead focus on designing effective OOD scores using approaches like maximum softmax probability, energy functions, Mahalanobis distance, and gradient-based methods.

The text then discusses the concept of zero-shot outlier exposure, where OOD labels are used as candidate labels to complete the outlier exposure task. Recent zero-shot OOD detection methods like ZOC, MCM, and NPOS have leveraged this idea, with MCM being the earliest post hoc zero-shot OOD detection method that uses temperature scaling and maximum softmax value as the OOD score. The summarized method, NegLabel, is also a post hoc zero-shot OOD detection method that leverages CLIP's zero-shot capabilities for text to design OOD scores.

Conclusion

The paper proposes a post hoc zero-shot detection framework called NegLabel. The approach incorporates a large set of negative labels that are semantically different from the ID labels. It determines whether an image belongs to OOD by comparing its affinity towards ID and negative labels. The NegMining algorithm is proposed to select high-quality negative labels to enhance the distinction between ID and OOD samples. The method also introduces a new scheme for the zero-shot OOD score that leverages the knowledge of VLMs.

Experimental results show the proposed method achieves state-of-the-art performance on multiple zero-shot OOD detection benchmarks and generalizes well on multiple VLM architectures. NegLabel also presents remarkable robustness against diverse domain shifts.

Acknowledgments

The research described in this work was funded by several grants from the National Natural Science Foundation of China, the Guangdong Basic and Applied Basic Research Foundation, the Hong Kong Baptist University Faculty Niche Research Areas program, and the Hong Kong Baptist University CSD Departmental Incentive Scheme. Additional funding was provided by the Australian Research Council and the NSF&CSIRO Responsible AI program.

Appendix A Further Experiments

The paper provides detailed information about the experiment setting and implementation of the proposed NegLabel method for out-of-distribution (OOD) detection. Key points:

  • NegLabel is implemented in Python 3.9 and PyTorch 1.9, running on a single NVIDIA GeForce RTX 3090Ti GPU. It introduces minimal computational overhead, less than 1% network forward latency.

  • NegLabel is evaluated on various vision-language model (VLM) architectures including CLIP, ALIGN, GroupViT, and AltCLIP. CLIP-B/16 is used as the default for zero-shot OOD detection.

  • The NegMining algorithm is used to select 10,000 negative labels from the WordNet corpus, with a threshold Ξ·=0.05. The NegLabel score uses the sum-softmax form with temperature Ο„=0.01.

  • Extensive ablation studies are conducted to analyze the impact of the NegMining algorithm, NegLabel score design, prompt engineering, and grouping strategy. The results demonstrate the effectiveness and robustness of the proposed approach.

  • NegLabel achieves superior zero-shot OOD detection performance compared to prior methods like MCM, especially under domain shift scenarios. It also shows strong generalization across different ID datasets.

The paper provides a thorough technical investigation of the proposed NegLabel method and its key components through detailed experimentation and analysis.

Appendix B Further Analysis

The paper analyzes the performance differences between the iNaturalist dataset and other OOD datasets used for evaluating out-of-distribution (OOD) detection. The authors find that iNaturalist has the largest category differences compared to ImageNet, the in-distribution dataset, as it contains mainly natural plant images rather than the animal and food images in ImageNet. This makes the introduction of negative labels particularly effective for improving OOD detection performance on iNaturalist.

The paper also proposes an upgraded version of the ZOC method, called NegLabel, which uses a multimodal model like LLaVA and ChatGPT to extract candidate OOD labels, rather than relying on a captioner trained on a limited dataset like COCO. NegLabel is shown to significantly outperform the original ZOC method on the ImageNet-1k benchmark.

Furthermore, the paper provides a more theoretical analysis, showing that the Poisson binomial distribution of the positive count can be approximated by a Normal distribution using the Lyapunov central limit theorem. This supports the effectiveness of the proposed NegLabel method, which does not require additional complex pretraining or data, and can generalize well to different datasets and models.

Appendix C Algorithms

The paper presents detailed implementations of several algorithms. The key idea behind the NegMining algorithm is to first calculate the 100Ξ·-th percentile nearest distance between a negative candidate and the entire set of ID labels. Then, it selects the top-k candidates with the greatest distances from the ID labels as the negative labels. This ensures a substantial margin between the negative labels and the ID labels. The paper also provides the formulations for the NegLabel score in a sum-softmax form (Algorithm 3) and the NegLabel score with a grouping strategy (Algorithm 4).



This summary was produced with help from an AI and may contain inaccuracies - check out the links to read the original source documents!

Related Papers

Envisioning Outlier Exposure by Large Language Models for Out-of-Distribution Detection

Envisioning Outlier Exposure by Large Language Models for Out-of-Distribution Detection

Chentao Cao, Zhun Zhong, Zhanke Zhou, Yang Liu, Tongliang Liu, Bo Han

YC

0

Reddit

0

Detecting out-of-distribution (OOD) samples is essential when deploying machine learning models in open-world scenarios. Zero-shot OOD detection, requiring no training on in-distribution (ID) data, has been possible with the advent of vision-language models like CLIP. Existing methods build a text-based classifier with only closed-set labels. However, this largely restricts the inherent capability of CLIP to recognize samples from large and open label space. In this paper, we propose to tackle this constraint by leveraging the expert knowledge and reasoning capability of large language models (LLM) to Envision potential Outlier Exposure, termed EOE, without access to any actual OOD data. Owing to better adaptation to open-world scenarios, EOE can be generalized to different tasks, including far, near, and fine-grained OOD detection. Technically, we design (1) LLM prompts based on visual similarity to generate potential outlier class labels specialized for OOD detection, as well as (2) a new score function based on potential outlier penalty to distinguish hard OOD samples effectively. Empirically, EOE achieves state-of-the-art performance across different OOD tasks and can be effectively scaled to the ImageNet-1K dataset. The code is publicly available at: https://github.com/tmlr-group/EOE.

Read more

6/4/2024

Learning Transferable Negative Prompts for Out-of-Distribution Detection

Learning Transferable Negative Prompts for Out-of-Distribution Detection

Tianqi Li, Guansong Pang, Xiao Bai, Wenjun Miao, Jin Zheng

YC

0

Reddit

0

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.

Read more

4/5/2024

Zero-Shot Out-of-Distribution Detection with Outlier Label Exposure

Zero-Shot Out-of-Distribution Detection with Outlier Label Exposure

Choubo Ding, Guansong Pang

YC

0

Reddit

0

As vision-language models like CLIP are widely applied to zero-shot tasks and gain remarkable performance on in-distribution (ID) data, detecting and rejecting out-of-distribution (OOD) inputs in the zero-shot setting have become crucial for ensuring the safety of using such models on the fly. Most existing zero-shot OOD detectors rely on ID class label-based prompts to guide CLIP in classifying ID images and rejecting OOD images. In this work we instead propose to leverage a large set of diverse auxiliary outlier class labels as pseudo OOD class text prompts to CLIP for enhancing zero-shot OOD detection, an approach we called Outlier Label Exposure (OLE). The key intuition is that ID images are expected to have lower similarity to these outlier class prompts than OOD images. One issue is that raw class labels often include noise labels, e.g., synonyms of ID labels, rendering raw OLE-based detection ineffective. To address this issue, we introduce an outlier prototype learning module that utilizes the prompt embeddings of the outlier labels to learn a small set of pivotal outlier prototypes for an embedding similarity-based OOD scoring. Additionally, the outlier classes and their prototypes can be loosely coupled with the ID classes, leading to an inseparable decision region between them. Thus, we also introduce an outlier label generation module that synthesizes our outlier prototypes and ID class embeddings to generate in-between outlier prototypes to further calibrate the detection in OLE. Despite its simplicity, extensive experiments show that OLE substantially improves detection performance and achieves new state-of-the-art performance in large-scale OOD and hard OOD detection benchmarks.

Read more

6/4/2024

VI-OOD: A Unified Representation Learning Framework for Textual Out-of-distribution Detection

VI-OOD: A Unified Representation Learning Framework for Textual Out-of-distribution Detection

Li-Ming Zhan, Bo Liu, Xiao-Ming Wu

YC

0

Reddit

0

Out-of-distribution (OOD) detection plays a crucial role in ensuring the safety and reliability of deep neural networks in various applications. While there has been a growing focus on OOD detection in visual data, the field of textual OOD detection has received less attention. Only a few attempts have been made to directly apply general OOD detection methods to natural language processing (NLP) tasks, without adequately considering the characteristics of textual data. In this paper, we delve into textual OOD detection with Transformers. We first identify a key problem prevalent in existing OOD detection methods: the biased representation learned through the maximization of the conditional likelihood $p(ymid x)$ can potentially result in subpar performance. We then propose a novel variational inference framework for OOD detection (VI-OOD), which maximizes the likelihood of the joint distribution $p(x, y)$ instead of $p(ymid x)$. VI-OOD is tailored for textual OOD detection by efficiently exploiting the representations of pre-trained Transformers. Through comprehensive experiments on various text classification tasks, VI-OOD demonstrates its effectiveness and wide applicability. Our code has been released at url{https://github.com/liam0949/LLM-OOD}.

Read more

4/10/2024