Papers › CLIPN for Zero-Shot OOD Detection: Teaching CLIP to Say No

CLIPN for Zero-Shot OOD Detection: Teaching CLIP to Say No

23 Aug 2023ICCV 2023 1arXiv:2308.12213archive 2025-07-28

Hualiang Wang, Yi Li, Huifeng Yao, Xiaomeng Li

Out-of-distribution (OOD) detection refers to training the model on an in-distribution (ID) dataset to classify whether the input images come from unknown classes. Considerable effort has been invested in designing various OOD detection methods based on either convolutional neural networks or transformers. However, zero-shot OOD detection methods driven by CLIP, which only require class names for ID, have received less attention. This paper presents a novel method, namely CLIP saying no (CLIPN), which empowers the logic of saying no within CLIP. Our key motivation is to equip CLIP with the capability of distinguishing OOD and ID samples using positive-semantic prompts and negation-semantic prompts. Specifically, we design a novel learnable no prompt and a no text encoder to capture negation semantics within images. Subsequently, we introduce two loss functions: the image-text binary-opposite loss and the text semantic-opposite loss, which we use to teach CLIPN to associate images with no prompts, thereby enabling it to identify unknown samples. Furthermore, we propose two threshold-free inference algorithms to perform OOD detection by utilizing negation semantics from no prompts and the text encoder. Experimental results on 9 benchmark datasets (3 ID datasets and 6 OOD datasets) for the OOD detection task demonstrate that CLIPN, based on ViT-B-16, outperforms 7 well-used algorithms by at least 2.34% and 11.64% in terms of AUROC and FPR95 for zero-shot OOD detection on ImageNet-1K. Our CLIPN can serve as a solid foundation for effectively leveraging CLIP in downstream OOD tasks. The code is available on https://github.com/xmed-lab/CLIPN.

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="2308.12213")

Code

Syntology Ran 10 of 16 code samples harvested from 1 repository linked to this paper; 6 have no recorded run. Of those that ran: 2 ran · our draft was wrong; 8 ran with no contract checked.

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

xmed-lab/clipn officialmentioned in papermentioned on GitHubpytorchMIT 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

16 samples harvested; 10 ran; 0 honoured the contract we drafted; 6 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.

2ran · our draft was wrong
8ran
6unverified

Licence: 0 of the 16 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 xmed-lab/CLIPN. “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.

ClipLoss xmed-lab/CLIPN/hand-crafted/src/open_clip/loss.py official repository ran MIT (permissive) · 398dd84d8c1a0c99 · report
cosine_lr xmed-lab/clipn/src/tuning_util.py official repository ran MIT (permissive) · 2d5d7a12d8de02b7 · report
energy_score xmed-lab/clipn/src/zero_shot_infer.py official repository ran MIT (permissive) · 77aa71bc99c32b88 · report
energy_score xmed-lab/clipn/hand-crafted/src/zero_shot_infer.py official repository ran MIT (permissive) · 570302e9d15c6b9b · report
load_state_dict xmed-lab/clipn/src/open_clip/factory.py official repository ran MIT (permissive) · 5e42380894ae9205 · report
load_state_dict_local xmed-lab/clipn/src/open_clip/factory.py official repository ran MIT (permissive) · 72166ecea4b59f55 · report
max_logit_score xmed-lab/clipn/src/zero_shot_infer.py official repository ran MIT (permissive) · 6ae44ac0f19069aa · report
maybe_dictionarize xmed-lab/clipn/src/tuning_util.py official repository ran · our draft was wrong MIT (permissive) · b1e9e0d3d7d7e615 · report
msp_score xmed-lab/clipn/src/zero_shot_infer.py official repository ran MIT (permissive) · be2496a325c68b28 · report
trace_model xmed-lab/clipn/src/open_clip/model.py official repository ran · our draft was wrong MIT (permissive) · 8e95157106d1df8c · report
accuracy xmed-lab/clipn/src/tuning_util.py official repository unverified MIT (permissive) · aafcff3ad1ccef6e · report
build_model_from_openai_state_dict xmed-lab/clipn/src/open_clip/model.py official repository unverified MIT (permissive) · 630cd10269e63c8c · report
gather_features xmed-lab/CLIPN/hand-crafted/src/open_clip/loss.py official repository unverified MIT (permissive) · 61c4ca21dc698a56 · report
load_checkpoint xmed-lab/clipn/src/open_clip/factory.py official repository unverified MIT (permissive) · 69e67ef52fe6fde8 · report
load_openai_model xmed-lab/clipn/src/open_clip/openai.py official repository unverified MIT (permissive) · ce3d74d26643c4c1 · report
torch_load xmed-lab/clipn/src/classification.py official repository unverified MIT (permissive) · 2235e9caabb77a27 · report

Tasks

NegationOut of Distribution (OOD) DetectionOut-of-Distribution Detection

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

CLIP

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