NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Recommendations for Datasets for Source Code Summarization

Alexander LeClair, Collin McMillanNAACL 2019

Abstract

Source code summarization—the task of automatically generating natural language descriptions for code snippets—currently lacks the standardized benchmarks found in other natural language processing domains. This paper identifies a "reproducibility crisis" in the field, showing that common dataset splitting practices can artificially inflate performance metrics by over 30%. We evaluate the impact of data leakage and auto-generated code, and introduce a massive new standardized dataset of 2.1 million Java method-comment pairs to facilitate more rigorous research.

Introduction

While the field of source code summarization is expanding rapidly, it suffers from a lack of standardized datasets. Researchers often "roll their own" datasets by scraping GitHub, leading to two major problems. First, inconsistency makes it impossible to compare models trained on different data. Second, "data leakage" occurs when datasets are split by individual methods rather than by project. Because developers use consistent naming conventions within a project, a model can "memorize" a project's style if methods from that project appear in both training and testing sets, rather than learning to generalize code understanding.

Methodology

To investigate these issues, we conducted controlled experiments using a standard baseline model, an attentional GRU (attendgru). We focused on two primary research questions:

  1. RQ1 (Splitting Strategy): How does performance change when splitting data by project (ensuring no project overlap between sets) versus splitting by individual methods?
  2. RQ2 (Auto-generated Code): Does the inclusion of boilerplate, automatically generated code skew performance results?

The Dataset

We introduce a curated dataset derived from the Sourcerer project, containing over 2.1 million Java method-comment pairs across 28,000 projects. The data was filtered for English comments, with constraints on method length (max 100 words) and comment length (3–13 words). We provide three versions: Raw SQL, Filtered (no auto-generated code), and Tokenized for machine learning.

Key Insights: The Concept Assignment Problem

Our analysis reveals a significant "concept assignment problem." There is surprisingly little lexical overlap between code and its summary; only about 30% of words in a comment typically appear in the code it describes.

Distribution of word overlap and length for code and comments.

As shown in Figure 4, the percentage of code words appearing in comments (a) and comment words appearing in code (b) is relatively low. This suggests that models cannot simply "extract" words from the code; they must synthesize high-level concepts to generate accurate summaries.

Experimental Results

The choice of splitting strategy has a profound impact on reported performance. When the dataset was split by individual functions, the model achieved an average BLEU score of 23.02. However, when using a more rigorous project-based split, the score dropped to 17.41—a 32% decrease.

Impact of splitting strategy and auto-generated code on BLEU scores.

Figure 3 illustrates this "false boost." Splitting by function allows the model to exploit project-specific "dialects," leading to inflated scores that do not reflect true generalization. Additionally, including auto-generated code (which is highly repetitive and easy to predict) provides a further unrealistic boost to performance metrics.

Conclusion and Future Work

Our findings demonstrate that dataset design is as critical as model architecture in source code summarization. Project-based splitting is essential for measuring a model's ability to generalize to unseen software. While this study focuses on Java, the principles likely apply to other programming languages. Future work should explore more nuanced metrics than BLEU and investigate how project-level context might be safely incorporated into training without introducing leakage.

Summary updated

BibTeX
@inproceedings{leclair2019recommendations,
  author = {Alexander LeClair and Collin McMillan},
  title = {{Recommendations for Datasets for Source Code Summarization}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2019},
  doi = {10.18653/v1/n19-1394},
}
Figure