Abstract
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.
1. Introduction
As AI-generated code becomes ubiquitous, the need to identify the specific origin of a code snippet has moved beyond simple human-vs-AI detection. Model-level attribution is now critical for software provenance, licensing audits, and security forensics. However, attributing code to a specific model is difficult because code is constrained by rigid syntax; two different models solving the same task often produce nearly identical logic. Previous methods often failed by focusing too heavily on this shared logic rather than the subtle, model-specific stylistic choices—such as variable naming preferences and API usage—that act as a digital signature.
2. Methodology: The DCAN Framework
The authors introduce the Disentangled Code Attribution Network (DCAN), which treats attribution as a representation disentanglement problem. The framework operates on the premise that AI-generated code contains two distinct types of information: Source-Agnostic Information (the core algorithm) and Source-Specific Information (the unique stylistic fingerprints of the LLM).
2.1 Architecture and Disentanglement
The DCAN architecture utilizes a Base Encoder (UniXcoder) to transform code into high-dimensional vectors. The core innovation lies in the Disentanglement Module, which isolates the shared task logic and effectively "subtracts" it from the original vector to isolate the model-specific residual.
Training is guided by two primary loss functions:
- Classification Loss ($L_{cls}$): Ensures that the isolated source-specific features accurately identify the originating model.
- Representation Consistency Loss ($L_{rc}$): Forces the model to ensure that code from different LLMs solving the same task results in the same "agnostic" logic vector, effectively stripping away the model's "personality" from the functional component.
3. Dataset and Experimental Setup
To evaluate DCAN, the researchers constructed a large-scale benchmark featuring 91,804 code samples generated from 2,869 LeetCode tasks. The dataset includes outputs from four prominent models—ChatGPT, Claude, Qwen, and DeepSeek—across four programming languages: Python, Java, C, and Go. The study compared performance in "Plain" (code only) and "Comment" (code with natural language explanations) settings.
4. Key Results and Insights
DCAN achieved state-of-the-art performance with an average F1-score of 92.94% in the Plain setting, rising to 98.38% when comments were included.
4.1 Complexity as a Discriminator
Counter-intuitively, DCAN performs better on "Hard" tasks than "Easy" ones. While simple tasks often lead models toward identical canonical solutions, complex tasks require more creative implementation choices, which amplifies unique stylistic fingerprints.
4.2 Model "Personalities"
The system successfully identified distinct generative habits for each model:
- Claude: Shows a preference for explicit control-flow (e.g.,
if/elif). - DeepSeek: Frequently utilizes stack-related API operations (e.g.,
.pop). - Qwen: Favors functional aggregation methods (e.g.,
sum). - ChatGPT: Uses distinctive variable naming conventions like
next_num.
4.3 Cross-Language Generalization
In "Leave-One-Language-Out" tests, the model demonstrated strong zero-shot capabilities. Training on multiple languages helped the model learn a generalized "personality" for each LLM, allowing it to attribute code in unseen languages with high accuracy, particularly when natural language comments provided additional stylistic signals.
5. Conclusion and Future Work
DCAN demonstrates that LLMs leave persistent, identifiable fingerprints in the code they generate. While highly effective, the authors note that future research is needed to address "open-set" scenarios (identifying unknown models) and potential evasion tactics where users might prompt models to mimic different styles. Expanding the framework to handle more models and varying decoding strategies remains a priority for future development.
Summary updated