代码指纹:解耦的LLM生成代码归因
Code Fingerprints: Disentangled Attribution of LLM-Generated Code
AI总结:
本文提出DCAN网络,通过解耦语义与风格信息,实现对LLM生成代码的多模型归因。
摘要:
大语言模型(LLM)的快速采用已经通过大规模自动化代码生成改变了现代软件开发。尽管这些系统提高了生产力,但它们在软件治理、责任和合规性方面引入了新的挑战。现有研究主要集中在区分机器生成的代码与人工编写代码;然而,许多实际场景——如漏洞优先级排序、事件调查和许可证审计——需要确定特定LLM生成了给定的代码片段。在本文中,我们研究了模型级别的代码归因问题,旨在确定生成代码的源LLM。尽管归因具有挑战性,但训练数据、架构、对齐策略和解码机制的差异引入了模型依赖的风格和结构变化,这些变化作为生成的指纹。利用这一观察,我们提出了解耦代码归因网络(DCAN),它将源无关的语义信息与源特定的风格表示分开。通过对比学习目标,DCAN隔离了判别性的模型依赖信号,同时保留了任务语义,从而在不同模型和编程语言上实现多类归因。为了支持系统评估,我们构建了第一个大规模基准数据集,包含由四个广泛使用的LLM(DeepSeek、Claude、Qwen和ChatGPT)在四种编程语言(Python、Java、C和Go)中生成的代码。实验结果表明,DCAN在各种设置中实现了可靠的归因性能,突显了在软件工程背景下模型级别的溯源分析的可行性。数据集和实现可在https://github.com/mtt500/DCAN上公开获取。
英文摘要:
The rapid adoption of Large Language Models (LLMs) has transformed modern software development by enabling automated code generation at scale. While these systems improve productivity, they introduce new challenges for software governance, accountability, and compliance. Existing research primarily focuses on distinguishing machine-generated code from human-written code; however, many practical scenarios--such as vulnerability triage, incident investigation, and licensing audits--require identifying which LLM produced a given code snippet. In this paper, we study the problem of model-level code attribution, which aims to determine the source LLM responsible for generated code. Although attribution is challenging, differences in training data, architectures, alignment strategies, and decoding mechanisms introduce model-dependent stylistic and structural variations that serve as generative fingerprints. Leveraging this observation, we propose the Disentangled Code Attribution Network (DCAN), which separates Source-Agnostic semantic information from Source-Specific stylistic representations. Through a contrastive learning objective, DCAN isolates discriminative model-dependent signals while preserving task semantics, enabling multi-class attribution across models and programming languages. To support systematic evaluation, we construct the first large-scale benchmark dataset comprising code generated by four widely used LLMs (DeepSeek, Claude, Qwen, and ChatGPT) across four programming languages (Python, Java, C, and Go). Experimental results demonstrate that DCAN achieves reliable attribution performance across diverse settings, highlighting the feasibility of model-level provenance analysis in software engineering contexts. The dataset and implementation are publicly available at https://github.com/mtt500/DCAN.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。