AIDAR: AI-Generated Code Detection via AST Structures
Abstract
Large language models can generate convincing solutions to programming problems, making surface cues such as comments, naming, and style increasingly unreliable for identifying AI-generated code. Yet most existing approaches remain text-based and overlook the rich structural information in programs. We first introduce AST-TED, a non-neural baseline that compares complete abstract syntax trees (ASTs) using normalized tree edit distance. We then develop AIDAR by improving this framework in two ways: Discriminative Subtree Selection identifies informative local AST regions, while Prototype Distribution Matching replaces direct edit-distance comparison by matching distributions over shared structural prototypes for complete ASTs and selected subtrees. On CodeNet100 and a historical contest benchmark (C1), AIDAR achieves 95.05% and 99.00% accuracy, respectively, the highest among the evaluated methods. In a subsequent live contest (C2), we deployed AIDAR as part of a screening workflow that referred 17 of 1,176 full-score submissions for human review. The workflow's eight highest-ranked referrals matched the eight cases human experts flagged as suspected AI-generated code. These results demonstrate the value of AST structure for detection and for prioritizing human investigation. Code is available at https://anonymous.4open.science/r/AIDAR-3BCA for anonymous review.
est. 32% chance this paper gets accepted at ICLR 2027.
What do you think this paper will get?
All positions stay anonymous.