让大模型在严格语法约束下仍保持推理能力,提升代码与数学题准确率。
CRANE: Reasoning with constrained LLM generation
- 通过扩展语法规则,平衡约束与推理灵活性
- 在GSM-symbolic等难题上提升10%准确率
- 适合需要高正确性输出的编程与数学推理场景
代码生成、符号数学推理等任务要求大模型输出既符合语法规则又语义正确。受限的大模型生成虽能保证形式语法正确,但已有研究发现严格约束会削弱模型推理能力。本文首先从理论上解释为何过于严格的语法限制会降低推理能力;其次证明,通过精心设计的附加规则扩展输出语法,可在保证语法和语义正确的同时完全保留模型推理能力。基于此,我们提出一种增强推理的受限解码算法CRANE,有效平衡生成正确性与自由度。在多个开源大模型和基准测试上的实验表明,CRANE显著优于现有最先进受限解码方法及标准无约束解码,在挑战性符号推理数据集GSM-symbolic和FOLIO上最高提升达10个百分点。
原文摘要 · Abstract (English)
Code generation, symbolic math reasoning, and other tasks require LLMs to produce outputs that are both syntactically and semantically correct. Constrained LLM generation is a promising direction to enforce adherence to formal grammar, but prior works have empirically observed that strict enforcement of formal constraints often diminishes the reasoning capabilities of LLMs. In this work, we first provide a theoretical explanation for why constraining LLM outputs to very restrictive grammars that only allow syntactically valid final answers reduces the reasoning capabilities of the model. Second, we demonstrate that by augmenting the output grammar with carefully designed additional rules, it is always possible to preserve the reasoning capabilities of the LLM while ensuring syntactic and semantic correctness in its outputs. Building on these theoretical insights, we propose a reasoning-augmented constrained decoding algorithm, CRANE, which effectively balances the correctness of constrained generation with the flexibility of unconstrained generation. Experiments on multiple open-source LLMs and benchmarks show that CRANE significantly outperforms both state-of-the-art constrained decoding strategies and standard unconstrained decoding, showing up to 10% points accuracy improvement over baselines on challenging symbolic reasoning benchmarks GSM-symbolic and FOLIO.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。