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.
Methods
To build Corrective Diffusion Language Models (CDLMs), the authors introduce a targeted post-training recipe using mixture noise:
- Standard Masking: Randomly replace a subset of clean tokens with
[MASK], just like standard MDLM training. - Visible Corruption: Take the remaining visible tokens and randomly swap a small fraction (probability $\alpha = 0.1$) with incorrect vocabulary tokens.
- 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.
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.
- 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