HybridCodeAuthorship: A Benchmark Dataset for Line-Level Code Authorship Detection

📄 arXiv: 2606.12620 📥 PDF

作者: Luke Patterson, Li Wang, Adam Faulkner

分类: cs.SE, cs.AI

发布日期: 2026-06-12


💡 一句话要点

提出HybridCodeAuthorship以解决代码作者检测的挑战

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 代码作者检测 AI生成代码 基准数据集 机器学习 软件工程

📋 核心要点

  1. 现有的代码作者检测方法往往假设代码片段完全由人类或AI编写,无法适应实际行业代码的复杂性。
  2. 本文提出了HybridCodeAuthorship基准,构建了包含人类和AI交错编写代码行的Python代码文件,以模拟真实场景。
  3. 实验结果显示,最佳算法在行级和块级检测任务上分别达到了0.56和0.48的F1分数,验证了基准的有效性和挑战性。

📝 摘要(中文)

随着大型语言模型驱动的AI代码助手的快速普及,行业代码库越来越多地融合了AI和人类编写的代码。为了风险管理和生产力分析,精确检测AI生成代码的位置至关重要。现有基准测试主要基于学术问题,且假设代码片段完全由人类或AI编写,无法反映行业代码库的多样性。为此,本文提出了HybridCodeAuthorship,一个包含交错人类和AI编写代码行的Python代码文件的新基准。我们展示了数据集构建流程,并对两种最先进的AI生成代码检测算法进行了基准测试,结果表明该基准具有挑战性,最佳算法在行级和块级检测任务上分别获得了0.56和0.48的F1分数。

🔬 方法详解

问题定义:本文旨在解决AI生成代码与人类编写代码的混合检测问题。现有方法的痛点在于缺乏能够反映真实行业代码库多样性的基准测试。

核心思路:通过构建一个包含交错人类和AI编写代码行的基准数据集,来提高代码作者检测算法的性能评估,确保算法能够适应实际应用场景。

技术框架:数据集构建流程利用CodeSearchNet,从GitHub开源代码库中提取数据,形成包含人类和AI代码的Python文件。随后,对两种最先进的检测算法进行性能基准测试,分别在行级和块级进行评估。

关键创新:HybridCodeAuthorship是首个针对混合代码的基准数据集,填补了现有基准测试的空白,能够更真实地反映行业应用中的代码作者检测需求。

关键设计:在数据集构建中,采用了多样化的代码风格和意图,确保数据集的代表性。同时,选择了两种先进的AI生成代码检测算法进行基准测试,以验证新数据集的有效性。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果表明,HybridCodeAuthorship基准具有挑战性,最佳算法AIGCode Detector在块级和行级检测任务上分别获得了0.48和0.56的F1分数,显示出相较于现有基准的显著提升。

🎯 应用场景

该研究的潜在应用领域包括软件开发、代码审查和安全性分析等。通过准确检测AI生成的代码,开发者可以更好地管理代码质量和安全性,从而提高生产力和降低风险。未来,该基准数据集还可用于进一步推动代码作者检测技术的发展。

📄 摘要(原文)

Thanks to the rapid adoption of AI code assistants powered by large language models (LLMs), industry codebases are, increasingly, a hybrid of AI- and human-authored code. For risk management and productivity analysis purposes, it is crucial to enable fine-grained location detection of AI-generated code. To develop algorithms for this task, quality benchmarks are needed to assess performance. However, existing benchmarks tend to comprise academic, LeetCode-style problems and presume a code snippet is either completely human-authored or completely AI-authored, which is not reflective of the diverse intents and styles of industry codebases utilizing AI code assistants. To fill these gaps, we introduce HybridCodeAuthorship, a novel benchmark of Python code files with interleaved human- and AI-authored lines of code to simulate authentic utilization of AI code assistants. In this paper, we first present our dataset construction pipeline, which leverages CodeSearchNet, a massive collection of links to open sourced repositories on GitHub. We then benchmark the performance of two state-of-the-art AI-generated code detection algorithms at both the line- and chunk-level. Experimental results demonstrate that HybridCodeAuthorship is a challenging benchmark with a top-scoring algorithm, AIGCode Detector, obtaining a highest F1 score of 0.48 and 0.56 on chunk-level and line-level code detection tasks, respectively.