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

Shangqing Liu, Xiaofei Xie, Jingkai Siow, Lei Ma, Guozhu Meng +1 more
11/4/2021
cs.SEcs.AI
gnn

Official code: shangqing-liu/GraphSearchNet (32 stars, Python, last commit 2022-12-31).

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

This repo is the implementation of the paper "GraphSearchNet: Enhancing GNNs via Capturing Global Dependency for Semantic Code Search". We encode the programs and descriptions in a dual graph framework to learn the semantic similarity.

327PythonDec 11, 20213 years ago

Similar Papers

Cite this paper

@article{liu2021graphsearchnet,
  title  = {GraphSearchNet: Enhancing GNNs via Capturing Global Dependencies for Semantic Code Search},
  author = {Shangqing Liu and Xiaofei Xie and Jingkai Siow and Lei Ma and Guozhu Meng and Yang Liu},
  year   = {2021},
  eprint = {2111.02671},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2111.02671}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2111.02671.svg)](https://codeofpaper.com/paper/2111.02671)

Discussion