Vision-Language Models (VLMs) like CLIP have revolutionized zero-shot visual recognition by mapping images and text into a shared embedding space. However, when these models are applied to highly specific, fine-grained tasks—such as identifying industrial defects or verifying workplace safety compliance—standard zero-shot prompting breaks down.
If you prompt a VLM to find "an anomaly," the model struggles. An anomaly on a polished semiconductor wafer looks entirely different from an anomaly on a woven fabric or a ceramic tile. This mismatch creates cross-semantic ambiguity: abstract textual terms fail to capture the precise, pixel-level visual features of a defect.
To bridge this gap, a powerful new paradigm has emerged: Dynamic Prompt Generation. Instead of relying on static, hand-crafted text prompts, these frameworks leverage the rich world knowledge of Large Language Models (LLMs) to synthesize highly descriptive, context-specific prompts at inference time. By translating abstract concepts into concrete visual descriptors tailored to the exact image being analyzed, this approach unlocks precise zero-shot detection and segmentation without requiring task-specific retraining.
The Core Mechanism: Bridging the Semantic Gap
The fundamental reason dynamic prompt generation works is that it shifts the burden of description from the human engineer to an automated, context-aware loop. The process typically follows a three-stage pipeline:
[Input Image] ──> [Context Extraction] ──> [LLM Prompt Expansion] ──> [VLM Alignment]
- Context Extraction: The system inspects the input image to determine its broad category or environmental context.
- LLM Prompt Expansion: An LLM uses this context to generate highly detailed descriptions of what "normal" and "abnormal" states look like for that specific object or scene.
- VLM Alignment: These fine-grained textual descriptions are fed into a pre-trained VLM, which can now easily match the highly specific text embeddings with the corresponding visual features in the image.
By replacing a generic prompt like "an anomaly" with an explicit descriptor like "a thin, jagged crack running across a glossy ceramic surface," the VLM's text encoder produces an embedding that sits much closer to the actual visual pixels of the defect.
Extracting Image-Aware Context
An LLM cannot generate a relevant prompt without knowing what is in the image. Researchers have developed several distinct strategies to feed visual context into the language model at runtime.
Image Tagging and Adjective Clauses
One straightforward method is to extract explicit visual tags from the image before querying the LLM. As demonstrated by SoYoung Park et al., an initial image-tagging step can capture the core visual characteristics of the target object. The LLM then combines these tags with predefined anomaly keywords to generate specific adjective clauses. This ensures that the generated text prompt is explicitly tailored to the texture, material, and shape of the input data.
Visual Question Answering (VQA) Integration
Rather than relying solely on tags, the framework introduced by Chengyuan Li et al. pairs an LLM with a VQA system. The VQA system generates detailed, image-specific descriptions on the fly. By blending the general world knowledge of the LLM with the immediate, localized observations of the VQA, the system synthesizes highly accurate, learnable anomaly prompts that bypass manual engineering entirely.
Multi-Stage Feature Grounding
To achieve even tighter coupling between text and pixels, the SIAD-LLM framework designed by JunhoLee et al. dynamically generates text prompts based on a combination of raw image content and multi-stage visual features extracted from the model's internal layers. Grounding the language generation in the model's own intermediate visual representations significantly enhances the accuracy of subsequent localization and anomaly mapping.
Inference-Time Adaptation and Filtering
Generating detailed text is highly effective, but it introduces a new challenge: LLMs can occasionally generate irrelevant or noisy descriptions that confuse the VLM. Successful architectures therefore implement runtime adaptation and filtering mechanisms.
The ALFA framework, detailed by Jiaqi Zhu et al. (ACM MM 2024), addresses this by using predefined templates to initiate prompt creation and querying an LLM at inference time for nuanced descriptions of both normal and abnormal states. To prevent cross-semantic ambiguity from creeping back into the system, Jiaqi Zhu et al. (MM2024) introduce a contextual scoring mechanism. This mechanism acts as an intelligent filter, evaluating the generated prompts and selecting only those most relevant to the specific input image, effectively pruning away misleading textual attributes.
Alternatively, optimization can be driven by specialized loss functions. The authors of KAnoCLIP utilize a knowledge-driven loss function to guide prompt generation. This loss function mathematically forces the system to optimize the prompts by minimizing their distance to abnormal visual representations while maximizing their distance to normal ones, ensuring a clean decision boundary during zero-shot inference.
Generalizing Across Domains
While industrial anomaly detection is a primary driver of this research, the principle of using LLMs as dynamic knowledge bases generalizes across several distinct visual domains.
Workplace Safety Compliance
In complex environments like construction sites or factories, safety rules change depending on the specific zone or task. Hanning Chen et al. developed Clip2Safety, a framework that uses an LLM to translate high-level safety standards into context-specific visual prompts and attribute requirements based on the identified scene. Because the system dynamically adapts to varied environments on the fly, it achieves fine-grained Personal Protective Equipment (PPE) inspection without task-specific retraining, running up to 200 times faster than heavy, end-to-end multi-modal models.
Multi-Turn Dialogue and Segmentation
In industrial settings, users often need to know more than just whether a defect exists; they need to understand its nature. The IAD-GPT framework, introduced by Zewen Li et al., leverages an MLLM to synthesize category-specific text attributes that condition and activate both the detection and pixel-level segmentation capabilities of pre-trained models. This enables detailed anomaly descriptions and multi-turn dialogues about the health of a component.
Mitigating Generative Hallucinations
Fascinatingly, this dynamic feedback loop also works in reverse to improve text-to-image generation. Diffusion models often suffer from structural inconsistencies or "hallucinations" when text prompts are ambiguous. To combat this, Kostas Triaridis et al. introduced a Dynamic Guidance method that adaptively sharpens the model's score function during the generation process. By dynamically adapting the text prompt during the sampling process under the guidance of a VLM, the system resolves ambiguities in real time, ensuring that the generated image strictly aligns with the intended semantic meaning.
Conclusion
Dynamic prompt generation turns a static vision-language alignment problem into an adaptive, intelligent conversation. By leveraging LLMs to translate abstract target concepts into granular, image-aware visual descriptors, these methods eliminate the need for manual prompt engineering and costly downstream fine-tuning. Whether pinpointing a microscopic fracture on a factory floor or verifying safety gear in a changing workplace, the intuition remains the same: the clearer and more contextually tailored the text description, the more precisely a vision model can see it.
Key Foundational Work
Do LLMs Understand Visual Anomalies? Uncovering LLM's Capabilities in Zero-shot Anomaly Detection (2024) — contributed 3 concept elements to this direction.
Do LLMs Understand Visual Anomalies? Uncovering LLM's Capabilities in Zero-shot Anomaly Detection (2024) — contributed 3 concept elements to this direction.
Vision Language Model for Interpretable and Fine-grained Detection of Safety Compliance in Diverse Workplaces (2024) — contributed 2 concept elements to this direction.