Skip to main content
QUICK REVIEW

[Paper Review] Automatic Code Summarization via Multi-dimensional Semantic Fusing in GNN.

Shangqing Liu, Yu Chen|arXiv (Cornell University)|Jun 9, 2020
Software Engineering ResearchComputer Science52 references19 citations
TL;DR

This paper proposes a graph neural network (GNN)-based method for automatic code summarization that fuses multiple code representations—AST, CFG, and PDG—into a joint code property graph. By integrating retrieval-augmented external knowledge and a dynamic graph attention mechanism, the model captures both local and global code semantics, achieving state-of-the-art performance with improvements of 1.66, 2.38, and 2.22 in BLEU-4, ROUGE-L, and METEOR on a new benchmark from 200+ open-source C projects.

ABSTRACT

Source code summarization aims to generate natural language summaries from structured code snippets for better understanding code functionalities. Recent works attempt to encode programs into graphs for learning program semantics and yield promising results. However, these methods only use simple code representations (e.g., AST), which limits the capability of learning the rich semantics for complex programs. Furthermore, these models primarily rely on graph-based message passing, which only captures local neighborhood relations. To this end, in this paper, we combine diverse representations of the source code (i.e., AST, CFG and PDG) into a joint code property graph. To better learn semantics from the joint graph, we propose a retrieval-augmented mechanism to augment source code semantics with external knowledge. Furthermore, we propose a novel attention-based dynamic graph to capture global interactions among nodes in the static graph and followed a hybrid message passing GNN to incorporate both static and dynamic graph. To evaluate our proposed approach, we release a new challenging benchmark, crawled from 200+ diversified large-scale open-source C projects. Our method achieves the state-of-the-art performance, improving existing methods by 1.66, 2.38 and 2.22 in terms of BLEU-4, ROUGE-L and METEOR metrics.

Motivation & Objective

  • Address the limitation of existing code summarization methods that rely on single or simple code representations like AST, which fail to capture rich semantics in complex programs.
  • Overcome the local receptive field of traditional graph-based message passing in GNNs by enabling global node interaction modeling.
  • Enhance code semantics by integrating external knowledge through a retrieval-augmented mechanism.
  • Develop a hybrid GNN architecture combining static and dynamic graph learning to improve representation learning on code graphs.
  • Establish a new, challenging benchmark for code summarization by crawling 200+ large-scale open-source C projects.

Proposed method

  • Construct a joint code property graph by fusing three static code representations: Abstract Syntax Tree (AST), Control Flow Graph (CFG), and Program Dependence Graph (PDG).
  • Introduce a retrieval-augmented mechanism to enrich node embeddings with external knowledge from code documentation and related code snippets.
  • Propose a novel attention-based dynamic graph to model long-range dependencies among nodes in the static code graph.
  • Design a hybrid message passing mechanism that combines information from both the static joint graph and the learned dynamic graph.
  • Train the model end-to-end using sequence-to-sequence learning with cross-attention to generate natural language summaries from code embeddings.

Experimental results

Research questions

  • RQ1Can fusing multiple static code representations (AST, CFG, PDG) into a unified graph improve code semantics representation for summarization?
  • RQ2To what extent does retrieval-augmented external knowledge enhance code representation learning in low-resource or complex code scenarios?
  • RQ3Does modeling global node interactions via a dynamic graph attention mechanism outperform standard local message passing in GNNs for code summarization?
  • RQ4How does the proposed hybrid GNN architecture compare to existing state-of-the-art models on diverse, real-world code summarization benchmarks?
  • RQ5What is the impact of using a large-scale, diverse open-source C code benchmark on model generalization and performance evaluation?

Key findings

  • The proposed method achieves state-of-the-art performance on code summarization, improving BLEU-4 by 1.66 points over existing methods.
  • The model improves ROUGE-L by 2.38 points, indicating significant gains in recall-oriented summary quality.
  • METEOR scores increase by 2.22 points, demonstrating better alignment with human-annotated summaries in terms of lexical and semantic precision.
  • The integration of retrieval-augmented knowledge consistently improves code representation, especially for rare or complex code patterns.
  • The dynamic graph attention mechanism enables better modeling of long-range dependencies, contributing to improved global understanding of code structure.
  • The newly released benchmark from 200+ open-source C projects provides a more realistic and challenging evaluation setting, revealing limitations in prior models.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.