Zero-Shot Detection of LLM-Generated Code via Approximated Task Conditioning
Not on the map. Why?
Abstract (arXiv)
Detecting Large Language Model (LLM)-generated code is a growing challenge with implications for security, intellectual property, and academic integrity. We investigate the role of conditional probability distributions in improving zero-shot LLM-generated code detection, when considering both the code and the corresponding task prompt that generated it. Our key insight is that when evaluating the probability distribution of code tokens using an LLM, there is little difference between LLM-generated and human-written code. However, conditioning on the task reveals notable differences. This contrasts with natural language text, where differences exist even in the unconditional distributions. Leveraging this, we propose a novel zero-shot detection approach that approximates the original task used to generate a given code snippet and then evaluates token-level entropy under the approximated task conditioning (ATC). We further provide a mathematical intuition, contextualizing our method relative to previous approaches. ATC requires neither access to the generator LLM nor the original task prompts, making it practical for real-world applications. To the best of our knowledge, it achieves state-of-the-art results across benchmarks and generalizes across programming languages, including Python, CPP, and Java. Our findings highlight the importance of task-level conditioning for LLM-generated code detection. The supplementary materials and code are available at https://github.com/maorash/ATC, including the dataset gathering implementation, to foster further research in this area.
Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Builds on 27 of its 35 references that are in the map. First posted on arXiv 6 Jun 2025.
Builds on
27 of 35 references.
References · 27
- 2017Attention Is All You Needcited by 60,361
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2021On the Opportunities and Risks of Foundation Modelscited by 4,033
- 2021Program Synthesis with Large Language Modelscited by 3,637
- 2019The Curious Case of Neural Text Degenerationcited by 2,916
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2022Competition-Level Code Generation with AlphaCodecited by 1,462
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
- 2021Measuring Coding Challenge Competence With APPScited by 902
- 2023DetectGPT: Zero-Shot Machine-Generated Text Detection using Probability Curvaturecited by 726
- 2019Defending Against Neural Fake Newscited by 559
- 2019GLTR: Statistical Detection and Visualization of Generated Textcited by 496
15 more
- 2023Fast-DetectGPT: Efficient Zero-Shot Detection of Machine-Generated Text via Conditional Probability Curvaturecited by 287
- 2023DetectLLM: Leveraging Log Rank Information for Zero-Shot Detection of Machine-Generated Textcited by 210
- 2020Automatic Detection of Machine Generated Text: A Critical Surveycited by 166
- 2024CodeGemma: Open Code Models Based on Gemmacited by 150
- 2023Who Wrote this Code? Watermarking for Code Generationcited by 141
- 2023DNA-GPT: Divergent N-Gram Analysis for Training-Free Detection of GPT-Generated Textcited by 129
- 2019Real or Fake? Learning to Discriminate Machine from Human Generated Textcited by 99
- 2023ChatGPT or Human? Detect and Explain. Explaining Decisions of Machine Learning Model for Detecting Short ChatGPT-generated Textcited by 85
- 2020Neural Deepfake Detection with Factual Structure of Textcited by 41
- 2022Deepfake Text Detection: Limitations and Opportunitiescited by 37
- 2024Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmerscited by 27
- 2023Zero-Shot Detection of Machine-Generated Codescited by 24
- 2024Uncovering LLM-Generated Code: A Zero-Shot Synthetic Code Detector via Code Rewritingcited by 11
- 2024The GPT-WritingPrompts Dataset: A Comparative Analysis of Character Portrayal in Short Storiescited by 8
- 2024AIGCodeSet: A New Annotated Dataset for AI Generated Code Detectioncited by 5
Built on by
Citing papers per year: 2026: 1.
1 paper.