Inference-Time-Derisking-in-Masked-Diffusion
risk control for diffusion LLMs
2 min readupdated
Researchers at NYCU-MLLab released the code and two trained linear risk heads (compact modules attached on top of the main model) for REDACT (Risk-Evaluated Decoding At Commit-Time). The repository tackles text generation safety in masked diffusion language models (diffusion LLMs that reconstruct masked text step by step rather than writing strictly left to right). During decoding, REDACT scores the risk of top-K token candidates based on the current noise level and picks a safer path along a single generation trajectory. The checkpoints run on top of the base models GSAI-ML/LLaDA-8B-Base and GSAI-ML/LLaDA-8B-Instruct, whose weights need to be downloaded separately. This release is useful for AI safety researchers and engineers working with diffusion language models.
Key features
- Two specialized modules: a dedicated toxicity checkpoint (for
LLaDA-8B-Base) and an auxiliary jailbreak-resistance module (forLLaDA-8B-Instruct). - Ultra-lightweight architecture: each head contains only 4,385 trainable parameters, takes 4096-dimensional pooled backbone features, and uses 8 noise bins with a 32-dimensional embedding.
- Built-in calibration: the checkpoints already include calibrated thresholds for each noise bin and output a scalar risk score via a softplus function.
- Full reproducible archive: alongside the
bestandlastweights, the release bundles source code, training logs, Hydra configs, andSHA256SUMSchecksums.
What you can do
- Reduce generation toxicity: attach the
time_dependent_mlp_best.pthead toLLaDA-8B-Baseto filter out unwanted tokens directly during diffusion decoding. - Strengthen filter-bypass defenses: pair the auxiliary
time_dependent_linear_best.ptcheckpoint withLLaDA-8B-Instructin jailbreak-resistance evaluation pipelines. - Integrate into your own code: load the lightweight linear head directly via
linear_head.runtimeto get risk scores from precomputed model hidden states.
Example
import torch
from linear_head.runtime import load_linear_checkpoint
head, _ = load_linear_checkpoint("checkpoints/linear_heads/time_dependent_mlp_best.pt", device=torch.device("cpu"))
# features: [batch, 4096], rho_idx: [batch] из диапазона [0, 7]
with torch.no_grad():
risk = head(features, rho_idx)["risk"]
Read more
DetailsValidation (at a target TPR of 0.95): for the toxicity checkpoint (epoch 23),
macro_fpr_at_tpr = 0.0843; for the jailbreak module (epoch 59), it is 0.4660.Environment: Linux, Python >= 3.12, CUDA 13.0 (targeted at Hopper/H200 GPUs, installed via
uv sync --extra cu130).Limitations: this is a research proxy tool and does not guarantee completely safe text; checkpoints for Dream and reward models are not included in the release.
License: the source code is distributed under MIT, while no separate license is specified for the weights in the archives.










Comments