Papers
Topics
Authors
Recent
Assistant
AI Research Assistant
Well-researched responses based on relevant abstracts and paper content.
Custom Instructions Pro
Preferences or requirements that you'd like Emergent Mind to consider when generating responses.
Gemini 2.5 Flash
Gemini 2.5 Flash 51 tok/s
Gemini 2.5 Pro 49 tok/s Pro
GPT-5 Medium 33 tok/s Pro
GPT-5 High 29 tok/s Pro
GPT-4o 90 tok/s Pro
Kimi K2 205 tok/s Pro
GPT OSS 120B 440 tok/s Pro
Claude Sonnet 4.5 34 tok/s Pro
2000 character limit reached

Zero-Shot Detection of LLM-Generated Code via Approximated Task Conditioning (2506.06069v1)

Published 6 Jun 2025 in cs.CL and cs.LG

Abstract: Detecting 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.

Summary

  • The paper reveals that task conditioning exposes distinct patterns between LLM-generated and human code compared to unconditional token distributions.
  • It proposes the Approximated Task Conditioning (ATC) method, achieving a state-of-the-art AUROC of 94.22 on the MBPP dataset across multiple programming languages.
  • The approach enhances zero-shot detection without needing original LLM prompts, enabling robust, cross-language analysis of code.

Zero-Shot Detection of LLM-Generated Code via Approximated Task Conditioning: An Academic Perspective

The paper "Zero-Shot Detection of LLM-Generated Code via Approximated Task Conditioning" explores the increasingly pertinent issue of distinguishing code generated by LLMs from human-created code. This task is of significant importance due to its implications for security, intellectual property, and academic integrity.

The researchers focus on a critical insight: while assessing the probability distribution of code tokens, there is minimal discrepancy between LLM-generated and human-written code. However, when conditioning on the task, notable differences emerge. This contrasts with natural language text where differences are apparent even in unconditional distributions. Based on this observation, the researchers propose a novel zero-shot detection approach termed Approximated Task Conditioning (ATC). This method leverages task approximation to condition the probability distribution, enhancing the detection accuracy of LLM-generated code.

The ATC methodology operates without needing access to the original generator LLM or task prompts, offering practicality for real-world applications. It employs an entropy-based scoring algorithm to assess token-level certainty under approximated task conditioning. The authors claim that ATC achieves state-of-the-art detection results across multiple benchmarks and generalizes effectively across programming languages, including Python, CPP, and Java.

In their experiments, the authors utilize datasets such as APPS and MBPP, which encompass human and machine-generated code, to benchmark against existing methods. A pivotal conclusion is that ATC substantially outperforms previous approaches, including perturbation-based methods and other zero-shot strategies. For example, in terms of AUROC, ATC demonstrates a performance of 94.22 on the MBPP dataset, showing significant improvements over earlier techniques.

The paper presents a robust comparison to existing methodologies, emphasizing that alternative approaches often grapple with generalization challenges that arise from the structured nature of code as opposed to natural language. By focusing on task conditioning, ATC sidesteps some of these limitations, utilizing a detector LLM to approximate tasks for code snippets and evaluate token entropy conditioned on these tasks.

Empirical results further highlight the robustness of the ATC approach, demonstrating minimal performance degradation when comments, which often guide task conditioning, are removed from the code. Moreover, the approach's adaptability to different programming languages reveals its versatile nature. This adaptability is crucial for deploying detection mechanisms in diverse environments where multiple programming languages are prevalent.

In contemplating the implications of this research on future developments, the methodology provides a foundation for enhancing LLM auditing tools aimed at content verification, potentially integrating with automated code review systems to maintain coding standards and intellectual property rights. Furthermore, the precision of ATC in distinguishing between human and LLM-generated code could stimulate advancements in understanding stylistic differences invoked by AI, ultimately refining LLM deployment strategies in commercial and educational sectors.

Overall, the authors critically address an emerging challenge in the field of artificial intelligence, especially given the rapid adoption of LLMs in code generation. As the landscape of AI-generated content continues to evolve, approaches like ATC provide promising directions for ensuring integrity and trustworthiness in technological tools powered by artificial intelligence.

Lightbulb Streamline Icon: https://streamlinehq.com

Continue Learning

We haven't generated follow-up questions for this paper yet.

List To Do Tasks Checklist Streamline Icon: https://streamlinehq.com

Collections

Sign up for free to add this paper to one or more collections.

Github Logo Streamline Icon: https://streamlinehq.com

Don't miss out on important new AI/ML research

See which papers are being discussed right now on X, Reddit, and more:

“Emergent Mind helps me see which AI papers have caught fire online.”

Philip

Philip

Creator, AI Explained on YouTube