Dual-Adapter: Training-free Dual Adaptation for Few-shot Out-of-Distribution Detection

Xinyi Chen, Yaohui Li, Haoxing ChenarXiv 2024 · DOI

Abstract

Out-of-Distribution (OOD) detection is critical for the safe deployment of machine learning models, yet it remains challenging in few-shot scenarios where labeled data is scarce. Traditional fine-tuning methods often suffer from overfitting and high computational costs. We present Dual-Adapter, a training-free framework that leverages the pre-trained knowledge of CLIP for efficient few-shot OOD detection. By decomposing feature vectors into positive and negative channels and employing a dual-cache mechanism, Dual-Adapter achieves state-of-the-art performance without the need for backpropagation.

Introduction

In real-world applications, machine learning models frequently encounter inputs that do not belong to any of the classes seen during training. Identifying these "unknowns" is the goal of Out-of-Distribution (OOD) detection. In the few-shot setting, where only a handful of examples per category are available, the risk of overfitting is high. Existing approaches like prompt tuning (CoOp) or adapter-based fine-tuning (Tip-Adapter) often struggle to balance identifying known classes with rejecting unknown ones.

Dual-Adapter addresses these challenges by introducing a training-free dual adaptation strategy. It avoids the pitfalls of fine-tuning by using a cache-based approach and enhances OOD sensitivity by explicitly modeling what an image is not alongside what it is.

Methodology

The Dual-Adapter framework is built upon the CLIP model and consists of two primary components: channel-wise feature selection and a dual cache model.

Feature Selection: Positive vs. Negative Channels

A key insight of this work is that not all dimensions of a CLIP feature vector are equally informative for a specific task. The authors categorize channels based on their utility:

  • Positive Channels: These are dimensions with high inter-class variance and low inter-class similarity, representing the "signal" that distinguishes known categories.
  • Negative Channels: These dimensions represent background noise or features common across many classes, which can interfere with classification but are useful for identifying OOD samples.

The Dual Cache Model

Instead of training weights, Dual-Adapter constructs two parallel adapters using a cache of few-shot features:

  1. Positive Adapter: Operates on positive channels to predict the most likely in-distribution (ID) class.
  2. Negative Adapter: Operates on negative channels and utilizes negative text templates (e.g., "background of {class}") to capture features that characterize what the image is not.
The Dual-Adapter architecture illustrating the separation of positive and negative channels and the dual cache mechanism.

By combining the outputs of these two adapters through a "softmax + half" operation, the model can effectively suppress OOD samples that might otherwise receive high confidence scores from a standard classifier.

Experimental Setup

The performance of Dual-Adapter was evaluated using ImageNet-1K as the In-Distribution (ID) dataset. Four diverse datasets were used for Out-of-Distribution (OOD) testing: iNaturalist (fine-grained), SUN (scenes), Places (locations), and Texture (patterns). The model was tested in 1, 2, 4, 8, and 16-shot settings.

Results and Discussion

Dual-Adapter demonstrates significant improvements over existing few-shot methods like CoOp, LoCoOp, and Tip-Adapter.

Comparison of Dual-Adapter with baseline methods. (a) and (b) show the intuition for ID vs OOD detection. (c) and (d) show AUROC and FPR95 performance across different shot counts.

Performance Metrics

  • AUROC: Dual-Adapter achieved an average AUROC of 93.62%, consistently outperforming LoCoOp across all shot settings.
  • FPR95: The method significantly reduced the False Positive Rate at 95% True Positive Rate (FPR95) to 30.50%, a 3.48% improvement over the previous state-of-the-art.

Efficiency

Unlike methods that require hours of fine-tuning (e.g., LoCoOp), Dual-Adapter is training-free. It reaches peak performance in seconds by simply populating its cache from the provided few-shot examples. This makes it highly suitable for dynamic environments where new classes must be integrated quickly.

Conclusion

Dual-Adapter provides a robust and efficient solution for few-shot OOD detection. By leveraging the inherent structure of CLIP features and a dual-cache strategy, it avoids overfitting and eliminates training overhead. Future work may explore extending this dual adaptation logic to more complex tasks such as open-world object detection and segmentation.

Summary updated

Abstract

We study the problem of few-shot out-of-distribution (OOD) detection, which aims to detect OOD samples from unseen categories during inference time with only a few labeled in-domain (ID) samples. Existing methods mainly focus on training task-aware prompts for OOD detection. However, training on few-shot data may cause severe overfitting and textual prompts alone may not be enough for effective detection. To tackle these problems, we propose a prior-based Training-free Dual Adaptation method (Dual-Adapter) to detect OOD samples from both textual and visual perspectives. Specifically, Dual-Adapter first extracts the most significant channels as positive features and designates the remaining less relevant channels as negative features. Then, it constructs both a positive adapter and a negative adapter from a dual perspective, thereby better leveraging previously outlooked or interfering features in the training dataset. In this way, Dual-Adapter can inherit the advantages of CLIP not having to train, but also excels in distinguishing between ID and OOD samples. Extensive experimental results on four benchmark datasets demonstrate the superiority of Dual-Adapter.
BibTeX
@misc{chen2024dual,
  author = {Xinyi Chen and Yaohui Li and Haoxing Chen},
  title = {{Dual-Adapter: Training-free Dual Adaptation for Few-shot Out-of-Distribution Detection}},
  year = {2024},
  eprint = {2405.16146},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.16146},
}
Figure