The adverse effects of code duplication in machine learning models of code
Open accessThe DOI matches its Crossref record; 29 of the 30 references it cites were found in a registry or an index.
Abstract
The field of big code relies on mining large corpora of code to perform some learning task towards creating better tools for software engineers. A significant threat to this approach was recently identified by Lopes et al. (2017) who found a large amount of near-duplicate code on GitHub. However, the impact of code duplication has not been noticed by researchers devising machine learning models for source code. In this work, we explore the effects of code duplication on machine learning models showing that reported performance metrics are sometimes inflated by up to 100% when testing on duplicated code corpora compared to the performance on de-duplicated corpora which more accurately represent how machine learning models of code are used by software engineers. We present a duplication index for widely used datasets, list best practices for collecting code corpora and evaluating machine learning models on them. Finally, we release tools to help the community avoid this problem in future research.
Overview
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Integrity signals
Registry
Cites
Statistics
Verification
Claims the paper makes
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Claims other papers make about this one
Each is checked against this paper’s own text: does it say what the citing paper says it does?
The source backs part of the claim, not all of it — or backs it for a different population, condition or comparison.
In the citing paper
“Such a strategy duplicates extremely low-resource languages thousands of times, which has been shown to significantly reduce performance (Allamanis, 2019).”
From Measuring The Impact Of Programming Language Distribution (2023) · cites this paper as Allamanis, 2019
Experimental — accuracy not yet measuredThe cited source says what the claim attributes to it.
In the citing paper
“Allamanis (2019) and Lopes et al. (2017) highlight the large fraction of near-duplicates present in code datasets and how they can inflate performance metrics.”
From The BigScience ROOTS Corpus: A 1.6TB Composite Multilingual Dataset (2023) · cites this paper as Allamanis (2019)
The cited source says what the claim attributes to it.
In the citing paper
“De-duplication is key: Code duplication in machine learning models can deceptively inflate performance metrics a lot, when compared to de-duplicated datasets [7,46,59].”
From Automatic Semantic Augmentation of Language Model Prompts (for Code Summarization) (2024) · cites this paper as [7]
Self-check
Percentages, sums and reported differences re-computed from the paper’s own numbers.
The self-check needs the paper’s full text.
Citations
Cites
(2012) · Cited by 9,062
A Neural Probabilistic Language Model
Bengio, Y., Ducharme, R., Vincent, P., Jauvin, C., Jaz, K., Hofmann, T., Poggio, T., & Shawe-Taylor, J. S. (2000) · Cited by 3,486
A Survey on Software Clone Detection Research
Roy, C. K., & Cordy, J. R. (2007) · QSpace (Queen's University Library) · Cited by 967
code2vec: Learning distributed representations of code
Alon, U., Zilberstein, M., Levy, O., & Yahav, E. (2019) · Proceedings of the ACM on Programming Languages · doi:10.1145/3290353 · Cited by 962
Learning to Represent Programs with GraphsPreprint
Allamanis, M., Brockschmidt, M., & Khademi, M. (2017) · arXiv (Cornell University) · doi:10.48550/arxiv.1711.00740 · Cited by 841
Self-citationSummarizing Source Code using a Neural Attention Model
Iyer, S., Konstas, I., Cheung, A., & Zettlemoyer, L. (2016) · Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers) · doi:10.18653/v1/p16-1195 · Cited by 701
Code completion with statistical language models
Raychev, V., Vechev, M., & Yahav, E. (2014) · Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation · doi:10.1145/2594291.2594321 · Cited by 555
On the naturalness of software
Hindle, A., Barr, E. T., Su, Z., Gabel, M., & Dévanbu, P. (2012) · doi:10.5555/2337223.2337322 · Cited by 541
Using Machine Learning for Vulnerability Detection and Classification
Alon, U., Brody, S., Levy, O., & Yahav, E. (2018) · arXiv (Cornell University) · doi:10.4230/oasics.slate.2021.14 · Cited by 467
SourcererCC: scaling code clone detection to big-code
Sajnani, H., Saini, V., Svajlenko, J., Roy, C. K., & Lopes, C. V. (2016) · Proceedings of the 38th International Conference on Software Engineering · doi:10.1145/2884781.2884877 · Cited by 447
On the naturalness of software
Hindle, A., Barr, E. T., Su, Z., Gabel, M., & Devanbu, P. (2012) · 2012 34th International Conference on Software Engineering (ICSE) · doi:10.1109/icse.2012.6227135 · Cited by 425
The Qualitas Corpus: A Curated Collection of Java Code for Empirical Studies
Tempero, E., Anslow, C., Dietrich, J., Han, T., Li, J., Lumpe, M., Melton, H., & Noble, J. (2010) · 2010 Asia Pacific Software Engineering Conference · doi:10.1109/apsec.2010.46 · Cited by 407
“Cloning considered harmful” considered harmful: patterns of cloning in software
Kapser, C. J., & Godfrey, M. W. (2008) · Empirical Software Engineering · doi:10.1007/s10664-008-9076-6 · Cited by 365
Mining source code repositories at massive scale using language modeling
Allamanis, M., & Sutton, C. (2013) · 2013 10th Working Conference on Mining Software Repositories (MSR) · doi:10.1109/msr.2013.6624029 · Cited by 313
Self-citationPredicting Program Properties from "Big Code"
Raychev, V., Vechev, M., & Krause, A. (2015) · Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages · doi:10.1145/2676726.2677009 · Cited by 296
Are deep neural networks the best choice for modeling source code?
Hellendoorn, V. J., & Devanbu, P. (2017) · Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering · doi:10.1145/3106237.3106290 · Cited by 292 · cited 2×
“Language models have been used for autocompletion [14, 15, 20, 24] and it would be unreasonable to assume that the true distribution of this particular use cases contains duplicate code.”
BackgroundMethodSourcererCC: Scaling Code Clone Detection to Big Code
Sajnani, H., Saini, V., Svajlenko, J., Roy, C. K., & Lopes, C. V. (2015) · arXiv (Cornell University) · doi:10.48550/arxiv.1512.06448 · Cited by 280
PHOG: probabilistic model for code
Bielik, P., Raychev, V., & Vechev, M. (2016) · International Conference on Machine Learning · Cited by 202
Code completion with statistical language models
Raychev, V., Vechev, M., & Yahav, E. (2014) · ACM SIGPLAN Notices · doi:10.1145/2666356.2594321 · Cited by 189
DéjàVu: a map of code duplicates on GitHub
Lopes, C. V., Maj, P., Martins, P., Saini, V., Yang, D., Zitny, J., Sajnani, H., & Vitek, J. (2017) · Proceedings of the ACM on Programming Languages · doi:10.1145/3133908 · Cited by 183
Hellendoorn, V. J., Bird, C., Barr, E. T., & Allamanis, M. (2018) · Proceedings of the 2018 26th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering · doi:10.1145/3236024.3236051 · Cited by 181
Self-citationMapping Language to Code in Programmatic Context
Iyer, S., Konstas, I., Cheung, A., & Zettlemoyer, L. (2018) · Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing · doi:10.18653/v1/d18-1192 · Cited by 180 · cited 1×
“The Concode dataset [17] seems to be the one suffering the most from duplication, by having about 68.”
A Convolutional Attention Network for Extreme Summarization of Source Code
Allamanis, M., Peng, H. M., & Sutton, C. A. (2016) · arXiv (Cornell University) · doi:10.48550/arxiv.1602.03001 · Cited by 126
Self-citationA Retrieve-and-Edit Framework for Predicting Structured Outputs
Hashimoto, T. B., Guu, K., Oren, Y., & Liang, P. (2018) · arXiv · doi:10.48550/arxiv.1812.01194 · Cited by 126 · cited 1×
“[12] that combine retrieval methods that find similar snippets within a database of code and then perform edits over those examples is an interesting example of such a direction.”
BackgroundLearning programs from noisy data
Raychev, V., Bielik, P., Vechev, M., & Krause, A. (2016) · Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages · doi:10.1145/2837614.2837671 · Cited by 123
Structured Generative Models of Natural Source Code
Maddison, C. J., & Tarlow, D. (2014) · arXiv (Cornell University) · doi:10.48550/arxiv.1401.0514 · Cited by 122
Barone, A. V. M., & Sennrich, R. (2017) · arXiv (Cornell University) · doi:10.48550/arxiv.1707.02275 · Cited by 96
Syntax errors just aren't natural: improving error reporting with language models
Campbell, J. C., Hindle, A., & Amaral, J. N. (2014) · Proceedings of the 11th Working Conference on Mining Software Repositories · doi:10.1145/2597073.2597102 · Cited by 81
Cross-project code clones in GitHub
Gharehyazie, M., Ray, B., Keshani, M., Zavosht, M. S., Heydarnoori, A., & Filkov, V. (2018) · Empirical Software Engineering · doi:10.1007/s10664-018-9648-z · Cited by 46
Research works printed but not linked: 3
- Miltiadis Allamanis, Earl T Barr, Premkumar Devanbu, and Charles Sutton. 2018. A survey of machine learning for big code and natural- ness. ACM Computing Surveys (CSUR) 51, 4 (2018), 81. · DOI · Paper page
- Uri Alon, Omer Levy, and Eran Yahav. 2010. code2seq: Generating Sequences from Structured Representations of Code. In Proceedings of the International Conference on Learning Representations (ICLR).
- Tijmen Tieleman and Geoffrey Hinton. 2012. Lecture 6.5-RMSProp: Divide the gradient by a running average of its recent magnitude. COURSERA: Neural networks for machine learning 4, 2 (2012), 26-31.
Cited by
PaLM: Scaling Language Modeling with Pathways
Chowdhery, A., Narang, S., Devlin, J., Bosma, M., Mishra, G., Roberts, A., Barham, P., Chung, H. W., Sutton, C., Gehrmann, S., et al. (2022) · arXiv · doi:10.48550/arxiv.2204.02311 · Cited by 2,590
“Further, we remove duplicates based on Levenshtein distance between the files because duplicate files are known to be common in source code repositories (Lopes et al., 2017; Allamanis, 2019).”
MethodOpen Graph Benchmark: Datasets for Machine Learning on Graphs
Hu, W., Fey, M., Žitnik, M., Dong, Y., Ren, H., Liu, B., Catasta, M., & Leskovec, J. (2020) · arXiv (Cornell University) · doi:10.48550/arxiv.2005.00687 · Cited by 470
Competition-level code generation with AlphaCode
Li, Y., Choi, D., Chung, J., Kushman, N., Schrittwieser, J., Leblond, R., Eccles, T., Keeling, J., Gimeno, F., Dal Lago, A., et al. (2022) · Science · doi:10.1126/science.abq1158 · Cited by 1,043
Competition-Level Code Generation with AlphaCode
Li, Y., Choi, D., Chung, J., Kushman, N., Schrittwieser, J., Leblond, R., Eccles, T., Keeling, J., Gimeno, F., Lago, A. D., et al. (2022) · arXiv · doi:10.48550/arxiv.2203.07814 · Cited by 1,043
SySeVR: A Framework for Using Deep Learning to Detect Software Vulnerabilities
Li, Z., Zou, D., Xu, S., Jin, H., Zhu, Y., & Chen, Z. (2022) · IEEE Transactions on Dependable and Secure Computing · doi:10.1109/tdsc.2021.3051525 · Cited by 639
Metadata
- Authors
- Allamanis, M.
- Affiliations
- Microsoft (United States) (US)
- Corresponding author
- Allamanis, Miltiadis
- ORCID
- Allamanis, Miltiadis
- Venue
- Proceedings of the 2019 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software
- Publisher
- ACM
- Published
- 2019-10-23
- Pages
- 143-153
- OpenAlex
- W2903709763
- Cited by
- 284
- References
- 30
- Citations by year
- 2026: 19 · 2025: 25 · 2024: 56 · 2023: 46 · 2022: 58 · 2021: 41 · 2020: 31 · 2019: 7
- FWCI
- 27.28
- Type
- conference paper
- Language
- en
- Open access
- green
- arxiv.org
- Locations
- ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software (Onward!) (publishedVersion)
- arXiv (Cornell University) (submittedVersion, other-oa)
- arXiv (Cornell University) (submittedVersion)
- arXiv (Cornell University)
- Topics
- Physical Sciences › Computer Science › Information Systems › Software Engineering Research
- Physical Sciences › Computer Science › Information Systems › Software Engineering Techniques and Practices
- Physical Sciences › Computer Science › Software › Software Testing and Debugging Techniques
- Keywords
- code duplication, data deduplication, code mining, assessment practices, GitHub
About these checks
Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.
Statistics and arithmetic are recomputed, not judged.
Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.
What counts as a claim ›How we measure confidence ›How we check this ›
Are you an author, or do you see a problem with this page? Request a review
Data sources
Bibliographic data: Semantic Scholar, OpenAlex, Crossref.
Contains information from the Semantic Scholar Academic Graph Datasets, made available under the ODC Attribution License (ODC-BY 1.0).
Semantic Scholar’s data is described in: Kinney, R., et al. (2023). The Semantic Scholar Open Data Platform. arXiv:2301.10140.