ChatGPT Code Detection: Techniques for Uncovering the Source of Code

Marc Oedingen, Raphael C. Engelhardt, Robin Denz, Maximilian Hammer, Wolfgang Konen
5/24/2024
cs.LGcs.AI

No official code found. Best implementation: MarcOedingen/ChatGPT-Code-Detection (9 stars, CC-BY-4.0, last commit 2024-08-13).

Abstract

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.

View on arXivView PDF

Code Implementations(1)

CC-BY-4.0

Code and data for the paper "ChatGPT Code Detection: Techniques for Uncovering the Source of Code" Published in MDPI AI journal

93CSS, HTMLNov 6, 20232 years agoCC-BY-4.0

Similar Papers

Cite this paper

@article{oedingen2024chatgpt,
  title  = {ChatGPT Code Detection: Techniques for Uncovering the Source of Code},
  author = {Marc Oedingen and Raphael C. Engelhardt and Robin Denz and Maximilian Hammer and Wolfgang Konen},
  year   = {2024},
  eprint = {2405.15512},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2405.15512v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2405.15512.svg)](https://codeofpaper.com/paper/2405.15512)

Discussion