一刀切并不适用:研究困惑度在检测LLM生成代码中的有效性
One Size Does Not Fit All: Investigating Efficacy of Perplexity in Detecting LLM-Generated Code
AI总结:
本文研究了基于困惑度的方法在检测大语言模型生成代码中的有效性,发现其泛化能力最佳但准确率和速度有限,并提出了改进建议。
摘要:
大语言模型生成代码(LLMgCode)在软件开发中日益普遍。目前,LLMgCode比人类编写的代码(HaCode)存在更多质量问题。在代码变更中,LLMgCode与HaCode混合的情况很常见,而这些变更仅由人类开发者署名,未经过仔细审查。已有许多自动化方法被提出用于从HaCode中检测LLMgCode,其中基于困惑度的方法(简称PERPLEXITY)是最先进的方法。然而,对PERPLEXITY的有效性评估主要集中在检测准确率上。目前尚不清楚PERPLEXITY在更广泛的现实评估场景中是否足够好。为此,我们开展了一系列实验,从三个角度将PERPLEXITY与基于特征和基于预训练的方法进行比较:检测准确率、检测速度和泛化能力。实验结果表明,PERPLEXITY具有最佳的泛化能力,但检测准确率和检测速度有限。基于此,我们讨论了PERPLEXITY的优势和局限性,例如,PERPLEXITY不适用于高级编程语言。最后,我们提供了改进PERPLEXITY并在实践中应用的建议。作为首个关于从HaCode中检测LLMgCode的大规模研究,本文为未来的改进提供了广泛的发现。
英文摘要:
Large language model-generated code (LLMgCode) has become increasingly common in software development. So far LLMgCode has more quality issues than human-authored code (HaCode). It is common for LLMgCode to mix with HaCode in a code change, while the change is signed by only human developers, without being carefully examined. Many automated methods have been proposed to detect LLMgCode from HaCode, in which the perplexity-based method (PERPLEXITY for short) is the state-of-the-art method. However, the efficacy evaluation of PERPLEXITY has focused on detection accuracy. Yet it is unclear whether PERPLEXITY is good enough in a wider range of realistic evaluation settings. To this end, we carry out a family of experiments to compare PERPLEXITY against feature- and pre-training-based methods from three perspectives: detection accuracy, detection speed, and generalization capability. The experimental results show that PERPLEXITY has the best generalization capability while having limited detection accuracy and detection speed. Based on that, we discuss the strengths and limitations of PERPLEXITY, e.g., PERPLEXITY is unsuitable for high-level programming languages. Finally, we provide recommendations to improve PERPLEXITY and apply it in practice. As the first large-scale investigation on detecting LLMgCode from HaCode, this article provides a wide range of findings for future improvement.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。