一句话:提出 DetectCodeGPT,通过分析代码风格模式并插入空格换行扰动,显著提升机器生成代码检测。
大语言模型代码生成能力增强,使机器与人类编写的源代码边界模糊,带来软件工件完整性与真实性识别问题。已有 DetectGPT 等方法虽能检测机器生成文本,却未利用代码特有模式,直接用于代码效果受限。本文系统分析词法多样性、简洁性、自然性等代码属性,揭示机器与人类代码的独特风格,并发现语法切分是判断来源的关键因素。基于此提出 DetectCodeGPT:不再依赖外部 LLM 扰动,而是通过策略性插入空格与换行扰动代码语料,兼顾有效性与效率。实验表明,该方法在机器生成代码检测任务上显著优于现有最先进技术。
Large language models have catalyzed an unprece-dented 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 DetectGPthave 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.1.
DOI 原文 ·
@inproceedings{paperbot8833,
title = {Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmers},
author = {Yuling Shi and Hongyu Zhang and Chengcheng Wan and Xiaodong Gu},
booktitle = {ICSE},
year = {2025},
doi = {10.1109/icse55347.2025.00005}
}