NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Generalized Few-Shot Out-of-Distribution Detection

Bing Cao, Pinxuan Li, Bing Cao 0002, Changqing Zhang, Qinghua HuarXiv 2025 · DOI

Abstract

Few-shot out-of-distribution (OOD) detection is a critical task for deploying machine learning models in open-world environments where training data is scarce. Current methods often suffer from a generalization gap, overfitting to small training sets and losing the broad contextual knowledge necessary to identify anomalies. We introduce GOOD (Generalized Few-shot OOD Detection), a framework that leverages a pre-trained General Knowledge Model (GKM) to anchor the learning process. By balancing task-specific specificity with general world knowledge through a theoretical GS-balance bound and a Knowledge Dynamic Embedding (KDE) mechanism, GOOD achieves state-of-the-art performance across multiple challenging OOD benchmarks.

Introduction

Deep learning models frequently struggle to identify inputs that fall outside their training distribution. While Out-of-Distribution (OOD) detection aims to address this, "few-shot" scenarios—where only 1 to 16 examples per class are available—present a significant challenge. Models trained on such limited data tend to "memorize" specific patterns, leading to poor generalization in the open world. They become experts on a narrow slice of data but lose the "common sense" required to detect diverse OOD samples.

Methodology: The GOOD Framework

The core philosophy of the GOOD framework is that a model should not learn from few-shot data in isolation. Instead, it should be guided by a "teacher" with a robust understanding of the world.

1. General Knowledge Model (GKM)

GOOD utilizes a zero-shot CLIP model as an auxiliary guide. CLIP’s extensive pre-training on millions of image-text pairs provides a robust, general understanding of object distributions that serves as a stable reference point.

2. GS-Balance (Generality-Specificity Balance)

The authors provide a theoretical foundation for GOOD by proving that the generalization error of an OOD detector is bounded by two factors: Specificity (how well it fits the training data) and Generality (how well it aligns with a general knowledge model). This "GS-balance" ensures the model doesn't drift too far from broad world knowledge while adapting to specific tasks.

Overview of the GOOD framework and GS-balance theory.

3. Knowledge Dynamic Embedding (KDE)

The practical implementation of this theory is the Knowledge Dynamic Embedding (KDE) mechanism. It employs a metric called Generalized Belief (G-Belief), derived from the GKM's confidence score:

  • High Confidence: When the GKM is certain about a sample, the model is constrained to align closely with the GKM’s general knowledge.
  • Low Confidence: When the GKM is uncertain, the model is granted more flexibility to learn specific patterns from the few-shot data.

This is enforced via a Distribution Regularization Loss ($L_{reg}$), which minimizes the distance between the fine-tuned model's outputs and the GKM's outputs, modulated by the G-Belief score.

Experimental Evaluation

The GOOD framework was evaluated using ImageNet-1K as the In-Distribution (ID) dataset. Performance was tested against standard OOD benchmarks (iNaturalist, SUN, Places, Texture) and "Hard-OOD" benchmarks (SSB-hard, NINCO, OpenImage-O) which are semantically similar to the ID classes.

Key Results

GOOD demonstrates significant improvements over existing state-of-the-art methods like LoCoOp. On the ImageNet-1K 1-shot benchmark, the GL-MCM variant of GOOD achieved an average FPR95 of 31.22% and an AUROC of 92.02%, compared to LoCoOp's 34.57% FPR95.

Performance comparison on hard OOD benchmarks across different shot counts.

The framework is particularly effective in "Hard-OOD" categories. As shown in the results, GOOD maintains high performance on datasets like SSB-hard and NINCO, where other few-shot methods typically degrade. Importantly, these gains in OOD detection do not come at the cost of classification accuracy on known classes, which remains competitive at approximately 66.7% for 1-shot ImageNet-1K.

Conclusion

The GOOD framework addresses the fundamental overfitting problem in few-shot OOD detection by introducing a theoretically grounded balance between specificity and generality. By dynamically anchoring a few-shot model to a General Knowledge Model, GOOD ensures robust performance across diverse and challenging real-world scenarios. Future work may explore extending this approach to multi-modal settings and refining uncertainty quantification for even more reliable G-Belief scores.

Summary updated

BibTeX
@misc{cao2025generalized,
  author = {Bing Cao and Pinxuan Li and Bing Cao and Changqing Zhang and Qinghua Hu},
  title = {{Generalized Few-Shot Out-of-Distribution Detection}},
  year = {2025},
  eprint = {2508.05732},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.05732},
}
Figure