使用检索到的模板函数和堆栈溢出答案生成代码
Generating Code with the Help of Retrieved Template Functions and Stack Overflow Answers
摘要:
我们的做法的重要挑战,代码自动完成作为一个开放的领域的任务,其中序列到序列的代码生成器模型增强的能力,参加参考代码片段提供的语义代码搜索引擎。在这项工作中,我们提出了一种新的框架,以精确地检索模板函数以及意图片段对,并有效地训练这样的检索引导代码生成器。为了证明我们的模型设计的有效性,我们使用包含模板函数的CodeSearchNet和包含Stack Overflow意图片段对的CoNaLa进行了广泛的实验。我们还研究了不同的检索模型,包括Elasticsearch,DPR和我们的融合表示搜索模型,该模型目前在CodeSearchNet排行榜上排名第一。我们通过利用多个数据库元素观察到改进,并通过使用最大边缘相关性从检索不同的数据点中进一步获益。总的来说,我们看到交叉熵损失提高了4%,编辑距离提高了15%,检索模板函数时BLEU得分提高了44%。在检索Stack Overflow intent-snippet对时,我们分别看到了2%、11%和6%的细微改进。我们还创建了一个新颖的Stack Overflow-Function Alignment数据集,它由150 K的函数元组和Stack Overflow意图片段对组成,这些对编写相关函数有帮助,其中1.7K是手动管理的。
英文摘要:
We approach the important challenge of code autocompletion as an open-domain task, in which a sequence-to-sequence code generator model is enhanced with the ability to attend to reference code snippets supplied by a semantic code search engine. In this work, we present a novel framework to precisely retrieve template functions as well as intent-snippet pairs and effectively train such a retrieval-guided code generator. To demonstrate the effectiveness of our model designs, we perform extensive experiments with CodeSearchNet which contains template functions and CoNaLa which contains Stack Overflow intent-snippet pairs. We also investigate different retrieval models, including Elasticsearch, DPR, and our fusion representation search model, which currently holds the number one spot on the CodeSearchNet leaderboard. We observe improvements by leveraging multiple database elements and further gain from retrieving diverse data points by using Maximal Marginal Relevance. Overall, we see a 4% improvement to cross-entropy loss, a 15% improvement to edit distance, and a 44% improvement to BLEU score when retrieving template functions. We see subtler improvements of 2%, 11%, and 6% respectively when retrieving Stack Overflow intent-snippet pairs. We also create a novel Stack Overflow-Function Alignment dataset, which consists of 150K tuples of functions and Stack Overflow intent-snippet pairs that are of help in writing the associated function, of which 1.7K are manually curated.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。