# Unveiling the potential of large language models in generating semantic and cross-language clones

arXiv: https://arxiv.org/abs/2309.06424 · HTML: https://mlsanity.com/paper/2309.06424/

## Key facts

- Cited by 3 papers in the map (data through 14 Oct 2026).
- Builds on 11 of its 48 references that are in the map.
- First posted on arXiv 12 Sep 2023.

## Builds on (most cited first, 11 of 11)

- [Chain-of-Thought Prompting Elicits Reasoning in Large Language Models](https://mlsanity.com/paper/2201.11903/) (2022)
- [Evaluating Large Language Models Trained on Code](https://mlsanity.com/paper/2107.03374/) (2021)
- [Competition-Level Code Generation with AlphaCode](https://mlsanity.com/paper/2203.07814/) (2022)
- [Oreo: Detection of Clones in the Twilight Zone](https://mlsanity.com/paper/1806.05837/) (2018)
- [Do Code Clones Matter?](https://mlsanity.com/paper/1701.05472/) (2017)
- [GPTCloneBench: A comprehensive benchmark of semantic clones and cross-language clones using GPT-3 model and SemanticCloneBench](https://mlsanity.com/paper/2308.13963/) (2023)
- [Towards Exploring the Code Reuse from Stack Overflow during Software Development](https://mlsanity.com/paper/2204.12711/) (2022)
- [SOTorrent: Studying the Origin, Evolution, and Usage of Stack Overflow Code Snippets](https://mlsanity.com/paper/1809.02814/) (2018)
- [On the Use of Context in Recommending Exception Handling Code Examples](https://mlsanity.com/paper/1807.02261/) (2018)
- [The Vision of Software Clone Management: Past, Present, and Future](https://mlsanity.com/paper/2005.01005/) (2020)
- [Are There Functionally Similar Code Clones in Practice?](https://mlsanity.com/paper/1803.10542/) (2018)

## Built on by (most cited first, 3 of 3)

- [Investigating the Efficacy of Large Language Models for Code Clone Detection](https://mlsanity.com/paper/2401.13802/) (2024)
- [On the Use of Deep Learning Models for Semantic Clone Detection](https://mlsanity.com/paper/2412.14739/) (2024)
- [A Unified Model for Cross-Domain Clone Detection via Model Merging](https://mlsanity.com/paper/2608.04215/) (2026)

## Abstract (arXiv)

Semantic and Cross-language code clone generation may be useful for code reuse, code comprehension, refactoring and benchmarking. OpenAI's GPT model has potential in such clone generation as GPT is used for text generation. When developers copy/paste codes from Stack Overflow (SO) or within a system, there might be inconsistent changes leading to unexpected behaviours. Similarly, if someone possesses a code snippet in a particular programming language but seeks equivalent functionality in a different language, a semantic cross-language code clone generation approach could provide valuable assistance. In this study, using SemanticCloneBench as a vehicle, we evaluated how well the GPT-3 model could help generate semantic and cross-language clone variants for a given fragment.We have comprised a diverse set of code fragments and assessed GPT-3s performance in generating code variants.Through extensive experimentation and analysis, where 9 judges spent 158 hours to validate, we investigate the model's ability to produce accurate and semantically correct variants. Our findings shed light on GPT-3's strengths in code generation, offering insights into the potential applications and challenges of using advanced language models in software development. Our quantitative analysis yields compelling results. In the realm of semantic clones, GPT-3 attains an impressive accuracy of 62.14% and 0.55 BLEU score, achieved through few-shot prompt engineering. Furthermore, the model shines in transcending linguistic confines, boasting an exceptional 91.25% accuracy in generating cross-language clones
