Abstract
State-of-the-art Text-to-Image (T2I) models like Stable Diffusion and DALL·E 2 are revolutionizing visual content generation. However, significant concerns persist regarding how adversaries might exploit these models to generate unsafe imagery. This work demystifies the generation of unsafe images and hateful memes by constructing a typology of five unsafe categories: sexually explicit, violent, disturbing, hateful, and political. We assess four advanced T2I models across four prompt datasets, finding that 14.56% of all generated images are unsafe, with Stable Diffusion reaching 18.92%. Furthermore, we demonstrate that adversaries can use image-editing methods like DreamBooth to generate targeted hateful meme variants with high fidelity. Our results suggest that the danger of large-scale unsafe image generation is imminent, necessitating better safeguard tools and training data curation.
Introduction
Text-to-Image (T2I) models have opened a "Pandora’s box" of safety concerns. While these models enable unprecedented creativity, they also provide a low-barrier tool for generating harmful content. Existing safety filters are often rudimentary and easily bypassed, and there is a lack of systematic understanding regarding how these models behave when intentionally pushed to generate harmful content. This research addresses two primary questions: how prone are T2I models to generating unsafe content across different categories, and can these models be weaponized to automatically create "meme variants"—new versions of hateful archetypes (e.g., "Pepe the Frog") that target specific individuals or communities?
Methodology
To systematically evaluate these risks, we employed a multi-stage approach to classify and generate unsafe content.
Typology and Classification
We defined five specific categories of unsafe content: sexually explicit, violent, disturbing, hateful, and political. To measure these accurately, we developed a Multi-headed Safety Classifier. This system utilizes a 2-layer Multilayer Perceptron (MLP) built on top of frozen CLIP embeddings. This custom classifier significantly outperformed standard built-in filters, achieving an accuracy of 0.90 compared to the 0.75 accuracy of Stable Diffusion’s native filter.
Adversarial Meme Generation
To simulate an attacker, we explored three state-of-the-art image editing methods supported by Stable Diffusion:
- DreamBooth: Fine-tuning the entire model on a small set of images to learn a specific subject.
- Textual Inversion: Optimizing a new "word" embedding to represent a specific concept.
- SDEdit: Using stochastic differential equations to guide image synthesis based on an existing image and a new prompt.
We also integrated a Large Language Model (LLM), ChatGPT, into the pipeline to rephrase and "boost" prompts. This improved visual alignment and helped bypass simple keyword-based filters.
Experimental Setup
We evaluated four prominent models: Stable Diffusion (SD), Latent Diffusion (LDM), DALL·E 2-demo, and DALL·E mini. Our evaluation used diverse prompt sources:
- 4chan Prompts: 2,470 toxic sentences from the /pol/ board.
- Lexica Prompts: 1,577 prompts scraped from real-world Stable Diffusion outputs associated with "unsafe" keywords.
- Template Prompts: 30 manually crafted "worst-case" prompts designed to trigger specific unsafe categories.
- MS COCO: 500 benign captions used as a "clean" baseline.
Additionally, we sampled 700,000 images from the LAION datasets to trace the "root cause" of unsafe generation back to the training data.
Key Results and Analysis
High Prevalence of Unsafe Content
Across all tested models and prompt datasets, 14.56% of generated images were classified as unsafe. Stable Diffusion proved to be the most prone to generating harmful content, with an unsafe rate of 18.92%. When using the "Template" prompts—specifically designed to be harmful—the unsafe generation rate skyrocketed to 50.56%.
Automated Meme Evolution
Traditionally, creating hateful memes required manual graphic design skills. Our study shows that AI enables "evolutionary" meme generation. Using DreamBooth, 24% of generated images were successful "hateful meme variants." these images preserved the features of the original hate symbol while clearly depicting a new target entity, such as a specific politician or ethnic group. The fidelity of these AI-generated memes is comparable to those found in extremist online communities.
The Training Data "Original Sin"
The primary driver behind unsafe generation is the training data itself. Our analysis of the LAION training sets (used for SD and LDM) estimates that between 3.46% and 5.80% of the data contains unsafe imagery. Because the models have learned these concepts during pre-training, they can reconstruct them even from seemingly innocuous prompts.
Discussion and Mitigation
The findings highlight a significant gap in current AI safety. While post-processing filters are a common defense, they are easily bypassed by prompt engineering or model fine-tuning. We suggest several mitigating measures:
- Training Data Curation: Removing unsafe content at the source is the most effective, albeit difficult, long-term solution.
- Prompt Regulation: Implementing more sophisticated LLM-based prompt analysis to detect adversarial intent.
- Concept Unlearning: Developing techniques to "erase" harmful concepts from pre-trained models without requiring full retraining.
Conclusion
The danger of large-scale, automated generation of unsafe images and hateful memes is no longer theoretical; it is imminent. As T2I models become more accessible, the potential for their weaponization by adversaries grows. It is imperative that the research community develops more robust safeguard tools and ethical guidelines for the release of powerful generative models.
Summary updated