Corrective Diffusion Language Models

Shuibai Zhang, Fred, Yiheng Zhang, Jin Pan, Grigorios ChrysosNeurIPS 2026

TL;DR

Unlike left-to-right autoregressive models, diffusion language models can look at a whole draft at once—making them theoretically ideal for editing text in place. Yet in practice, they fail to fix mistakes because standard training ignores visible words, leaving the model blind to typos right in front of it. By training models to catch and fix corrupted visible tokens—while crucially leaving clean tokens alone—researchers unlock genuine self-correction and boost generation quality across code and math.

What Problem Does This Paper Address?

Autoregressive models (like GPT) write strictly left-to-right; if they make a mistake on line three, they cannot go back and patch just that word without regenerating everything that follows. Masked Diffusion Language Models (MDLMs) work differently: they start with a sequence of [MASK] tokens and iteratively fill them in across the whole document in parallel.

To refine an existing draft, an MDLM checks its own confidence at every position, re-masks tokens that look suspicious (falling below a confidence threshold $\tau$), and re-predicts them. In theory, this makes MDLMs natural-born editors. In practice, off-the-shelf MDLMs are terrible proofreaders. Because standard MDLM training calculates loss only on [MASK] positions, the model never receives a learning signal on unmasked, visible words. As a result, it becomes blindly confident in whatever is already on the page—assigning nearly identical probabilities to valid code and blatant bugs.

Figure 1: An illustrative example in which the model is equally confident in the correct variable (i) and the undefined bug (j). Global metrics (Average/Min) fail to detect this failure mode.

Methods

To build Corrective Diffusion Language Models (CDLMs), the authors introduce a targeted post-training recipe using mixture noise:

  1. Standard Masking: Randomly replace a subset of clean tokens with [MASK], just like standard MDLM training.
  2. Visible Corruption: Take the remaining visible tokens and randomly swap a small fraction (probability $\alpha = 0.1$) with incorrect vocabulary tokens.
  3. Selective Supervision (The Secret Sauce): Compute the cross-entropy loss against the original clean tokens only at the masked positions and the corrupted visible positions.
Figure 3: Comparison of training supervision in MDLM and CDLM and its implication for corrective behavior. Cross-marked boxes denote masked tokens, and beige boxes denote visible inputs. Standard MDLMs apply supervision only to masked tokens, leaving visible tokens unsupervised even when incorrect. CDLM explicitly supervises corrupted visible tokens and encourages lower confidence on unreliable content. This supervision difference enables error-aware confidence and targeted, in-place correction during iterative refinement.

While mixing masking and random token swaps isn't new (frameworks like BERT and GIDD do this), those older methods supervise all positions, including clean visible tokens. CDLM deliberately leaves clean visible tokens unsupervised, aligning the training signal directly with confidence-gated "remask-then-repredict" decoding. Because only the loss mask changes, this works as lightweight post-training (e.g., 2,000 steps) on existing models.

Datasets

  • Code Revision Benchmark (CRB) [New]: Existing coding benchmarks only test generating code from scratch given a prompt. Built on top of HumanEval(+), MBPP(+), CRB takes working canonical programs and injects 1 to 5 length-preserving token swaps across operators (== $\to$ !=), identifiers, or numeric literals. Crucially, every corrupted program is executed against unit tests—only genuine, test-failing bugs make it into the benchmark.
Figure 2: CRB corruption types. A canonical program (left, HumanEval/31) is corrupted by type- preserving token replacements of three kinds (right; original token in blue, replacement in red). A corrupted program enters CRB only if it fails the tests.
  • Post-Training Corpora: Nemotron-SFT-Code (for 0.5B and 8B code experiments) and Nemotron-Math-v2 (for 16B math experiments).
  • From-Scratch Evaluation: HumanEval(+), MBPP(+), the MATH suite (including MATH-500), and ParallelBench (evaluating parallel decoding under high uncertainty).

Key Insights and Ideas

  • Supervising clean tokens kills iterative refinement: You might think supervising clean visible tokens ("teaching the model to copy good text") is harmless. It isn't. Adding a clean-token loss makes the model overconfident everywhere, causing fewer bugs to drop below the remasking threshold $\tau$. When tested, models with clean-token supervision actually got worse with extra refinement steps (Pass@1 dropped from 0.204 to 0.182 over four steps), whereas CDLM steadily improved.
  • Decoupling error detection from prediction certainty: On LLaDA-8B, when CDLM encounters a corrupted token, the probability assigned to that wrong token collapses to 0.192, while its top predicted replacement stays sharp at 0.866. In plain English: the model knows that the current word is wrong AND knows what should replace it.
  • Not just memorizing random noise: Even when CRB bugs are replaced with "plausible" errors—drawn from the base model's own top-5 predictions rather than uniform random swaps—CDLM retains 72% of its multi-step repair advantage over standard MDLM fine-tuning.

Key Results

  • 0.5B Controlled Code Repair: Fine-tuning Open-dCoder-0.5B under matched compute and data, CDLM beats standard MDLM across the board—widening the confidence gap between clean and buggy tokens and lifting 4-step CRB Pass@1 to 0.286 vs. MDLM's 0.243 across seeds (while actually remasking fewer tokens in step one).
  • Scaling to 8B: Applying LoRA post-training to LLaDA-8B-Base (a scratch-trained MDLM) boosts single-error localization (Hit@1) on HumanEval from 0.152 (MDLM) to 0.608 (CDLM), and lifts single-step Pass@1 from 0.600 to 0.725.
  • Better From-Scratch Generation: Even when there is no corrupted input, error-aware confidence helps models clean up their own drafts during parallel decoding. At 16B (LLaDA2.0-mini), CDLM lifts high-entropy ParallelBench accuracy under remasking from 0.45 (MDLM) to 0.62 (beating the base model's 0.56), and pushes MATH-500 accuracy to 47.8% (vs. 44.6% for vanilla SFT).

Limitations and Future Work

  • Fixed-length straitjacket: Remask-then-repredict decoding operates on a fixed number of tokens. It cannot insert missing lines or delete extra tokens, which is why CRB is restricted to 1-to-1 length-preserving swaps.
  • Can't fix total trainwrecks: When asked to repair a model's own failing from-scratch generations—which differ from canonical solutions by a median of 59 tokens—all methods stay at the floor. Localized editing fixes localized bugs, not fundamentally broken logic.
  • Inconsistent from-scratch gains across scales: While CDLM helps from-scratch HumanEval(+) at 0.5B and MATH at 16B, both fine-tuned arms drop below the base model on MBPP(+) at 0.5B, and neither objective improves from-scratch generation at 8B. Future directions were not explicitly discussed in the main text beyond noting the need for safeguards against incorrect outputs.

Summary updated

Abstract

While Diffusion Language Models (DLMs) are theoretically well-suited for iterative refinement due to their non-causal structure, off-the-shelf masked diffusion language models (MDLMs) often fail to reliably revise incorrect tokens in practice. The key challenge lies in the model's inability to distinguish between correct and erroneous tokens in a visible sequence. Standard MDLM training supervises only masked positions, undermining the effectiveness of refinement guided by confidence. Based on this observation, we study corrective behavior in DLMs, defined as the ability to assign lower confidence to incorrect tokens and iteratively refine them while preserving correct content. Under matched compute and data, we show that conventional masked-diffusion fine-tuning induces much less of this capability than a correction-oriented post-training principle that explicitly supervises visible corrupted tokens, which enables discriminative confidence and targeted refinement. We further find that also supervising clean visible tokens, as in BERT- or GIDD-style training, stops remask-based refinement from improving with additional steps. To evaluate corrective behavior, we introduce the Code Revision Benchmark, a controllable and executable benchmark for assessing error localization and in-place correction. The effect transfers from a 0.5B model to LLaDA-8B and persists, with a smaller margin, when corruptions are drawn from the base model's own most plausible predictions. Beyond in-place correction, the same error-aware confidence also makes parallel decoding more effective. In HumanEval(+) code completion at 0.5B, mathematical reasoning at 16B, and high-entropy parallel decoding with remasking (ParallelBench), models trained with our objective outperform standard masked-diffusion fine-tuning under matched compute, and outperform the base model on HumanEval(+), MATH, and the high-entropy ParallelBench average; at 8B, neither objective improves from-scratch generation over the base model. Code, checkpoints and the CRB data are available at https://github.com/zhangshuibai/CDLM.
BibTeX
@inproceedings{zhang2026corrective,
  author = {Shuibai Zhang and Fred and Yiheng Zhang and Jin Pan and Grigorios Chrysos},
  title = {{Corrective Diffusion Language Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=Gteb9OmhzF},
}
Figure