TL;DR
Diffusion Language Models (DLMs) are naturally brilliant at "fill-in-the-blank" tasks because they read both the past and the future simultaneously, yet they have an Achilles' heel: you have to tell them exactly how many tokens belong in the blank before they start. This paper reveals that DLMs actually "know" the right blank size from their very first step of denoising, though this intuition is buried under a predictable statistical bias. By calibrating away that bias, the authors unlock massive, training-free improvements in code and text infilling—just by listening to the model's initial confidence.
What Problem Does This Paper Address?
Traditional autoregressive language models generate text left-to-right, making "infilling"—generating a missing middle section between an existing prefix and suffix—awkward to engineer. Diffusion Language Models (DLMs) generate text by starting with a canvas of [MASK] tokens and iteratively refining them all at once using bidirectional context. In theory, they are tailor-made for infilling.
In practice, however, DLMs lack an internal "stop button" when filling a gap. While chat models can generate an <eos> (end-of-sequence) token to finish a thought, infilling models require you to hardcode the exact number of [MASK] tokens upfront. Guess too short, and the model truncates its thought; guess too long, and it hallucinates redundant or broken logic (like dividing by zero) just to fill the quota.
Methods
To find the Goldilocks length without retraining the model, the authors introduce CAL (Calibrated Adaptive Length), a lightweight, two-stage inference wrapper:
- First-Step Confidence Probing: Before running the full, multi-step diffusion process, CAL feeds the model a candidate mask length $L$ and runs just a single forward pass—capturing the model's "first guess" probabilities across the masked span. It averages the top-1 token probabilities to get a raw confidence score, $\Phi(L)$.
- Bias Calibration: Raw confidence naturally plummets as mask spans get longer because larger blanks weaken contextual clues. The authors fit a simple double-exponential decay curve, $B(L)$, to a small set of non-ground-truth lengths to model this structural Length Bias. Dividing raw confidence by this baseline yields a clean, signal-to-noise-style metric: $\Phi_c(L) = \Phi(L) / B(L)$.
- Bidirectional Hill-Climbing: Starting from an initial guess $L_{init}$, CAL probes slightly longer and shorter canvases, climbing the calibrated confidence curve until improvements stall. Once it finds the winning length $\hat{L}$, standard iterative denoising begins.
Datasets
CAL is training-free, requiring no training datasets—only a tiny calibration subset (100 excluded samples from HumanEval-Infilling, though ablations show even 3 samples suffice). No new benchmarks are introduced; instead, the authors evaluate across established datasets:
- Code Infilling: HumanEval-Infilling (Single-Line and Multi-Line Python tasks).
- Text Infilling: ROCStories (short narratives), CS Abstracts (academic prose), and Yelp Reviews (informal text), masking 2–8 words per sample.
- Multimodal Infilling: MS COCO image captions (conditioning on both the image and surrounding text, using 50 samples for model-specific calibration).
Key Insights and Ideas
- The "Oracle Peak": At step one of denoising—looking at nothing but
[MASK]tokens framed by a prefix and suffix—the model's average confidence spikes into a local maximum right around the ground-truth token length. DLMs implicitly sense semantic completeness before generating a single final word. - Why Raw Confidence Lies: Without calibration, shorter masks almost always look more confident than longer ones because nearby prefix/suffix tokens tightly constrain adjacent masks. Dividing out this Length Bias transforms a lopsided slope into a sharp, searchable peak.
- Universal Structural Decay: Remarkably, the exact same bias curve $B(L)$ fitted on Python code using LLaDA-8B-Base transfers zero-shot to other code models (DiffuCoder, DreamCoder, using different tokenizers) and directly to English stories, abstracts, and reviews. Length Bias appears to be a fundamental property of masked diffusion geometry rather than a quirk of one dataset.
- Code Peaks Sharper Than Prose: Gains are much larger in code than natural language. Strict syntax narrows valid completions to a tight length window, creating arazor-sharp Oracle Peak, whereas open-ended text allows many valid phrasings of varying lengths, diffusing the signal.
Key Results
- Massive Code Gains: Providing the true "Oracle" length boosts LLaDA-Base Single-Line Pass@1 from ~44.4% to 87.6%, proving length is the primary bottleneck. Using CAL, LLaDA-Base average Pass@1 jumps from 44.8% to 65.4% across four initial lengths ($L_{init} \in \{4, 8, 16, 32\}$). When initialized poorly at $L_{init}=4$, Pass@1 leaps by +47.7 percentage points (22.7% to 70.4%), crushing chat-adapted baselines like DAEDAL (+40.5pp).
- Modest Overhead: Finding the optimal length takes roughly 11 to 18 single-pass probes—adding about 1 second per sample on an A40 GPU—and beats fixed-length baselines even when those baselines are given extra denoising steps to match total compute.
- Text & Multimodal Improvements: Across Stories, Abstracts, and Yelp, CAL consistently lifts generation quality, with gains reaching up to +8.5pp in BLEU-2 and +9.9pp in ROUGE-L (Stories at $L=2$). On MS COCO with multimodal DLMs (LaViDa and LLaDA-V), CAL boosts average BLEU-2 by ~3.1 points.
Limitations and Future Work
- Initialization Range Matters: As the masked span grows very large, the first-step signal decays into background noise. While CAL works well for ~200-token spans if initialized nearby ($L_{init}=200$), starting at $L_{init}=32$ cannot bridge the gap to a 200-token answer.
- Added Latency: The probing phase adds ~1 second per sample in tested setups, and its cost scales with span length and deployment hardware rather than remaining a fixed constant.
- Untested Frontiers: While static calibration transferred surprisingly well across tested text and code domains, arbitrary out-of-distribution transfer and online/unsupervised bias fitting remain untested. Extending CAL to infill multiple simultaneous blanks in one document—perhaps by updating one span's length at a time—is left for future exploration.
Summary updated