arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1808.10025cs.CL
收藏

基于检索的神经代码生成

Retrieval-Based Neural Code Generation

Carnegie Mellon University(卡内基梅隆大学)

Shirley Anugrah Hayati, Raphael Olivier, Pravalika Avvaru, Pengcheng Yin, Anthony Tomasic, Graham Neubig

摘要:

在从自然语言生成程序源代码的模型中,以树结构表示该代码已经是常见的方法。然而,现有的方法往往无法正确地生成复杂的代码,由于缺乏记忆能力的大型和复杂的结构。我们介绍ReCode,一种基于子树检索的方法,可以显式引用神经代码生成模型中的现有代码示例。首先,我们使用基于动态规划的句子相似度评分方法检索与输入句子相似的句子。接下来,我们提取动作序列的n-gram来构建相关的抽象语法树。最后,我们增加了导致检索到的n-gram动作子树出现在预测代码中的动作的概率。我们表明,我们的方法提高了两个代码生成任务的性能高达+2.6 BLEU。

英文摘要:

In models to generate program source code from natural language, representing this code in a tree structure has been a common approach. However, existing methods often fail to generate complex code correctly due to a lack of ability to memorize large and complex structures. We introduce ReCode, a method based on subtree retrieval that makes it possible to explicitly reference existing code examples within a neural code generation model. First, we retrieve sentences that are similar to input sentences using a dynamic-programming-based sentence similarity scoring method. Next, we extract n-grams of action sequences that build the associated abstract syntax tree. Finally, we increase the probability of actions that cause the retrieved n-gram action subtree to be in the predicted code. We show that our approach improves the performance on two code generation tasks by up to +2.6 BLEU.

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

↑