mlsanityData to 7 Oct 2026

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

arXiv 2409.01382 ↗First posted 2 Sep 2024cs.SE cs.AI cs.LGcited by 1

Not on the map. Why?

Abstract (arXiv)

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.

Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Builds on 41 of its 118 references that are in the map. First posted on arXiv 2 Sep 2024.

Builds on

41 of 118 references.

References · 41

  1. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  2. 2017A Unified Approach to Interpreting Model Predictionscited by 6,488
  3. 2016XGBoost: A Scalable Tree Boosting Systemcited by 5,120
  4. 2021Program Synthesis with Large Language Modelscited by 3,509
  5. 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 638
  6. 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
  7. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
  8. 2022Text and Code Embeddings by Contrastive Pre-Trainingcited by 358
  9. 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
  10. 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 327
  11. 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 193
  12. 2023Large Language Models for Software Engineering: Survey and Open Problemscited by 178
29 more
  1. 2023ClassEval: A Manually-Crafted Benchmark for Evaluating LLMs on Class-level Code Generationcited by 166
  2. 2020Automatic Detection of Machine Generated Text: A Critical Surveycited by 160
  3. 2022Few-shot training LLMs for project-specific code-summarizationcited by 128
  4. 2023The Science of Detecting LLM-Generated Textscited by 126
  5. 2022Large Language Models are Few-shot Testers: Exploring LLM-based General Bug Reproductioncited by 110
  6. 2022Automating Code Review Activities by Large-Scale Pre-trainingcited by 98
  7. 2020Retrieval-Augmented Generation for Code Summarization via Hybrid GNNcited by 89
  8. 2023How Secure is Code Generated by ChatGPT?cited by 77
  9. 2022Automated Repair of Programs from Large Language Modelscited by 71
  10. 2023A Survey on Detection of LLMs-Generated Contentcited by 70
  11. 2023Unifying the Perspectives of NLP and Software Engineering: A Survey on Language Models for Codecited by 62
  12. 2021Multilingual training for Software Engineeringcited by 43
  13. 2024Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmerscited by 27
  14. 2024Toward Secure Code Generation: Bridging Correctness and Security via Task-Adaptive Vulnerability Modeling and Execution-Based Benchmarkingcited by 26
  15. 2023Zero-Shot Detection of Machine-Generated Codescited by 24
  16. 2023A Comparative Analysis of Large Language Models for Code Documentation Generationcited by 24
  17. 2022AUGER: Automatically Generating Review Comments with Pre-training Modelscited by 23
  18. 2024How secure is AI-generated Code: A Large-Scale Comparison of Large Language Modelscited by 23
  19. 2024LLMs in Web Development: Evaluating LLM-Generated PHP Code Unveiling Vulnerabilities and Limitationscited by 21
  20. 2023Enhancing Large Language Models for Secure Code Generation: A Dataset-driven Study on Vulnerability Mitigationcited by 14
  21. 2024Whodunit: Classifying Code as Human Authored or GPT-4 Generated -- A case study on CodeChef problemscited by 13
  22. 2024Uncovering LLM-Generated Code: A Zero-Shot Synthetic Code Detector via Code Rewritingcited by 11
  23. 2021On Wasted Contributions: Understanding the Dynamics of Contributor-Abandoned Pull Requestscited by 6
  24. 2022MultiCoder: Multi-Programming-Lingual Pre-Training for Low-Resource Code Completioncited by 6
  25. 2023Is this Snippet Written by ChatGPT? An Empirical Study with a CodeBERT-Based Classifiercited by 6
  26. 2024ChatGPT Code Detection: Techniques for Uncovering the Source of Codecited by 6
  27. 2020Predictive Models in Software Engineering: Challenges and Opportunitiescited by 5
  28. 2023Utilization of Pre-trained Language Model for Adapter-based Knowledge Transfer in Software Engineeringcited by 3
  29. 2023Predicting the First Response Latency of Maintainers and Contributors in Pull Requestscited by 3

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2026: 1.

1 paper.