Thinking Before Constraining: A Unified Decoding Framework for Large Language Models
Reading guide · Based on sections of the original paper
Why read this
Practitioners who need schema-valid outputs (for example JSON) from open models without a second parser model, and without losing chain-of-thought accuracy, should read this.
What the authors found
- On GSM8K, Last Letter and Shuffled Objects, In-Writing* (with <eos> as the sole trigger) was usually best or tied in the authors' tests. The comparison covered Llama3-8B, Gemma2-9B, Qwen3/3.5 and SmolLM3 (1.7B–9B), against natural-language extraction, vanilla JSON-constrained decoding and NL-to-Format with a Qwen3-32B parser. For example, Llama3-8B zero-shot GSM8K accuracy was 77.9 for In-Writing*, versus 74.7 for NL-to-Format and 48.9 for constrained decoding, averaged over 9 prompt variations. Parse rate was 100% at a cost of 5–20 extra tokens. There are exceptions: on DDXPlus with Gemma2-9B, constrained decoding scored 53 versus 50.1. The abstract attributes the 'up to 27%' gain to natural generation, while the results section attributes it to LLM-based parsing. 6.1.1 Overall Assessment
- Trigger choice matters a great deal. Using both <eos> and '{' as triggers (In-Writing-Base) cut reasoning short. GSM8K accuracy fell by more than 30 points relative to In-Writing* (Qwen3.5-9B zero-shot: 61.9 vs 93.4). The effect on classification tasks was small. 6.1.1 Overall Assessment
- On eight-shot GSM-Symbolic, In-Writing* beat CRANE's reported scores for 7 of 8 models, for example 77 vs 45 on Qwen2.5-Coder-14B. The exception was DeepSeek-R1-Llama-8B (30 vs 31). The authors graded their own outputs manually, treating division and rounding operators as equivalent. CRANE's numbers come from the prior paper, so the two evaluations are not strictly comparable. 6.2 CRANE Comparison: Limitations of Grammar-Constrained Decoding in LLM Reasoning
Main limitation
The authors did not optimise prompts for In-Writing, so some results may not reflect its best performance. They also state that adding few-shot examples helped the baseline but hurt In-Writing and NL-to-Format. They attribute this to adherence to the 'answer is:' prefix rather than to differences in reasoning. Limitations
Where to start
A.4.4 Empirical Contradictions to the CRANE Framework · Look here for the full per-model, per-shot tables (2–9), the overlap counts showing where each extraction method uniquely succeeds, and the authors' estimate-based critique of CRANE's GSM-Symbolic results.
Abstract
Natural generation allows Language Models (LMs) to produce free-form responses with rich reasoning, but the lack of guaranteed structure makes outputs difficult to parse or verify. Structured generation, or constrained decoding, addresses this drawback by producing content in standardized formats such as JSON, ensuring consistency and guaranteed-parsable outputs, but it can inadvertently restrict the model's reasoning capabilities. In this work, we propose a simple approach that combines the advantages of both natural and structured generation. By allowing LLMs to reason freely until specific trigger tokens are generated, and then switching to structured generation, our method preserves the expressive power of natural language reasoning while ensuring the reliability of structured outputs. We further evaluate our approach on several datasets, covering both classification and reasoning tasks, to demonstrate its effectiveness, achieving a substantial gain of up to 27% in accuracy compared to natural generation, while requiring only a small overhead of 10-20 extra tokens.