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

Impact of Evaluation Methodologies on Code Summarization

Pengyu Nie, Jiyang Zhang, Junyi Jessy Li, Raymond J. Mooney, Milos Gligoric

Introduction

In the field of Machine Learning for Software Engineering (ML4SE), code summarization—the automated generation of natural language descriptions for code snippets—has emerged as a cornerstone task. As models become increasingly sophisticated, the rigor of their evaluation becomes paramount. However, standard evaluation practices often overlook a critical dimension of software development: time. This paper investigates how traditional data-splitting strategies can lead to inflated performance metrics and, more importantly, how they can fundamentally misrepresent the relative effectiveness of different models.

The Problem: Temporal Leakage

Traditional evaluation in code summarization typically relies on two strategies: Mixed-Project (randomly shuffling all samples) and Cross-Project (training on one set of projects and testing on another). While these methods are common in general machine learning, they fail to account for the temporal evolution of software.

In a real-world "continuous-mode" scenario, a developer uses a model to summarize new code based on the project's existing history. Standard benchmarks often allow for "temporal leakage," where a model might be trained on code written in 2021 to predict a comment written in 2018. This ignores the natural evolution of programming languages, libraries, and project-specific coding styles, resulting in models that appear highly performant in the lab but struggle in production environments.

Evaluation Methodologies

To address these biases, the researchers formalize three distinct evaluation methodologies, each representing a different use case:

  1. Mixed-Project (In-Project Batch-Mode): This is the current industry standard. Data from all projects and all time periods are shuffled and split. While it yields high performance scores, it is often unrealistic due to temporal leakage.
  2. Cross-Project (Cross-Project Batch-Mode): This methodology tests a model's ability to generalize to an entirely new codebase. It is often the most challenging setting and typically yields the lowest performance metrics.
  3. Time-Segmented (Continuous-Mode): The authors propose this as a more realistic alternative. It splits data chronologically: training on historical data (before $T_1$), validating on subsequent data ($T_1$ to $T_2$), and testing on the most recent samples (after $T_2$).
The standard Mixed-Project approach shuffles samples across all projects and time periods.
The proposed Time-Segmented approach trains on the past to predict the future, mirroring real-world usage.

To ensure a fair comparison, the study utilizes Common Test Sets (TestC). These are intersections of test samples that remain valid across all three methodologies, allowing researchers to evaluate the same models on identical data while only varying the composition of the training set.

Experimental Setup and Dataset

Existing datasets often lack the necessary metadata (like commit timestamps) for temporal evaluation. Consequently, the authors curated a new dataset comprising 160 active open-source Java projects from GitHub. The dataset includes pairs of code and comments, as well as code and method names, spanning three distinct snapshots: January 2019, January 2020, and January 2021. After rigorous cleaning—including the removal of non-English comments and empty method bodies—the final dataset contained approximately 77,000 samples.

Key Findings: The Impact of Methodology

1. Ranking Flips

A critical discovery of this research is that the choice of evaluation methodology can completely reverse model rankings. For the task of method naming, Code2Seq outperformed Code2Vec in the cross-project setting. However, in both the mixed-project and time-segmented settings, Code2Vec emerged as the winner. This occurs because Code2Vec relies heavily on retrieving names from the training set; when the "future" code closely resembles the "past" code within the same project, Code2Vec maintains an advantage that disappears when it encounters a completely unfamiliar project.

2. Performance Inflation and Pessimism

Performance metrics like BLEU and METEOR are consistently highest under the mixed-project methodology. For instance, a Transformer model achieved a 58.1 BLEU score in a mixed-project setup, which plummeted to 14.3 BLEU in a cross-project setup. The time-segmented score (56.1 BLEU) provided a more realistic middle ground. The authors argue that mixed-project scores are "inflated" due to the model essentially "cheating" by seeing samples from the same project and time period in both training and testing. Conversely, cross-project evaluation may be overly pessimistic for developers working on long-term, stable projects.

3. Data Leakage via Clones

The study also highlighted the prevalence of "near-duplicate" code clones. Even after removing exact duplicates, similarity levels reached up to 77% in some cases. Without time-segmentation, these clones act as a form of data leakage, further artificially boosting the performance of models in standard splits.

Conclusion

The findings demonstrate that time-unaware evaluation methodologies provide a distorted view of model performance in code summarization. The authors recommend that Time-Segmented Evaluation should become the new standard for ML4SE tasks, including bug localization and code synthesis. Future work should investigate the impact of these methodologies on large-scale pre-trained models like CodeBERT, which may already contain "future" data in their massive training snapshots.

Summary updated

BibTeX
@inproceedings{nie2022impact,
  author = {Pengyu Nie and Jiyang Zhang and Junyi Jessy Li and Raymond J. Mooney and Milos Gligoric},
  title = {{Impact of Evaluation Methodologies on Code Summarization}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  url = {https://openreview.net/forum?id=eLyxKrJPI-y},
}
Figure