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 ranMethod as code

In Syntology View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.

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

For agents, on Syntology's MCP service (how to connect):

Code

Syntology 16 code samples harvested from 1 repository linked to this paper: 10 ran (of which 1 constructed an object rather than computing a result; 8 with no instrument failure: 0 honoured, 0 violated, 8 with no contract checked; 2 where Syntology's instrument failed) · 6 unverified. Where Syntology's instrument failed: 2 where our contract draft was wrong; failures of Syntology's instrument, not of the code.

By repository: official repository: 16 samples from 1 repository, 10 ran (8 with no instrument failure; 2 where Syntology's instrument failed). The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

Levels written between 2026-09-22 and 2026-09-24 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed.

xmed-lab/clipn officialmentioned in papermentioned on GitHubpytorchMITSyntology: 16 samples, 10 ran (2 instrument-failed) · 6 unverified 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 (of which 1 constructed an object rather than computing a result; 8 with no instrument failure: 0 honoured, 0 violated, 8 with no contract checked; 2 where Syntology's instrument failed) · 6 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page has not changed since , the first build that kept a record date for it; when this build read Syntology's graph is in the build record. That date is not when the samples ran.

2ran · our draft was wrong
8ran
6unverified

Licence: 2 of the 16 samples are pointer only, meaning Syntology does not serve that copy's text. For 2 of them, this paper's copy is under a permissive licence and cleared, but the stored copy of the same code that Syntology serves is not; the licence label's tooltip gives Syntology's recorded reason. 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. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.

Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (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 are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. 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 six 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; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. 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.

A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity. A census tag appears when Syntology's census ran implementations with that name on one shared input per bucket: it gives how many were compared, from how many papers, and how many distinct outputs they produced, and names this sample's bucket when this sample was one of them.

xmed-lab/clipn official repository 16 samples, 10 ran (2 instrument-failed) · 6 unverified
ClipLoss in 6 papers hand-crafted/src/open_clip/loss.py ran MIT (permissive) · 398dd84d8c1a0c99 · report fixture: returned ClipLoss · level recorded 2026-09-22
cosine_lr in 31 papers src/tuning_util.py ran MIT (permissive) here; the stored copy is pointer only · 2d5d7a12d8de02b7 · report fixture: signature optimizer:SGD/0/?, base_lrs:list/1/float, warmup_length:int/0/int, steps:int/0/int · returned function · level recorded 2026-09-24
energy_score src/zero_shot_infer.py ran MIT (permissive) · 77aa71bc99c32b88 · report fixture: signature logits:Tensor/2/float · returned ndarray · level recorded 2026-09-24
energy_score hand-crafted/src/zero_shot_infer.py ran MIT (permissive) · 570302e9d15c6b9b · report fixture: signature logits:Tensor/2/float, temperature:int/0/int · returned ndarray · level recorded 2026-09-24
load_state_dict in 114 papers src/open_clip/factory.py ran MIT (permissive) · 5e42380894ae9205 · report fixture: signature checkpoint_path:str/0/str, map_location:str/0/str · returned dict · level recorded 2026-09-24
load_state_dict_local src/open_clip/factory.py ran MIT (permissive) · 72166ecea4b59f55 · report fixture: signature checkpoint_path:str/0/str, map_location:str/0/str · returned dict · level recorded 2026-09-24
max_logit_score src/zero_shot_infer.py ran MIT (permissive) · 6ae44ac0f19069aa · report fixture: signature logits:Tensor/2/float · returned ndarray · level recorded 2026-09-24
maybe_dictionarize in 14 papers src/tuning_util.py ran · our draft was wrong MIT (permissive) · b1e9e0d3d7d7e615 · report fixture: signature batch:dict/0/? · returned dict · level recorded 2026-09-22
msp_score src/zero_shot_infer.py ran MIT (permissive) · be2496a325c68b28 · report fixture: signature logits:Tensor/2/float · returned ndarray · level recorded 2026-09-24
trace_model in 12 papers src/open_clip/model.py ran · our draft was wrong MIT (permissive) here; the stored copy is pointer only · 8e95157106d1df8c · report fixture: signature model:callable/0/?, batch_size:int/0/int, device:device/0/? · returned TopLevelTracedModule · level recorded 2026-09-22
build_model_from_openai_state_dict in 42 papers src/open_clip/model.py unverified MIT (permissive) · 630cd10269e63c8c · report
gather_features in 78 papers hand-crafted/src/open_clip/loss.py unverified MIT (permissive) · 61c4ca21dc698a56 · report
load_checkpoint in 277 papers src/open_clip/factory.py unverified MIT (permissive) · 69e67ef52fe6fde8 · report
load_openai_model in 16 papers src/open_clip/openai.py unverified MIT (permissive) · ce3d74d26643c4c1 · report
torch_load in 9 papers src/classification.py unverified MIT (permissive) · 2235e9caabb77a27 · report

Method as code Syntology

What Syntology's graph records as this paper's claimed method, lifted into code: each assembly names its bricks (functions and classes), each with its own role and its own verification level. An assembly is not a check that the code implements the method correctly or reproduces the paper's results. Levels are each brick's own verification level in Syntology's graph (level 0: no recorded run), listed brick by brick and never combined into one level; “ran” means the brick executed on a synthesized input, not that its output is correct, and the instrument figure counts failures of Syntology's instrument, not of the code. Where a model read the code against the paper's claim, each assembly's label verdict is one model's judgement, kept in this page's JSON twin; it is not calibrated, so no card prints it.

1 assembly on this paper: 1 harvested, 0 generated.

harvested Assembly for CLIPN (graph method: CLIPN). 2 bricks; individually on a fixture: 1 ran (of which 1 constructed an object rather than computing a result; 1 with no instrument failure: 0 honoured, 0 violated, 1 with no contract checked; 0 where Syntology's instrument failed) · 1 unverified; the one sample that ran constructed an object rather than computing a result. The assembly has not been run end-to-end.

  1. ClipLoss entry · level 1 · ran · 398dd84d8c1a0c99
  2. gather_features helper · level 0 · unverified · 61c4ca21dc698a56

Each brick ends with its code_sha256, Syntology's identity for that exact code; click one to copy the get_code call that returns it. For agents, on Syntology's MCP service: assembly(arxiv_id="2308.12213") returns these assemblies with each brick's role and wiring (how to connect).

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