Quantifying Contamination in Evaluating Code Generation Capabilities of Language Models

Martin Riddell, Ansong Ni, Arman Cohan

Abstract

As Large Language Models (LLMs) become integral to software development, benchmarks like HumanEval and MBPP are used to assess their coding proficiency. However, the integrity of these evaluations is threatened by data contamination—the presence of test data in training sets. This paper quantifies leakage in massive open-source corpora, finding that up to 20.8% of benchmark solutions are present in training data. Models exhibit significantly higher performance on these contaminated subsets, suggesting that current evaluation metrics may reflect memorization rather than true reasoning capabilities.

Introduction

The rapid adoption of LLMs in software engineering has led to a heavy reliance on standardized benchmarks to rank model performance. A critical concern is whether these models are "stochastic parrots," merely reproducing memorized code snippets from their training data. Data contamination occurs when test samples leak into pretraining or fine-tuning sets, making it impossible to distinguish between a model's ability to generalize and its capacity for recall. This study provides a rigorous framework to detect and quantify such contamination in popular code generation benchmarks.

Methodology

To identify overlaps between benchmarks and training corpora, the researchers developed a multi-faceted detection pipeline:

  1. Surface-Level Matching: Utilizing a sliding window approach, the training data is scanned for literal character-by-character matches using normalized Levenshtein similarity.
  2. Semantic-Level Matching: To detect "fuzzy" contamination where logic remains identical despite changes in syntax (e.g., variable renaming, comment changes), the authors employed the Dolos toolkit. This tool builds Abstract Syntax Trees (ASTs) to identify semantically equivalent programs.
  3. Aggregated Scoring: An overall similarity score is derived by taking the maximum of the surface and semantic scores. The researchers analyzed both the single most similar match (Top-1) and the average of the ten most similar matches (Top-10).
Distribution of similarity scores across training corpora using surface, semantic, and aggregated metrics.

The study analyzed The PILE (GitHub split) and StarCoderData (Python split) against the MBPP and HumanEval benchmarks.

Quantifying Data Leakage

The analysis reveals that contamination is pervasive across major datasets. Even datasets like StarCoderData, which underwent initial string-matching decontamination, show significant traces of benchmark solutions.

Quantified data contamination on the MBPP benchmark for The PILE and StarCoderData.

As shown in the results for the MBPP benchmark, StarCoderData contains a perfect match (100% similarity) for 20.8% of the problems, while The PILE contains perfect matches for 3.6%. When the threshold is lowered to a similarity score of >80, over half of the MBPP benchmark is represented in StarCoderData.

Impact on Model Performance

The presence of contaminated data leads to a substantial "performance gap." Models perform markedly better on problems they have likely encountered during training. For instance, StarCoderBase-15.5B achieves 72% accuracy on the most similar 10% of MBPP problems, compared to only 22% on the least similar 10%.

Furthermore, the study finds that:

  • Memorization Scales with Model Size: Larger models demonstrate a greater capacity for memorizing training data, leading to wider performance gaps between seen and unseen subsets.
  • Accuracy Inflation: Removing "potentially contaminated" samples (similarity > 80) causes a sharp drop in reported performance. StarCoderBase-15.5B’s HumanEval accuracy decreased by 34.4% relative to its original score after decontamination.

Discussion and Limitations

While this study provides a robust quantification of leakage, it faces certain constraints. The computational cost of searching terabyte-scale datasets necessitated limiting the search to specific language splits, potentially missing cross-lingual contamination. Additionally, the study focuses on open-weights models; the contamination levels in proprietary models like GPT-4 remain unknown and require alternative detection methods.

Conclusion

The findings underscore the urgent need for more rigorous decontamination processes and the development of "unseen" or dynamic benchmarks. As LLMs continue to evolve, ensuring that evaluations measure genuine problem-solving ability rather than memorization is paramount for the fair and accurate assessment of AI capabilities in software engineering.

Summary updated

BibTeX
@inproceedings{riddell2024quantifying,
  author = {Martin Riddell and Ansong Ni and Arman Cohan},
  title = {{Quantifying Contamination in Evaluating Code Generation Capabilities of Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.761},
}
Figure