Dark Miner: Defend against undesired generation for text-to-image diffusion models

Zheling Meng, Bo Peng, Xiaochuan Jin, Yue Jiang, Jing Dong, Wei WangarXiv 2024 · DOI · arXiv

Abstract

Generative AI models frequently produce undesirable content, including nudity and copyrighted material, due to unfiltered training data. Existing defense mechanisms often fail against adversarial prompts that exploit "dark corners" of the model's embedding space. This paper introduces Dark Miner, a proactive framework that identifies and neutralizes these vulnerabilities. By iteratively mining for problematic embeddings and redirecting them to safe outputs via LoRA fine-tuning, Dark Miner provides a robust defense that preserves overall image quality.

Introduction

Text-to-image (T2I) diffusion models have revolutionized content creation but carry significant risks. Malicious users can bypass safety filters using complex or nonsensical adversarial prompts. Current concept erasure methods, such as Erasing Stable Diffusion (ESD), typically target specific keywords or training prompts, leaving vast areas of the model's internal representation unprotected.

Dark Miner addresses this by treating concept erasure as a global optimization problem. Instead of patching visible holes, it actively searches for any internal trigger—even those without linguistic meaning—that might lead to undesirable generation.

Figure 1: Comparison of standard Stable Diffusion (SD) and Erased SD across nudity, object, and style categories.

The Dark Miner Framework

Dark Miner employs an iterative loop to systematically harden the model. The framework consists of four key stages:

  1. Mining Stage: The system optimizes continuous embeddings to maximize the likelihood of generating a target "undesirable" concept. This "red-teaming" approach finds internal triggers that human-designed prompts might miss.
  2. Verifying Stage: Mined embeddings are validated using CLIP delta features. By measuring the similarity between the generated output and the target concept relative to a neutral prompt (e.g., "a photo"), the system filters out noise.
  3. Circumventing Stage: Validated vulnerabilities are patched using Low-Rank Adaptation (LoRA). The model is fine-tuned to map "dark" embeddings to safe anchor prompts. A preservation loss is included to prevent "catastrophic forgetting" of benign concepts.
  4. Merge Stage: The learned LoRA weights are integrated back into the base model, and the process repeats until no further vulnerabilities can be mined.
Figure 2: The Dark Miner framework consists of iterative stages: Mine, Verify, Circumvent, and Merge.

Experimental Evaluation

The authors evaluated Dark Miner across several domains, including inappropriate content (nudity via the I2P dataset), object erasure (e.g., "church" and "French horn"), and style erasure (e.g., "Van Gogh"). General image quality was benchmarked against COCO 2017 to ensure standard generation remains intact.

Results and Discussion

Dark Miner demonstrates superior performance in both erasure effectiveness and adversarial robustness. For nudity, Dark Miner reduced the concept ratio to 12.1%, compared to 49.1% in the original Stable Diffusion. Against white-box attacks like CCE, Dark Miner maintained a significantly lower Attack Success Rate (ASR) than competing methods. For instance, in church erasure, its ASR was 29.1%, while others often exceeded 80%. Crucially, Dark Miner maintained a high CLIP-Score (30.0) and low FID (21.7), preserving the model's utility for safe prompts.

Conclusion

Dark Miner represents a significant step forward in securing T2I models. By moving from keyword-based patching to embedding-space mining, it offers a more comprehensive defense against both standard and adversarial misuse. Future work will focus on extending this framework to black-box models and improving the efficiency of the iterative tuning process.

Summary updated

BibTeX
@misc{meng2024dark,
  author = {Zheling Meng and Bo Peng and Xiaochuan Jin and Yue Jiang and Jing Dong and Wei Wang},
  title = {{Dark Miner: Defend against undesired generation for text-to-image diffusion models}},
  year = {2024},
  eprint = {2409.17682},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2409.17682},
}
Figure