# CURE: Counterfactual Unsafe-token Re-masking for Diffusion Large Language Model Test-time Alignment

*Lichao Wang, Mingquan Zhang, Xian Zhang, Juntao Dai, Chi Liu, Yaodong Yang, Jingwei Yi*

[NeurIPS page](https://neurips.cc/virtual/2026/poster/151876) · [OpenReview](https://openreview.net/forum?id=XF2UgJwAIj) · [Open on the map](../papers.html#p151876)

Category: [AI Safety, Security & Alignment](../pcat/16.md) › [LLM Safety Alignment](../pgroup/208.md) · Type: new method · Keywords: diffusion language models, test-time alignment, safety value model, counterfactual token re-masking, jailbreak defense, efficiency

Areas: [Safety & Security](../areas/safety.md) › Safe Alignment › Steering Safety Across Modalities

## Summary
CURE is a test-time alignment method that selectively re-masks risk-inducing tokens in diffusion language models to prevent unsafe responses while preserving utility and efficiency.

## Explained to a 5-year-old
When a computer talks, it sometimes says bad things. The computer works step by step, and sometimes a harmless word can lead to a bad answer. The researchers added a checker that looks at each step and removes the risky words before they cause trouble. This helps keep the answers safe while still letting the computer answer normal questions. It does this without changing the computer’s main brain.

## Explained to a 5-year-old, longer
A computer that writes text uses a process called diffusion, where it slowly cleans up a messy picture of words until the final sentence appears. Sometimes, even a small word that looks safe can push the computer toward writing something dangerous. The researchers created a helper that watches each step of this cleaning process and decides if a word might cause trouble. If it thinks a word is risky, the helper hides it again so the computer can rewrite it later. This way, the computer can still answer normal questions correctly, but the dangerous words never make it into the final answer. The helper does not need to change the computer’s main brain, so it works quickly and uses only a little extra computer power. It also works on many different computer models that write text, and it helps them avoid being tricked by clever attacks. The method is simple enough that other people can use it easily, and it keeps the computer’s normal abilities intact while making it safer.

## For a technical reader
CURE is a test-time alignment technique for diffusion language models that does not require retraining the base model. It introduces a time-conditioned safety value model that predicts whether a partially denoised state will lead to an unsafe output. During inference, CURE creates counterfactual views of the denoising trajectory, isolates or removes risky tokens, and re-masks only those that are likely to cause unsafe completions. This token-level intervention preserves the model’s original capabilities on benchmarks like MMLU and GSM8K while dramatically lowering attack success rates. The method adds only a modest computational overhead of about 0.84 TFLOPs per generation.

## Problem
Diffusion language models can generate unsafe text when given harmful prompts, and existing defenses often require model training, extra inference passes, or coarse regeneration, making fine-grained safety control difficult.

## Method
The approach trains a time-conditioned safety value model to predict whether a partially denoised state will lead to an unsafe final response. At inference time, it creates counterfactual views that isolate or remove tokens, estimates their contribution to future unsafe output, and re-masks only high-risk tokens for later rewriting, leaving the base model unchanged.

## Results
The approach reduces macro-average attack success rate from 47.20% to 1.36% across three diffusion language models and five jailbreak benchmarks, while preserving performance on MMLU and GSM8K and adding only 0.84 extra TFLOPs.

## Contributions
It introduces a counterfactual value-driven safety model that can be applied at test time without modifying the base diffusion language model, and provides a fine-grained token-level re-masking mechanism that improves safety while maintaining utility and efficiency.

## Research questions this paper is counted under

- [How can we reliably prevent large language models from generating harmful content across diverse contexts and modalities?](../q/24.md)

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. [Suggest a correction](../feedback/?on=p/151876)
