Robust Concept Erasure Using Task Vectors

Minh Pham, Kelly O. Marshall, Chinmay Hegde, Niv Cohen

TL;DR

Researchers from NYU propose a more robust way to "sanitize" text-to-image models by using Task Vectors to erase undesirable concepts unconditionally. By shifting from prompt-specific filtering to global weight-space edits and introducing a tuning method called Diverse Inversion, they create models that are significantly harder to "jailbreak" with adversarial prompts while preserving general image-generation quality.

What Problem Does This Paper Address?

Text-to-image (T2I) models like Stable Diffusion are incredibly powerful but can be coaxed into generating "unsafe" content, such as copyrighted art styles, NSFW images, or deepfakes. Current safety methods typically focus on input-dependent erasure. They try to "forget" a concept only when the user explicitly asks for it (e.g., "a painting by Van Gogh").

The authors demonstrate that this creates a false sense of security. Adversaries can use techniques like "Concept Inversion" or "Ring-A-Bell" to find alternative prompt embeddings—often far away from the original concept name in vector space—that still trigger the forbidden generation. Essentially, existing methods poke a small hole in the model's capability, but leave the rest of the "unsafe" landscape untouched.

Figure 2. Input-independent vs. Input-dependent concept era- sure. Illustration of the probability distribution to generate the target concept “Van Gogh” across the input space. Images fea- turing the “Van Gogh” concept are framed in red, other images are framed in green. Input-dependent concept erasure leaves high probability areas of generating the target concept, while input- independent erasure methods erase the target concept across the entire input space. (Top) In generative T2I models, the proba- bility of generating a specific concept is high for prompt embed- dings close to the concept name, but high generation probability is possible also for prompts embedding in a significant distance from it. (Middle) Input-dependent concept-erasure attenuates the generation probability within a small environment of the given prompt but leaves a high probability of generating the erased con- cept further away from the prompt embedding. (Bottom) Input- independent erasure attenuates the probability of generating the target concept more consistently across the input space.

Methods

The paper introduces a two-pronged approach to achieve unconditional safety:

  1. Task Vectors (TV): Instead of fine-tuning a model to not generate a concept, the authors first fine-tune a model to only generate the target concept. The difference between these new weights and the original weights is the "Task Vector." By subtracting this vector (scaled by a factor $\alpha$) from the original model, they perform a prompt-agnostic edit in the weight space.
  2. Diverse Inversion: A major challenge with Task Vectors is knowing how "hard" to edit (the value of $\alpha$). Too low, and the concept remains; too high, and the model's general utility breaks. The authors propose Diverse Inversion, an optimization process that finds a wide variety of "hidden" prompts that all trigger the target concept. This diverse set acts as a robust validation suite to find the optimal $\alpha$ and identify which specific layers of the model (like the first few blocks of the U-Net) are most effective to edit.

Datasets

The researchers evaluated their approach using:

  • MNIST: A toy setup to rigorously test the concept of "unconditional safety" in a low-dimensional space.
  • Stable Diffusion 1.4: The primary testbed for large-scale T2I erasure.
  • Target Concepts: "Van Gogh" (style), "French Horn" (object), "Nudity" (safety), and others like "Brad Pitt" or "garbage truck."
  • Control Tasks: To ensure the model still worked for general tasks, they measured performance on unrelated prompts like "art by Picasso" or "Angelina Jolie."

Key Insights and Ideas

  • Global vs. Local Erasure: Input-dependent methods are like putting a "Do Not Enter" sign on one specific door. Task Vectors are more like removing the room entirely from the building's blueprint.
  • The Vulnerability of Proximity: As shown in Figure 1, methods like Erased Stable Diffusion (ESD) fail as soon as an adversarial prompt moves slightly outside the narrow similarity range used during training.
  • Diversity is a Defense: When tuning the erasure strength, relying on a single prompt is insufficient. By forcing the "Diverse Inversion" to find embeddings that are both far from the concept name and far from each other, the researchers create a much harder "stress test" for the model.
  • Layer Pruning: They discovered that you don't need to edit the whole model. Pruning the Task Vector to affect only specific U-Net blocks can maintain a better trade-off between erasing the bad stuff and keeping the model useful for everything else.
Qualitative results showing that while standard models and weakly edited models can be bypassed by Concept Inversion, the TV-based approach remains robust.

Key Results

  • Adversarial Robustness: In tests against the "Ring-A-Bell" attack—which successfully bypassed seven other leading erasure methods—the Task Vector approach successfully blocked the generation of the erased concepts (see Figure 6 in the paper).
  • Quantitative Success: On object erasure tasks, the TV method achieved an average accuracy of near 0% for the erased concept even under attack, whereas methods like ESD saw accuracy jump back up to ~60% when faced with adversarial inputs (Table 2).
  • Utility Preservation: By using the trade-off curves generated via Diverse Inversion (Figure 4), the authors could select parameters that erased the target concept (low Erasure Score) while keeping the model's performance on unrelated "Control Tasks" high.
Figure 4. The trade-off between erasure score and control task performance. We plot the robustness measured according to era- sure score, lower is better, and control task performance, higher is better, for models erased with different TV edit strengths (pa- rameterized by α). Our Diverse Inversion method allows us to ex- plore the trade-off between concept erasure robustness and model utility when editing different subsets of the model parameter. We discover that different target concepts may benefit from editing different subsets of model parameters.

Limitations and Future Work

  • No Provable Guarantees: The authors admit that while their method is robust against current attacks, it's impossible to prove it will be safe against all future unknown adversarial methods.
  • Performance Trade-offs: High-strength erasure can still degrade the model's ability to follow complex prompts or generate high-quality images in unrelated styles.
  • Scalability to Many Concepts: It is currently unclear how the model behaves when you try to erase dozens or hundreds of concepts simultaneously; the cumulative weight edits might eventually lead to catastrophic forgetting of general knowledge.
  • Modality Expansion: The current work focuses on T2I; extending these "input-independent" safety concepts to Large Language Models (LLMs) remains an open challenge.

Summary updated

BibTeX
@misc{pham2024robust,
  author = {Minh Pham and Kelly O. Marshall and Chinmay Hegde and Niv Cohen},
  title = {{Robust Concept Erasure Using Task Vectors}},
  year = {2024},
  eprint = {2404.03631},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.03631},
}
Figure