arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2005.09997cs.SEcs.LGcs.PL
收藏

图区间神经网络学习语义程序嵌入

Learning Semantic Program Embeddings with Graph Interval Neural Network

Nanjing University(南京大学);Visa Research(Visa研究院)

Yu Wang, Fengjuan Gao, Linzhang Wang, Ke Wang

摘要:

学习源代码的分布式表示一直是机器学习模型的一项具有挑战性的任务。早期的作品将程序视为文本,以便可以容易地应用自然语言方法。不幸的是,这样的方法不利用源代码所拥有的丰富的结构信息。最近,图神经网络(GNN)被提出来从程序的图表示中学习程序的嵌入。由于同质和昂贵的消息传递过程,GNN可能会遇到精度问题,特别是在处理渲染成大型图形的程序时。在本文中,我们提出了一个新的图神经架构,称为图区间神经网络(GINN),以解决现有的GNN的弱点。与标准的GNN不同,GINN通过一种旨在帮助模型学习的抽象方法获得了一个精选的图形表示。特别是,GINN专门关注用于挖掘程序特征表示的间隔,此外,GINN对间隔的层次结构进行操作,以将学习扩展到大型图。我们评估GINN的两个流行的下游应用程序:变量误用预测和方法名称预测。结果显示,在这两种情况下,GINN的表现都优于最先进的模型。我们还创建了一个基于GINN的神经bug检测器,以捕获Java代码中的空指针遵从bug。在从64个项目中提取的相同的9,000种方法中学习的同时,基于GINN的错误检测器在13个看不见的测试项目中显著优于基于GNN的错误检测器。接下来,我们部署经过训练的基于GINN的bug检测器和Facebook Infer来扫描GitHub上20个高星级项目的代码库。通过我们的手动检查,我们确认了基于GINN的错误检测器提出的102个警告中的38个错误,而Facebook Infer提出的129个警告中有34个错误。

英文摘要:

Learning distributed representations of source code has been a challenging task for machine learning models. Earlier works treated programs as text so that natural language methods can be readily applied. Unfortunately, such approaches do not capitalize on the rich structural information possessed by source code. Of late, Graph Neural Network (GNN) was proposed to learn embeddings of programs from their graph representations. Due to the homogeneous and expensive message-passing procedure, GNN can suffer from precision issues, especially when dealing with programs rendered into large graphs. In this paper, we present a new graph neural architecture, called Graph Interval Neural Network (GINN), to tackle the weaknesses of the existing GNN. Unlike the standard GNN, GINN generalizes from a curated graph representation obtained through an abstraction method designed to aid models to learn. In particular, GINN focuses exclusively on intervals for mining the feature representation of a program, furthermore, GINN operates on a hierarchy of intervals for scaling the learning to large graphs. We evaluate GINN for two popular downstream applications: variable misuse prediction and method name prediction. Results show in both cases GINN outperforms the state-of-the-art models by a comfortable margin. We have also created a neural bug detector based on GINN to catch null pointer deference bugs in Java code. While learning from the same 9,000 methods extracted from 64 projects, GINN-based bug detector significantly outperforms GNN-based bug detector on 13 unseen test projects. Next, we deploy our trained GINN-based bug detector and Facebook Infer to scan the codebase of 20 highly starred projects on GitHub. Through our manual inspection, we confirm 38 bugs out of 102 warnings raised by GINN-based bug detector compared to 34 bugs out of 129 warnings for Facebook Infer.

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

↑