TL;DR
This paper identifies a fundamental "trajectory bias" in current constrained decoding methods for Masked Diffusion Language Models (MDLMs). The authors introduce TWISTER, a Sequential Monte Carlo (SMC) decoder that uses "automaton twists" to correct this bias, ensuring that generated text follows the model's true distribution while strictly adhering to structural constraints like JSON or specific regex patterns.
What Problem Does This Paper Address?
Masked Diffusion Language Models (MDLMs) generate text by starting with a fully masked sequence and repeatedly unmasking tokens. When we want these models to follow specific rules (e.g., "output only valid JSON"), we use constrained decoding.
Recent state-of-the-art methods use finite automata (DFAs) to ensure that each unmasking step is "exact"—meaning the tokens chosen at step $t$ are guaranteed to be part of at least one valid complete sequence. However, this paper proves a surprising result: local exactness does not equal global exactness.
Because MDLMs re-evaluate the entire sequence at every step (reconditioning the denoiser), the model's estimate of "valid future paths" changes as more tokens are revealed. This causes the decoding process to "tilt" away from the model's true intended distribution, leading to trajectory bias. Even if every individual step looks correct, the final sequence is sampled from a distorted version of the model's logic.
Methods
The authors propose TWISTER (Automaton-Twisted Sequential Monte Carlo) to solve this.
- Characterizing the Bias: They derive an exact mathematical expression for the trajectory bias, showing it is a product of "re-freezing ratios"—the difference between how a "frozen" denoiser at step $t$ views the future versus how the updated denoiser at step $t+1$ views it.
- Sequential Monte Carlo (SMC): TWISTER maintains multiple candidate sequences (particles) simultaneously.
- The "Twist": Instead of just sampling, TWISTER uses a Feynman–Kac correction. It calculates a "twist" (an incremental potential) for each particle based on the ratio of partition sums ($Z$). These partition sums represent the total probability mass of all valid ways to complete a sequence.
- Efficient Computation: Crucially, the authors show that these twists can be computed using the same dynamic programming quantities (from Forward-Filtering Backward-Sampling) already used for the basic constrained decoding, making the correction computationally feasible.
Datasets
The researchers evaluated TWISTER across several open-weight MDLMs:
- Models: OWT-130M, DREAM-7B (Base and Instruct), DREAMCODER-7B-Instruct, and LLaDA-8B (Base and Instruct).
- Benchmarks:
- Synthetic Regex Constraints: Used to measure trajectory bias (Total Variation Distance) against a ground-truth "rejection sampling" baseline.
- JSON-Mode-Eval: A dataset of 100 prompts requiring complex JSON schema adherence.
Key Insights and Ideas
- The "Re-freezing" Problem: In MDLMs, the denoiser is "frozen" during a single sampling step to make the math tractable. When we move to the next step, we "re-freeze" it at a new state. This jump is the source of the bias.
- Doob h-transform: The paper frames the ideal constrained decoder as a "Doob h-transform" of the model's native path law. TWISTER is the first MDLM decoder designed to target this unbiased path law.
- Bias is Structural: The authors show that trajectory bias is not a bug in specific implementations but a structural property of how MDLMs interact with local constraints.
Key Results
- Bias Reduction: As shown in Figure 1, TWISTER significantly reduces the Total Variation Distance (TVD) compared to the previous state-of-the-art (Dang & Ermon). As the number of denoising steps increases, the bias in standard methods grows, while TWISTER keeps the distribution close to the noise floor of the true model.
- Constraint Satisfaction: In the JSON-Mode-Eval task, TWISTER achieved 100% parse validity across all tested models, proving that correcting for trajectory bias does not break the hard constraints.
- Efficiency: While SMC is naturally more expensive than single-sequence decoding, TWISTER is parallelizable. The total automaton cost scales linearly with the number of particles ($K$).
Limitations and Future Work
- Computational Overhead: Using $K$ particles in SMC increases the number of denoiser queries, which is the main bottleneck in diffusion models.
- Regular Languages Only: The current implementation relies on DFAs, meaning it handles regular languages (regex, fixed JSON schemas). Extending this to Context-Free Grammars (CFGs) for full programming language syntax is a logical next step.
- Particle Count: The paper notes that while $K=4$ or $K=8$ particles help significantly, very complex constraints might require more particles to fully converge to the unbiased distribution.
Summary updated