Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Constrained Decoding for Diffusion Language Models via Efficient Inference over Finite Automata

About

Constrained decoding is essential for serving LLMs, ensuring that generated outputs follow specific structures such as JSON schema-formatted function calls. Existing systems are designed for autoregressive models and assume left-to-right generation, masking out invalid next tokens at each step. Diffusion language models, however, break this assumption: they sample multiple positions simultaneously from a fully-factorized mean-field distribution at each denoising step. In this paper, we present an exact and tractable algorithm for sampling from the constrained mean-field posterior under any constraint expressible as a finite automaton. Viewing finite automata as graphical models, we obtain tractable representations of the constrained distribution that enable efficient inference. The approach guarantees constraint satisfaction by construction, supports both greedy and sampling-based decoding, and is compatible with parallel and block-wise decoding under arbitrary remasking schedules. Applying depth-reduction techniques from arithmetic circuit theory, we further reduce sampling depth from linear to logarithmic in the sequence length. Empirical evaluations on Dream-7B and LLaDA-8B show substantial accuracy gains across various tasks including function calling (xLAM, BFCL), planning (Sudoku, Countdown), text-to-SQL (Spider), and math reasoning (GSM-Symbolic), with little inference overhead relative to unconstrained decoding. For example, on BFCL-Live, our approach improves Dream-7B's greedy decoding accuracy from 63.9% to 71.5%, and stochastic sampling accuracy from 22.3% to 69.0%, where the unconstrained baseline collapses, with under 5% wall-clock overhead.

Meihua Dang, Stefano Ermon• 2026

Related benchmarks

TaskDatasetResultRank
Function CallingxLAM JSON
Accuracy76.6
8
Function CallingBFCL Live JSON
Accuracy71.5
8
Function CallingBFCL Non-Live JSON
Accuracy85.5
8
Function CallingxLAM Python
Accuracy76.8
8
Function CallingBFCL Live Python
Accuracy69.7
8
Function CallingBFCL Non-Live (Python)
Accuracy83.8
8
Mathematical ReasoningGSM-Symbolic
Accuracy49.6
8
PlanningSudoku
Accuracy92.4
8
PlanningCountdown
Accuracy100
8
SQL GenerationSpider
Accuracy53.6
8
Showing 10 of 12 rows

Other info

Follow for update