arXiv:2502.17749cs.AI2025-02被引 9

通过编码风格差异,识别代码是否由大模型改写并定位具体模型。

Detection of LLM-Paraphrased Code and Identification of the Responsible LLM Using Coding Style Features

  • 基于命名一致性、代码结构和可读性差异,构建检测方法。
  • 在两个任务上显著优于基线,F1提升最高达15.17%。
  • 适合关注代码版权保护与模型溯源的研究者使用。

大型语言模型(LLM)在代码生成上的进展引发了知识产权保护的严重担忧。恶意用户可利用LLM生成与原始代码高度相似的改写版本。尽管此类风险日益增长,相关检测研究仍显不足,亟需有效检测系统。本文提出两项任务:一是检测代码是否为大模型改写的伪原创版本;二是识别生成该代码的具体大模型。为此,我们构建了名为LPcode的数据集,包含多种大模型生成的改写代码对。统计分析显示,人类编写代码与大模型生成代码在命名一致性、代码结构和可读性方面存在显著差异。基于此,我们提出LPcodedec方法,能准确识别代码间的改写关系并定位生成模型。实验表明,该方法在两项任务中均优于最佳基线,F1分数分别提升2.64%和15.17%,推理速度加快1,343倍和213倍。代码与数据已开源于https://github.com/Shinwoo-Park/detecting_llm_paraphrased_code_via_coding_style_features。

原文摘要 · Abstract (English)

Recent progress in large language models (LLMs) for code generation has raised serious concerns about intellectual property protection. Malicious users can exploit LLMs to produce paraphrased versions of proprietary code that closely resemble the original. While the potential for LLM-assisted code paraphrasing continues to grow, research on detecting it remains limited, underscoring an urgent need for detection system. We respond to this need by proposing two tasks. The first task is to detect whether code generated by an LLM is a paraphrased version of original human-written code. The second task is to identify which LLM is used to paraphrase the original code. For these tasks, we construct a dataset LPcode consisting of pairs of human-written code and LLM-paraphrased code using various LLMs. We statistically confirm significant differences in the coding styles of human-written and LLM-paraphrased code, particularly in terms of naming consistency, code structure, and readability. Based on these findings, we develop LPcodedec, a detection method that identifies paraphrase relationships between human-written and LLM-generated code, and discover which LLM is used for the paraphrasing. LPcodedec outperforms the best baselines in two tasks, improving F1 scores by 2.64% and 15.17% while achieving speedups of 1,343x and 213x, respectively. Our code and data are available at https://github.com/Shinwoo-Park/detecting_llm_paraphrased_code_via_coding_style_features.

代码检测模型溯源风格分析

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。