Detection of LLM-Generated Java Code Using Discretized Nested Bigrams

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Paek, Timothy, Mohan, Chilukuri
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866917933664436224
author Paek, Timothy
Mohan, Chilukuri
author_facet Paek, Timothy
Mohan, Chilukuri
contents Large Language Models (LLMs) are currently used extensively to generate code by professionals and students, motivating the development of tools to detect LLM-generated code for applications such as academic integrity and cybersecurity. We address this authorship attribution problem as a binary classification task along with feature identification and extraction. We propose new Discretized Nested Bigram Frequency features on source code groups of various sizes. Compared to prior work, improvements are obtained by representing sparse information in dense membership bins. Experimental evaluation demonstrated that our approach significantly outperformed a commonly used GPT code-detection API and baseline features, with accuracy exceeding 96% compared to 72% and 79% respectively in detecting GPT-rewritten Java code fragments for 976 files with GPT 3.5 and GPT4 using 12 features. We also outperformed three prior works on code author identification in a 40-author dataset. Our approach scales well to larger data sets, and we achieved 99% accuracy and 0.999 AUC for 76,089 files and over 1,000 authors with GPT 4o using 227 features.
format Preprint
id arxiv_https___arxiv_org_abs_2502_15740
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Detection of LLM-Generated Java Code Using Discretized Nested Bigrams
Paek, Timothy
Mohan, Chilukuri
Software Engineering
Artificial Intelligence
Computation and Language
Machine Learning
68T50, 62H30
I.2.7; K.6.5; D.2.8
Large Language Models (LLMs) are currently used extensively to generate code by professionals and students, motivating the development of tools to detect LLM-generated code for applications such as academic integrity and cybersecurity. We address this authorship attribution problem as a binary classification task along with feature identification and extraction. We propose new Discretized Nested Bigram Frequency features on source code groups of various sizes. Compared to prior work, improvements are obtained by representing sparse information in dense membership bins. Experimental evaluation demonstrated that our approach significantly outperformed a commonly used GPT code-detection API and baseline features, with accuracy exceeding 96% compared to 72% and 79% respectively in detecting GPT-rewritten Java code fragments for 976 files with GPT 3.5 and GPT4 using 12 features. We also outperformed three prior works on code author identification in a 40-author dataset. Our approach scales well to larger data sets, and we achieved 99% accuracy and 0.999 AUC for 76,089 files and over 1,000 authors with GPT 4o using 227 features.
title Detection of LLM-Generated Java Code Using Discretized Nested Bigrams
topic Software Engineering
Artificial Intelligence
Computation and Language
Machine Learning
68T50, 62H30
I.2.7; K.6.5; D.2.8
url https://arxiv.org/abs/2502.15740