Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

One Size Does Not Fit All: Investigating Efficacy of Perplexity in Detecting LLM-Generated Code

About

Large language model-generated code (LLMgCode) has become increasingly common in software development. So far LLMgCode has more quality issues than human-authored code (HaCode). It is common for LLMgCode to mix with HaCode in a code change, while the change is signed by only human developers, without being carefully examined. Many automated methods have been proposed to detect LLMgCode from HaCode, in which the perplexity-based method (PERPLEXITY for short) is the state-of-the-art method. However, the efficacy evaluation of PERPLEXITY has focused on detection accuracy. Yet it is unclear whether PERPLEXITY is good enough in a wider range of realistic evaluation settings. To this end, we carry out a family of experiments to compare PERPLEXITY against feature- and pre-training-based methods from three perspectives: detection accuracy, detection speed, and generalization capability. The experimental results show that PERPLEXITY has the best generalization capability while having limited detection accuracy and detection speed. Based on that, we discuss the strengths and limitations of PERPLEXITY, e.g., PERPLEXITY is unsuitable for high-level programming languages. Finally, we provide recommendations to improve PERPLEXITY and apply it in practice. As the first large-scale investigation on detecting LLMgCode from HaCode, this article provides a wide range of findings for future improvement.

Jinwei Xu, He Zhang, Yanjing Yang, Lanxin Yang, Zeru Cheng, Jun Lyu, Bohan Liu, Xin Zhou, Alberto Bacchelli, Yin Kia Chiam, Thiam Kian Chiew• 2024

Related benchmarks

TaskDatasetResultRank
LLM-generated content detectionGB Creative Deepseek V3
F1 Score0.9547
5
LLM-generated text detectionHC3 (test)
AUROC0.9947
5
LLM-generated text detectionGB Essay ChatGPT (test)
AUROC99.81
5
LLM-generated text detectionGB Essay GPT4o (test)
AUROC99.365
5
LLM-generated text detectionGB Essay Deepseek V3 (test)
AUROC99.881
5
LLM-generated content detectionGB Creative ChatGPT
F1 Score89.799
5
LLM-generated content detectionGB Essay GPT4o
F1 Score93.493
5
LLM-generated content detectionGB News Claude
F1 Score76.009
5
LLM-generated text detectionAI vs Human (test)
AUROC90.743
5
LLM-generated text detectionHC3 Plus (test)
AUROC0.91
5
Showing 10 of 25 rows

Other info

Follow for update