Boosting Alignment for Post-Unlearning Text-to-Image Generative Models

Myeongseob Ko, Henry Li, Zhun Wang, Jonathan Patsenker, Jiachen T. Wang, Qinbin Li, Ming Jin, Dawn Song, Ruoxi Jia

TL;DR

Removing "harmful" knowledge from text-to-image models usually comes at a cost: the model becomes worse at following prompts for everything else. This paper introduces a "Restricted Gradient" framework and a data diversification strategy that allows models to unlearn specific concepts (like nudity or copyrighted styles) while maintaining near-perfect text-image alignment for the remaining data.

Comparison of unlearning methods on Nudity and Van Gogh concepts, showing RGD maintains the highest alignment score.

What Problem Does This Paper Address?

Large-scale diffusion models like Stable Diffusion are trained on massive, often uncurated, web-scraped datasets. Consequently, they can generate inappropriate content or infringe on copyrights. Machine unlearning aims to "purge" this undesirable knowledge without retraining the model from scratch.

However, the authors identify a "competitive nature" between two core unlearning objectives:

  1. Forgetting: Maximizing the loss on the target concept (e.g., "Van Gogh style" or "nudity").
  2. Retention: Minimizing the loss on everything else to maintain image quality and prompt adherence.

Existing methods often fail because these two goals produce conflicting gradients—improving one hurts the other. Furthermore, many unlearning methods use very simplistic "remaining" datasets (e.g., a single prompt), leading to overfitting and a sharp drop in text-image alignment (how well the generated image actually matches the text prompt).

Methods

The authors propose a two-pronged approach to solve this alignment degradation:

  1. Restricted Gradient (RGD): Instead of simply summing the gradients from the forgetting and retention tasks, the authors use "gradient surgery." If the two gradients conflict (pointing in opposite directions), they project each gradient onto the normal vector of the other. This ensures that the model update achieves a "monotonic improvement" on both objectives simultaneously, preventing the unlearning process from inadvertently damaging the model's general capabilities.
  2. Strategic Data Diversification: To prevent overfitting during the retention phase, the authors use a Large Language Model (LLM) to generate a diverse set of prompts related to the concept being removed. For example, if removing "nudity," the LLM generates prompts for people in various settings (parks, studios, deserts) wearing clothes. This creates a robust "remaining dataset" ($D_r$) that teaches the model exactly what to keep while it learns what to forget.

Datasets

The researchers evaluated their approach across several benchmarks:

  • CIFAR-10: Used for class-wise forgetting (e.g., making the model forget what a "bird" is).
  • Stable Diffusion (v1.4 and v3): Used for real-world concept removal.
  • I2P (Inappropriate Image Prompts): A dataset used to test the model's tendency to generate harmful content.
  • LLM-Generated Sets: They used ChatGPT to create "parallel" datasets—one set containing the target concept ($D_f$) and a corresponding "safe" set ($D_r$) with the concept removed but the context preserved.

Key Insights and Ideas

  • Unlearning as Multi-Task Optimization: The paper treats unlearning not just as "erasing," but as a delicate balancing act between two competing tasks.
  • The Alignment Gap: The authors highlight that while previous methods might successfully stop a model from generating nudity, they often "break" the model's ability to follow complex prompts in general. Their method reduces this "alignment gap" by up to 20x compared to baselines.
  • Diversity is King: A key "aha moment" in the ablation studies was that the diversity of the remaining data is often more important than the specific unlearning algorithm used. Reminding the model of many different "safe" fragments prevents it from collapsing into a state where it can only generate a few types of images.

Key Results

Nudity detection results and qualitative comparisons across unlearning methods, demonstrating RGD's effectiveness at removing harmful content.
  • Nudity Removal: On the I2P benchmark, the proposed method (RGD) reduced the number of detected exposed body parts to zero, whereas the original Stable Diffusion model produced 598.
  • Maintaining Alignment: While baselines like SalUn saw their CLIP alignment scores drop significantly (from 0.352 to 0.305), the authors' method maintained a score of 0.350, nearly identical to the original model.
  • Art Style Removal: The model successfully unlearned the "Van Gogh" style while remaining able to generate images in the style of Monet or Picasso, whereas baselines often lost the ability to follow style instructions entirely.
  • Architecture Agnostic: The method proved effective on both the older UNet-based Stable Diffusion v1.4 and the newer transformer-based Stable Diffusion v3.

Limitations and Future Work

  • Hyperparameter Sensitivity: The method relies on two key hyperparameters ($\lambda$ for gradient weight and $\alpha$ for loss truncation). Finding the "sweet spot" for these can be challenging and may vary depending on the concept being removed.
  • Computational Overhead: Generating diverse datasets using LLMs and then passing them through the diffusion model to create image-text pairs adds a pre-processing step that is more computationally expensive than simpler methods.
  • Future Directions: The authors suggest exploring different sampling strategies for the "retain" set, such as investigating the impact of data proximity (how "close" the safe data is to the forbidden data) on unlearning efficiency.

Summary updated

BibTeX
@inproceedings{ko2024boosting,
  author = {Myeongseob Ko and Henry Li and Zhun Wang and Jonathan Patsenker and Jiachen T. Wang and Qinbin Li and Ming Jin and Dawn Song and Ruoxi Jia},
  title = {{Boosting Alignment for Post-Unlearning Text-to-Image Generative Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=93ktalFvnJ},
}
Figure