Retrieval-Augmented Generation for Code Summarization via Hybrid GNN

Shangqing Liu, Yu Chen, Xiaofei Xie, Jingkai Siow, Yang Liu
6/9/2020
cs.LGcs.AI
gnnrag

Official code: shangqing-liu/CCSD-benchmark-for-code-summarization (26 stars, last commit 2021-03-18).

Abstract

Source code summarization aims to generate natural language summaries from structured code snippets for better understanding code functionalities. However, automatic code summarization is challenging due to the complexity of the source code and the language gap between the source code and natural language summaries.

Show full abstract

Most previous approaches either rely on retrieval-based (which can take advantage of similar examples seen from the retrieval database, but have low generalization performance) or generation-based methods (which have better generalization performance, but cannot take advantage of similar examples). This paper proposes a novel retrieval-augmented mechanism to combine the benefits of both worlds. Furthermore, to mitigate the limitation of Graph Neural Networks (GNNs) on capturing global graph structure information of source code, we propose a novel attention-based dynamic graph to complement the static graph representation of the source code, and design a hybrid message passing GNN for capturing both the local and global structural information. To evaluate the proposed approach, we release a new challenging benchmark, crawled from diversified large-scale open-source C projects (total 95k+ unique functions in the dataset). Our method achieves the state-of-the-art performance, improving existing methods by 1.42, 2.44 and 1.29 in terms of BLEU-4, ROUGE-L and METEOR.

View on arXivView PDF

Code Implementations(1)

This repo is the benchmark for source code summarization on C language

261Mar 18, 20215 years ago

Similar Papers

Cite this paper

@article{liu2020retrievalaugmented,
  title  = {Retrieval-Augmented Generation for Code Summarization via Hybrid GNN},
  author = {Shangqing Liu and Yu Chen and Xiaofei Xie and Jingkai Siow and Yang Liu},
  year   = {2020},
  eprint = {2006.05405},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2006.05405}
}

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/2006.05405.svg)](https://codeofpaper.com/paper/2006.05405)

Discussion