arXiv:2608.29467cs.CVAug 2026

Manuscript Offprint

arXiv:2608.29467

Co-Evolutionary Prompt Optimization with Cross-Category Transfer for Zero-Shot Anomaly Detection

Sisi Zhu, Changwei Yu, Renshuai Tao, Zhenliang Ni

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Zero-shot anomaly detection (ZSAD) has gained significant attention for its practical value in industrial inspection. Recently, CLIP-based approaches have been widely adopted in ZSAD due to their strong vision-language generalization capabilities. However, existing methods commonly employ continuous prompt embeddings for prompt optimization and encode semantics in latent vectors, which lack interpretability and scalability. To this end, we propose CoEvoAD, a co-evolutionary framework for discrete prompt selection. CoEvoAD performs prompt search in the discrete natural-language space using an evolutionary algorithm. Candidate prompts are iteratively generated, evaluated, and selected throughout population evolution, thus preserving the interpretability and composability of natural language. Furthermore, we introduce a Cross-Category Transfer Objective (CCTO), which treats held-out source categories as proxies for unseen categories and scores prompt rules based on their estimated cross-category transferability, effectively improving cross-category generalization. Extensive experiments are conducted to validate the effectiveness of CoEvoAD, and the results show that it achieves state-of-the-art performance across multiple anomaly detection datasets. The code is available at https://github.com/rstao-bjtu/CoEvoAD.

1 Introduction

Industrial anomaly detection aims to identify defective samples and localize anomalous regions in visual inspection images. In practice, deploying a detector to a new product category often requires normal images from the target category and, in supervised settings, defect labels or pixel-level masks, followed by category-specific retraining or calibration. This requirement is especially costly when

Figure

Figure 1: Prompt regimes for ZSAD: handcrafted templates, continuous prompts, and CoEvoAD.

production lines change frequently and real defects are scarce. Built on CLIP (Radford et al., 2021), recent zero-shot anomaly detection (ZSAD) methods reduce this dependency by comparing visual features with normal and abnormal text prompts, enabling detection in unseen categories (Jeong et al., 2023; Zhou et al., 2024; Qu et al., 2025). In this setting, prompt selection becomes central to specifying transferable normal–abnormal rules. We study how interpretable prompt rules can be automatically generated and selected for cross-category transfer, as illustrated in Figure 1.

Despite recent progress in CLIP-based ZSAD, prompt construction and selection still face two limitations for cross-category transfer. First, existing prompt construction still struggles to jointly achieve prompt interpretability and scalability. Handcrafted rules remain explicit but fixed after design, while prompt-learning methods such as AnomalyCLIP (Zhou et al., 2024), AdaCLIP (Cao et al., 2024), and Bayes-PFL (Qu et al., 2025) improve adaptation by optimizing learnable prompt embeddings or distributions over them. Yet the learned prompt semantics are encoded in uninterpretable continuous representations rather than ex-

∗^{*} Equal contribution.

†^{\dagger} Corresponding author.

explicit natural-language rules, limiting prompt interpretability and rule-level reuse. Second, source-category performance alone does not provide reliable evidence of cross-category generalization. A prompt may perform well on the source categories used for selection yet fail on unseen categories, because its transferability across categories has not been evaluated. In summary, current prompt-selection methods in ZSAD still fail to achieve both interpretability and scalability. Moreover, candidate prompt selection relies solely on performance within the optimization categories, lacking cross-category validation signals.

To address the lack of prompt interpretability and scalability, we introduce CoEvoAD, a co-evolutionary discrete prompt-rule search framework. This framework performs search in the discrete natural language space using an evolutionary algorithm rather than relying on opaque black-box vector representations. Candidate prompt rules are continuously generated, evaluated, and selected throughout population evolution, while maintaining the interpretability, composability, and auditability of natural language, which provides strong potential for scalability. The fitness function combines the evaluation score on source data with the semantic contrast between normal and abnormal descriptions, thereby enabling a transparent and controllable optimization process without gradients. To avoid the objective conflict caused by mixing normal and abnormal rules in traditional methods, we maintain independent populations for the two roles and achieve co-evolution through a joint fitness design. This allows them to expand along their respective semantic directions in the large-scale natural language space while preserving the necessary semantic contrast. Overall, the framework transforms prompt-rule search from a single black-box vector into a structured, multi-role, multi-candidate co-evolutionary system, effectively improving interpretability and scalability.

To address the cross-category generalization issue, we introduce the Cross-Category Transfer Objective (CCTO), a prompt-rule selection criterion specifically designed for cross-category transfer. The key idea behind CCTO is to construct systematic held-out splits within the source domain, where a subset of source categories is treated as proxy unseen categories. This design enables the evaluation of candidate prompt rules under a simulated zero-shot transfer scenario, allowing us to assess their consistency and robustness when applied across categories. By leveraging only source-domain data, CCTO provides an evaluation signal that aligns more closely with the requirements of zero-shot generalization, without relying on any target-domain supervision. As a result, the proposed objective significantly improves the cross-category generalization ability of the selected rules, offering a more reliable selection criterion under the zero-shot setting.