arXiv:2603.01243cs.CL2026-03

让大模型自由推理后,仅约束输出结尾格式,效果更好。

Suffix-Constrained Greedy Search Algorithms for Causal Language Models

  • 只约束生成结果末尾部分的格式,更灵活实用。
  • 在多个数据集上保持甚至提升生成质量。
  • 适合需要自由思考后输出固定格式的任务。

大语言模型(LLMs)已广泛应用于人机交互之外的领域。除了自由文本生成,受限生成也受到关注,即要求模型生成符合形式语法的输出。然而,这种设定对下游任务可能过于严格。例如,许多任务需模型先自由推理,再以特定格式输出最终回答。本文提出后缀受限生成(suffix-constrained generation),即仅对响应末尾施加语法约束,这是现有方法无法支持的场景。我们设计了几种基于贪婪搜索的后缀受限生成算法,并在多个数据集上进行实验,结果表明该方法能保证后缀约束,且不影响甚至提升了生成性能。

原文摘要 · Abstract (English)

Large language models (LLMs) are powerful tools that have found applications beyond human-machine interfaces and chatbots. Beside free-form generation, there has been an interest in constrained generation, a setting where LLMs are constrained to generate well-formed outputs with respect to the language defined by a formal grammar. Although appealing, this setting may be over restrictive for downstream applications. For example, many LLM tasks require the model to reason freely before generating its final response in a specific format. In this work, we introduce suffix-constrained generation, a constrained generation setting in which only the end of the response is constrained by a grammar, a scenario that is not supported by existing constrained generation methods. We introduce several suffix-constrained generation algorithms that are based on greedy search. We experiment on several datasets, and show that our approach allows to guarantee suffix constraints without having a negative impact on results, and even improving them in many settings.

大模型生成约束语法控制

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。