TRANSMISSION // 2409.01382v3
Why AI-code detection differs by code unit
Source published
A comparison of four language models finds that detecting generated code differs between functions and classes, and across models.

Can a detector reliably tell whether code was written by a person or generated by an AI? This study suggests the answer depends on which model produced it and whether the detector examines functions or classes.
Detecting functions and classes
AI-generated code can introduce vulnerabilities into software, making its origins a practical concern. But a detector that performs well on one language model may not work as well on another. The unit of analysis may matter, too: a function and a class offer different amounts and kinds of structure for a classifier to examine.
Researchers compared code generated by four language models: GPT-3.5, Claude 3 Haiku, Claude Haiku 4.5 and GPT-OSS. They used Python functions and classes from CodeSearchNet as source examples: the abstract reports analyzing 14,485 functions and 11,913 classes, then generating corresponding code with each model. The researchers trained CatBoost classifiers using interpretable software metrics and used SHAP analysis to examine which metrics contributed to their decisions.
Results varied by granularity and model
The authors report that granularity—whether the detector analyzes functions or classes—had an effect 8.6 times larger than model differences in their comparison. The abstract does not explain how this ratio was defined or calculated, so it should be understood as the authors’ reported result rather than a general measure of how much granularity matters in other settings.
The authors also report negligible overlap between features associated with function-level and class-level detection. This suggests that a detector’s useful signals may depend on which kind of code unit it examines, though the abstract alone does not provide enough detail to assess the feature analysis.
Performance patterns differed across models and granularity. In the study’s comparison, Claude models and GPT-OSS were more detectable at the class level, while GPT-3.5 was an exception, with stronger detectability at the function level. The abstract reports an AUC-ROC of 0.96 for GPT-3.5 and approximate values between 0.68 and 0.80 for the other models. AUC-ROC summarizes how well a classifier separates two groups across decision thresholds; higher values indicate better separation. These figures describe the study’s evaluation, not a universal measure of detector reliability.
One metric appeared across all the configurations the authors examined: the ratio of comments to code. They identify it as the sole universal discriminator, while noting that its predictive strength varied substantially across models. That variation may help explain why a detector developed around one model does not necessarily transfer to another.
What the findings can tell us
The results imply that a high score in one model-and-granularity setting is not, by itself, evidence of broad detection ability. In this comparison, GPT-3.5’s reported performance differed from the other models, and results also depended on whether the code was analyzed as functions or classes. Evaluating detectors across multiple models and code units may therefore provide a more informative picture than testing only one configuration.
There are limits to what can be concluded. The available source is the paper’s abstract, not its full methods, tables or discussion. It does not give enough detail to assess dataset splits, model-generation settings, classifier configurations or uncertainty around the reported scores. The study concerns generated code based on CodeSearchNet examples; the abstract does not establish how well the results transfer to code produced in real development workflows.
Security motivates the research, but the abstract does not say that the researchers tested whether generated code contained vulnerabilities, or whether the detector can identify insecure code. Detecting generated code and detecting vulnerable code are different tasks.
The source is an arXiv preprint, and the supplied record does not establish its peer-review status. These findings are best read as results from a particular comparison, not as proof that detectors can reliably determine code authorship in general.
- AI-generated code
- code detection
- large language models
- software metrics
- machine learning
Related reading
Automatically matched by shared topic keywords. These links do not imply that the sources agree or establish a consensus.
Can a language model help protect spacecraft polymers from atomic oxygen?
Source published
Shared keywords: large language models, machine learning
How causal maps could clarify AI benchmark results
Source published
Shared keywords: large language models
When do AI-generated survey answers reflect real patterns?
Source published
Shared keywords: large language models, machine learning
Can an AI agent improve a live search-ranking system?
Source published
Shared keywords: large language models
When Clinician Edits Help—and When They Could Teach AI to Make Things Up
Source published
Shared keywords: large language models, machine learning