Text-to-Image (T2I) models like Stable Diffusion and DALL-E 3 have transformed digital creativity, but their inner workings remain something of a "black box." While researchers have spent significant effort trying to "jailbreak" these models to produce unsafe content, a new paper from researchers at UC Riverside takes a different approach. Instead of just trying to break the models, they use adversarial attacks as a scalpel to dissect the internal biases that make these models vulnerable in the first place.
TL;DR
This paper identifies a curious "asymmetric bias" in T2I models: it is often much easier to adversarially trick a model into swapping entity A for entity B than it is to do the reverse. By introducing two new gradient-based attack algorithms and novel probing metrics, the authors demonstrate that an attack's success depends heavily on the model's internal "beliefs" and how closely a target entity matches the model's default expectations for a given context.
What Problem Does This Paper Address?
While we know T2I models are susceptible to adversarial attacks—small, calculated perturbations to a prompt that drastically change the output—we don't fully understand why some prompts are easier to attack than others.
Most research focuses on inducing Not-Safe-For-Work (NSFW) content. This paper shifts the focus to entity swapping: trying to replace one benign object with another (e.g., changing a "human" to a "robot" in a scene) using an adversarial suffix. By studying these swaps in both directions, the authors uncover a fundamental asymmetry in model robustness linked to internal data biases rather than just algorithmic cleverness.
Methods
The authors propose a targeted attack where an adversarial suffix is appended to a prompt to force the model to generate a target entity instead of the original one.
To achieve this, they developed two optimization algorithms:
- Single Token Perturbation: A modification of the Greedy Coordinate Gradient (GCG) algorithm used for LLMs.
- Multiple Token Perturbation: A novel approach that updates multiple tokens in the suffix simultaneously. This is specifically designed for the "bag-of-words" nature of the CLIP text encoders used in models like Stable Diffusion, where semantic relationships between words are less rigid than in traditional language models.
To understand the results, they introduced two key probing metrics:
- Base Success Rate (BSR): How reliably the model generates the target entity without any attack.
- Baseline Distance Difference ($\Delta_2$): This measures how far the target entity is from the model's "baseline" or "default" entity for a specific context in the CLIP embedding space.
Datasets
The study utilized two primary datasets for evaluation:
- HQ-Pairs: A manually curated set of 100 high-quality sentence pairs designed for entity swapping (e.g., "a swan in a lake" vs. "a horse in a lake").
- COCO-Pairs: A larger-scale dataset of 1,000 pairs generated deterministically from MS-COCO captions using Named-Entity-Recognition (NER) and Fill-Mask models to ensure visual distinctness.
Key Insights and Ideas
- The Asymmetry Phenomenon: The most striking finding is that attack success is not a two-way street. For example, replacing "human" with "robot" in "a human dancing in the rain" is relatively easy, but replacing "robot" with "human" is significantly harder.
- Perplexity is a Poor Predictor: Contrary to intuition, a prompt's perplexity (how "unnatural" the text is) does not strongly correlate with how easy it is to attack.
- The Power of the "Baseline": The model has inherent biases toward certain objects in specific contexts. If you prompt Stable Diffusion with "a [PAD] swimming in a lake," it might default to a specific animal. If your target entity is closer to this "baseline" than the original entity, the attack is much more likely to succeed.
- CLIP's Bag-of-Words Weakness: Because CLIP encoders don't capture complex syntax well, updating multiple tokens at once during an attack leads to faster convergence and higher success rates compared to methods optimized for LLMs.
Key Results
- Algorithm Performance: The Multiple Token Perturbation algorithm outperformed the single-token version, achieving a 26.4% Attack Success Rate (ASR) compared to 24.4% on the COCO-Pairs dataset.
- Predictive Metrics: The combination of BSR and $\Delta_2$ proved to be a powerful predictor of vulnerability. When the target's BSR was high and the $\Delta_2$ was negative (meaning the target was closer to the model's internal baseline), the ASR jumped to 60%. Conversely, when these conditions weren't met, the ASR dropped below 5%.
- Transferability: Interestingly, adversarial suffixes do not transfer well between different versions of Stable Diffusion (e.g., from v1.4 to v2.1) or to closed-source models like DALL-E 3, suggesting that the specific training data curation plays a massive role in these biases.
Limitations and Future Work
The authors acknowledge that calculating the Base Success Rate (BSR) is computationally expensive, as it requires generating a large number of images (64 in their tests) to get a statistically significant measure. Finding ways to approximate BSR more efficiently is a key area for future research.
Additionally, the study was primarily conducted on Stable Diffusion. Whether closed-source models like Midjourney or DALL-E 3 exhibit the same asymmetric biases remains an open question, as their creators may have mitigated these issues through more rigorous data curation or different architectures. Finally, the authors noted that their gradient-based attacks often "leaked" synonyms of the target word into the adversarial suffix, making the attacks less "stealthy" than desired.
Summary updated