Abstract
Data contamination—the inclusion of evaluation datasets in a model's training corpus—poses a significant threat to the integrity of Code Language Model (CLM) benchmarks. This study systematically evaluates the effectiveness of common countermeasures, such as utilizing recent data or code refactoring. Our findings reveal that these methods are often insufficient: models frequently exhibit superior performance on newer data due to an AI-generated feedback loop, and standard membership inference metrics fail to distinguish between seen and unseen code.
Introduction
As Large Language Models (LLMs) for code become increasingly sophisticated, benchmarks are essential for tracking progress. However, because these models are trained on massive, often opaque web crawls, they risk memorizing specific code snippets. This leads to data contamination, where a model "passes" a test through memorization rather than logical reasoning. To mitigate this, researchers typically employ three strategies: testing on recent data (post-training cutoff), using curated benchmarks like HumanEval, or refactoring code to break memorization patterns. This paper quantitatively assesses whether these countermeasures provide genuine security or merely a false sense of it.
Methods and Research Framework
The authors conducted a large-scale empirical study using state-of-the-art CLMs, including StarCoder, CodeLlama, and GPT-3.5. The research was structured around three primary questions (RQs) regarding temporal data, curated benchmarks, and refactored code.
Key methodological components included:
- Temporal Analysis: Partitioning code by year (2018–2023) to compare performance on pre-cutoff ("contaminated") vs. post-cutoff ("recent") data.
- Refactoring Operators: Applying syntactic changes (e.g., flipping
if-elseconditions) and semantic changes (e.g., identifier renaming, adding performance decorators) to test model robustness. - Metric Evaluation: Testing Membership Inference Attack (MIA) metrics, such as Perplexity and Zlib Compression Entropy, to determine if they can statistically identify contaminated data.
- Core Task: The study focused on code completion (masking the final line of a function) to minimize human intervention and reflect real-world CLM usage.
Datasets
The study utilized a massive repository of Python code totaling nearly 2.5 million functions. This included historical data from The Stack v2 (up to March 2022) and a new GitHub crawl of over 15,000 repositories created between April 2022 and December 2023.
For the core experiments, a statistically significant sample of 2,304 functions (384 per year) was used, alongside HumanEval (Code-HumE) and CoderEval (Code-CodE) as curated benchmarks.
Key Insights and Results
The AI-Generated Feedback Loop
Counterintuitively, models often performed better on code from 2023 than on older data. For instance, StarCoder's Pass@1 improved from ~30% on 2018 data to ~34% on late 2023 data. The authors suggest this is due to the prevalence of AI assistants like GitHub Copilot; as more new code is AI-generated, it naturally aligns with the distribution of the models, making "recent" data potentially more contaminated by proxy.
The Ineffectiveness of Structural Refactoring
Syntactic refactoring proved to be a weak shield. In some cases, structural changes actually increased model performance, suggesting that CLMs are robust to syntax shifts and that such changes do not effectively obscure the underlying logic. Conversely, semantic changes—specifically identifier renaming and the addition of decorators—caused significant performance drops (e.g., a 15.9% drop for WizardCoder), indicating that models rely heavily on specific naming patterns.
The Failure of Detection Metrics
Standard metrics like Perplexity, commonly used to detect if a model has "seen" text, were unable to distinguish between code from 2018 and 2023. Mean perplexity remained nearly identical across groups (3.37 to 5.17), rendering these metrics currently ineffective for quantifying code contamination.
Conclusion and Future Work
The study concludes that existing countermeasures against data contamination in CLMs are largely inadequate. The community must move beyond structural refactoring and temporal cutoffs, which are increasingly undermined by AI-assisted programming. Future research should focus on developing code-specific contamination metrics and reconsidering how to construct truly "unseen" benchmarks in an era where the boundary between human and AI-generated code is blurring.
Summary updated