让大模型先思考再约束,生成更准的结构化回答
Thinking Before Constraining: A Unified Decoding Framework for Large Language Models
- 先自由推理再应用格式约束,用触发词分离思考与输出
- 在多个任务上提升准确率最高达27%,优于纯自由生成
- 适合需要严谨推理和固定格式的复杂问答场景
自然生成允许大语言模型以自由形式输出丰富推理内容,但缺乏结构导致难以验证。相反,受限解码虽能保证格式统一,却可能因过早施加约束而抑制推理能力。本文提出一种混合方法In-Writing,将自由推理与结构化生成整合于单次调用中:模型先进行无约束推理,仅在生成触发词后才启用结构化解码,明确分离推理与格式化过程。实验表明,该触发词策略几乎完全消除提前触发问题(即约束过早中断推理)。在涵盖分类与推理任务的多个数据集上评估显示,该方法相较现有最优方案,准确率提升最高达27%。代码已开源:https://github.com/Nokia-Bell-Labs/InWriting。
原文摘要 · Abstract (English)
Natural generation allows Large Language Models (LLMs) to produce free-form responses with rich reasoning, yet the lack of structure makes outputs difficult to verify. Conversely, constrained decoding ensures standardized formats but can inadvertently restrict reasoning capabilities by imposing constraints too early in the generation process. We propose a hybrid approach, namely In-Writing, that combines free-form reasoning and structured generation in a single call. The model first performs unconstrained reasoning and only applies structured decoding after a trigger token is generated, explicitly decoupling reasoning from formatting. We establish that our trigger-token strategies are able to virtually eradicate premature triggering, a failure mode in which constrained decoding interrupts on-going reasoning. Evaluations across diverse datasets covering classification and reasoning tasks demonstrate that our approach outperforms the state-of-the-art by achieving accuracy gains of up to 27% over natural generation. Our code are available at: https://github.com/Nokia-Bell-Labs/InWriting.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。