通过上下文敏感文法的有效左商与右商实现填空式代码语言模型的受限解码
Constrained Decoding for Fill-in-the-Middle Code Language Models via Efficient Left and Right Quotienting of Context-Sensitive Grammars
AI总结:
本文提出一种基于 Earley 解析扩展的左商与右商解析方法,用于在填空式代码生成中尽早拒绝语法错误代码,并在 Python 3 上验证其可显著降低语法错误率。
摘要:
大型语言模型是程序合成和高级自动补全的强大工具,但无法保证其输出代码在语法上正确。本文贡献了一个增量解析器,该解析器能够尽早拒绝语法不正确的代码,并能够高效检测填空式(FIM)任务中的完整程序。我们扩展了 Earley 解析算法,以支持上下文无关文法的左商和右商,并开发了处理多种上下文敏感特性的商运算方法,这些特性存在于许多常见编程语言的文法中。这些贡献的成果是一种高效、通用且理论基础扎实的左商和右商解析方法。为了验证我们的理论贡献——以及某些设计决策的有效性——我们在 Python 3 的 FIM 补全这一特别困难的情形下,结合语法正确性约束,对我们的方法进行了评估。我们的结果表明,受限生成可以显著降低推荐代码中语法错误的发生率。
英文摘要:
Large Language Models are powerful tools for program synthesis and advanced auto-completion, but come with no guarantee that their output code is syntactically correct. This paper contributes an incremental parser that allows early rejection of syntactically incorrect code, as well as efficient detection of complete programs for fill-in-the-middle (FIM) tasks. We extend the Earley parsing algorithm to allow for left and right quotients of context-free grammars, and develop methods to handle quotienting of several context-sensitive features present in the grammars of many common programming languages. The result of these contributions is an efficient, general, and well-grounded method for left and right quotient parsing. To validate our theoretical contributions -- and the effectiveness of certain design decisions -- we evaluate our method on the particularly difficult case of FIM completion for Python 3, with syntax-correctness constraints. Our results demonstrate that constrained generation can significantly reduce the incidence of syntax errors in recommended code.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。