[Paper Review] GuardT2I: Defending Text-to-Image Models from Adversarial Prompts
GuardT2I proposes a novel generative moderation framework that uses a conditional Large Language Model (c·LLM) to translate text guidance embeddings from text-to-image models into natural language, enabling robust detection of adversarial prompts without altering the original model. It achieves state-of-the-art performance, outperforming commercial systems like OpenAI-Moderation and Microsoft Azure Moderator with AUROC scores above 98% on key adversarial benchmarks.
Recent advancements in Text-to-Image (T2I) models have raised significant safety concerns about their potential misuse for generating inappropriate or Not-Safe-For-Work (NSFW) contents, despite existing countermeasures such as NSFW classifiers or model fine-tuning for inappropriate concept removal. Addressing this challenge, our study unveils GuardT2I, a novel moderation framework that adopts a generative approach to enhance T2I models' robustness against adversarial prompts. Instead of making a binary classification, GuardT2I utilizes a Large Language Model (LLM) to conditionally transform text guidance embeddings within the T2I models into natural language for effective adversarial prompt detection, without compromising the models' inherent performance. Our extensive experiments reveal that GuardT2I outperforms leading commercial solutions like OpenAI-Moderation and Microsoft Azure Moderator by a significant margin across diverse adversarial scenarios. Our framework is available at https://github.com/cure-lab/GuardT2I.
Motivation & Objective
- Address the growing threat of adversarial prompts that bypass traditional NSFW classifiers and induce harmful image generation in text-to-image models.
- Overcome the limitations of post-hoc classification-based moderation, which rely on fixed decision boundaries and struggle with generalization to unseen attack patterns.
- Develop a plug-and-play defense mechanism that preserves the original T2I model’s generation quality while enhancing robustness against semantic-level adversarial manipulations.
- Leverage the semantic understanding of large language models to interpret latent representations of prompts and reveal hidden malicious intentions.
Proposed method
- Introduce a conditional LLM (c·LLM) that conditions on text guidance embeddings from the T2I model’s latent space to generate natural language interpretations of the input prompt.
- Implement a cross-attention module to bridge the gap between implicit latent representations and interpretable text, enabling the LLM to reconstruct the original prompt’s semantic intent.
- Design a two-component pipeline: a Verbalizer to parse and reconstruct the prompt from latent embeddings, and a Sentence Similarity Checker to compare reconstructed text with original input for semantic consistency.
- Train the c·LLM on standard datasets like LAION-COCO to enable accurate and generalizable reconstruction of prompt semantics without requiring task-specific fine-tuning.
- Use the reconstructed text to detect adversarial intent by measuring semantic divergence between original and generated prompts, flagging inconsistencies as potential threats.
- Deploy the framework as a plug-in solution that operates at inference time, requiring no retraining or architectural changes to the underlying T2I model.
Experimental results
Research questions
- RQ1Can a generative approach based on LLMs outperform traditional classification-based methods in detecting adversarial prompts targeting text-to-image models?
- RQ2To what extent can a conditional LLM reconstruct the semantic meaning of a prompt from its latent representation in the T2I model’s guidance space?
- RQ3How effective is the combination of prompt reconstruction (Verbalizer) and semantic consistency checking (Sentence Similarity Checker) in identifying adversarial prompts across diverse attack types?
- RQ4Does the proposed framework maintain the original T2I model’s generation quality while improving robustness against NSFW content generation?
- RQ5Can the system generalize to previously unseen adversarial prompt patterns without requiring retraining or labeled data for each new attack type?
Key findings
- GuardT2I achieves an AUROC of 97.86% on the SneakyPrompt adversarial benchmark, significantly outperforming commercial systems like OpenAI-Moderation and Microsoft Azure Moderator.
- The framework attains an AUROC of 98.86% on the MMA-Diffusion attack, demonstrating superior robustness against complex adversarial prompt engineering.
- The Sentence Similarity Checker alone achieves AUROC scores above 91% across all tested adversarial prompts, indicating strong semantic discrimination capability.
- The Verbalizer component alone performs variably, with 80.20% AUROC on MMA-Diffusion but weaker performance on I2P, highlighting its limitations in handling subtle adversarial structures.
- The fusion of Verbalizer and Sentence Similarity Checker yields a synergistic effect, resulting in the highest overall performance and confirming the value of multi-stage analysis.
- Failure cases include rare false positives due to uncommon terminology and false negatives from prompts evading reconstruction—both addressable via keyword enrichment or active learning.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.