The adverse effects of code duplication in machine learning models of code

By Miltiadis Allamanis. 2018

352 citations recorded by the source corpus.

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.

Subfields: Information Systems, Software, Natural Language Processing, Program Analysis & Verification, Signal Processing

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Information Systems

  1. Miltiadis Allamanis
  2. Charles Sutton
  3. Uri Alon
  4. Prem Devanbu
  5. Eran Yahav
  6. Vincent J. Hellendoorn
  7. Baishakhi Ray
  8. Omer Levy

In Software

  1. Prem Devanbu
  2. Charles Sutton
  3. Miltiadis Allamanis
  4. Toufique Ahmed
  5. Vincent J. Hellendoorn
  6. Earl T. Barr
  7. Rafael-Michael Karampatsis
  8. Marc Brockschmidt

In Natural Language Processing

  1. Graham Neubig
  2. Luke S. Zettlemoyer
  3. Mohit Bansal
  4. Percy Liang
  5. Jianfeng Gao
  6. Kyunghyun Cho
  7. Yejin Choi
  8. Yoav Goldberg

In Program Analysis & Verification

  1. Prem Devanbu
  2. Kevin Jesse
  3. Eran Yahav
  4. Uri Alon
  5. Marc Brockschmidt
  6. Charles Sutton
  7. Petros Maniatis
  8. Miltiadis Allamanis

In Signal Processing

  1. Eran Yahav
  2. Uri Alon
  3. Charles Sutton
  4. Julian McAuley
  5. Omer Levy
  6. Prem Devanbu
  7. Yoshua Bengio
  8. Nicholas Carlini

Citations in the corpus