arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.17749cs.AI
收藏

检测 LLM 生成的代码并识别负责的 LLM 使用编码风格特征

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

Yonsei University(延世大学);Changwon National University(昌原国立大学)

Shinwoo Park, Hyundong Jin, Jeong-won Cha, Yo-Sub Han

AI总结:

本文提出通过编码风格特征检测 LLM 生成的代码并识别负责的 LLM,改进了检测性能和效率。

摘要:

近年来,大型语言模型(LLMs)在代码生成方面的进展引发了对知识产权保护的严重担忧。恶意用户可以利用 LLMs 生成与原始代码非常相似的改写代码。尽管 LLM 协助的代码改写潜力持续增长,但针对其检测的研究仍然有限,凸显了检测系统的需求。我们通过提出两个任务来回应这一需求。第一个任务是检测由 LLM 生成的代码是否是原始人工编写代码的改写版本。第二个任务是识别用于改写原始代码的 LLM。为了完成这些任务,我们构建了一个名为 LPcode 的数据集,该数据集包含通过各种 LLM 生成的人工编写代码和 LLM 生成的改写代码的配对。我们统计确认了人工编写代码和 LLM 生成的改写代码在编码风格上的显著差异,特别是在命名一致性、代码结构和可读性方面。基于这些发现,我们开发了 LPcodedec,一种能够识别人工编写代码和 LLM 生成代码之间改写关系的检测方法,并发现用于改写的 LLM。LPcodedec 在两个任务中均优于最佳基线,提高了 2.64% 和 15.17% 的 F1 分数,同时分别实现了 1,343 倍和 213 倍的速度提升。我们的代码和数据可在 https://github.com/Shinwoo-Park/detecting_llm_paraphrased_code_via_coding_style_features 上获取。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑