CodeGNN
A code summarizer that reads both the token sequence and the syntax tree of a subroutine.
Language · 446 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
- Language
- Parameters
- 45.1M
- Operations
- 446
- Framework
- PyTorch
- Recurrent
- Yes
- Published
- ICPC 2020
- Cited by
- 323 (as of 26 October 2026)
- Authors
- Alexander LeClair, Sakib Haque, Lingfei Wu, Collin McMillan
- License
- MIT
- 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
- m15360
- Graph hash
- bfc7710b569ba5e85ac35251860ad4a9f48019c055f546c871138113db669c45
- Skeleton hash
- aaf743068a894489631163757ab785bfcc14e5d6b8d6c05329c107a7f1380bd8
- Architecture hash
- 0095496afbda2bf10f74c4aa5d6b64d2ecabec47473b621bff50e17607f7b90d
- Diagram SHA-256
- 85a1144463f36a05d9dab82edf77356441fdb197b73445237e48103f8ba0602b
- 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
CodeGNN generates short natural-language summaries of program subroutines: source code goes in and a brief description comes out. This model is a PyTorch implementation of CodeGNN from the ICPC 2020 paper that introduced it.
The paper starts from the observation that source code is not merely a sequence of words, so a summarizer should see the structure of the code as well as its tokens. The model has two encoders, one for the token sequence and one for the abstract syntax tree (AST). The AST encoder is a stack of graph convolution (ConvGNN) layers followed by a GRU. The number of ConvGNN layers follows the number of hops, meaning how far across the tree a node gathers information, and the best model in the paper used 2 hops. The decoder attends to the code encoding and the AST encoding through separate attention mechanisms, and the two results are concatenated to predict the next word of the summary.
The design builds on the graph2seq model, adapted to a software engineering setting. The paper evaluates on a data set of 2.1 million Java method-comment pairs against four baseline techniques. It reports a 4.6% BLEU score improvement over recent baselines.
Key idea. The paper processes the abstract syntax tree with a graph neural network and combines that encoding with a sequence encoding of the code tokens to generate summaries.
- codegnn
- icpc2020 gnn code summarizer
- code summarization
- source code summarization
- graph neural network
- abstract syntax tree
- convgnn
- automatic documentation
- java method summaries
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{leclair2020improvedcodesummarizationgraph,
title={Improved Code Summarization via a Graph Neural Network},
author={Alexander LeClair and Sakib Haque and Lingfei Wu and Collin McMillan},
year={2020},
eprint={2004.02843},
archivePrefix={arXiv},
primaryClass={cs.SE},
url={https://arxiv.org/abs/2004.02843},
}