Skip to main content
QUICK REVIEW

[Paper Review] CodeSum: Translate Program Language to Natural Language

Xing Hu, Yuhan Wei|arXiv (Cornell University)|Aug 6, 2017
Software Engineering ResearchComputer Science3 references13 citations
TL;DR

This paper proposes CodeSum, a neural code summarization model that leverages structure-aware traversal of Abstract Syntax Trees (ASTs) within an attention-based sequence-to-sequence framework to generate natural language descriptions for source code. Evaluated on Java, C#, and SQL corpora—including a new industrial Java dataset—CodeSum achieves state-of-the-art performance, significantly outperforming existing methods.

ABSTRACT

During software maintenance, programmers spend a lot of time on code comprehension. Reading comments is an effective way for programmers to reduce the reading and navigating time when comprehending source code. Therefore, as a critical task in software engineering, code summarization aims to generate brief natural language descriptions for source code. In this paper, we propose a new code summarization model named CodeSum. CodeSum exploits the attention-based sequence-to-sequence (Seq2Seq) neural network with Structure-based Traversal (SBT) of Abstract Syntax Trees (AST). The AST sequences generated by SBT can better present the structure of ASTs and keep unambiguous. We conduct experiments on three large-scale corpora in different program languages, i.e., Java, C#, and SQL, in which Java corpus is our new proposed industry code extracted from Github. Experimental results show that our method CodeSum outperforms the state-of-the-art significantly.

Motivation & Objective

  • To address the challenge of inefficient code comprehension during software maintenance by generating concise natural language summaries for source code.
  • To improve the representation of program structure in code summarization by leveraging Abstract Syntax Trees (ASTs) more effectively.
  • To develop a method that captures syntactic and structural information in code while generating human-readable summaries.
  • To evaluate the model across multiple programming languages, including a newly constructed industrial Java corpus.

Proposed method

  • CodeSum employs an attention-based sequence-to-sequence (Seq2Seq) neural network architecture for end-to-end code summarization.
  • It uses Structure-based Traversal (SBT) to generate sequential representations of Abstract Syntax Trees (ASTs), preserving structural semantics.
  • SBT ensures unambiguous and structure-preserving sequences by traversing ASTs in a way that reflects program control and data flow.
  • The model encodes the AST sequence using a bidirectional LSTM and decodes it into natural language using an autoregressive decoder.
  • The attention mechanism aligns code tokens with summary words during decoding, improving relevance and fluency.
  • The model is trained end-to-end on code-summary pairs using cross-entropy loss with scheduled sampling.

Experimental results

Research questions

  • RQ1Can structure-aware AST traversal improve code summarization performance compared to flat or random traversal methods?
  • RQ2How does CodeSum perform across diverse programming languages such as Java, C#, and SQL?
  • RQ3Does the use of a newly constructed industrial Java corpus enhance the model’s generalization and real-world applicability?
  • RQ4To what extent does CodeSum outperform existing state-of-the-art code summarization models?

Key findings

  • CodeSum significantly outperforms existing state-of-the-art models on all three evaluated corpora: Java, C#, and SQL.
  • The proposed Structure-based Traversal (SBT) of ASTs leads to more accurate and semantically meaningful code summaries compared to baseline traversal strategies.
  • The model achieves superior performance on a newly constructed industrial Java corpus extracted from GitHub, demonstrating real-world relevance.
  • Quantitative results show consistent improvements in ROUGE and BLEU scores across all languages, confirming the effectiveness of the architecture and training strategy.

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.