Abstract
Large language models (LLMs) are increasingly used to generate executable outputs, JSON objects, and API calls, where a single syntax error can make the output unusable. Constrained decoding enforces validity token-by-token via masking and renormalization, but it can distort generation when the model assigns low probability mass to valid continuations, pushing decoding toward locally valid yet semantically incorrect trajectories. We propose Draft-Conditioned Constrained Decoding (DCCD), a simple two-step, training-free inference procedure that decouples semantic planning from structural enforcement: an unconstrained draft is generated first, and constrained decoding is then applied, conditioned on this draft, to guarantee validity. We analyze DCCD through a KL-projection view, showing that draft conditioning increases feasible mass and reduces the cumulative "projection tax" induced by hard constraints. Across structured reasoning benchmarks, DCCD improves strict structured accuracy by up to +24 percentage points over standard constrained decoding (e.g., 15.2% to 39.0% on GSM8K with a 1B model), and enables smaller model pairs to match or exceed much larger constrained baselines.
The Challenge of Structured Generation
LLMs are increasingly deployed as "engines" in software pipelines, requiring them to output machine-readable formats like JSON or SQL. In these contexts, a single missing bracket can render an entire output useless. To prevent this, Constrained Decoding (CD) is often employed to mask out invalid tokens during generation, ensuring perfect syntax.
However, this approach imposes a "hidden tax." When a model is forced to follow a strict schema from the very first token, it often assigns low probability to required formatting characters (like { or [). Forcing the model to select these low-probability tokens distorts its internal state, leading to a "trajectory bias." The model becomes syntactically perfect but logically incoherent; it gets so distracted by the "paperwork" of formatting that it fails to solve the underlying reasoning problem.
Decoupling Planning from Enforcement with DCCD
DCCD addresses this by decoupling semantic planning from structural enforcement through a two-step, training-free procedure:
- Draft Generation: The model generates an unconstrained, free-form response (a "draft"). This allows the model to utilize its full reasoning capabilities without the pressure of schema constraints.
- Conditioned Constrained Generation: The model generates the final structured output, now conditioned on the draft from Step 1. Because the model has already "solved" the problem in the draft, the probability it assigns to valid structured tokens (the "feasible mass") increases significantly.
The researchers also introduce a Best-of-K variant, where multiple drafts are generated, and the final output is selected based on which one incurred the least "projection tax"—the cumulative log-probability of the forced constraints.
Performance and Efficiency
The performance gains from DCCD are substantial across various reasoning benchmarks, including GSM8K, MATH500, and FOLIO. On the GSM8K benchmark, DCCD improved the strict structured accuracy of a 1B model from 15.2% to 39.0%.
Key findings from the evaluation include:
- Consistency Across Scales: Benefits were observed from 1B to 14B parameter models, with DCCD consistently outperforming state-of-the-art constrained decoding.
- Parameter Efficiency: A small model (e.g., 3B) using DCCD can match or exceed the performance of a much larger model (e.g., 14B) using standard constrained decoding. This suggests that for structured tasks, intelligent decoding strategies can be more impactful than raw parameter count.
- Quality and Faithfulness: In "Win Rate" tests against standard CD, DCCD-generated summaries were preferred by an LLM-judge approximately 80% of the time for their quality and faithfulness.
Discussion and Future Directions
While DCCD requires two passes—increasing inference latency—the authors note that the second constrained pass can often be handled by a much smaller, faster "projector" model. Future work may explore "speculative" versions of this approach to mitigate latency or investigate fine-tuning models specifically to project drafts into structured formats. Ultimately, DCCD demonstrates that by allowing models to "think" before they "format," we can significantly improve the reliability of LLMs in structured software environments.
Summary updated