Skip to main content
QUICK REVIEW

[论文解读] Learning Semantic Program Embeddings with Graph Interval Neural Network

Yu Wang, Fengjuan Gao|arXiv (Cornell University)|May 18, 2020
Software Engineering Research参考文献 37被引用 4
一句话总结

本文提出图区间神经网络(GINN),一种新颖的图神经网络(GNN)架构,通过聚焦控制流图中的区间结构(主要是循环)来学习语义程序嵌入。通过将程序抽象为分层区间,GINN在标准GNN的基础上提升了精度与可扩展性,在真实世界Java代码库的变量误用预测、方法名预测和神经程序错误检测任务中均优于当前最先进模型。

ABSTRACT

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.

研究动机与目标

  • 解决标准图神经网络(GNN)在从源代码学习精确、可扩展程序嵌入方面的局限性。
  • 通过将控制流图抽象为分层区间,利用程序特有的结构特征(尤其是循环)来提升模型性能。
  • 开发一种通用的深度学习模型,使其比现有基于文本或图的模型更有效地捕捉程序的语义特征。
  • 提升下游程序分析任务的性能,如错误检测、变量误用预测和方法名预测。
  • 证明基于区间的抽象方法在降低计算成本的同时,能保持或提升模型准确率。

提出的方法

  • GINN采用一种新颖的抽象方法,将控制流图转换为分层区间,其中每个区间代表一个循环结构。
  • 模型仅聚焦于这些区间以提取深层语义特征,从而减少非关键图组件带来的噪声。
  • GINN在区间层次上运行,通过抽象嵌套循环结构,实现对大型程序的高效扩展。
  • 它利用标准GNN的消息传递机制,但仅在区间内部及区间之间应用,而非在整个图上进行。
  • 该抽象确保仅处理具有语义重要性的子图(即循环),从而提升学习效率与精度。
  • GINN端到端训练,用于下游任务如变量误用预测、方法名预测和错误检测。

实验结果

研究问题

  • RQ1聚焦控制流图中的区间结构(如循环)是否能提升程序嵌入模型的精度?
  • RQ2区间的分层抽象如何提升GNN在大型代码库上的可扩展性?
  • RQ3GINN在下游程序分析任务中是否优于标准GNN和先前最先进模型?
  • RQ4基于GINN的神经错误检测器是否比现有工具(如Facebook Infer)更有效地检测真实世界中的错误?
  • RQ5基于区间的抽象在多大程度上减少了对大型图中广泛消息传递的需求?

主要发现

  • GINN在变量误用预测和方法名预测任务中均优于最先进模型,在两项任务中均取得显著优势。
  • 在13个未见过的测试项目中,当在64个项目的9,000个方法上进行训练时,基于GINN的错误检测器检测到的真正例数量多于基于GNN的检测器。
  • 在20个高度星标的GitHub真实项目中进行评估时,GINN共发出102条警告,其中38条被确认为真实错误,而Facebook Infer则发出129条警告,其中仅34条为真实错误。
  • 在GINN捕获的38个错误中,11个已被修复,12个已确认(修复待定),显示出强大的实际应用价值。
  • 分层区间抽象使GINN能够高效扩展至大型图,且不损失精度,而标准GNN则难以做到这一点。
  • GINN专注于循环区间,使其能够捕捉更深层次的语义特征,从而生成更准确、更具泛化能力的程序嵌入。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。