NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

AutoPrompt: Automated Red-Teaming of Text-to-Image Models via LLM-Driven Adversarial Prompts

Yufan Liu, Wanqian Zhang, Huashan Chen, Lin Wang, Xiaojun Jia, Zheng Lin, Weiping Wang

TL;DR

This paper introduces AutoPrompt (APT), a novel black-box framework that uses Large Language Models (LLMs) to automatically generate human-readable adversarial prompts for text-to-image (T2I) models. APT effectively bypasses existing safety filters and achieves high red-teaming success rates, demonstrating a more practical and scalable approach to evaluating T2I model safety.

What Problem Does This Paper Address?

Text-to-image (T2I) models have become incredibly powerful, capable of generating highly realistic and contextually relevant images from textual descriptions. However, this power comes with risks: these models can be manipulated to produce unsafe or inappropriate content through adversarial prompts. Existing methods for identifying these vulnerabilities often require white-box access to the T2I model (meaning they need to know the model's internal workings), are computationally expensive, and generate prompts that are often nonsensical and easily blocked by safety filters. This lack of effective, scalable, and practical red-teaming hinders the development of truly safe T2I systems.

Methods

AutoPrompt (APT) tackles this problem with a black-box approach, meaning it doesn't need access to the T2I model's internal parameters. The core idea is to leverage the natural language generation capabilities of LLMs to create adversarial "suffixes" that can be appended to benign prompts.

The framework employs an alternating optimization-and-finetuning pipeline:

  1. Adversarial Suffix Optimization: A frozen LLM is used to generate candidate adversarial suffixes. These suffixes are optimized using a stochastic beam search algorithm to minimize a "jailbreak constraint." This constraint has two main components:
  2. Unsafe Content Alignment: This ensures the generated image aligns with both unsafe images and unsafe textual concepts. It uses CLIP similarity to measure how well the generated image matches a set of unsafe images and a list of unsafe words.
  3. Dual-Evasion Strategy: To bypass common safety filters, APT incorporates two key mechanisms:
  4. Perplexity Constraint: An auxiliary LLM is used to score the perplexity (a measure of how "natural" or predictable a text is) of the generated suffixes. This encourages human-readable prompts and helps evade perplexity-based filters.
  5. Banned-Token Penalties: This strategy directly penalizes the generation of tokens that are semantically similar to words on an "unsafe words list." A secondary penalty mechanism is also implemented to catch prohibited words formed by the combination of multiple tokens.
  6. LLM Fine-tuning: The optimized adversarial suffixes are then used to fine-tune the LLM suffix generator. This iterative process progressively improves the LLM's ability to generate effective adversarial prompts.

Datasets

  • I2P Dataset: Used for evaluation, specifically focusing on prompts related to nudity and violence. The dataset was partitioned into training and testing sets for each T2I model.
  • Unsafe Image Dataset: A dataset of 50 classifier-verified images containing nudity or violence was used for the unsafe content alignment objective.
  • Unsafe Words Lists: Lists of nudity-related (23 words) and violence-related (17 words) terms were used for the banned-token penalties.

Key Insights and Ideas

  • LLMs as Red-Teaming Agents: The paper demonstrates that LLMs, with appropriate fine-tuning and optimization, can be powerful tools for generating sophisticated adversarial prompts, moving beyond simple keyword stuffing.
  • Human-Readability is Key: Generating prompts that are not only effective but also human-readable is crucial for practical red-teaming. This makes prompts less likely to be flagged by simple filters and more representative of real-world adversarial use cases.
  • Dual-Evasion is Necessary: Modern T2I models employ multiple layers of safety mechanisms (e.g., perplexity filters, blacklist filters). A robust red-teaming method must actively circumvent these, and APT's dual-evasion strategy proves effective.
  • Alternating Optimization and Fine-tuning: This iterative approach allows the LLM to learn from its own successes and failures, progressively refining its ability to generate effective adversarial suffixes.
  • Zero-Shot Transferability: The prompts generated by APT show strong transferability across different T2I models, even those not seen during training, highlighting the generality of the approach.

Key Results

  • Highest Red-Teaming Success Rate (RSR): AutoPrompt achieved the highest RSR across four different safe T2I models, significantly outperforming baseline methods like Ring-A-Bell, P4D, and AdvUnlearn, even when prompts were filtered.
  • Lowest Perplexity (PPL): APT generated adversarial prompts with significantly lower perplexity scores compared to baselines, indicating superior human-readability and naturalness. For example, the average perplexity was nearly 70 times lower than Ring-A-Bell.
  • Fast Generation: APT generates adversarial prompts orders of magnitude faster than baseline approaches.
  • Effective Evasion: The dual-evasion strategy resulted in the lowest blocking rates for both nudity and violence prompts.
  • Strong Transferability: Prompts crafted for one T2I model showed high success rates when applied to others, demonstrating the robustness of the generated adversarial prompts.
  • Successful Jailbreaks on Latest Models: APT demonstrated successful jailbreaks on cutting-edge T2I architectures (SDXL, SD3.5-medium, FLUX.1-dev) and online services (Midjourney, Leonardo.Ai), showcasing its applicability to current state-of-the-art systems.

Limitations and Future Work

  • Limitations:
    • The paper notes that while the "prior suffix" helps guide the LLM, relying solely on it without the alternating training framework leads to poorer RSR. This suggests the iterative refinement is critical.
  • The performance of the "w/ ps only" variant (prior suffix appended directly) was insufficient, indicating that the LLM needs to actively learn to generate adversarial content rather than just relying on a pre-defined prefix.
  • Future Work:
    • The authors advocate for establishing open safety evaluation benchmarks for T2I models to encourage the development of more robust and defensive safety mechanisms.
  • The success of APT in bypassing safety measures on the latest models and online services suggests a continued need for advanced red-teaming techniques to ensure proactive safety evaluations in AI.

Summary updated

BibTeX
@inproceedings{liu2025autoprompt,
  author = {Yufan Liu and Wanqian Zhang and Huashan Chen and Lin Wang and Xiaojun Jia and Zheng Lin and Weiping Wang},
  title = {{AutoPrompt: Automated Red-Teaming of Text-to-Image Models via LLM-Driven Adversarial Prompts}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2025},
}
Figure