code2seq: Generating Sequences from Structured Representations of Code

code2seq: Generating Sequences from Structured Representations of Code
复制标题

DOI:
--
复制
发表时间:
2018-08
期刊:
ArXiv
影响因子:
--
通讯作者:
Uri Alon;Shaked Brody;Omer Levy;Eran Yahav
Uri Alon;Shaked Brody;Omer Levy;Eran Yahav
中科院分区:
其他
文献类型:
--
作者:
Uri Alon;Shaked Brody;Omer Levy;Eran Yahav

文献摘要

被引文献

相似文献

从源代码片段生成自然语言序列的能力有各种各样的应用,例如代码摘要、文档和检索。从神经机器翻译(NMT)中采用的序列到序列(seq2seq)模型通过将源代码视为标记序列,在这些任务上实现了最先进的性能。我们提出${\rm {\scriptsize CODE2SEQ}}$:一种利用编程语言的语法结构来更好地编码源代码的替代方法。我们的模型将代码片段表示为其抽象语法树(AST)中的组合路径集,并在解码时使用注意力来选择相关路径。我们展示了我们的方法在两个任务、两种编程语言和四个数据集上的有效性,这些数据集最多有1600万个示例。我们的模型明显优于以前专门为编程语言设计的模型,以及最先进的NMT模型。我们的代码、数据和训练过的模型都可以在这个http URL上找到
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 this http URL Our code, data and trained models are available at this http URL