[Paper Review] Towards Understanding the Capability of Large Language Models on Code Clone Detection: A Survey
The paper empirically evaluates diverse LLMs for code clone detection across prompts, reasoning styles, embeddings, and languages, showing Prompts and embeddings improve performance, with language effects observed.
Code cloning, the duplication of code fragments, is common in software development. While some reuse aids productivity, excessive cloning hurts maintainability and introduces bugs. Hence, automatic code clone detection is vital. Meanwhile, large language models (LLMs) possess diverse code-related knowledge, making them versatile for various software engineering challenges. However, LLMs' performance in code clone detection is unclear and needs more study for accurate assessment. In this paper, we provide the first comprehensive evaluation of LLMs for clone detection, covering different clone types, languages, and prompts. We find advanced LLMs excel in detecting complex semantic clones, surpassing existing methods. Adding intermediate reasoning steps via chain-of-thought prompts noticeably enhances performance. Additionally, representing code as vector embeddings, especially with text encoders, effectively aids clone detection.Lastly, the ability of LLMs to detect code clones differs among various programming languages. Our study suggests that LLMs have potential for clone detection due to their language capabilities, offering insights for developing robust LLM-based methods to enhance software engineering.
Motivation & Objective
- Assess how open-source and API-based LLMs perform on code clone detection compared to traditional tools across clone types.
- Investigate the impact of simple prompts, one-step and multi-step chain-of-thought prompts on detection accuracy.
- Evaluate the effectiveness of code embeddings versus code-specific models for clone detection.
- Examine how cloning detection performance varies across programming languages.
Proposed method
- Define a multi-prompt framework including simple prompts, one-step and multi-step chain-of-thought prompts, and code embedding approaches for clone detection.
- Evaluate 12 language models (open-source, API-based, and embedding-based) on a BigCloneBench-based dataset with Java, C/C++, and Python code.
- Compare LLMs against eight traditional clone detectors using standard metrics (precision, recall, F1).
- Analyze the influence of model instruction tuning on clone detection performance.
- Characterize how different languages and clone types affect detection results.
- Provide open-source data and code to support replication and further study.
Experimental results
Research questions
- RQ1RQ1: Can LLMs detect code clones with a simple prompt?
- RQ2RQ2: How do LLMs perform by using one-step chain-of-thought prompts?
- RQ3RQ3: Can LLMs perform better by using multi-step chain-of-thought prompts?
- RQ4RQ4: How do LLMs perform using code embedding?
- RQ5RQ5: How does the performance of LLMs in code clone detection vary across different programming languages?
Key findings
- LLMs outperform some non-LLM tools on complex clone types (Type-3 and Type-4) using simple prompts, with GPT-3.5-Turbo and GPT-4 achieving high recall and accuracy.
- One-step chain-of-thought prompts improve GPT-3.5-Turbo and GPT-4 performance, while aggregating all intermediate reasoning can hurt GPT-3.5-Turbo but not GPT-4.
- Multi-step chain-of-thought prompts can cause interference between reasonings and reduce results; separate explanations and deep analyses offer some benefits.
- Text embeddings (text-embedding-ada-002) can outperform code-focused models (CodeBERT variants) for clone detection.
- Performance of LLMs varies by language, with Python generally yielding better results due to training data familiarity and simplicity.
- GPT-3.5-Turbo and GPT-4 show the best overall results among evaluated models.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.