LoCoOp: Few-Shot Out-of-Distribution Detection via Prompt Learning

Atsuyuki Miyai, Qing Yu, Go Irie, K. Aizawa
2/12/2026

No official code found. Best implementation: AtsuMiyai/LoCoOp (106 stars, MIT, last commit 2025-07-05).

Abstract

We present a novel vision-language prompt learning approach for few-shot out-of-distribution (OOD) detection. Few-shot OOD detection aims to detect OOD images from classes that are unseen during training using only a few labeled in-distribution (ID) images. While prompt learning methods such as CoOp have shown effectiveness and efficiency in few-shot ID classification, they still face limitations in OOD detection due to the potential presence of ID-irrelevant information in text embeddings. To address this issue, we introduce a new approach called Local regularized Context Optimization (LoCoOp), which performs OOD regularization that utilizes the portions of CLIP local features as OOD features during training. CLIP's local features have a lot of ID-irrelevant nuisances (e.g., backgrounds), and by learning to push them away from the ID class text embeddings, we can remove the nuisances in the ID class text embeddings and enhance the separation between ID and OOD. Experiments on the large-scale ImageNet OOD detection benchmarks demonstrate the superiority of our LoCoOp over zero-shot, fully supervised detection methods and prompt learning methods. Notably, even in a one-shot setting -- just one label per class, LoCoOp outperforms existing zero-shot and fully supervised detection methods. The code will be available via https://github.com/AtsuMiyai/LoCoOp.

View on arXivView PDF

Code Implementations(1)

AtsuMiyai/LoCoOpCommunity100%
MIT

[NeurIPS2023] LoCoOp: Few-Shot Out-of-Distribution Detection via Prompt Learning

1064Shell, PythonJun 2, 20231 years agoMIT

Similar Papers

Cite this paper

@article{miyai2026locoop,
  title  = {LoCoOp: Few-Shot Out-of-Distribution Detection via Prompt Learning},
  author = {Atsuyuki Miyai and Qing Yu and Go Irie and K. Aizawa},
  year   = {2026},
  eprint = {2306.01293},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/pdf/2306.01293},
  journal = {NEURIPS 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2306.01293.svg)](https://codeofpaper.com/paper/2306.01293)

Discussion