Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmers
Authors:
- 26 April 2025
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 1628-1639
Abstract
Large language models have catalyzed an unprece-dented wave in code generation. While achieving significant advances, they blur the distinctions between machine- and human-authored source code, causing integrity and authenticity issues of software artifacts. Previous methods such as DetectGPthave proven effective in discerning machine-generated texts, but they do not identify and harness the unique patterns of machine-generated code. Thus, its applicability falters when applied to code. In this paper, we carefully study the specific patterns that characterize machine- and human-authored code. Through a rigorous analysis of code attributes such as lexical diversity, conciseness, and naturalness, we expose unique patterns inherent to each source. We particularly notice that the syntactic segmentation of code is a critical factor in identifying its provenance. Based on our findings, we propose DetectCodeGPT, a novel method for detecting machine-generated code, which improves DetectGPT by capturing the distinct stylized patterns of code. Diverging from conventional techniques that depend on external LLMs for perturbations, DetectCodeGPT perturbs the code corpus by strategically inserting spaces and newlines, ensuring both efficacy and efficiency. Experiment results show that our approach significantly outperforms state-of-the-art techniques in detecting machine-generated code. 1.Keywords
All Related Versions
This publication has 29 references indexed in Scilit:
- ChatGPT: A comprehensive review on background, applications, key challenges, bias, ethics, limitations and future scopeInternet of Things and Cyber-Physical Systems, 2023
- Competition-level code generation with AlphaCodeScience, 2022
- On the naturalness of softwareCommunications of the ACM, 2016
- Discovering power laws in computer programsInformation Processing & Management, 2009
- Exploring Regularity in Source Code: Software Science and Zipf's Law2008
- Some misconceptions about lines of code2002
- Digital WatermarkingJournal of Electronic Imaging, 2002
- May the source be with youWork Study, 2000
- The minimum description length principle in coding and modelingIEEE Transactions on Information Theory, 1998
- Software Function, Source Lines of Code, and Development Effort Prediction: A Software Science ValidationIEEE Transactions on Software Engineering, 1983