Constrained Decoding: Harmful or Beneficial? Revisiting Its Impact on LLM Performance
Organizations: Télécom Paris, Institut Polytechnique de Paris, France · Nokia Bell Labs
Abstract
Constrained decoding guarantees that Large Language Models (LLMs) produce outputs conforming to predefined formats, but is often assumed to inherently degrade reasoning. We examine this assumption through a taxonomy of three constraint types: format constraints, which enforce output structure; validity constraints, which mask invalid answer; and reasoning constraints, which restrict reasoning trajectories. We theoretically show that appropriate constraints can preserve or improve performance by eliminating invalid paths. Across four model families and eleven open-source models, causal ablations on diverse benchmarks using state-of-the-art constrained decoding strategies reveal that apparent performance degradation largely stems from non-equivalent prompting and output formats rather than from decoder-level masking. Meanwhile, validity constraints improve reliability and extractability by eliminating invalid answers, while reasoning constraints can improve reasoning and, consequently, accuracy when they enforce beneficial trajectories. These findings show that the impact of constrained decoding depends on the type of constraint and the output space it removes. Our code is available.
Figures & tables
| Model | NL (Baseline) | JSON +FC+VC | NL-to-Format Unconstr. (plain-text) | +FC+VC |
| Qwen3-1.7B | 33.6 21.9 | 45.4 19.1 | 60.7 4.3 | 66.1 4.8 |
| Qwen3-4B | 32.1 26.2 | 41.9 21.6 | 57.5 7.5 | 60.4 7.1 |
| Qwen3-8B | 63.8 17.4 | 78.4 7.9 | 69.4 11.4 | 72.4 10.6 |
| Qwen3.5-2B | 22.4 29.9 | 69.1 2.2 | 62.9 5.6 | 68.7 5.2 |
| Qwen3.5-4B | 81.6 1.6 | 71.6 28 | 84.1 2.3 | 86.9 2.6 |
| Qwen3.5-9B | 85.9 1.2 | 77 27 | 86.8 1.2 | 89.9 0.5 |
| Model | NL-to-Format Unconstr. (plain-text) | +FC+VC | NL-to-Format Unconstr. (JSON) | +FC+VC |
| Qwen3-1.7B | 60.7 4.3 | 66.1 4.8 | 67.3 4.1 | 68.9 4.6 |
| Qwen3-4B | 57.5 7.5 | 60.4 7.1 | 60.3 6.4 | 61.4 6.5 |
| Qwen3-8B | 69.4 11.4 | 72.4 10.6 | 72.1 10.5 | 73.5 10.6 |
| Qwen3.5-2B | 62.9 5.6 | 68.7 5.2 | 68.6 5.9 | 71.3 5.4 |
| Qwen3.5-4B | 84.1 2.3 | 86.9 2.6 | 87.7 1.5 | 88.8 1.5 |
| Qwen3.5-9B | 86.8 1.2 | 89.9 0.5 | 89.6 1.0 | 91.6 1.0 |
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
| Experiment Type | Parameter | Value | Note |
| Standard Setting | Temperature | 0 | |
| Sampling | False | ||
| Max Reasoning Tokens | 600 | ||
| Thinking Mode | Off | ||
| Random Seed | 1 | ||
| Extended-Reasoning Setting (AIME-2026 only) | Temperature | Default |
| Model | Unconstrained Baseline | Label- Constrained | Alternative- Constrained |
| Qwen3-1.7B | 81.6 | 81.6 | 76.0 |
| Qwen3-4B | 92.6 | 92.6 | 83.4 |
| Qwen3.5-2B | 89.6 | 89.6 | 80.8 |
| Qwen3.5-4B | 94.6 | 94.8 | 85.8 |
| Model | NL (Baseline) | JSON +FC+VC | NL-to-Format Unconstr. (plain-text) | +FC+VC | |
| 0 | Qwen3-1.7B | 33.6 21.9 | 45.4 19.1 | 60.7 4.3 | 66.1 4.8 |
| Qwen3-4B | 32.1 26.2 | 41.9 21.6 | 57.5 7.5 | 60.4 7.1 | |
| Qwen3-8B | 63.8 17.4 | 78.4 7.9 | 69.4 11.4 | 72.4 10.6 | |
| Qwen3.5-2B | 22.4 29.9 | 69.1 2.2 | 62.9 5.6 | 68.7 5.2 | |
| Qwen3.5-4B | 81.6 1.6 | 71.6 28 | 84.1 2.3 | 86.9 2.6 | |
| Qwen3.5-9B | 85.9 1.2 | 77 27 | 86.8 1.2 | 89.9 0.5 |
| Model | JSON Unconstr. | +FC +VC | InWriting Unconstr. | +FC +VC | NL-to-Format Unconstr. | +FC +VC |
| Llama3-8B | 42.1 11.8 | 71.8 1.6 | 74.7 1.3 | 77.8 1.2 | 76.4 1.1 | 77.1 1.2 |
| Gemma2-9B | 0 0 | 86.7 0.3 | 82.9 1.4 | 86.7 0.6 | 83.6 1.6 | 84.4 1.3 |
| Qwen3-1.7B | 17.6 24.8 | 63.4 0.5 | 68.8 8.5 | 75.8 0.8 | 72.9 1.1 | 74.8 1.1 |
| Qwen3-4B | 85.3 1.2 | 88.3 0.2 | 85.8 3.0 | 89.7 0.4 | 86.0 1.1 | 87.4 0.8 |
| Qwen3-8B | 56.7 22.4 | 90.9 0.4 | 89.4 0.9 | 91.4 0.5 | 88.8 1.6 | 90.1 1.2 |
| Qwen3.5-2B | 61 1.2 | 69.9 0.9 | 47.1 28.4 | 74.9 2.2 | 69.0 4.6 | 72.1 4.0 |
| Model | JSON Unconstr. | +FC+VC | InWriting Unconstr. | +FC+VC | NL-to-Format Unconstr. | +FC+VC |
| Llama3-8B | 0 0 | 2.0 1.4 | 53.6 5.4 | 71.0 3.8 | 68.7 4.4 | 71.3 4.0 |
| Gemma2-9B | 0 0 | 43.8 2.2 | 42.5 4.1 | 56.6 4.4 | 51 5.8 | 54.1 5.0 |
| Qwen3-1.7B | 0 0 | 9.8 1.1 | 54.2 4.8 | 65.2 5.1 | 67.3 4.1 | 68.9 4.6 |
| Qwen3-4B | 55.6 5.7 | 56.7 5.5 | 55.2 8.0 | 59.6 7.3 | 60.3 6.4 | 61.4 6.5 |
| Qwen3-8B | 75.6 2.8 | 79.6 2.8 | 72.0 4.9 | 76.4 5.6 | 72.1 10.5 | 73.5 10.6 |
| Qwen3.5-2B | 60.9 1.7 | 69.1 2.8 | 50.1 21.9 | 75.5 2.7 | 68.6 5.9 | 71.3 5.4 |
| Model | JSON Unconstr. | +FC+VC | InWriting Unconstr. | +FC+VC | NL-to-Format Unconstr. | +FC+VC |
| Llama3-8B | 0 0 | 2.4 3.5 | 15.5 3.6 | 28.7 5.8 | 28.8 9.6 | 31.9 10.4 |
| Gemma2-9B | 0 0 | 17.6 0.3 | 14.0 1.8 | 23.9 4.1 | 24.0 3.1 | 25.6 3.0 |
| Qwen3-1.7B | 0 0 | 0 0 | 13.5 4.8 | 23.8 6.9 | 27.0 5.6 | 28.4 5.3 |
| Qwen3-4B | 15.3 0.0 | 19.1 0.6 | 22.4 6.4 | 33.4 7.8 | 26.1 7.7 | 27.5 7.3 |
| Qwen3-8B | 34.4 2.7 | 39.6 3.5 | 38.7 5.4 | 47.3 6.2 | 42.1 7.2 | 43.5 6.9 |
| Qwen3.5-2B | 15.1 4.4 | 20.4 5.4 | 18.1 9.3 | 38.4 8.2 | 34.4 11.3 | 36.5 10.0 |
| Model | JSON Unconstr. | +FC | +FC+VC | InWriting Unconstr. | +FC | +FC+VC |
| Llama3-8B | 0 0 | 1.8 1.6 | 2.0 1.4 | 53.6 5.4 | 53.6 5.4 | 71.0 3.8 |
| Gemma2-9B | 0 0 | 35.8 2.7 | 43.8 2.2 | 42.5 4.1 | 42.6 4.0 | 56.6 4.4 |
| Qwen3-1.7B | 0 0 | 8.4 1.4 | 9.8 1.1 | 54.2 4.8 | 55.0 5.4 | 65.2 5.1 |
| Qwen3-4B | 55.6 5.7 | 55.8 5.6 | 56.7 5.5 | 55.2 8.0 | 56.4 6.9 | 59.6 7.3 |
| Qwen3-8B | 75.6 2.8 | 75.6 2.8 | 79.6 2.8 | 72.0 4.9 | 72.0 4.9 | 76.4 5.6 |
| Qwen3.5-2B | 60.9 1.7 | 61.6 2.7 | 69.1 2.8 | 50.1 21.9 | 63.0 2.2 | 75.5 2.7 |
| Model | JSON Unconstr. | +FC | +FC+VC | InWriting Unconstr. | +FC | +FC+VC |
| Llama3-8B | 0 0 | 1.8 2.5 | 2.4 3.5 | 15.5 3.6 | 15.5 3.6 | 28.7 5.8 |
| Gemma2-9B | 0 0 | 15.6 0.6 | 17.6 0.3 | 14.0 1.8 | 14.0 1.8 | 23.9 4.1 |
| Qwen3-1.7B | 0 0 | 0 0 | 0 0 | 13.5 4.8 | 13.8 4.9 | 23.8 6.9 |
| Qwen3-4B | 15.3 0.0 | 15.8 0.3 | 19.1 0.6 | 22.4 6.4 | 22.8 6.5 | 33.4 7.8 |
| Qwen3-8B | 34.4 2.7 | 34.4 2.7 | 39.6 3.5 | 38.7 5.4 | 39.0 5.4 | 47.3 6.2 |
| Qwen3.5-2B | 15.1 4.4 | 15.1 4.4 | 20.4 5.4 | 18.1 9.3 | 27.2 6.6 | 38.4 8.2 |
| Model | JSON Unconstr. | +FC | InWriting Unconstr. | +FC | NL-to-Format Unconstr. | +FC |
| Llama3-8B | 58.7 | 99.9 | 99.4 | 100 | 99.3 | 100 |
| Gemma2-9B | 0.2 | 100 | 99.8 | 100 | 99.7 | 100 |
| Qwen3-1.7B | 28.5 | 97.3 | 90.7 | 100 | 97.9 | 100 |
| Qwen3-4B | 96.7 | 99.8 | 97.3 | 100 | 98.2 | 100 |
| Qwen3-8B | 62.6 | 99.8 | 99.7 | 100 | 98.6 | 100 |
| Qwen3.5-2B | 82.2 | 88.4 | 63.1 | 99.6 | 95.9 | 100 |
| Model | JSON Unconstr. | +FC | InWriting Unconstr. | +FC | NL-to-Format Unconstr. | +FC |
| Llama3-8B | 0 | 100 | 99.8 | 100 | 99.6 | 100 |
| Gemma2-9B | 0 | 100 | 100 | 100 | 100 | 100 |
| Qwen3-1.7B | 0.7 | 96.2 | 97.4 | 100 | 99.6 | 100 |
| Qwen3-4B | 100 | 100 | 99.7 | 100 | 100 | 100 |
| Qwen3-8B | 100 | 100 | 99.5 | 100 | 99.6 | 100 |
| Qwen3.5-2B | 99.6 | 99.6 | 67.9 | 99.6 | 99.6 | 100 |
| Tasks | Model | JSON Unconstr. | +FC +VC | InWriting Unconstr. | +FC +VC | NL-to-Format Unconstr. | +FC +VC |
| GSM8K | Qwen3-1.7B | 221.1 | 129.2 | 189.5 | 201.1 | 190.4 | 190.2 |
| Qwen3-4B | 135.8 | 135.0 | 164.6 | 172.8 | 161.4 | 161.3 | |
| Qwen3-8B | 223.0 | 159.0 | 176.4 | 188.2 | 174.4 | 174.3 | |
| Qwen3.5-2B | 242.2 | 242.8 | 278.4 | 286.9 | 304.2 | 302.2 | |
| Qwen3.5-4B | 164.2 | 163.5 | 272.8 | 280.6 | 269.8 | 269.7 | |
| Qwen3.5-9B | 184.7 | 183.7 | 277.5 | 285.2 | 259.5 | 259.4 |
| Model | +FC+VC | +FC+VC +RC |
| Qwen3-1.7B | 75.8 0.8 | 77.7 0.9 |
| Qwen3-4B | 89.7 0.4 | 89.6 0.3 |
| Qwen3-8B | 91.4 0.5 | 91.9 0.6 |
| Qwen3.5-2B | 74.9 2.2 | 77.4 0.5 |
| Qwen3.5-4B | 91.8 0.4 | 91.5 0.5 |
| Qwen3.5-9B | 93.9 0.3 | 93.9 0.3 |
| Model | +FC+VC | +FC+VC +RC |
| Qwen3-4B | 14.8 4.5 | 16.7 2.7 |
| Qwen3-8B | 12.2 2.2 | 13.3 3.1 |
| Qwen3.5-4B | 62.2 3.1 | 55.6 5.7 |
| Qwen3.5-27B | 81.9 3.9 | 84.3 5.6 |
Constrained Decoding
Constrained decoding steers language model outputs to satisfy formal or task-specific rules while balancing validity, quality, and faithful probabilities.
See all 66 papers