Recent statements about the impressive code capabilities of large language models (LLMs) are usually supported by evaluating on open-access benchmarks. Considering the vast size and wide-ranging sources of LLMs’ training code data, it could explicitly or implicitly include code data of test set, leading to LLMs being more susceptible to data contamination on code generation benchmarks. However, due to the opacity of training code data, massive code reuse, the black-box access of models, and the rapid growth of synthetic code data, detecting and mitigating data contamination for LLMs on code generation benchmarks faces significant challenges. In this paper, we propose CDD, which stands for Contamination Detection via output Distribution for LLMs in code generation. CDD necessitates only the sampled code texts to detect data contamination, by identifying the peakedness of LLM’s output distribution. To mitigate the impact of data contamination in code evaluation, we present TED: Trustworthy Evaluation via output Distribution, based on the correction of LLM’s output distribution. To facilitate this study, we introduce two benchmarks, i.e., DETCON and COMIEVAL, for data contamination detection and contamination mitigation evaluation in code-related tasks. Extensive experimental results show that CDD achieves the average relative improvements of 21.8%-30.2% over other contamination detection approaches in terms of Accuracy, F1 Score, and AUC metrics, and can effectively detect implicit contamination. TED substantially mitigates performance improvements up to 66.9% attributed to data contamination across various contamination setups. In real-world applications, we reveal that certain LLMs exhibit a high potential to suffer from data contamination on HumanEval benchmark. Moreover, we also introduce a new evaluation metric MGI, Memorization Generalization Index, to assess the generalizability of LLM’s evaluation results on the benchmark. MGI is applied to wellknown open-source code LLMs, offering a novel dimension for evaluating model performance on the code generation benchmark.
更多