arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2111.02671cs.SEcs.AI
收藏

GraphSearchNet:通过捕获全局语义代码搜索增强GNN

GraphSearchNet: Enhancing GNNs via Capturing Global Dependencies for Semantic Code Search

Nanyang Technological University(南洋理工大学);Singapore Management University(新加坡管理大学);University of Alberta(阿尔伯塔大学);Institute of Information Engineering, Chinese Academy of Sciences(中国科学院信息工程研究所)

Shangqing Liu, Xiaofei Xie, Jingkai Siow, Lei Ma, Guozhu Meng, Yang Liu

摘要:

代码搜索旨在基于自然语言查询检索准确的代码片段,以提高软件生产率和质量。由于有大量可用的程序,例如(在GitHub或Stack Overflow上),识别和本地化精确的代码对于软件开发人员来说至关重要。此外,深度学习最近已被广泛应用于不同的代码相关场景,例如,漏洞检测,源代码总结。然而,自动化深度代码搜索仍然具有挑战性,因为它需要代码和自然语言查询之间的高级语义映射。大多数现有的基于深度学习的代码搜索方法依赖于顺序文本,将程序和查询作为令牌的平坦序列来馈送,以在没有充分考虑结构信息的情况下学习程序语义。此外,广泛采用的图神经网络(GNNs)已经证明了它们在学习程序语义方面的有效性,然而,它们也遭受在构造的图中捕获全局依赖的问题,这限制了模型学习能力。为了解决这些挑战,在本文中,我们设计了一种新的神经网络框架,命名为GraphSearchNet,使一个有效的和准确的源代码搜索,通过共同学习源代码和自然语言查询丰富的语义。具体来说,我们建议用双向GGNN(BiGGNN)为源代码和查询构建图,以捕获源代码和查询的局部结构信息。此外,我们通过利用多头注意力模块来补充BiGGNN遗漏的全局依赖关系,以提高模型的学习能力,从而增强BiGGNN。在Java和Python程序设计语言上的广泛实验证实了GraphSearchNet优于当前最先进的作品。

英文摘要:

Code search aims to retrieve accurate code snippets based on a natural language query to improve software productivity and quality. With the massive amount of available programs such as (on GitHub or Stack Overflow), identifying and localizing the precise code is critical for the software developers. In addition, Deep learning has recently been widely applied to different code-related scenarios, e.g., vulnerability detection, source code summarization. However, automated deep code search is still challenging since it requires a high-level semantic mapping between code and natural language queries. Most existing deep learning-based approaches for code search rely on the sequential text i.e., feeding the program and the query as a flat sequence of tokens to learn the program semantics while the structural information is not fully considered. Furthermore, the widely adopted Graph Neural Networks (GNNs) have proved their effectiveness in learning program semantics, however, they also suffer the problem of capturing the global dependencies in the constructed graph, which limits the model learning capacity. To address these challenges, in this paper, we design a novel neural network framework, named GraphSearchNet, to enable an effective and accurate source code search by jointly learning the rich semantics of both source code and natural language queries. Specifically, we propose to construct graphs for the source code and queries with bidirectional GGNN (BiGGNN) to capture the local structural information of the source code and queries. Furthermore, we enhance BiGGNN by utilizing the multi-head attention module to supplement the global dependencies that BiGGNN missed to improve the model learning capacity. The extensive experiments on Java and Python programming language from the public benchmark CodeSearchNet confirm that GraphSearchNet outperforms current state-of-the-art works.

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

↑