arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1808.01400cs.LGcs.PLstat.ML
收藏

code2seq:从代码的结构化表示生成序列

code2seq: Generating Sequences from Structured Representations of Code

Technion(以色列理工学院);Facebook AI Research(脸书人工智能研究院)

Uri Alon, Shaked Brody, Omer Levy, Eran Yahav

摘要:

从源代码片段生成自然语言序列的能力具有多种应用,例如代码摘要、文档和检索。从神经机器翻译(NMT)中采用的序列到序列(seq2seq)模型通过将源代码视为令牌序列,在这些任务上实现了最先进的性能。我们提出了${\rm {\scriptsize CODE2SEQ}}$:一种替代方法,利用程序设计语言的语法结构,以更好地编码源代码。我们的模型代表了一个代码片段的组合路径在其抽象语法树(AST),并使用注意力来选择相关的路径,而解码。我们证明了我们的方法的有效性,两个任务,两种程序设计语言,四个数据集的$16$ M的例子。我们的模型显着优于以前的模型,专门为程序设计语言,以及国家的最先进的NMT模型。我们的模型的交互式在线演示可在http://code2seq.org上获得。我们的代码,数据和训练模型可在http://github.com/tech-srl/code2seq上获得。

英文摘要:

The ability to generate natural language sequences from source code snippets has a variety of applications such as code summarization, documentation, and retrieval. Sequence-to-sequence (seq2seq) models, adopted from neural machine translation (NMT), have achieved state-of-the-art performance on these tasks by treating source code as a sequence of tokens. We present ${\rm {\scriptsize CODE2SEQ}}$: an alternative approach that leverages the syntactic structure of programming languages to better encode source code. Our model represents a code snippet as the set of compositional paths in its abstract syntax tree (AST) and uses attention to select the relevant paths while decoding. We demonstrate the effectiveness of our approach for two tasks, two programming languages, and four datasets of up to $16$M examples. Our model significantly outperforms previous models that were specifically designed for programming languages, as well as state-of-the-art NMT models. An interactive online demo of our model is available at http://code2seq.org. Our code, data and trained models are available at http://github.com/tech-srl/code2seq.

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

↑