跳到正文
arXiv cs.AI· Musfiqur Rahman, SayedHassan Khatoonabadi, Ahmad Abdellatif, Emad Shihab·· 2 小时前AI 评分43

LLM 生成代码的自动检测:GPT-3.5、Claude 3 Haiku、Claude Haiku 4.5 与 GPT-OSS 在函数与类粒度上的对比研究

Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularities

AI 导读

一项对比研究评估了 GPT-3.5、Claude 3 Haiku、Claude Haiku 4.5 和 GPT-OSS 生成代码的可检测性,基于 CodeSearchNet 的 14,485 个 Python 函数和 11,913 个类训练 CatBoost 分类器。

正文 · 原文

View PDF HTML (experimental)

Abstract:The adoption of Large Language Models (LLMs) for code generation risks incorporating vulnerable code into software systems. Existing detectors face two critical limitations: a lack of systematic cross-model validation and opaque "black box" operation. We address this through a comparative study of code generated by four distinct LLMs: GPT-3.5, Claude 3 Haiku, Claude Haiku 4.5, and GPT-OSS.
Analyzing 14,485 Python functions and 11,913 classes from the CodeSearchNet dataset, we generated corresponding code with all four LLMs. Using interpretable software metrics, we trained CatBoost classifiers for each configuration. Our analysis reveals that granularity effects dominate model differences by a factor of 8.6, with negligible feature overlap, indicating that function-level and class-level detection rely on fundamentally disjoint structural signatures.
We discover critical granularity-dependent inversions: while modern models (Claude, GPT-OSS) are more detectable at the class level, GPT-3.5 is an anomaly that uniquely excels at the function level. SHAP analysis identifies the Comment-to-Code Ratio as the sole universal discriminator. However, its predictive magnitude varies drastically across models, explaining why detectors trained on specific LLMs fail to generalize.
Our findings demonstrate that GPT-3.5's exceptional detectability (AUC-ROC 0.96) is unrepresentative of contemporary models (AUC-ROC approximately between 0.68 and 0.80). Robust detection requires moving beyond single-model studies to account for substantial diversity in structural fingerprints across architectures and granularities.
Comments: Submitted to a journal for publication. This is the version after major revision round 2
Subjects: Software Engineering (cs.SE); Artificial Intelligence (cs.AI); Machine Learning (cs.LG)
Cite as: arXiv:2409.01382 [cs.SE]
  (or arXiv:2409.01382v3 [cs.SE] for this version)
  https://doi.org/10.48550/arXiv.2409.01382

arXiv-issued DOI via DataCite

Submission history

From: Musfiqur Rahman [view email]
[v1] Mon, 2 Sep 2024 17:25:15 UTC (142 KB)
[v2] Mon, 22 Dec 2025 01:18:44 UTC (1,604 KB)
[v3] Thu, 19 Nov 2026 19:26:30 UTC (951 KB)

来源:arXiv cs.AI · arxiv.org