发表机构
University of Luxembourg; Imperial College London(卢森堡大学; 伦敦帝国学院)
机构由 AI 辅助整理,请以论文原文为准。AI 中文总结
本研究提出基于下推自动机的距离引导解码框架,解决文法约束解码中前缀无法接受的问题,在JSON、SQL、LTL任务上实现稳定句法有效性与更优完成质量。
AI 中文摘要
文法约束解码可帮助大型语言模型生成符合句法的结构化输出,如代码、JSON和SQL。对于上下文无关文法,许多实用解码器会实施局部前缀可行性:每个token必须确保当前前缀可扩展为某个有效完成形式。然而,在分词器-文法不匹配和有限token预算下,可行前缀仍可能无法达到接受状态。我们提出一种基于下推自动机的上下文无关文法前瞻引导解码框架:离线时,计算带可达性标签和到接受状态的上界距离的有界下推摘要;在线时,这些估计值指导感知视界的剪枝和束搜索。所得解码器在句法上是可靠的:每个输出都被目标文法接受。在JSON、SQL和线性时序逻辑(LTL)上的实验表明,其相比现有基线兼具稳定的句法有效性和改进的完成质量。
英文摘要
Grammar-constrained decoding helps large language models produce syntactically valid structured outputs, such as code, JSON, and SQL. For context-free grammars, many practical decoders enforce local prefix feasibility: each token must keep the current prefix extendable to some valid completion. Yet, under tokenizer-grammar mismatch and finite token budgets, feasible prefixes may still fail to reach acceptance. We propose a lookahead-guided decoding framework for context-free grammars based on pushdown automata. Offline, we compute bounded pushdown summaries with reachability labels and upper-bound distances to acceptance. Online, these estimates guide horizon-aware pruning and beam search. The resulting decoder is syntactically sound: every output is accepted by the target grammar. Experiments on JSON, SQL, and Linear Temporal Logic (LTL) show both consistent syntactic validity and improved completion quality over existing baselines.
CommentsEMNLP 2026 Findings, Long Paper