Prompt Optimization Meets Subspace Representation Learning for Few-shot Out-of-Distribution Detection

Faizul Rakib Sayem, Shahana Ibrahim · DOI

Abstract

This paper introduces SubCoOp, a novel framework designed to enhance Out-of-Distribution (OOD) detection in few-shot Vision-Language Models (VLMs) like CLIP. By treating learnable prompt vectors as a geometric basis for a low-dimensional subspace, SubCoOp effectively separates meaningful In-Distribution (ID) features from irrelevant noise. This approach achieves state-of-the-art performance by projecting ID features into the learned subspace while pushing "proxy OOD" features into the orthogonal null space, ensuring robust detection of unknown classes.

Introduction

Deep learning models are notoriously overconfident, often classifying images from unseen categories (OOD) as known classes (ID) with high certainty. This behavior poses a major safety concern for critical applications like autonomous driving or medical diagnosis. While Vision-Language Models (VLMs) have shown promise in "few-shot" OOD detection, existing prompt-tuning approaches often ignore the underlying geometry of visual features. By attempting to align every part of an image with a class label, these models inadvertently incorporate background clutter into ID representations, making it difficult to distinguish between known and unknown data at test time.

Methodology: Subspace Learning-based Context Optimization

The core innovation of SubCoOp is the utilization of learnable prompt vectors not merely as text inputs, but as a geometric basis ($W$) for a low-dimensional subspace. This allows the model to explicitly manage the representation space.

  1. Subspace Projection: The model defines an "ID subspace" spanned by the columns of the prompt matrix $W$.
  2. Geometry-Aware Regularization: Two new loss terms are introduced to enforce geometric constraints:
  3. $L_{Sub-ID}$: Minimizes the components of ID features that fall outside the prompt subspace, keeping them tightly packed.
  4. $L_{Sub-OOD}$: Minimizes the components of "proxy OOD" features (irrelevant image regions) that fall inside the prompt subspace, pushing noise into the "null space."
  5. Proxy OOD Selection: To simulate OOD data during training, the framework uses a ranking-based method to identify local image regions that do not align with the ground-truth class label.
The SubCoOp architecture: Local features are extracted and compared with text embeddings. The learnable prompts form a matrix $W$ that spans a subspace, allowing the model to separate ID-relevant regions from ID-irrelevant noise.

Experimental Results

The authors evaluated SubCoOp using ImageNet-1k and ImageNet-100 as In-Distribution data, tested against standard OOD benchmarks including iNaturalist, SUN, Places365, and Textures. In few-shot scenarios (1 to 16 samples per class), SubCoOp consistently outperformed existing state-of-the-art (SOTA) methods like LoCoOp and SCT.

On ImageNet-1k (16-shot), SubCoOp achieved an average FPR95 of 25.47% (lower is better) and an AUROC of 94.07%. This represents a significant 2.76% reduction in FPR95 compared to the previous best method, SCT. Furthermore, the method maintained high ID classification accuracy (approx. 70.57% on ImageNet-1k), demonstrating that OOD robustness does not require a trade-off with standard performance.

Performance comparison across multiple OOD benchmarks. SubCoOp (orange) consistently achieves the lowest FPR95 compared to CoOp, LoCoOp, and SCT, indicating superior OOD detection capability.

Conclusion

SubCoOp demonstrates that the geometric structure of CLIP’s feature embeddings is a powerful tool for OOD detection. By treating prompts as a linear basis, the model learns to ignore features that do not contribute to class identity—the very features that often cause OOD overconfidence. While future work may explore non-linear manifold learning, SubCoOp currently provides a highly efficient and effective solution for robust few-shot VLM deployment.

Summary updated

BibTeX
@inproceedings{sayem2025prompt,
  author = {Faizul Rakib Sayem and Shahana Ibrahim},
  title = {{Prompt Optimization Meets Subspace Representation Learning for Few-shot Out-of-Distribution Detection}},
  booktitle = {Prompt Optimization @ KDD},
  year = {2025},
  url = {https://openreview.net/forum?id=mtxDl8S7vh},
}
Figure