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

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

arXiv:2404.05231 · 2026-07-27 공개 · arXiv · PDF

vision-language anomaly-detection few-shot prompt-learning visa industrial one-class mvtec

Abstract

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. Code is available at https://github.com/FuNz-0/PromptAD.git

한국어 요약

한 줄 요약

PromptAD는 정상 샘플만을 사용해 few-shot 환경에서 이상 탐지를 수행하는 one-class prompt 학습 방법으로, MVTec 및 VisA 데이터셋에서 11/12 설정에서 1위 성능을 달성한다.

핵심 기여도

핵심 아이디어

기존 few-shot 이상 탐지 연구는 수백 개의 수동 프롬프트를 설계하는 prompt engineering에 의존했으나, PromptAD는 정상 샘플만을 사용해 프롬프트를 자동 학습하는 one-class prompt learning을 제안한다. 이는 기존 many-class prompt learning이 one-class 설정에서 잘 동작하지 않는 문제를 해결하기 위한 접근이다. 핵심 아이디어는 두 가지: 첫째, **Semantic Concatenation (SC)**를 통해 정상 프롬프트에 이상 접미사를 결합해 음성 샘플을 생성함으로써, 대규모 음성 샘플을 구성해 prompt learning을 유도한다. 둘째, **Explicit Anomaly Margin (EAM)**을 도입해 정상/이상 프롬프트 간 거리를 하이퍼파라미터로 명시적으로 제어함으로써, 대조 학습 없이도 충분한 마진을 유지하도록 한다. 이는 이상 샘플이 없는 환경에서 학습의 안정성을 높이는 핵심 기술이다.

기술적 접근법

주요 결과

의의 및 한계

PromptAD는 정상 샘플만을 사용하는 one-class 설정에서 few-shot 이상 탐지를 가능하게 하며, 기존 prompt engineering에 의존하는 방식을 자동화한 점에서 학술적·실용적 가치가 높다. 특히, SC와 EAM을 통해 대규모 음성 샘플을 생성하고, 마진을 명시적으로 제어함으로써, 기존 대비 훨씬 적은 프롬프트 개수로 뛰어난 성능을 달성했다는 점에서 혁신적이다. 그러나, 이상 샘플이 전혀 없는 환경에서 학습이 이루어지는 한계가 있으며, 이는 모델이 이상 정보를 완전히 학습하지 못할 가능성도 남긴다. 또한, 학습 가능한 선형 레이어와 prompt learning 간의 상호 간섭 문제도 일부 실험에서 드러났다.

실용적 활용

PromptAD는 제조업, 의료 영상 분석 등에서 적은 샘플로 신속한 이상 탐지 모델 학습이 필요한 산업에 적용 가능하다. 특히, 프롬프트 엔지니어링 없이도 자동 학습이 가능하므로, 자동화된 산업 검사 시스템 구축에 유용하다. 또한, MVTec 및 VisA와 유사한 구조를 가진 데이터셋에서도 즉시 적용 가능하다.