arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2103.15361cs.SEcs.AI
收藏

嵌入API依赖图的神经代码生成

Embedding API Dependency Graph for Neural Code Generation

Shandong Normal University(山东师范大学);The University of Newcastle(纽卡斯尔大学);Big Data Center of Shandong Province(山东省大数据中心);Institute of Information Engineering, Chinese Academy of Sciences(中国科学院信息工程研究所);University of Chinese Academy of Sciences(中国科学院大学)

Chen Lyu, Ruyun Wang, Hongyu Zhang, Hanwen Zhang, Songlin Hu

摘要:

从文本程序描述生成代码生成的问题一直被视为软件工程中的一个重大挑战。近年来,已经提出了许多基于深度学习的方法,其可以从文本程序描述的序列生成代码序列。然而,现有的方法忽略了API方法之间的全局关系,这对于理解API的使用是很重要的。在本文中,我们建议将API方法之间的依赖关系建模为API依赖图(ADG),并将图形嵌入到序列到序列(Seq 2Seq)模型中。除了现有的编码器-解码器结构,一个新的模块命名为“嵌入器”。通过这种方式,解码器可以利用全局结构依赖性和文本程序描述来预测目标代码。我们进行了广泛的代码生成实验上的三个公共数据集和两个程序设计语言(Python和Java)。我们提出的方法称为ADG-Seq 2Seq,与现有的最先进的方法相比有了显着的改进,并且随着目标代码长度的增加而保持其性能。广泛的消融测试表明,建议的ADG嵌入是有效的,优于基线。

英文摘要:

The problem of code generation from textual program descriptions has long been viewed as a grand challenge in software engineering. In recent years, many deep learning based approaches have been proposed, which can generate a sequence of code from a sequence of textual program description. However, the existing approaches ignore the global relationships among API methods, which are important for understanding the usage of APIs. In this paper, we propose to model the dependencies among API methods as an API dependency graph (ADG) and incorporate the graph embedding into a sequence-to-sequence (Seq2Seq) model. In addition to the existing encoder-decoder structure, a new module named ``embedder" is introduced. In this way, the decoder can utilize both global structural dependencies and textual program description to predict the target code. We conduct extensive code generation experiments on three public datasets and in two programming languages (Python and Java). Our proposed approach, called ADG-Seq2Seq, yields significant improvements over existing state-of-the-art methods and maintains its performance as the length of the target code increases. Extensive ablation tests show that the proposed ADG embedding is effective and outperforms the baselines.

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

↑