Papers › PromptAD: Learning Prompts with only Normal Samples for Few-Shot Anomaly Detection

PromptAD: Learning Prompts with only Normal Samples for Few-Shot Anomaly Detection

8 Apr 2024CVPR 2024 1arXiv:2404.05231archive 2025-07-28

Xiaofan Li, Zhizhong Zhang, Xin Tan, Chengwei Chen, Yanyun Qu, Yuan Xie, Lizhuang Ma

The vision-language model has brought great improvement to few-shot industrial anomaly detection, which usually needs to design of hundreds of prompts through prompt engineering. For automated scenarios, we first use conventional prompt learning with many-class paradigm as the baseline to automatically learn prompts but found that it can not work well in one-class anomaly detection. To address the above problem, this paper proposes a one-class prompt learning method for few-shot anomaly detection, termed PromptAD. First, we propose semantic concatenation which can transpose normal prompts into anomaly prompts by concatenating normal prompts with anomaly suffixes, thus constructing a large number of negative samples used to guide prompt learning in one-class setting. Furthermore, to mitigate the training challenge caused by the absence of anomaly images, we introduce the concept of explicit anomaly margin, which is used to explicitly control the margin between normal prompt features and anomaly prompt features through a hyper-parameter. For image-level/pixel-level anomaly detection, PromptAD achieves first place in 11/12 few-shot settings on MVTec and VisA.

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

Code

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

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

funz-0/promptad officialmentioned in papermentioned on GitHubpytorchUnlicense 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; 4 ran; 0 honoured the contract we drafted; 12 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 · violated contract
2ran · our draft was wrong
1ran
12unverified

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 FuNz-0/PromptAD. “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.

_convert_to_rgb FuNz-0/PromptAD/PromptAD/model.py official repository ran · our draft was wrong Unlicense (permissive) · 4d42af1bb1e8a623 · report
convert_to_custom_text_state_dict funz-0/promptad/PromptAD/CLIPAD/model.py official repository ran · violated contract Unlicense (permissive) · f19962ebb134b3d7 · report
get_cast_dtype funz-0/promptad/PromptAD/CLIPAD/model.py official repository ran · our draft was wrong Unlicense (permissive) · dcd422d66b0581d8 · report
load_state_dict funz-0/promptad/PromptAD/CLIPAD/factory.py official repository ran Unlicense (permissive) · 4b3a4d17e1df3140 · report
PromptAD FuNz-0/PromptAD/PromptAD/model.py official repository unverified Unlicense (permissive) · 1f60e2ee2a81490c · report
PromptLearner FuNz-0/PromptAD/PromptAD/model.py official repository unverified Unlicense (permissive) · a04cfa7dc81328f3 · report
build_model_from_openai_state_dict funz-0/promptad/PromptAD/CLIPAD/model.py official repository unverified Unlicense (permissive) · c92f832f94b5a1c1 · report
gather_features funz-0/promptad/PromptAD/CLIPAD/loss.py official repository unverified Unlicense (permissive) · ddcbd45e940484ee · report
get_model_config funz-0/promptad/PromptAD/CLIPAD/factory.py official repository unverified Unlicense (permissive) · 5c7cf820e99443ff · report
get_tokenizer funz-0/promptad/PromptAD/CLIPAD/factory.py official repository unverified Unlicense (permissive) · f34d8f34635af394 · report
list_pretrained funz-0/promptad/PromptAD/CLIPAD/pretrained.py official repository unverified Unlicense (permissive) · 7dbf4e7ea5607d08 · report
list_pretrained_models_by_tag funz-0/promptad/PromptAD/CLIPAD/pretrained.py official repository unverified Unlicense (permissive) · 68fec9113b65fcf3 · report
list_pretrained_tags_by_model funz-0/promptad/PromptAD/CLIPAD/pretrained.py official repository unverified Unlicense (permissive) · 7f5bb5f5599e5ad5 · report
load_openai_model funz-0/promptad/PromptAD/CLIPAD/openai.py official repository unverified Unlicense (permissive) · a1693b09a14a516f · report
prepare_inputs_for_generation funz-0/promptad/PromptAD/CLIPAD/coca_model.py official repository unverified Unlicense (permissive) · fb651d0a97fd4d3f · report
register_pooler funz-0/promptad/PromptAD/CLIPAD/hf_model.py official repository unverified Unlicense (permissive) · 2a377da4a76a2d44 · report

Tasks

Anomaly DetectionLanguage ModelingLanguage ModellingPrompt EngineeringPrompt Learning

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

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