ChatGPT Code Detection: Techniques for Uncovering the Source of Code
Not on the map. Why?
Abstract (arXiv)
In recent times, large language models (LLMs) have made significant strides in generating computer code, blurring the lines between code created by humans and code produced by artificial intelligence (AI). As these technologies evolve rapidly, it is crucial to explore how they influence code generation, especially given the risk of misuse in areas like higher education. This paper explores this issue by using advanced classification techniques to differentiate between code written by humans and that generated by ChatGPT, a type of LLM. We employ a new approach that combines powerful embedding features (black-box) with supervised learning algorithms - including Deep Neural Networks, Random Forests, and Extreme Gradient Boosting - to achieve this differentiation with an impressive accuracy of 98%. For the successful combinations, we also examine their model calibration, showing that some of the models are extremely well calibrated. Additionally, we present white-box features and an interpretable Bayes classifier to elucidate critical differences between the code sources, enhancing the explainability and transparency of our approach. Both approaches work well but provide at most 85-88% accuracy. We also show that untrained humans solve the same task not better than random guessing. This study is crucial in understanding and mitigating the potential risks associated with using AI in code generation, particularly in the context of higher education, software development, and competitive programming.
Key facts. Cited by 6 papers in the map (data through 14 Oct 2026). Builds on 36 of its 69 references that are in the map. First posted on arXiv 24 May 2024.
Builds on
36 of 69 references.
References · 36
- 2017Attention Is All You Needcited by 60,361
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2023GPT-4 Technical Reportcited by 18,396
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2020A Simple Framework for Contrastive Learning of Visual Representationscited by 12,049
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2016XGBoost: A Scalable Tree Boosting Systemcited by 5,166
- 2013Efficient Estimation of Word Representations in Vector Spacecited by 4,375
- 2021Program Synthesis with Large Language Modelscited by 3,637
- 2013Distributed Representations of Words and Phrases and their Compositionalitycited by 3,474
- 2014Sequence to Sequence Learning with Neural Networkscited by 2,986
- 2022Competition-Level Code Generation with AlphaCodecited by 1,462
24 more
- 2021Ethical and social risks of harm from Language Modelscited by 966
- 2021Measuring Coding Challenge Competence With APPScited by 902
- 2023DetectGPT: Zero-Shot Machine-Generated Text Detection using Probability Curvaturecited by 726
- 2019Release Strategies and the Social Impacts of Language Modelscited by 513
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 498
- 2019GLTR: Statistical Detection and Visualization of Generated Textcited by 496
- 2023How Close is ChatGPT to Human Experts? Comparison Corpus, Evaluation, and Detectioncited by 481
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
- 2022Text and Code Embeddings by Contrastive Pre-Trainingcited by 361
- 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 333
- 2018code2vec: Learning Distributed Representations of Codecited by 250
- 2021Entailment as Few-Shot Learnercited by 123
- 2022Productivity Assessment of Neural Code Completioncited by 98
- 2023ChatGPT and a New Academic Reality: Artificial Intelligence-Written Research Papers and the Ethics of the Large Language Models in Scholarly Publishingcited by 52
- 2023From Text to MITRE Techniques: Exploring the Malicious Use of Large Language Models for Generating Cyber Attack Payloadscited by 32
- 2023Towards Possibilities & Impossibilities of AI-generated Text Detection: A Surveycited by 28
- 2023Zero-Shot Detection of Machine-Generated Codescited by 24
- 2024Assessing AI Detectors in Identifying AI-Generated Code: Implications for Educationcited by 18
- 2023Evaluating AIGC Detectors on Code Contentcited by 12
- 2023Distinguishing Human Generated Text From ChatGPT Generated Text Using Machine Learningcited by 10
- 2023Discriminating Human-authored from ChatGPT-Generated Code Via Discernable Feature Analysiscited by 7
- 2020Oblique Predictive Clustering Treescited by 6
- 2023Ethical Considerations and Policy Implications for Large Language Models: Guiding Responsible Development and Deploymentcited by 5
- 2022Exploring the Impact of Code Style in Identifying Good Programmerscited by 2
Built on by
Citing papers per year: 2024: 2; 2025: 3; 2026: 1.
6 papers.
- 2024AIGCodeSet: A New Annotated Dataset for AI Generated Code Detectioncited by 5
- 2025AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Softwarecited by 4
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarioscited by 2
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularitiescited by 1
- 2025ChatGPT vs. DeepSeek: A Comparative Study on AI-Based Code Generationcited by 0
- 2026Argus: Academic Integrity in the Era of Generative AIcited by 0
- 2026Argus: Academic Integrity in the Era of Generative AI28 Sep 2026
- 2025AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Software21 Dec 2025
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarios29 Jul 2025
- 2025ChatGPT vs. DeepSeek: A Comparative Study on AI-Based Code Generation30 Jan 2025
- 2024AIGCodeSet: A New Annotated Dataset for AI Generated Code Detection21 Dec 2024
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularities2 Sep 2024