Detection of LLM-Generated Java Code Using Discretized Nested Bigrams

Timothy Paek, Chilukuri Mohan
2/7/2025
cs.SEcs.AIcs.CL

No official code found. Best implementation: tipaek/NestedBigramsResearch (1 star, last commit 2025-05-15).

Abstract

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.

View on arXivView PDF

Code Implementations(1)

Code for "Detection of LLM-Generated Java Code Using Discretized Nested Bigrams" (arXiv:2502.15740). Achieves state-of-the-art performance in distinguishing human vs. LLM-written Java.

10Java, PythonSep 30, 20231 years ago
abstract-syntax-treeauthorship-attributionbigramsbinary-classificationcode-stylometry+8 more

Similar Papers

Cite this paper

@article{paek2025detection,
  title  = {Detection of LLM-Generated Java Code Using Discretized Nested Bigrams},
  author = {Timothy Paek and Chilukuri Mohan},
  year   = {2025},
  eprint = {2502.15740},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.15740v1}
}

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/2502.15740.svg)](https://codeofpaper.com/paper/2502.15740)

Discussion