GraphSearchNet
GraphSearchNet matches natural language queries to code using a bidirectional GGNN with multi-head attention.
Graphs and geometry · 395 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Task
- Graphs and geometry
- Parameters
- 19.7M
- Operations
- 395
- Framework
- PyTorch
- Recurrent
- Yes
- Published
- IEEE Transactions on Software Engineering (arXiv 2021)
- Cited by
- 61 (as of 29 October 2026)
- Authors
- Shangqing Liu, Xiaofei Xie, Jingkai Siow and others
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m17161
- Graph hash
- 65c40e58d290183fc8ecd2064107bce65cd0cff69a4104e39b9f37caf8f7ecba
- Skeleton hash
- ba59f800f9d7a3de1d2ee28f63c3fe15137b9e2fa9c0d9f548fa6abe4b5d8864
- Architecture hash
- e052926cc086535c086d068fdbe4ba7b2b662fff1ec20325d5c71e99694baa71
- Diagram SHA-256
- c398c47e89c15a6007fa6296758f86f769dbf013efcbd891ca65d7fd5908c0b9
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
GraphSearchNet is a neural network framework for source code search that jointly learns the semantics of source code and natural language queries. The paper observes that most existing deep learning approaches feed the program and the query as a flat sequence of tokens, so the structural information is not fully considered. The code release describes its approach as encoding programs and descriptions in a dual graph framework to learn their semantic similarity.
A program is converted to a graph with syntactic edges and data-flow edges that represent the program semantics. The summary graph is built from dependency parsing. In each encoder, the constructed graph is fed to a Bidirectional Gated Graph Neural Network (BiGGNN) to capture the structural information in the graph. A multi-head attention module then supplements the global dependencies that BiGGNN misses. The vectors produced by the Bidirectional GGNN and by multi-head attention are concatenated to give the final representation.
For training, the paper follows CodeSearchNet and uses a cross-entropy loss. At query time, GraphSearchNet embeds a new query with the summary encoder and computes the cosine similarity between the query vector and all stored program vectors in the search codebase. The paper reports that, in experiments on Java and Python from the CodeSearchNet benchmark, GraphSearchNet outperforms the works it is compared against.
Key idea. GraphSearchNet encodes both code and queries as graphs with a bidirectional GGNN and adds multi-head attention to supply the global dependencies the GGNN misses.
- semantic code search
- bidirectional GGNN
- multi-head attention
- program graph
- summary graph
- data-flow edges
- dependency parsing
- global dependencies
- cosine similarity
- CodeSearchNet
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{liu2023graphsearchnetenhancinggnnscapturing,
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={2023},
eprint={2111.02671},
archivePrefix={arXiv},
primaryClass={cs.SE},
url={https://arxiv.org/abs/2111.02671},
}