DualCodeDetect: Zero-Shot LLM-Generated Code Detection via Dual-Channel Perturbation
Zhengdao Li, Xiuwei Shang, Zhenkan Fu, Shikai Guo, Weiming Zhang, Nenghai Yu, Kejiang Chen
摘要
The rapid advancement of large language models (LLMs) in code generation has greatly improved software development efficiency, but it has also raised concerns about misuse, making the distinction between human-written and LLM-generated code an urgent task. However, existing detection methods for LLM-generated content, particularly perturbation-based zero-shot methods, are primarily designed for natural language scenarios and fail to transfer effectively to the task of detecting generated code. When directly applied to code, they face two major challenges: (1) the low-entropy nature of code restricts the perturbation space and weakens discriminative signals; and (2) prior perturbation methods often compromise semantic integrity or executability, leading to substantial performance degradation. To address these issues, we propose DualCodeDetect, a novel zero-shot detection framework that amplifies the differences between LLM-generated and human-written code through a dual-channel perturbation mechanism. In the semantic channel, we design an identifier perturbation strategy based on outside-nucleus sampling, which disrupts the strong consistency of LLMs in identifier selection. In the structural channel, empirical analysis reveals that LLM-generated code exhibits greater uniformity in stylistic features; leveraging this insight, we construct a rule-based library of semantics-preserving code transformations to introduce structural perturbations that further magnify statistical disparities. In experiments conducted across two datasets and ten representative code LLMs, DualCodeDetect achieves an average AUROC of 0.8477, alongside FPR and FNR values of 0.0430 and 0.0552, respectively, on Python under both T =0.2 and T =1.0 temperature settings with a reasonable runtime overhead. Furthermore, it demonstrates strong cross-language generalization on Java, C++, and JavaScript, confirming its significant superiority over existing detection methods.
问问这篇 Paper
问问你的智能体。
Lune 读过与它相关的顶会 Paper,每个回答都会注明依据哪几篇。
相关 Paper
- Uncovering LLM-Generated Code: A Zero-Shot Synthetic Code Detector via Code RewritingTong Ye, Yangkai Du, Tengfei Ma, Lingfei Wu 等AAAI 2025 · 被引用 21 次
- Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human ProgrammersYuling Shi, Hongyu Zhang, Chengcheng Wan, Xiaodong GuICSE 2025 · 被引用 9 次
- Zero-Shot Detection of LLM-Generated Text using Temperature SensitivityShixuan Ma, Jiahao Li, Zhendong Mao, Quan WangACL 2026
- DNA-DetectLLM: Unveiling AI-Generated Text via a DNA-Inspired Mutation-Repair ParadigmXiaowei Zhu, Yubing Ren, Fang Fang, Qingfeng Tan 等NeurIPS 2025 · 被引用 10 次
- Zero-Shot Detection of LLM-Generated Text using Token CohesivenessShixuan Ma, Quan WangEMNLP 2024 · 被引用 5 次
