deGraphCS:基于变量的流图神经代码搜索
deGraphCS: Embedding Variable-based Flow Graph for Neural Code Search
摘要:
随着公共代码库数量的迅速增加,开发人员对使用自然语言检索精确的代码片段有着极大的需求。尽管现有的基于深度学习的方法(例如,DeepCS和MMAN)提供了端到端解决方案(即,接受自然语言作为查询并示出直接从代码语料库检索的相关代码片段),但是大规模储存库中的代码搜索的准确性仍然受到代码表示的限制(例如,AST)和建模(例如,直接融合注意阶段的特征)。在本文中,我们提出了一种新的可学习的深度图代码搜索(calleddeGraphCS),源代码转换为基于变量的流图的基础上的中间表示技术,它可以更精确地建模代码语义相比,直接处理代码作为文本或使用语法树表示。此外,我们提出了一个精心设计的图优化机制,以改善代码表示,并应用改进的门控图神经网络模型变量为基础的流图。为了评估deGraphCS的有效性,我们从GitHub上收集了一个包含41,152个C语言代码片段的大规模数据集,并复制了几种典型的深度代码搜索方法进行比较。此外,我们设计了一个定性的用户研究,以验证我们的方法的实用价值。实验结果表明,deGraphCS能够达到最先进的性能,准确地检索出满足用户需求的代码片段。
英文摘要:
With the rapid increase in the amount of public code repositories, developers maintain a great desire to retrieve precise code snippets by using natural language. Despite existing deep learning based approaches(e.g., DeepCS and MMAN) have provided the end-to-end solutions (i.e., accepts natural language as queries and shows related code fragments retrieved directly from code corpus), the accuracy of code search in the large-scale repositories is still limited by the code representation (e.g., AST) and modeling (e.g., directly fusing the features in the attention stage). In this paper, we propose a novel learnable deep Graph for Code Search (calleddeGraphCS), to transfer source code into variable-based flow graphs based on the intermediate representation technique, which can model code semantics more precisely compared to process the code as text directly or use the syntactic tree representation. Furthermore, we propose a well-designed graph optimization mechanism to refine the code representation, and apply an improved gated graph neural network to model variable-based flow graphs. To evaluate the effectiveness of deGraphCS, we collect a large-scale dataset from GitHub containing 41,152 code snippets written in C language, and reproduce several typical deep code search methods for comparison. Besides, we design a qualitative user study to verify the practical value of our approach. The experimental results have shown that deGraphCS can achieve state-of-the-art performances, and accurately retrieve code snippets satisfying the needs of the users.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。