Zero-Shot Detection of Machine-Generated Codes
Not on the map. Why?
Abstract (arXiv)
This work proposes a training-free approach for the detection of LLMs-generated codes, mitigating the risks associated with their indiscriminate usage. To the best of our knowledge, our research is the first to investigate zero-shot detection techniques applied to code generated by advanced black-box LLMs like ChatGPT. Firstly, we find that existing training-based or zero-shot text detectors are ineffective in detecting code, likely due to the unique statistical properties found in code structures. We then modify the previous zero-shot text detection method, DetectGPT (Mitchell et al., 2023) by utilizing a surrogate white-box model to estimate the probability of the rightmost tokens, allowing us to identify code snippets generated by language models. Through extensive experiments conducted on the python codes of the CodeContest and APPS dataset, our approach demonstrates its effectiveness by achieving state-of-the-art detection results on text-davinci-003, GPT-3.5, and GPT-4 models. Moreover, our method exhibits robustness against revision attacks and generalizes well to Java codes. We also find that the smaller code language model like PolyCoder-160M performs as a universal code detector, outperforming the billion-scale counterpart. The codes will be available at https://github.com/ Xianjun-Yang/Code_detection.git
Key facts. Cited by 24 papers in the map (data through 7 Oct 2026). Builds on 39 of its 52 references that are in the map. First posted on arXiv 8 Oct 2023.
Builds on
39 of 52 references.
References · 39
- 2023GPT-4 Technical Reportcited by 18,132
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,491
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2022OPT: Open Pre-trained Transformer Language Modelscited by 3,464
- 2023Sparks of Artificial General Intelligence: Early experiments with GPT-4cited by 2,579
- 2020The Pile: An 800GB Dataset of Diverse Text for Language Modelingcited by 2,346
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
- 2023Teaching Large Language Models to Self-Debugcited by 963
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2021Measuring Coding Challenge Competence With APPScited by 879
27 more
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
- 2023DetectGPT: Zero-Shot Machine-Generated Text Detection using Probability Curvaturecited by 705
- 2023A Watermark for Large Language Modelscited by 667
- 2019Defending Against Neural Fake Newscited by 553
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
- 2023Paraphrasing evades detectors of AI-generated text, but retrieval is an effective defensecited by 401
- 2022A Systematic Evaluation of Large Language Models of Codecited by 360
- 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 294
- 2019Mitigating Gender Bias in Natural Language Processing: Literature Reviewcited by 287
- 2022Efficient Training of Language Models to Fill in the Middlecited by 248
- 2023LEVER: Learning to Verify Language-to-Code Generation with Executioncited by 228
- 2023SantaCoder: don't reach for the stars!cited by 169
- 2023DNA-GPT: Divergent N-Gram Analysis for Training-Free Detection of GPT-Generated Textcited by 127
- 2023On the Risk of Misinformation Pollution with Large Language Modelscited by 124
- 2023Who Wrote this Code? Watermarking for Code Generationcited by 116
- 2022CERT: Continual Pre-Training on Sketches for Library-Oriented Code Generationcited by 87
- 2020PyMT5: multi-mode translation of natural language and Python code with transformerscited by 80
- 2022Language Generation Models Can Cause Harm: So What Can We Do About It? An Actionable Surveycited by 80
- 2018A Survey on Natural Language Processing for Fake News Detectioncited by 67
- 2022Real or Fake Text?: Investigating Human Ability to Detect Boundaries Between Human-Written and Machine-Generated Textcited by 63
- 2023ALGO: Synthesizing Algorithmic Programs with LLM-Generated Oracle Verifierscited by 41
- 2023Machine-Made Media: Monitoring the Mobilization of Machine-Generated Articles on Misinformation and Mainstream News Websitescited by 37
- 2023Smaller Language Models are Better Black-box Machine-Generated Text Detectorscited by 35
- 2022ERNIE-Code: Beyond English-Centric Cross-lingual Pretraining for Programming Languagescited by 29
- 2023Game of Tones: Faculty detection of GPT-4 generated content in university assessmentscited by 15
- 2023Evaluating AIGC Detectors on Code Contentcited by 12
Built on by
Citing papers per year: 2023: 2; 2024: 7; 2025: 7; 2026: 8.
24 papers.
Sort:
By area:
- 2023A Survey on Detection of LLMs-Generated Contentcited by 70
- 2023Unifying the Perspectives of NLP and Software Engineering: A Survey on Language Models for Codecited by 62
- 2024Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmerscited by 27
- 2024EAGLE: A Domain Generalization Framework for AI-generated Text Detectioncited by 13
- 2024DALD: Improving Logits-based Detector without Logits from Black-box LLMscited by 12
- 2024Uncovering LLM-Generated Code: A Zero-Shot Synthetic Code Detector via Code Rewritingcited by 11
- 2025textttDroid: A Resource Suite for AI-Generated Code Detectioncited by 9
- 2025Human Texts Are Outliers: Detecting LLM-generated Texts via Out-of-distribution Detectioncited by 8
- 2024ChatGPT Code Detection: Techniques for Uncovering the Source of Codecited by 6
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMscited by 6
- 2025Large Language Model Sourcing: A Surveycited by 5
- 2025Detection of LLM-Paraphrased Code and Identification of the Responsible LLM Using Coding Style Featurescited by 4
12 more
- 2024Self-Explained Keywords Empower Large Language Models for Code Generationcited by 2
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarioscited by 2
- 2026Beyond Raw Detection Scores: Markov-Informed Calibration for Boosting Machine-Generated Text Detectioncited by 2
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularitiescited by 1
- 2025Zero-Shot Detection of LLM-Generated Code via Approximated Task Conditioningcited by 1
- 2026Whitespaces Don't Lie: Feature-Driven and Embedding-Based Approaches for Detecting Machine-Generated Codecited by 0
- 2026Code Fingerprints: Disentangled Attribution of LLM-Generated Codecited by 0
- 2026Multi-Level Contextual Token Relation Modeling for Machine-Generated Text Detectioncited by 0
- 2026Hidden Human-Like Nature of Machine-Generated Texts: Theory and Detection Enhancementcited by 0
- 2026Detecting AI Coding Agents in Open Source: A Validated Multi-Method Census of 180 Million Repositoriescited by 0
- 2026Latent Trajectory Discrimination for AI-Generated Text Detectioncited by 0
- 2026Style, Not Self: Surface Cues Explain Zero-Shot Code Attribution by Large Language Modelscited by 0
- 2026Style, Not Self: Surface Cues Explain Zero-Shot Code Attribution by Large Language Models24 Sep 2026
- 2026Latent Trajectory Discrimination for AI-Generated Text Detection16 Jul 2026
- 2026Detecting AI Coding Agents in Open Source: A Validated Multi-Method Census of 180 Million Repositories23 Jun 2026
- 2026Hidden Human-Like Nature of Machine-Generated Texts: Theory and Detection Enhancement22 May 2026
- 2026Multi-Level Contextual Token Relation Modeling for Machine-Generated Text Detection15 May 2026
- 2026Code Fingerprints: Disentangled Attribution of LLM-Generated Code4 Mar 2026
- 2026Beyond Raw Detection Scores: Markov-Informed Calibration for Boosting Machine-Generated Text Detection8 Feb 2026
- 2026Whitespaces Don't Lie: Feature-Driven and Embedding-Based Approaches for Detecting Machine-Generated Code27 Jan 2026
- 2025Large Language Model Sourcing: A Survey11 Oct 2025
- 2025Human Texts Are Outliers: Detecting LLM-generated Texts via Out-of-distribution Detection7 Oct 2025
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarios29 Jul 2025
- 2025textttDroid: A Resource Suite for AI-Generated Code Detection11 Jul 2025
12 more
- 2025Zero-Shot Detection of LLM-Generated Code via Approximated Task Conditioning6 Jun 2025
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMs27 May 2025
- 2025Detection of LLM-Paraphrased Code and Identification of the Responsible LLM Using Coding Style Features25 Feb 2025
- 2024Self-Explained Keywords Empower Large Language Models for Code Generation21 Oct 2024
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularities2 Sep 2024
- 2024DALD: Improving Logits-based Detector without Logits from Black-box LLMs7 Jun 2024
- 2024Uncovering LLM-Generated Code: A Zero-Shot Synthetic Code Detector via Code Rewriting25 May 2024
- 2024ChatGPT Code Detection: Techniques for Uncovering the Source of Code24 May 2024
- 2024EAGLE: A Domain Generalization Framework for AI-generated Text Detection23 Mar 2024
- 2024Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmers12 Jan 2024
- 2023Unifying the Perspectives of NLP and Software Engineering: A Survey on Language Models for Code14 Nov 2023
- 2023A Survey on Detection of LLMs-Generated Content24 Oct 2023
- 2023A Survey on Detection of LLMs-Generated Contentcited by 70
- 2023Unifying the Perspectives of NLP and Software Engineering: A Survey on Language Models for Codecited by 62
- 2024Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmerscited by 27
- 2024EAGLE: A Domain Generalization Framework for AI-generated Text Detectioncited by 13
- 2024DALD: Improving Logits-based Detector without Logits from Black-box LLMscited by 12
- 2024Uncovering LLM-Generated Code: A Zero-Shot Synthetic Code Detector via Code Rewritingcited by 11
- 2025textttDroid: A Resource Suite for AI-Generated Code Detectioncited by 9
- 2025Human Texts Are Outliers: Detecting LLM-generated Texts via Out-of-distribution Detectioncited by 8
- 2024ChatGPT Code Detection: Techniques for Uncovering the Source of Codecited by 6
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMscited by 6
- 2025Large Language Model Sourcing: A Surveycited by 5
- 2025Detection of LLM-Paraphrased Code and Identification of the Responsible LLM Using Coding Style Featurescited by 4
12 most cited of 23 All 23 (JSON)
- 2026Style, Not Self: Surface Cues Explain Zero-Shot Code Attribution by Large Language Models24 Sep 2026
- 2026Latent Trajectory Discrimination for AI-Generated Text Detection16 Jul 2026
- 2026Hidden Human-Like Nature of Machine-Generated Texts: Theory and Detection Enhancement22 May 2026
- 2026Multi-Level Contextual Token Relation Modeling for Machine-Generated Text Detection15 May 2026
- 2026Code Fingerprints: Disentangled Attribution of LLM-Generated Code4 Mar 2026
- 2026Beyond Raw Detection Scores: Markov-Informed Calibration for Boosting Machine-Generated Text Detection8 Feb 2026
- 2026Whitespaces Don't Lie: Feature-Driven and Embedding-Based Approaches for Detecting Machine-Generated Code27 Jan 2026
- 2025Large Language Model Sourcing: A Survey11 Oct 2025
- 2025Human Texts Are Outliers: Detecting LLM-generated Texts via Out-of-distribution Detection7 Oct 2025
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarios29 Jul 2025
- 2025textttDroid: A Resource Suite for AI-Generated Code Detection11 Jul 2025
- 2025Zero-Shot Detection of LLM-Generated Code via Approximated Task Conditioning6 Jun 2025
12 newest of 23 All 23 (JSON)