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

代码的结构化语言模型

Structural Language Models of Code

Technion(以色列理工学院);Facebook AI Research(Facebook 人工智能研究院);Tel Aviv University(特拉维夫大学)

Uri Alon, Roy Sadaka, Omer Levy, Eran Yahav

摘要:

我们解决了任何代码完成的问题-在给定的程序中生成一段缺失的源代码,而不对词汇表或结构进行任何限制。我们介绍了一种新的方法来完成任何代码,利用严格的语法的程序设计语言建模的代码片段作为树结构语言建模(SLM)。SLM通过将程序的抽象语法树(AST)分解为其节点上的条件概率的乘积来估计程序的抽象语法树的概率。我们提出了一个神经模型,通过考虑所有AST路径导致目标节点来计算这些条件概率。不像以前的技术,严格限制了可以在这个任务中生成的表达式的种类,我们的方法可以生成任意代码在任何程序设计语言。我们的模型在生成Java和C#代码方面明显优于seq 2seq和各种结构化方法。我们的代码、数据和训练模型可以在http://github.com/tech-srl/slm-code-generation/上找到。在线演示可在http://AnyCodeGen.org上获得。

英文摘要:

We address the problem of any-code completion - generating a missing piece of source code in a given program without any restriction on the vocabulary or structure. We introduce a new approach to any-code completion that leverages the strict syntax of programming languages to model a code snippet as a tree - structural language modeling (SLM). SLM estimates the probability of the program's abstract syntax tree (AST) by decomposing it into a product of conditional probabilities over its nodes. We present a neural model that computes these conditional probabilities by considering all AST paths leading to a target node. Unlike previous techniques that have severely restricted the kinds of expressions that can be generated in this task, our approach can generate arbitrary code in any programming language. Our model significantly outperforms both seq2seq and a variety of structured approaches in generating Java and C# code. Our code, data, and trained models are available at http://github.com/tech-srl/slm-code-generation/ . An online demo is available at http://AnyCodeGen.org .

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

↑