Safe Latent Diffusion: Mitigating Inappropriate Degeneration in Diffusion Models

Patrick Schramowski, Manuel Brack, Björn Deiseroth, Kristian Kersting

Introduction

Large-scale text-to-image diffusion models, such as Stable Diffusion, have revolutionized creative AI. However, because they are trained on massive, often unfiltered web-scraped datasets like LAION-5B, they frequently inherit and amplify harmful biases. A significant challenge is "inappropriate degeneration": the generation of unsafe content (e.g., nudity, violence, self-harm) even when prompted with seemingly benign text. For instance, the prompt "Japanese body" in Stable Diffusion v1.4 has been shown to produce nudity in 75% of cases.

Existing safeguards, such as post-hoc safety checkers that blur images after generation, are reactive and easily bypassed. To address this at the source, researchers have introduced Safe Latent Diffusion (SLD), a method that suppresses inappropriate content during the inference process itself, requiring no retraining or fine-tuning.

Safe Latent Diffusion (SLD)

SLD operates by modifying the sampling process through a novel "safety guidance" mechanism. It builds upon classifier-free guidance (CFG), which typically steers the model toward a text prompt. SLD introduces a third component: a textual description of "unsafe" concepts (e.g., "hate, violence, nudity").

Conceptual overview of SLD guidance. The safety guidance steers the latent representation away from the 'Unsafe' region identified by the model's internal knowledge.

As shown in the figure above, the model calculates a "safety direction" that identifies dimensions of the image aligning with unsafe concepts. By pushing the generation in the opposite direction, SLD effectively avoids these regions of the latent space. The method includes several key hyperparameters to balance safety and image quality:

  • Safety Guidance Scale ($s_S$): Controls the strength of the suppression.
  • Thresholding ($\lambda$): Ensures that only pixels clearly identified as "unsafe" are modified, preserving the rest of the image.
  • Warm-up ($\delta$): Delays the safety guidance for a few steps to allow the basic image composition to form.

Evaluation and Results

The authors evaluated SLD using the I2P (Inappropriate Image Prompts) benchmark, a new dataset of 4,703 prompts designed to trigger unsafe content across categories like hate, harassment, and violence.

Quantitative results on the I2P benchmark. SLD configurations (Weak to Max) significantly reduce the probability of inappropriate content compared to standard Stable Diffusion (SD 1.4).

The results demonstrate that SLD significantly reduces the probability of generating inappropriate content. The "Max" configuration achieved over a 75% reduction in harm compared to the base Stable Diffusion v1.4 model. Notably, SLD also successfully mitigated the "Japanese body" bias, reducing the nudity rate from 75% to 12%.

Furthermore, human evaluations using DrawBench confirmed that SLD does not sacrifice general image quality or text alignment. In many cases, users preferred SLD-generated images, as the removal of "degenerate" artifacts often improved the overall aesthetic.

Conclusion

Safe Latent Diffusion provides a flexible, "plug-and-play" solution for safer AI image generation. By leveraging the model's own internal knowledge of what constitutes inappropriate content, SLD steers the creative process away from harm without the need for expensive retraining. While the definition of "inappropriate" remains culturally subjective, SLD offers a powerful tool for developers to implement fine-grained safety controls in generative AI applications.

Summary updated

BibTeX
@inproceedings{schramowski2022safe,
  author = {Patrick Schramowski and Manuel Brack and Björn Deiseroth and Kristian Kersting},
  title = {{Safe Latent Diffusion: Mitigating Inappropriate Degeneration in Diffusion Models}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
}
Figure