arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2511.01176cs.SE
收藏

基于 LLM 的代码克隆检测的实证研究

An Empirical Study of LLM-Based Code Clone Detection

Nagoya University(名古屋大学);Ritsumeikan University(立命馆大学);Kyoto Institute of Technology(京都工艺纤维大学)

Wenqing Zhu, Norihiro Yoshida, Eunjong Choi, Yutaka Matsubara, Hiroaki Takada

AI总结:

本文针对 LLM 在代码克隆检测中的跨数据集性能与响应一致性问题,构建七个数据集评估五个 LLM,发现其在 CodeNet 表现优异但在 BigCloneBench 上显著下降,且响应一致性高。

摘要:

大型语言模型(LLMs)因其在编程语言和自然语言之间进行转换的能力,在代码生成和调试等各种软件工程任务中展现出了卓越的能力。现有研究已经证明了 LLMs 在代码克隆检测中的有效性。然而,仍有两个关键问题尚未解决:LLMs 在不同数据集上实现相当性能的能力,以及 LLMs 在代码克隆检测中响应的一致性。为了解决这些问题,我们构建了七个代码克隆数据集,然后使用这些数据集在四种现有提示下评估了五个 LLMs。这些数据集是通过使用两个不同代码集合(CodeNet 和 BigCloneBench)中的代码对的 Levenshtein 比率进行采样创建的。我们的评估显示,尽管 LLMs 在与 CodeNet 相关的数据集上表现良好,其中 o3-mini 达到了 0.943 的 F1 分数,但它们在与 BigCloneBench 相关的数据集上性能显著下降。大多数模型实现了很高的响应一致性,在所有五次提交中,超过 90% 的判断保持一致。受不一致性影响的 F1 分数波动也很小;其变化小于 0.03。

英文摘要:

Large language models (LLMs) have demonstrated remarkable capabilities in various software engineering tasks, such as code generation and debugging, because of their ability to translate between programming languages and natural languages. Existing studies have demonstrated the effectiveness of LLMs in code clone detection. However, two crucial issues remain unaddressed: the ability of LLMs to achieve comparable performance across different datasets and the consistency of LLMs' responses in code clone detection. To address these issues, we constructed seven code clone datasets and then evaluated five LLMs in four existing prompts with these datasets. The datasets were created by sampling code pairs using their Levenshtein ratio from two different code collections, CodeNet and BigCloneBench. Our evaluation revealed that although LLMs perform well in CodeNet-related datasets, with o3-mini achieving a 0.943 F1 score, their performance significantly decreased in BigCloneBench-related datasets. Most models achieved a high response consistency, with over 90\% of judgments remaining consistent across all five submissions. The fluctuations of the F1 score affected by inconsistency are also tiny; their variations are less than 0.03.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑