理解大语言模型在代码克隆检测中的能力:一项综述
Towards Understanding the Capability of Large Language Models on Code Clone Detection: A Survey
AI总结:
本文首次系统评估了大语言模型在代码克隆检测中的能力,发现其在复杂语义克隆检测上优于现有方法,思维链提示和文本编码器嵌入可进一步提升性能,且能力因编程语言而异。
摘要:
代码克隆,即代码片段的重复,在软件开发中十分常见。虽然某些复用有助于提高生产力,但过度克隆会损害可维护性并引入缺陷。因此,自动代码克隆检测至关重要。与此同时,大语言模型(LLMs)拥有多样化的代码相关知识,使其能够应对各种软件工程挑战。然而,LLMs在代码克隆检测中的表现尚不明确,需要更多研究以进行准确评估。在本文中,我们首次对LLMs进行全面的克隆检测评估,涵盖不同的克隆类型、编程语言和提示方式。我们发现先进的LLMs在检测复杂语义克隆方面表现出色,超越了现有方法。通过思维链提示添加中间推理步骤可显著提升性能。此外,将代码表示为向量嵌入,尤其是使用文本编码器,能够有效辅助克隆检测。最后,LLMs检测代码克隆的能力在不同编程语言之间存在差异。我们的研究表明,LLMs凭借其语言能力在克隆检测方面具有潜力,为开发基于LLMs的稳健方法以增强软件工程提供了见解。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。