NeurIPS 2026Coming to NeurIPS in Sydney?Explore papers, orals & directions

Keep It CALM: Analyzing the Limits of Global Unsafety in Text-to-Image Generation

NaHyeon Park, Minhyun Lee, Hyunjung ShimNeurIPS 2026

TL;DR

Many lightweight safety filters for text-to-image AI try to block harmful outputs by erasing a single, universal "unsafe" region from the model's vocabulary space—an approach that either misses diverse threats or accidentally wrecks harmless prompts like medical scenes. By studying the geometry of text embeddings, the authors show why "unsafety" isn't one neat target you can cleanly delete. Instead, they introduce CALM, a training-free method that acts like a surgical GPS: it detects the specific type of harm in a prompt and gently nudges only the offending words toward their safe, benign counterparts.

What Problem Does This Paper Address?

Keeping text-to-image models (like Stable Diffusion or FLUX) from generating explicit, violent, or harmful images is tough. Retraining massive models to "unlearn" bad concepts is expensive and rigid, which makes training-free, inference-time safeguards deeply appealing. You just freeze the generator and steer the prompt away from danger on the fly.

Most existing inference-time safeguards assume that "unsafety" is a single, compact geometric object—like a global toxic subspace or direction—that you can calculate once and subtract from every prompt. The authors ask a fundamental question: Does a single "unsafe" region actually exist in text embedding space?

They discover a painful coverage–selectivity trade-off. Harmful concepts (hate, self-harm, sexual content, violence) are geometrically scattered. If you carve out a small subspace, you miss many harmful categories (poor coverage). If you carve out a huge subspace to catch everything, you inevitably slice through "safety-adjacent" benign prompts—ruining legitimate requests for historical battle scenes, boxing matches, or medical stitch-training pads (poor selectivity).

Coverage diagnostics showing that unsafe categories lack shared compact structure and transfer poorly when pooled.

Methods

Instead of asking what to globally erase, CALM (Counterfactual Adaptive Local Modulation) asks where to locally move. Rather than lumping bad words into a giant deletion zone, CALM uses a fixed bank of matched unsafe–benign counterfactual pairs generated once beforehand by an LLM. Each pair acts as a local compass pointing from a specific harmful concept toward its safe equivalent.

Figure 1: 2D illustration of text embedding space

At generation time, CALM works in three lightweight, training-free steps:

  1. Prompt Routing: It checks if the user's prompt sits closer to the unsafe anchors than their benign counterparts, routing the prompt to at most $K=3$ active harm categories. If none trigger, CALM does nothing, leaving safe prompts untouched.
  2. Text-Side Correction: Rather than altering the whole prompt, it checks individual word tokens. Only tokens that cross into the "unsafe" half-space of the routed categories are minimally projected across the boundary toward the benign side.
  3. Residual-Side Correction: Because harmful visuals can still sneak in during image denoising, CALM applies the same counterfactual logic to the diffusion model's classifier-free guidance residual during the first 30% of denoising steps—subtracting noise components that align with the routed unsafe directions.

Datasets

Because CALM is training-free, no datasets are used for training. For evaluation and geometric diagnostics, the authors use:

  • Adversarial & Harmful Benchmarks: Ring-A-Bell, UnlearnDiff-Atk, and MMA-Diffusion to test resilience against explicit and jailbreak-style prompts.
  • Multi-Harm Benchmarks: I2P and ViSU to evaluate suppression across seven distinct harm categories (harassment, hate, illegal activity, self-harm, sexual, shocking, and violence).
  • Benign Utility: 10k prompts from COCO to ensure everyday image quality and prompt adherence remain intact.
  • Diagnostic Reference Sets: Stanford Dogs breeds (as a control group for geometrically coherent families) alongside custom lexical sets of unsafe, general benign, and safety-adjacent benign concepts. No new standalone benchmark dataset is introduced, though a reusable LLM-generated counterfactual anchor bank is created.

Key Insights and Ideas

  • "Unsafe" is no more unified than random safe topics: When comparing subspace angles between different unsafe categories, they share no more geometric overlap than completely unrelated benign topics—looking nothing like coherent families (such as dog breeds). Pooling them together doesn't find a "core of evil"; it just Mashes unrelated vectors together.
  • The neighborhood entanglement trap: A linear classifier easily separates unsafe terms from everyday benign ones, but 27% of safety-adjacent benign concepts (like combat sports or emergency medicine) trigger false positives compared to just 3.4% of general benign terms. Harm and harmlessness share the same street; bulldozing the block destroys both.
  • Direction matters more than deletion: Simply switching from erasing unsafe vectors to steering along unsafe-to-benign counterfactual vectors preserves local semantic neighborhoods far better—enabling edits like putting clothes on a classical statue without warping the rest of the room.

Key Results

  • Stronger Suppression on SD-v1.4: CALM achieves the lowest Attack Success Rate (ASR) across all major attack benchmarks—dropping ASR on Ring-A-Bell from 0.797 (unprotected) to 0.076, and on MMA-Diffusion from 0.962 down to 0.182 (beating strong baselines like SAFREE at 0.603 and UCE at 0.414).
  • Preserved Benign Quality: On COCO, CALM keeps image quality (FID 24.68) virtually identical to unmodified SD-v1.4 (24.53) while achieving the highest prompt-adherence score (CLIP-T 0.309) among all tested safeguards.
  • Plug-and-Play Backbone Transfer: Re-embedding the anchor bank into newer architectures (SDXL, FLUX.1, SANA1.5, and OmniGen2) cuts unsafe ASR by 41% to 69% across the board without tanking prompt fidelity.
  • Multi-Harm & Speed: On I2P, CALM lowers the average VLM-judged unsafe rate from 0.378 to 0.159. It runs at 7.69 sec/image on SD-v1.4—comparable to SAFREE (7.75s) and much faster than evaluator-guided STG (17.70s).

Limitations and Future Work

  • Not a silver bullet against adaptive attackers: Adversarially optimized prompts (like MMA-Diffusion) remain tougher to block than standard prompts, and white-box attackers who know CALM's exact anchor bank or routing thresholds could potentially craft bypasses.
  • Text-centric geometry: The geometric investigation focuses strictly on the frozen text-encoder space; extending this controlled analysis into the internal latent representations of the diffusion denoiser itself is left as a natural next step.

Summary updated

Abstract

Training-free safeguards for text-to-image generation often rely on a reusable safety signal, such as an unsafe direction or global toxic subspace, applied broadly across prompts. We provide a controlled geometric analysis of this global-unsafety assumption and reveal a consistent coverage-selectivity trade-off: compact unsafe subspaces fail to cover heterogeneous unsafe semantics, whereas broader aggregation increasingly distorts safety-adjacent benign prompts. Motivated by this finding, we propose CALM (Counterfactual Adaptive Local Modulation), a training-free safeguard that replaces uniform global removal with prompt-local counterfactual correction. Using matched unsafe-benign anchors, CALM routes each prompt to active unsafe categories, minimally edits only violating token representations toward the safe side, and suppresses positively aligned unsafe residual components. Across broad evaluation, CALM significantly improves unsafe content suppression while preserving benign utility, demonstrating that local counterfactual correction provides a more selective alternative to global unsafe signal removal.
BibTeX
@inproceedings{park2026keep,
  author = {NaHyeon Park and Minhyun Lee and Hyunjung Shim},
  title = {{Keep It CALM: Analyzing the Limits of Global Unsafety in Text-to-Image Generation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=VjTAXEfv0N},
}
Figure