[论文解读] Program Classification Using Gated Graph Attention Neural Network for Online Programming Service
该论文提出了一种门控图注意力神经网络(GGANN),通过将数据流和函数调用信息整合到抽象语法树(AST)中,构建统一的程序图,从而提升程序分类性能。该模型利用注意力机制捕捉程序的语义和结构特征,实现了97.8%的最先进分类准确率。
The online programing services, such as Github,TopCoder, and EduCoder, have promoted a lot of social interactions among the service users. However, the existing social interactions is rather limited and inefficient due to the rapid increasing of source-code repositories, which is difficult to explore manually. The emergence of source-code mining provides a promising way to analyze those source codes, so that those source codes can be relatively easy to understand and share among those service users. Among all the source-code mining attempts,program classification lays a foundation for various tasks related to source-code understanding, because it is impossible for a machine to understand a computer program if it cannot classify the program correctly. Although numerous machine learning models, such as the Natural Language Processing (NLP) based models and the Abstract Syntax Tree (AST) based models, have been proposed to classify computer programs based on their corresponding source codes, the existing works cannot fully characterize the source codes from the perspective of both the syntax and semantic information. To address this problem, we proposed a Graph Neural Network (GNN) based model, which integrates data flow and function call information to the AST,and applies an improved GNN model to the integrated graph, so as to achieve the state-of-art program classification accuracy. The experiment results have shown that the proposed work can classify programs with accuracy over 97%.
研究动机与目标
- 解决现有程序分类模型在有效捕捉语法和语义信息方面的局限性。
- 通过实现准确的程序理解与推荐,提升GitHub、TopCoder和EduCoder等在线编程服务中的社交互动效率。
- 构建一种统一的图表示方法,以同时捕捉细粒度的数据流和粗粒度的函数调用关系。
- 设计一种图神经网络模型,能够学习具有语义丰富性的节点表示,用于程序分类。
提出的方法
- 通过在抽象语法树(AST)中增加数据流边和函数调用边,构建程序图,以捕捉语法和语义信息。
- 提出一种门控图注意力神经网络(GGANN),将注意力机制集成到门控图神经网络(GGNN)中,以在消息传递过程中动态加权节点重要性。
- 基于注意力分数设计图级聚合函数,计算用于分类的最终图表示。
- 将GGANN模型应用于源自源代码的程序图表示,实现结构和语义特征的端到端学习。
- 利用t-SNE可视化和K-means聚类对学习到的节点嵌入进行分析,以验证语义聚类行为。
- 开展消融研究并与最先进模型(如TBCNN)进行比较,以评估性能和泛化能力。
实验结果
研究问题
- RQ1通过将数据流和函数调用信息整合到AST中,图神经网络模型能否有效学习源代码的语法和语义特征?
- RQ2GGANN中的注意力机制是否能成功识别并优先关注程序图中语义重要的节点?
- RQ3学习到的节点表示是否能反映有意义的语义聚类,例如将控制流语句或操作符分组?
- RQ4在未见代码上的分类准确率和泛化能力方面,所提出的GGANN模型相较于TBCNN等现有模型表现如何?
主要发现
- 所提出的GGANN模型在基准数据集上实现了97.8%的程序分类准确率,优于最先进方法。
- 对学习到的节点表示进行t-SNE可视化,显示出清晰的聚类模式,表明模型成功捕捉了节点之间的语义相似性。
- 对节点嵌入进行K-means聚类显示,语义相关的节点(如控制流语句,例如ForStmt、BreakStmt,以及操作符,例如BinaryOperator、IntegerLiteral)被有效分组。
- GGANN中的注意力分数突出了IfStmt、CallExpr和CompoundStmt等关键结构节点的重要性,证实了模型对语义丰富组件的关注能力。
- 该模型在未见测试数据上表现出良好的泛化能力,展示了在多样化编程任务中稳健的特征学习能力。
- 将数据流和函数调用边整合到AST中,显著提升了表示质量,相较于仅使用AST的模型具有明显优势。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。