CGCE: Classifier-Guided Concept Erasure in Generative Models

Viet Nguyen, Vishal M. PatelarXiv 2025 · DOI

Abstract

Generative models for images and videos face significant safety risks from producing unsafe content. Current mitigation strategies either degrade model utility through weight editing or are easily bypassed by adversarial attacks. We present Classifier-Guided Concept Erasure (CGCE), a training-free, plug-and-play framework that steers text embeddings away from harmful concepts at inference time. CGCE achieves state-of-the-art robustness across multiple modalities while preserving the original model's creative quality for safe prompts.

Introduction

The rapid advancement of Text-to-Image (T2I) and Text-to-Video (T2V) models has introduced risks regarding the generation of "unsafe" content, including nudity, copyrighted styles, and specific objects. Existing solutions generally fall into two categories: model fine-tuning and inference-time filtering. Fine-tuning is computationally expensive and often leads to "utility degradation," where the model loses performance on benign prompts. Conversely, training-free filters are often fragile and susceptible to adversarial "red-teaming" attacks.

CGCE addresses these challenges by operating in the text embedding space, providing a robust yet non-destructive safeguard that maintains the integrity of the underlying generative model.

Methodology

CGCE utilizes a three-stage pipeline to identify and redirect harmful prompts without altering the generative model's weights.

The three-stage CGCE pipeline: Synthetic Data Generation, Classifier Training, and Concept Erasure via iterative refinement.
  1. Synthetic Data Generation: Large Language Models (LLMs) generate pairs of semantically similar "safe" and "unsafe" prompts.
  2. Lightweight Classifier Training: A small cross-attention classifier is trained on these prompt embeddings to identify tokens associated with unsafe concepts.
  3. Concept Erasure (Safeguard + Refiner): During inference, the classifier evaluates the user prompt. If flagged as unsafe, a "Refiner" uses gradient descent to iteratively modify the text embedding, steering it toward a safe region of the embedding space.

Because CGCE modifies the input embeddings rather than the model parameters, it is highly portable. A classifier trained on CLIP embeddings can be applied to any model using the same encoder, such as Stable Diffusion or FLUX.

Experimental Results

The framework was evaluated against standard and adversarial benchmarks, including nudity removal (I2P, SixCD), artistic style erasure (Van Gogh), and video safety (SafeSora).

Visual comparison of CGCE against baseline methods across nudity, art, and object erasure tasks in both image and video models.

Robustness and Utility

On the SD-v1.4 backbone, CGCE reduced the Attack Success Rate (ASR) on the SixCD nudity benchmark from 82.13% to just 2.47%, outperforming weight-editing methods like ESD. Crucially, CGCE maintains "zero utility loss"; metrics like FID and CLIP scores on the COCO-30K dataset remained identical to the original model, as safe prompts are passed through without modification.

Efficiency and Versatility

Training the CGCE classifier is highly efficient, requiring approximately 440 seconds on a single A6000 GPU—nearly 10x faster than popular fine-tuning alternatives. The method's architecture-agnostic nature allowed successful deployment on modern high-performance models, including FLUX.1-dev, SD-v3, and video generators like HunyuanVideo and CogVideoX.

Discussion and Limitations

CGCE demonstrates that safety can be treated as an optimization problem in the embedding space. By using token importance weighting, the system performs "surgical" refinement, preserving the context (background, lighting) of a prompt while erasing only the harmful concept.

However, some limitations remain. The refinement process relies on a task-specific step size ($\eta$), which currently requires manual tuning to balance erasure robustness and image quality. Additionally, the iterative nature of the Refiner adds a minor overhead to inference time. Future work will focus on automated hyperparameter tuning and expanding the diversity of synthetic training data to cover more complex adversarial edge cases.

Conclusion

CGCE provides a powerful, lightweight alternative to model editing for concept erasure. By decoupling safety from model weights, it offers a scalable and robust solution for the responsible deployment of large-scale generative models across various modalities.

Summary updated

BibTeX
@misc{nguyen2025cgce,
  author = {Viet Nguyen and Vishal M. Patel},
  title = {{CGCE: Classifier-Guided Concept Erasure in Generative Models}},
  year = {2025},
  eprint = {2511.05865},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.05865},
}
Figure