arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2305.00909cs.PLcs.AIcs.LG
收藏

先大纲后细节:语法引导的从粗到细代码生成

Outline, Then Details: Syntactically Guided Coarse-To-Fine Code Generation

The University of Texas at Austin(德克萨斯大学奥斯汀分校)

Wenqing Zheng, S P Sharan, Ajay Kumar Jaiswal, Kevin Wang, Yihan Xi, Dejia Xu, Zhangyang Wang

AI总结:

针对大语言模型单次生成代码缺乏结构化思考的问题,提出多轮从粗到细生成代码的ChainCoder模型,通过语法树分解构建层级表示、定制transformer联合编码,实现了更优的代码生成效果。

摘要:

对于复杂算法,人类程序员的实现通常从勾勒粗略的控制流开始,随后进行迭代细化,最终在层级结构中生成精心设计的语法结构与变量。然而,当前最先进的大语言模型均为单次生成代码,没有中间预热过程来体现“先大纲后细节”的结构化思考过程。受思维链提示近期成功的启发,我们提出ChainCoder,一种逐步生成Python代码的程序综合语言模型,即通过多轮从粗到细地生成代码。我们首先通过抽象语法树解析将源代码分解为布局框架组件和附属组件,构建层级表示。接着我们将预测目标重构为多轮目标,每一轮生成一个子序列,这些子序列在层级结构中拼接。最后,我们采用定制化的transformer架构,对自然语言描述和语法对齐的输入输出数据样本进行联合编码。大量评估表明,ChainCoder的性能优于当前最先进的模型,证明我们的渐进式生成简化了推理过程,能引导语言模型生成更高质量的解决方案。我们的代码可在以下地址获取:https://github.com/VITA-Group/ChainCoder。

英文摘要:

For a complicated algorithm, its implementation by a human programmer usually starts with outlining a rough control flow followed by iterative enrichments, eventually yielding carefully generated syntactic structures and variables in a hierarchy. However, state-of-the-art large language models generate codes in a single pass, without intermediate warm-ups to reflect the structured thought process of "outline-then-detail". Inspired by the recent success of chain-of-thought prompting, we propose ChainCoder, a program synthesis language model that generates Python code progressively, i.e. from coarse to fine in multiple passes. We first decompose source code into layout frame components and accessory components via abstract syntax tree parsing to construct a hierarchical representation. We then reform our prediction target into a multi-pass objective, each pass generates a subsequence, which is concatenated in the hierarchy. Finally, a tailored transformer architecture is leveraged to jointly encode the natural language descriptions and syntactically aligned I/O data samples. Extensive evaluations show that ChainCoder outperforms state-of-the-arts, demonstrating that our progressive generation eases the reasoning procedure and guides the language model to generate higher-quality solutions. Our codes are available at: https://github.com/VITA-Group/ChainCoder.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑