arXiv:2506.17323cs.LGcs.AI2025-06被引 19

通过代码风格识别大模型生成的代码来源,准确率超95%。

I Know Which LLM Wrote Your Code Last Summer: LLM generated Code Stylometry for Authorship Attribution

  • 用CodeT5编码器+分类头,从代码首标记提取作者特征。
  • 在8个模型中区分代码来源,多分类准确率达95.40%。
  • 开源数据集与工具链,支持代码生成溯源研究。

检测由大型语言模型(LLMs)生成的代码、深度伪造等合成内容是新兴的研究挑战。随着LLM生成代码日益普遍,识别具体生成模型变得愈发重要。本文首次系统性研究了C语言程序的LLM作者归属问题。我们发布了CodeT5-Authorship,该模型仅使用原始CodeT5编码器-解码器架构中的编码器部分,舍弃解码器以专注分类任务。模型的编码器输出(首个标记)经两层带有GELU激活和丢弃的分类头处理,生成各可能作者的概率分布。为评估方法,我们引入LLM-AuthorBench基准,包含32,000个可编译的C程序,由8个顶尖LLM在多样化任务中生成。我们将模型与七种传统机器学习分类器及八种微调的Transformer模型(包括BERT、RoBERTa、CodeBERT、ModernBERT、DistilBERT、DeBERTa-V3、Longformer以及LoRA微调的Qwen2-1.5B)进行对比。在二分类任务中,模型对密切相关的GPT-4.1与GPT-4o生成代码的区分准确率达97.56%;在五类主流模型(Gemini 2.5 Flash、Claude 3.5 Haiku、GPT-4.1、Llama 3.3、DeepSeek-V3)的多分类任务中,准确率为95.40%。为推动开放科学,我们已在GitHub上公开CodeT5-Authorship架构、LLM-AuthorBench基准及全部Google Colab脚本:https://github.com/LLMauthorbench/

原文摘要 · Abstract (English)

Detecting AI-generated code, deepfakes, and other synthetic content is an emerging research challenge. As code generated by Large Language Models (LLMs) becomes more common, identifying the specific model behind each sample is increasingly important. This paper presents the first systematic study of LLM authorship attribution for C programs. We released CodeT5-Authorship, a novel model that uses only the encoder layers from the original CodeT5 encoder-decoder architecture, discarding the decoder to focus on classification. Our model's encoder output (first token) is passed through a two-layer classification head with GELU activation and dropout, producing a probability distribution over possible authors. To evaluate our approach, we introduce LLM-AuthorBench, a benchmark of 32,000 compilable C programs generated by eight state-of-the-art LLMs across diverse tasks. We compare our model to seven traditional ML classifiers and eight fine-tuned transformer models, including BERT, RoBERTa, CodeBERT, ModernBERT, DistilBERT, DeBERTa-V3, Longformer, and LoRA-fine-tuned Qwen2-1.5B. In binary classification, our model achieves 97.56% accuracy in distinguishing C programs generated by closely related models such as GPT-4.1 and GPT-4o, and 95.40% accuracy for multi-class attribution among five leading LLMs (Gemini 2.5 Flash, Claude 3.5 Haiku, GPT-4.1, Llama 3.3, and DeepSeek-V3). To support open science, we release the CodeT5-Authorship architecture, the LLM-AuthorBench benchmark, and all relevant Google Colab scripts on GitHub: https://github.com/LLMauthorbench/.

代码生成模型溯源大模型分析

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