Syntax-Aware Detection of Training Data Contamination in Code LLMs

Jiazheng Zhang, Cheng Liu, Long Cheng, Xiaowei Li, Huawei Li


Abstract
Despite rapid advances in Code LLMs, their training datasets are often opaque due to proprietary and competitive concerns. Since many evaluation benchmarks are open-source and widely available online, models may unintentionally train on them, leading to data contamination that compromises evaluation validity. Reliable techniques for detecting whether a code snippet appears in a model’s training data are therefore essential. Compared with natural language, code contamination detection presents two unique challenges. First, code tokens from different syntactic categories contribute unequally to contamination signals, making uniform token treatment ineffective. Second, models trained on semantically equivalent code variants can evade detectors based solely on text matching. To address these challenges, we propose a syntax-aware framework that explicitly models token-type contributions. With a lightweight supervised detector trained on few labels, it captures contamination signals efficiently. Experiments across 8 Code LLMs, 2 languages, and 4 code transformations show absolute AUC gains of 8–10% for pretraining data detection and 15–20% for fine-tuning data detection, with AUC exceeding 90% on most fine-tuned tasks. Our work demonstrates that syntax-aware modeling is essential for trustworthy Code LLM evaluation.
Anthology ID:
2026.findings-emnlp.1010
Volume:
Findings of the Association for Computational Linguistics: EMNLP 2026
Month:
October
Year:
2026
Address:
Budapest, Hungary
Editors:
Hung-Yi Lee, Sunipa Dev, Jessy Li, Desmond Elliott
Venue:
Findings
SIG:
SIGDAT
Publisher:
Association for Computational Linguistics
Note:
Pages:
21342–21367
Language:
URL:
https://aclanthology.org/2026.findings-emnlp.1010/
DOI:
Bibkey:
Cite (ACL):
Jiazheng Zhang, Cheng Liu, Long Cheng, Xiaowei Li, and Huawei Li. 2026. Syntax-Aware Detection of Training Data Contamination in Code LLMs. In Findings of the Association for Computational Linguistics: EMNLP 2026, pages 21342–21367, Budapest, Hungary. Association for Computational Linguistics.
Cite (Informal):
Syntax-Aware Detection of Training Data Contamination in Code LLMs (Zhang et al., Findings 2026)
Copy Citation:
PDF:
https://aclanthology.org/2026.findings-emnlp.1010.pdf