# GPTCloneBench: A comprehensive benchmark of semantic clones and cross-language clones using GPT-3 model and SemanticCloneBench

Ajmain Inqiad Alam\*, **Palash Ranjan Roy\***, Farouq Al-Omari, Chanchal K. Roy, Banani Roy, Kevin A. Schneider. *2023 IEEE International Conference on Software Maintenance and Evolution (ICSME), pp. 1–13, 2023*. Venue ranking: CORE A.

\* Equal contribution (co-first authors). Palash Ranjan Roy is co-first author (equal contribution with Ajmain Inqiad Alam).

Role of Palash Ranjan Roy: Co-led (equal contribution): conception, methodology, validation, supervision of four undergraduates, writing.

Areas: Program Comprehension, Code Clones, AI for Software Engineering (AI4SE), Benchmark.

ML topics: LLM-Generated Code, Benchmarks & Datasets, Prompting.

Page: https://palashroy.me/publications/gptclonebench/

- PDF: https://palashroy.me/papers/gptclonebench.pdf
- arXiv: https://arxiv.org/abs/2308.13963
- Slides: https://palashroy.me/slides/gptclonebench-slides.pdf
- DOI: https://doi.org/10.1109/ICSME58846.2023.00013
- Replication package: https://github.com/srlabUsask/GPTCloneBench

## Abstract

With the emergence of Machine Learning, there has been a surge in leveraging its capabilities for problem-solving across various domains. In the code clone realm, the identification of type-4 or semantic clones has emerged as a crucial yet challenging task. Researchers aim to utilize Machine Learning to tackle this challenge, often relying on the Big-CloneBench dataset. However, it’s worth noting that BigCloneBench, originally not designed for semantic clone detection, presents several limitations that hinder its suitability as a comprehensive training dataset for this specific purpose. Furthermore, CLCDSA dataset suffers from a lack of reusable examples aligning with real-world software systems, rendering it inadequate for cross-language clone detection approaches. In this work, we present a comprehensive semantic clone and cross-language clone benchmark, GPTCloneBench by exploiting SemanticCloneBench and OpenAI’s GPT-3 model. In particular, using code fragments from SemanticCloneBench as sample inputs along with appropriate prompt engineering for GPT-3 model, we generate semantic and cross-language clones for these specific fragments and then conduct a combination of extensive manual analysis, tool-assisted filtering, functionality testing and automated validation in building the benchmark. From 79,928 clone pairs of GPT-3 output, we created a benchmark with 37,149 true semantic clone pairs, 19,288 false semantic pairs(Type-1/Type-2), and 20,770 cross-language clones across four languages (Java, C, C#, and Python). Our benchmark is 15-fold larger than SemanticCloneBench, has more functional code examples for software systems and programming language support than CLCDSA, and overcomes BigCloneBench’s qualities, quantification, and language variety limitations. GPTCloneBench is available at https://doi.org/10.5281/zenodo.8259987.

## Problem addressed

Existing clone benchmarks such as BigCloneBench and CLCDSA have limitations for training and evaluating semantic and cross-language clone detectors.

## Relevant to research on

- code clone benchmarks
- semantic (Type-4) clone detection
- cross-language clone detection
- LLM-generated code clones
- GPT-3 for code generation
- training data for machine-learning clone detectors
- limitations of BigCloneBench and CLCDSA

## BibTeX

```bibtex
@inproceedings{alam2023gptclonebench,
  title = {GPTCloneBench: A comprehensive benchmark of semantic clones and cross-language clones using GPT-3 model and SemanticCloneBench},
  url = {https://doi.org/10.1109/ICSME58846.2023.00013},
  doi = {10.1109/ICSME58846.2023.00013},
  booktitle = {2023 IEEE International Conference on Software Maintenance and Evolution (ICSME)},
  publisher = {IEEE},
  author = {Alam, Ajmain I. and Roy, Palash R. and Al-Omari, Farouq and Roy, Chanchal K. and Roy, Banani and Schneider, Kevin A.},
  year = {2023},
  month = {Oct},
  pages = {1--13}
}
```
