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

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

2 Jun 2023NeurIPS 2023 11arXiv:2306.01293archive 2025-07-28

Atsuyuki Miyai, Qing Yu, Go Irie, Kiyoharu Aizawa

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.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2306.01293")

Code

Syntology Ran 5 of 12 code samples harvested from 1 repository linked to this paper; 7 have no recorded run. Of those that ran: 1 ran · honoured contract; 3 ran · our draft was wrong; 1 ran · fixture could not drive it.

By repository: official repository: 12 samples from 1 repository, 5 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

atsumiyai/locoop officialmentioned in papermentioned on GitHubpytorchMIT report
haiv-lab/ospcoop_imagenet-bg mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

12 samples harvested; 5 ran; 1 honoured the contract we drafted; 7 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
3ran · our draft was wrong
1ran · fixture could not drive it
7unverified

Licence: 0 of the 12 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from AtsuMiyai/LoCoOp. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

basic_clean AtsuMiyai/LoCoOp/clip_w_local/simple_tokenizer.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 98f385d847636a3e · report
fpr_and_fdr_at_recall AtsuMiyai/LoCoOp/utils/detection_util.py official repository ran · fixture could not drive it fingerprinted MIT (permissive) · 3853ecdb6fc74451 · report
get_pairs AtsuMiyai/LoCoOp/clip_w_local/simple_tokenizer.py official repository ran · our draft was wrong MIT (permissive) · d919ae32e5e4e616 · report
stable_cumsum AtsuMiyai/LoCoOp/utils/detection_util.py official repository ran · honoured contract fingerprinted MIT (permissive) · d4acb3120a027622 · report
whitespace_clean AtsuMiyai/LoCoOp/clip_w_local/simple_tokenizer.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 9542161e9640b858 · report
build_model AtsuMiyai/LoCoOp/clip_w_local/model.py official repository unverified MIT (permissive) · dbbf313e1d3a69ba · report
entropy_select_topk AtsuMiyai/LoCoOp/trainers/locoop.py official repository unverified MIT (permissive) · 65319c2dbd4ac5e8 · report
get_measures AtsuMiyai/LoCoOp/utils/detection_util.py official repository unverified MIT (permissive) · 24570af601666d85 · report
load AtsuMiyai/LoCoOp/clip_w_local/clip.py official repository unverified MIT (permissive) · fbf8c0143d9c48e3 · report
load_resize_image AtsuMiyai/LoCoOp/demo_visualization.py official repository unverified MIT (permissive) · f8757a034583434b · report
set_ood_loader_ImageNet AtsuMiyai/LoCoOp/utils/train_eval_util.py official repository unverified MIT (permissive) · eb7800d0c58c4a14 · report
set_val_loader AtsuMiyai/LoCoOp/utils/train_eval_util.py official repository unverified MIT (permissive) · eb2c2fac20121ca2 · report

Tasks

Out of Distribution (OOD) DetectionOut-of-Distribution DetectionPrompt Learning

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

CLIPCoOp

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections