[论文解读] Towards Understanding the Capability of Large Language Models on Code Clone Detection: A Survey
本论文对多种大语言模型在代码克隆检测方面进行经验评估,涵盖提示、推理风格、嵌入和语言,结果显示提示和嵌入提升了性能,同时观察到语言效应。
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.
研究动机与目标
- 评估开源和基于API的LLM在代码克隆检测中的表现,与传统工具在克隆类型上的对比。
- 研究简单提示、一阶段链式思维提示和多阶段链式思维提示对检测精度的影响。
- 评估代码嵌入与针对代码的模型在克隆检测中的有效性。
- 考察跨编程语言的克隆检测性能如何变化。
提出的方法
- 定义一个多提示框架,包括简单提示、一阶段和多阶段链式思维提示,以及用于克隆检测的代码嵌入方法。
- 在基于 BigCloneBench 的数据集上评估12种语言模型(开源、基于API、以及基于嵌入的),代码涵盖 Java、C/C++ 和 Python。
- 使用标准指标(精确率、召回率、F1)将LLMs与八个传统克隆检测器进行比较。
- 分析模型指令微调对克隆检测性能的影响。
- 描述不同语言和克隆类型如何影响检测结果。
- 提供开源数据和代码以支持复现和进一步研究。
实验结果
研究问题
- RQ1研究问题1:LLMs 是否能用简单提示检测代码克隆?
- RQ2研究问题2:使用一阶段链式思维提示时,LLMs 的表现如何?
- RQ3研究问题3:使用多阶段链式思维提示能否提升LLMs的表现?
- RQ4研究问题4:使用代码嵌入时,LLMs 的表现如何?
- RQ5研究问题5:在不同编程语言下,LLMs在代码克隆检测中的表现如何变化?
主要发现
- LLMs 在使用简单提示时,在复杂克隆类型(Type-3 和 Type-4)上优于某些非LLM工具,GPT-3.5-Turbo 和 GPT-4 取得了较高的召回率和准确率。
- 一阶段链式思维提示提升 GPT-3.5-Turbo 和 GPT-4 的性能,而聚合所有中间推理可能会降低 GPT-3.5-Turbo 的表现,但对 GPT-4 则无此影响。
- 多阶段链式思维提示可能导致推理之间的干扰并降低结果;分离的解释和深入分析带来一定好处。
- 文本嵌入(text-embedding-ada-002)在克隆检测方面可能优于面向代码的模型(CodeBERT 变体)。
- LLMs 的表现因语言而异,Python 通常因训练数据的熟悉度和简洁性而获得更好结果。
- 在评估的模型中,GPT-3.5-Turbo 和 GPT-4 展示出最佳的整体结果。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。