代码行间:揭示机器与人类程序员的独特模式
Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmers
AI总结:
本文提出DetectCodeGPT方法,通过分析代码的词汇多样性、简洁性和自然性等独特模式,利用语法分割作为关键因素,通过策略性插入空格和换行符扰动代码,显著提升了机器生成代码的检测效果。
摘要:
大型语言模型在代码生成领域引发了前所未有的浪潮。尽管取得了显著进展,它们却模糊了机器与人类编写的源代码之间的区别,导致软件工件的完整性和真实性出现问题。以往的方法如DetectGPT在识别机器生成的文本方面已被证明有效,但它们并未识别并利用机器生成代码的独特模式。因此,其在应用于代码时效果不佳。本文仔细研究了表征机器与人类编写代码的特定模式。通过对词汇多样性、简洁性和自然性等代码属性的严格分析,我们揭示了每种来源固有的独特模式。我们特别注意到,代码的语法分割是识别其来源的关键因素。基于我们的发现,我们提出了DetectCodeGPT,这是一种用于检测机器生成代码的新方法,它通过捕获代码独特的风格化模式来改进DetectGPT。与依赖外部LLM进行扰动的传统技术不同,DetectCodeGPT通过策略性地插入空格和换行符来扰动代码语料库,确保了有效性和效率。实验结果表明,我们的方法在检测机器生成代码方面显著优于最先进的技术。
英文摘要:
Large language models have catalyzed an unprecedented wave in code generation. While achieving significant advances, they blur the distinctions between machine- and human-authored source code, causing integrity and authenticity issues of software artifacts. Previous methods such as DetectGPT have proven effective in discerning machine-generated texts, but they do not identify and harness the unique patterns of machine-generated code. Thus, its applicability falters when applied to code. In this paper, we carefully study the specific patterns that characterize machine- and human-authored code. Through a rigorous analysis of code attributes such as lexical diversity, conciseness, and naturalness, we expose unique patterns inherent to each source. We particularly notice that the syntactic segmentation of code is a critical factor in identifying its provenance. Based on our findings, we propose DetectCodeGPT, a novel method for detecting machine-generated code, which improves DetectGPT by capturing the distinct stylized patterns of code. Diverging from conventional techniques that depend on external LLMs for perturbations, DetectCodeGPT perturbs the code corpus by strategically inserting spaces and newlines, ensuring both efficacy and efficiency. Experiment results show that our approach significantly outperforms state-of-the-art techniques in detecting machine-generated code.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。