atlas

Research map / Large language models / Language, safety and interpretability

Uncovering LLM-Generated Code: A Zero-Shot Synthetic Code Detector via Code Rewriting

AAAI 2025 · Large language models › Language, safety and interpretability · approach: Zero-shot machine-text detection · 11 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes a zero-shot, black-box synthetic code detector that scores code by the average similarity between it and LLM-rewritten variants, using a GraphCodeBERT similarity model trained with unsupervised SimCSE.

Problem

Detecting LLM-generated (synthetic) code, where existing zero-shot text detectors based on token log probabilities perform poorly because code contains many low-entropy tokens.

Approach

LLM rewrites of synthetic code stay closer to the original than rewrites of human-written code, so the embedding similarity between a snippet and its LLM rewrites serves as a black-box detection score; the similarity model is trained with self-supervised SimCSE on unlabeled code.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Use code rewriting with similarity measurement rather than in-fill perturbation with similarity (ablation)Zero-shot synthetic code detection · APPSAUROC: 74.55 -> 87.77; 71.55 -> 76.96; 74.23 -> 80.23; 53.43 -> 74.51Helped
Use similarity measurement rather than token-wise LogProb scoring (ablation)Code rewriting detector · APPSAUROC: 57.29 -> 87.77; 46.70 -> 76.96; 50.58 -> 80.23; 55.13 -> 74.51Helped
Use similarity measurement rather than token-wise LogRank scoring (ablation)Code rewriting detector · APPSAUROC: 75.28 -> 87.77; 64.76 -> 76.96; 75.85 -> 80.23; 67.69 -> 74.51Helped
Use similarity measurement rather than token-wise Rank scoring (ablation)Code rewriting detector · APPSAUROC: 62.34 -> 87.77; 55.42 -> 76.96; 60.59 -> 80.23; 59.34 -> 74.51Helped
Use similarity measurement rather than token-wise Entropy scoring (ablation)Code rewriting detector · APPSAUROC: 60.39 -> 87.77; 59.42 -> 76.96; 68.20 -> 80.23; 59.35 -> 74.51Helped
Use code rewriting rather than in-fill perturbation (ablation)Similarity-based synthetic code detector · APPS (GPT-4-generated)AUROC: 53.43 -> 74.51Helped
Use UniXcoder SimCSE instead of GraphCodeBERT SimCSE (ablation)Similarity model · APPS (GPT-3.5-generated)AUROC: 83.25 -> 86.37Helped
Increase rewrite count from m=2 to m=4 to m=8 (ablation)Proposed detector with CodeLlama detector LLM · APPS (Avg.)AUROC: 73.75 -> 78.49 -> 80.16Helped
Increase rewrite count from m=2 to m=4 to m=8 (ablation)Proposed detector with CodeLlama detector LLM · MBPP (Avg.)AUROC: 74.54 -> 77.99 -> 81.81Helped

Surprising findings

Limitations

Experimental setup

Datasets: CodeSearchNet APPS MBPP Code Contest

Benchmarks: APPS synthetic code detection MBPP synthetic code detection Code Contest C++

Metrics: AUROC

Baselines: GPTZero OpenAI-Detector log P(x) LogRank Rank Entropy DetectGPT LRR NPR

Builds on: SimCSE DetectGPT GraphCodeBERT chain-of-thought prompting

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy