约束解码:有害还是有益?重新审视其对LLM性能的影响

·

研究论文 · 2026/10/27

本文重新审视了约束解码对大型语言模型性能的影响。通过将约束分为格式约束、有效性约束和推理约束三类,理论分析表明适当的约束可以通过消除无效路径来保持或提升性能。在四个模型家族和十一个开源模型上的因果消融实验显示,表面上的性能下降主要源于非等价的提示和输出格式,而非解码器层面的掩码。有效性约束通过消除无效答案提高了可靠性和可提取性,而推理约束在强制有益轨迹时能提升推理能力和准确率。这些发现表明约束解码的影响取决于约束类型及其移除的输出空间。

该研究挑战了约束解码必然降低性能的常见假设,通过理论分析和大规模实验澄清了性能下降的真正原因,为合理使用约束解码提供了指导,对提升LLM输出的可靠性和推理能力具有重要意义。

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.

阅读原文

参与讨论