Prompt-Agnostic Erasure for Diffusion Models Using Task Vectors

Minh Pham, Kelly O. Marshall, Chinmay Hegde, Niv Cohen · Submission to ICLR 2025 · Rejected

TL;DR

Current concept erasure methods for text-to-image (T2I) diffusion models act like shallow keyword filters—adversaries can easily circumvent them using alternative or optimized prompts. This paper demonstrates that Task Vectors (TV) can perform unconditional, prompt-agnostic concept erasure directly in weight space. To prevent the edit from degrading overall image quality, the authors introduce Diverse Inversion, an optimization technique that mines diverse adversarial embeddings to carefully calibrate edit strength and prune task vectors across model layers.

What Problem Does This Paper Address?

Generative diffusion models can replicate copyrighted artistic styles, specific identities, and sensitive or unsafe imagery. Existing sanitization methods—such as Erased Stable Diffusion (ESD), Unified Concept Editing (UCE), and Safe Latent Diffusion (SLD)—primarily rely on input-dependent suppression. They adjust weights or inference paths conditioned on explicit textual descriptions or prompts (e.g., "Van Gogh").

However, diffusion models learn complex, many-to-many mappings between text embeddings and image features. Adversarial attacks like Concept Inversion and Ring-A-Bell easily discover "jailbreak" dense embeddings far away from the original text prompt that still generate the forbidden concept. The authors define unconditional safety—the guarantee that a model will not produce the concept regardless of the input prompt—and show that existing erasure methods fail this standard.

Methods

The authors address this vulnerability by shifting from conditional suppression to unconditional model surgery:

  1. Task Vector (TV) Erasure: The authors fine-tune the diffusion model's U-Net to unconditionally generate only the unwanted concept, obtaining fine-tuned weights $\theta_{ft}$. The task vector is defined as $\tau = \theta_{ft} - \theta_{pre}$. By subtracting this direction ($\theta_{\text{edited}} = \theta_{\text{pre}} - \alpha \tau$), the model's capacity to render the concept is removed across the latent space, independent of any user prompt.

  2. Diverse Inversion: TV editing can harm unrelated generations if the edit strength $\alpha$ is too high. Because the true distribution of adversarial prompts is unknown, the authors propose Diverse Inversion to build a synthetic validation set. They optimize a set of dense token embeddings $\{v_1, \dots, v_n\}$ conditioned to generate the target concept while enforcing cosine similarity boundaries: keeping them distinct from the original concept text embedding and diverse relative to one another.

  3. Calibrating and Pruning: Using an Erasure Score (ES) computed across the Diverse Inversion set, the authors identify the minimal edit strength $\alpha$ required to eliminate the concept. Additionally, they show that pruning the TV (e.g., setting weights to zero in the first few U-Net blocks) successfully preserves utility on unrelated control tasks while maintaining adversarial robustness.

                    ┌───────────────────────────┐
                    │  Fine-Tune on Target (S)  │ ──► Compute τ = θ_ft - θ_pre
                    └───────────────────────────┘
                                                              │
Diverse Inversion   ┌───────────────────────────┐             ▼
Embeddings {v_i}  ──►│ Measure Erasure Score (ES)│ ──► Select α & Prune Blocks
                    └───────────────────────────┘             │
                                                              ▼
                                                   Apply θ_new = θ_orig - α * τ

Datasets

  • MNIST: Used to train a low-dimensional ($d=8$) toy diffusion model, enabling exhaustive grid evaluations of the unconditional safety metric.
  • ImageNet / Imagenette: 10 object classes (e.g., chainsaw, church, gas pump, french horn) evaluated for object-level concept removal.
  • Artistic Styles & Specific Concepts: Artists such as Vincent van Gogh and Thomas Kinkade, alongside control identity/style tasks (Picasso, Brad Pitt, etc.).
  • MS COCO (2014 Validation Set): 10,000 captions evaluated via FID to monitor general text-to-image quality degradation.
  • I2P Benchmark: Evaluated for sensitive/inappropriate content erasure (nudity).

Key Insights and Ideas

  • Input-filtering is not concept erasure: Standard methods simply carve out a small basin around the concept token's text embedding. Diverse Inversion reveals that the original concept remains easily accessible elsewhere in dense prompt space.
  • Unconditional fine-tuning enables prompt-agnostic unlearning: Fine-tuning the network unconditionally on a concept concentrates the unwanted behavior into the model weights alone, rendering the resulting task vector agnostic to prompt phrasing.
  • Not all U-Net layers need modification: Concept representation is localized enough that zeroing out modifications in early U-Net blocks maintains control-task fidelity while retaining attack resistance.

Key Results

  • Robustness Against Adversarial Prompt Attacks: Under Concept Inversion attacks on Imagenette (Table 2), baseline erasure methods failed dramatically: ESD allowed erased objects to appear 60.1% of the time, UCE 59.4%, and SLD-Med 79.5%. In contrast, the TV-based approach reduced attack success to 0.2% (with standard prompt accuracy dropping to 10.8%).

  • Hard-Prompt Jailbreaks: Against Ring-A-Bell, UnlearnDiffAtk, and P4D adversarial prompts, the proposed TV edit blocked generation of the target styles where seven leading baselines failed (Figure 6, Figure 11).

  • Preserved Model Quality: On MS COCO, TV erasure of Van Gogh achieved an FID of 26.96, virtually matching the unedited base model (26.75) and outperforming Ablating Concepts (27.51) and Negative Prompting (32.57).

Limitations and Future Work

  • Broad vs. Narrow Concepts: TV erasure works exceptionally well on well-defined styles, objects, and identities. For diffuse, broad concepts like "nudity," achieving safety required large edit strengths that dropped MS COCO FID by 31.32%.
  • Collateral Damage to Semantic Neighbors: Erasing a specific artist (Van Gogh) noticeably degrades performance on stylistically adjacent artists (Monet) compared to distant ones (Picasso).
  • Absence of Provable Guarantees: While empirically resilient against current gradient- and inversion-based attacks, the method does not provide a formal mathematical proof against arbitrary future adversarial attacks.

Summary updated

BibTeX
@misc{pham2024prompt,
  author = {Minh Pham and Kelly O. Marshall and Chinmay Hegde and Niv Cohen},
  title = {{Prompt-Agnostic Erasure for Diffusion Models Using Task Vectors}},
  year = {2024},
  eprint = {2404.03631},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.03631},
}
Figure