Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmers

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Shi, Yuling, Zhang, Hongyu, Wan, Chengcheng, Gu, Xiaodong
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911971679404032
author Shi, Yuling
Zhang, Hongyu
Wan, Chengcheng
Gu, Xiaodong
author_facet Shi, Yuling
Zhang, Hongyu
Wan, Chengcheng
Gu, Xiaodong
contents Large language models have catalyzed an unprecedented 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 DetectGPT have 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.
format Preprint
id arxiv_https___arxiv_org_abs_2401_06461
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmers
Shi, Yuling
Zhang, Hongyu
Wan, Chengcheng
Gu, Xiaodong
Software Engineering
Artificial Intelligence
Computation and Language
Large language models have catalyzed an unprecedented 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 DetectGPT have 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.
title Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmers
topic Software Engineering
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2401.06461