Skip to main content
QUICK REVIEW

[Paper Review] Concerned with Data Contamination? Assessing Countermeasures in Code Language Model

Jialun Cao, Wuqi Zhang|arXiv (Cornell University)|Mar 25, 2024
Software Engineering ResearchComputer Science3 citations
TL;DR

This study evaluates three countermeasures—using recent data, curated benchmarks, and code refactoring—against data contamination in code language models (CLMs). It finds that CLMs often perform equally or better on post-cut-off data and that refactoring can improve performance, challenging assumptions about contamination effects and highlighting limitations of standard metrics like perplexity in detecting contamination.

ABSTRACT

Various techniques have been proposed to leverage the capabilities of code language models (CLMs) for SE tasks. While these techniques typically evaluate their effectiveness using publicly available datasets, the evaluation can be subject to data contamination threats where the evaluation datasets have already been used to train the concerned CLMs. This can significantly affect the reliability of the evaluation. Different countermeasures have been suggested to mitigate the data contamination threat. Countermeasures include using more recent data, curating new data, and refactoring existing data are introduced, yet it is unclear whether these countermeasures could really mitigate data contamination threats to model evaluation. To fill the gap, we systematically study to quantify the impacts of these countermeasures on CLMs' performance. To facilitate the study, we collected over 2 million Python functions with timestamps ranging from January 1st, 2018, to December 31st, 2023. The data created before the models' cut-off date are considered "contaminated data", while the data where the countermeasures are taken are regarded as "cleansed data". We study the impact of these countermeasures by investigating the difference in CLMs' performance on contaminated and cleansed data derived from different countermeasures. Our experiments yield several interesting observations. For instance, CLMs do not necessarily perform worse on data after the models' cut-off date; on the contrary, they sometimes perform better. In addition, refactoring did not always result in decreased performance; it could lead to improvements instead. Furthermore, existing metrics such as perplexity cannot distinguish contaminated/cleansed data. We hope that the results and observations could help deepen the understanding of CLMs' capabilities and inform the community about data contamination.

Motivation & Objective

  • To investigate whether common countermeasures against data contamination in code language models (CLMs) are effective in practice.
  • To quantify the performance differences of CLMs on contaminated data (before model cut-off) versus cleansed data (after applying countermeasures).
  • To evaluate the reliability of existing metrics—like perplexity—in detecting data contamination in CLM evaluations.
  • To provide empirical insights into how data contamination affects CLM performance across different countermeasure strategies.
  • To inform the software engineering community about the limitations of current evaluation practices and the need for more robust benchmarks.

Proposed method

  • Collected 2,493,174 Python functions with timestamps from January 1, 2018, to December 31, 2023, to define contaminated data as those created before the model’s training cut-off date.
  • Applied three countermeasures: (1) using data from after the cut-off date (recent data), (2) using curated benchmarks, and (3) refactoring pre-cut-off code via identifier renaming and structural changes.
  • Measured performance differences between contaminated and cleansed data using code completion tasks with masked last statements.
  • Quantified overlap between contaminated and cleansed data using Jaccard and Levenshtein distances to ensure minimal similarity.
  • Evaluated model performance using standard metrics, including perplexity, to assess their ability to detect contamination.
  • Used three similarity metrics to validate that cleansed data were distinct from contaminated data, minimizing semantic and syntactic overlap.
Figure 1 : Experiment Design for RQ1-3. We assess CLMs’ performance on contaminated and cleaned data. Three countermeasures ( i.e. , using recent data, using curated data or refactored contaminated data) are considered.
Figure 1 : Experiment Design for RQ1-3. We assess CLMs’ performance on contaminated and cleaned data. Three countermeasures ( i.e. , using recent data, using curated data or refactored contaminated data) are considered.

Experimental results

Research questions

  • RQ1How does the performance of code language models (CLMs) differ when evaluated on contaminated data versus data cleansed using recent data, curated benchmarks, or refactoring?
  • RQ2To what extent do standard metrics like perplexity detect data contamination in CLM evaluations?
  • RQ3Does code refactoring consistently degrade or improve CLM performance, and can it lead to performance gains on previously seen code?
  • RQ4How significant is the overlap between contaminated and cleansed data, and does it affect the validity of performance comparisons?
  • RQ5Are existing curated benchmarks truly free from contamination, and how do they compare to post-cut-off data in terms of model performance?

Key findings

  • CLMs do not necessarily perform worse on data created after the model’s cut-off date; in some cases, they perform better, challenging the assumption that post-cut-off data are inherently more reliable.
  • Refactoring pre-cut-off code through identifier renaming and structural changes did not degrade performance and sometimes led to performance improvements, indicating that refactoring may not reliably mitigate contamination.
  • Standard metrics like perplexity are ineffective at distinguishing between contaminated and cleansed data, as they show minimal performance differences across data types.
  • The overlap between contaminated and cleansed data, measured via Jaccard and Levenshtein distances, remained at a relatively low level, supporting the validity of performance comparisons across data groups.
  • Performance on curated benchmarks was not consistently lower than on contaminated data, suggesting that many benchmarks may still contain data that overlaps with model training data.
  • The study reveals that current countermeasures—especially refactoring and benchmark curation—may not effectively eliminate contamination risks, calling for more rigorous evaluation protocols in CLM research.
Figure 2 : Pairwise Code Similarity Comparison
Figure 2 : Pairwise Code Similarity Comparison

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.