TL;DR
Direct Unlearning Optimization (DUO) is a new framework that makes text-to-image models safer by teaching them to "forget" unsafe visual concepts rather than just blocking specific words. By using preference optimization on paired images, DUO creates models that are significantly more robust against adversarial prompt attacks while maintaining high-quality generation for safe topics.
What Problem Does This Paper Address?
Large-scale text-to-image (T2I) models like Stable Diffusion are often trained on massive, uncurated web datasets (e.g., LAION-5B) that contain Not Safe For Work (NSFW) content, copyright infringements, and privacy violations. Consequently, these models can easily generate harmful imagery.
Existing safety measures generally fall into two categories:
- Post-generation filters: Ad-hoc classifiers that block images after they are created. These are prone to false positives and can be bypassed if the model weights are open-sourced.
- Prompt-based unlearning: Fine-tuning the model to ignore specific "unsafe" words (like "nudity").
The authors argue that prompt-based methods are brittle. Because there are infinite synonyms and adversarial ways to describe a concept (e.g., using "soft embeddings" or slightly perturbed words like "grponypui" instead of "naked"), an attacker can easily circumvent these filters. The core issue is that the model still retains the visual concept of the unsafe content; it just doesn't associate it with the specific blocked word.
Methods
The authors propose Direct Unlearning Optimization (DUO), which shifts the focus from text to images. Instead of unlearning a word, the model unlearns the visual features themselves.
1. Synthesizing Paired Data
To avoid "catastrophic forgetting"—where the model forgets how to draw a "woman" or a "forest" while trying to forget "nudity"—the authors use SDEdit to create paired datasets.
- They start with an unsafe image ($x_0^-$).
- They add noise and then denoise it using negative guidance for the unsafe concept (and positive guidance for a safe concept like "dressed").
- This produces a "safe" counterpart ($x_0^+$) that is visually identical in every way (background, lighting, subject) except for the unsafe feature.
2. Direct Preference Optimization (DPO)
DUO treats unlearning as a preference problem. Using the paired data, they apply a modified version of DPO for diffusion models. The objective is to maximize the model's preference for the safe image ($x_0^+$) over the unsafe one ($x_0^-$). This forces the model to move away from the unsafe visual manifold.
3. Output-Preserving Regularization
To ensure the model doesn't degrade on unrelated tasks, the authors introduce a novel regularization term ($L_{prior}$). This term forces the model to maintain its original denoising behavior at the final timestep ($t=T$), where the image is pure noise. This helps preserve the model's overall generative "prior" without interfering with the unlearning of specific features at lower timesteps.
Datasets
- Training: The authors generated 256 paired images for "nudity" and 256 for "violence" (further subdivided into blood, suffering, gun, and horror).
- Evaluation:
- MS COCO 30k: Used to measure general image quality (FID and CLIP scores) to ensure unlearning didn't break the model.
- i2p Benchmark: Used to generate malicious prompts for testing.
- Red Teaming: They tested against state-of-the-art attacks like Ring-A-Bell, SneakyPrompt, and Concept Inversion.
Key Insights and Ideas
- Visual Features > Text Tokens: Unlearning at the image level is fundamentally more robust than at the text level. If the model no longer knows how to draw a concept, it doesn't matter what prompt the user provides.
- Resolving Ambiguity with Pairs: A single unsafe image is ambiguous; the model doesn't know if it should forget the "nudity" or the "forest" in the background. The safe/unsafe pairs act as a precise surgical tool, telling the model exactly which pixels to change.
- Robustness to White-Box Attacks: DUO is particularly effective against "Concept Inversion," a white-box attack that tries to find a special token representing the unsafe concept. Because DUO removes the internal visual features, these attacks result in corrupted, noisy images rather than unsafe ones.
Key Results
DUO achieved a Defense Success Rate (DSR) of nearly 90% against all tested red-teaming methods, significantly outperforming baselines like ESD, UCE, and SPM.
- Prior Preservation: On the MS COCO dataset, DUO maintained FID and CLIP scores comparable to the original Stable Diffusion 1.4 model, proving that safety doesn't have to come at the cost of general performance.
- Scalability: The authors successfully applied DUO to Stable Diffusion 3, demonstrating that the method works on modern transformer-based architectures, not just older U-Net designs.
Limitations and Future Work
- Concept Overlap: Since DUO unlearns visual features, there is a risk that unrelated concepts sharing similar features might be affected. For example, unlearning "blood" might slightly impact the model's ability to generate "ketchup" or "strawberry jam."
- Malicious Misuse: The authors acknowledge that unlearning techniques could theoretically be misused by actors to remove safety mechanisms or "unlearn" copyright protections.
- Defense in Depth: DUO is not a silver bullet. The authors suggest it should be used in conjunction with other safety layers like dataset filtering and post-generation checkers for a comprehensive safety strategy.
Summary updated