Is This You, LLM? Recognizing AI-written Programs with Multilingual Code Stylometry

With the increasing popularity of LLM-based code completers, like GitHub Copilot, the interest in automatically detecting AI-generated code is also increasing-in particular in contexts where the use of LLMs to program is forbidden by policy due to security, intellectual property, or ethical concerns. We introduce a novel technique for AI code stylometry, i.e., the ability to distinguish code generated by LLMs from code written by humans, based on a transformer-based encoder classifier. Differently from previous work, our classifier is capable of detecting AI-written code across 10 different programming languages with a single machine learning model, maintaining high average accuracy across all languages (84.1% ± 3.8%). Together with the classifier we also release H-AIRosettaMP, a novel open dataset for AI code stylometry tasks, consisting of 121 247 code snippets in 10 popular programming languages, labeled as either human-written or AI-generated. The experimental pipeline (dataset, training code, resulting models) is the first fully reproducible one for the AI code stylometry task. Most notably our experiments rely only on open LLMs, rather than on proprietary/closed ones like ChatGPT.

Authors

Institutions

Publication Details

Published
2025-03-04
DOI
https://doi.org/10.1109/saner64311.2025.00044
Citations
7
Primary Topic
Software Engineering Research
Type
article
Field-Weighted Citation Impact
22.72
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Is This You, LLM? Recognizing AI-written Programs with Multilingual Code Stylometry

Stefano Zacchiroli, Maurizio Gabbrielli, Andrea Gurioli
7 citations
Software Engineering Research
22.72
article

Is This You, LLM? Recognizing AI-written Programs with Multilingual Code Stylometry

Stefano Zacchiroli, Maurizio Gabbrielli, Andrea Gurioli
article en
7 citations

Abstract

With the increasing popularity of LLM-based code completers, like GitHub Copilot, the interest in automatically detecting AI-generated code is also increasing-in particular in contexts where the use of LLMs to program is forbidden by policy due to security, intellectual property, or ethical concerns. We introduce a novel technique for AI code stylometry, i.e., the ability to distinguish code generated by LLMs from code written by humans, based on a transformer-based encoder classifier. Differently from previous work, our classifier is capable of detecting AI-written code across 10 different programming languages with a single machine learning model, maintaining high average accuracy across all languages (84.1% ± 3.8%). Together with the classifier we also release H-AIRosettaMP, a novel open dataset for AI code stylometry tasks, consisting of 121 247 code snippets in 10 popular programming languages, labeled as either human-written or AI-generated. The experimental pipeline (dataset, training code, resulting models) is the first fully reproducible one for the AI code stylometry task. Most notably our experiments rely only on open LLMs, rather than on proprietary/closed ones like ChatGPT.

Laboratoire Traitement et Communication de l’Information (FR), University of Bologna (IT)
Quality Education
Openalex Percentile: Top 1%
Software Engineering Research
22.72
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Is This You, LLM? Recognizing AI-written Programs with Multilingual Code Stylometry — Stefano Zacchiroli, Maurizio Gabbrielli, et al. · (2025) | TGRS Research Map | TGRS