University of Saskatchewan
Application of Large Language Models in Code Clone: Benchmarking, Evaluation and Detection
Abstract
dc:description.abstractAs software systems grow increasingly complex, the detection of code clones has become vital for software maintenance and security analysis. Among the various types of clones, Type-4 or semantic clones (code fragments that perform the same function but differ syntactically) is difficult to detect due to their functional similarity rather than syntactic patterns. Traditionally, researchers have relied on benchmarks such as BigCloneBench to develop a code clone detector. However, BigCloneBench is not well-suited for handling the complex semantic clones, Bellon's benchmark is not suitable for assessing the capabilities of modern clone detection tools and SemanticCloneBench has few semantic examples. Additionally, the rise of large language models (LLMs) in software development has introduced diverse AI-generated clones, which differ from traditional developer clones by varying syntax, structure, control flow and language while maintaining the same functionality. As LLMs, like GPT-3, generate code at scale, existing detection tools struggle to handle this complexity, making both syntactic and semantic clone detection more challenging. To address these challenges, our first study introduces GPTCloneBench, a new benchmark designed to overcome the limitations of BigCloneBench and other datasets. By leveraging GPT-3 model and carefully designed prompt engineering, we generated 37,149 true semantic clones, 19,288 syntactic clones, and 20,770 cross-language clones across Java, C, C#, and Python—offering a more than 10-fold increase in scale compared to SemanticCloneBench. The GPTCloneBench creation process involved rigorous manual analysis, tool-assisted filtering, and manual and automated validation to ensure the accuracy and utility of the benchmark. In our second study, we evaluated the performance of nine different clone detection tools—ranging from classical detectors to AI-based tools—using three benchmarks: BigCloneBench, SemanticCloneBench, and GPTCloneBench. Our goal was to assess how well existing tools can detect clones using three different benchmarks specially the increasingly prevalent AI-generated semantic clones. The results revealed that while classical tools excel at identifying simpler clones (types 1–3), they fall short when applied to complex semantic clones, particularly those generated by LLMs. Even though AI-based tools achieved good recall, they required extensive computational resources to achieve this performance. These findings emphasize the need for more efficient and effective code clone detection models, particularly as the use of AI-generated code and LLM-based code clone detection tools continue to rise. In response to this need, our third study developed an efficient LLM-based code clone detection model using knowledge distillation (KD) and INT8 quantization-aware training (QAT). Our approach compressed LLM model, significantly reducing the number of attention heads, hidden dimensions, and layers while maintaining high performance. To compare with the existing LLM-tools which were trained and tested on BigCloneBench, our model was also trained on BigCloneBench and optimized to detect clones with greater speed and efficiency. Our compressed model consumes 77% less inference time and 51.2% less memory, while achieving a 93% precision and 96% recall in code clone detection. Our model, just 1.6 MB in size, proves that high performance can be achieved without the need for large, resource-intensive architectures, offering a scalable solution for detecting clones specially semantic clones.
Degree
thesis:*- Name thesis:degree_name
- Master of Science (M.Sc.)
- Level thesis:degree_level
- Masters
- Discipline thesis:degree_discipline
- Computer Science
- Department thesis:degree_department
- Computer Science
- Grantor
- University of Saskatchewan
- Year dc:date.issued
- 2025
Author and committee
dc:creator, dc:contributor.*- Author dc:creator
-
- Alam, Ajmain Inqiad
- Advisors dc:contributor.advisor
-
- Roy, Dr. Chanchal
- Schneider, Dr. Kevin
- Committee members dc:contributor.committeemember
-
- Schneider, Dr. Kevin
- Roy, Dr. Banani
- Lehnert, Dr. Lucas
- ORCID person:identifier.orcid
Subjects
dc:subject × 1Rights
- Language dc:language.iso
- en
Identifiers
dc:identifier.*- Handle dc:identifier.uri
- https://hdl.handle.net/10388/16468