mlsanityData to 26 Nov 2026

From Tokens to Files: Multi-Granularity Detection and Localization of AI-Involved Code

arXiv 2610.27863 ↗Submitted 20 Oct 2026cs.SE cs.CL cs.LGcited by 0

Not on the map. Why?

Abstract (arXiv)

The increasing use of large language models for code generation calls for methods that distinguish purely human-written code from AI-involved code: files in which any part, however small, was generated or substantially modified by a model. Beyond flagging such files, we aim to localize the lines or blocks attributable to AI. Existing approaches compress a file into a single score, from surface stylistic features or a global code representation, which averages away the evidence when only a few blocks are AI-involved. We propose a framework that models AI authorship at the token level and predicts at the line, block, and file levels. A frozen code language model is equipped with two low-rank adapters, trained separately on machine-written and human-written files; their per-token log-likelihood ratio provides local evidence of AI authorship. Lightweight heads aggregate this evidence within lines and blocks, using the surrounding code context, and their local predictions are aggregated into a file-level decision. We train on mixed-authorship files built from human originals and their AI-generated or AI-modified counterparts, including continuation and fill-in-the-middle scenarios. On an internal test set of 11,773 AI-involved files across six generation regimes against 2,541 human files, our method reaches 72.4 macro F1 at a 1% FPR operating point. With no adaptation, it reaches 62.5 line-level F1 on HybridCodeAuthorship, an external human-AI co-writing benchmark with no training split, above the 56 its own paper reports as the best line-level result. On 19,445 human-written files from repositories created before 2022, the false-positive rate stays between 0.55% and 0.81% under the transported 1% threshold, so the operating point holds on real human code.

Key facts. No citing papers in the map yet (data through 26 Nov 2026). Builds on 26 of its 32 references that are in the map. Submitted 20 Oct 2026.

Builds on

26 of 32 references.

References · 26

  1. 2014Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translationcited by 4,222
  2. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,337
  3. 2024Qwen2.5-Coder Technical Reportcited by 1,301
  4. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,241
  5. 2023DetectGPT: Zero-Shot Machine-Generated Text Detection using Probability Curvaturecited by 759
  6. 2022Contrastive Decoding: Open-ended Text Generation as Optimizationcited by 640
  7. 2019GLTR: Statistical Detection and Visualization of Generated Textcited by 519
  8. 2021DExperts: Decoding-Time Controlled Text Generation with Experts and Anti-Expertscited by 458
  9. 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 371
  10. 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 343
  11. 2023Fast-DetectGPT: Efficient Zero-Shot Detection of Machine-Generated Text via Conditional Probability Curvaturecited by 317
  12. 2024Spotting LLMs With Binoculars: Zero-Shot Detection of Machine-Generated Textcited by 291
14 more
  1. 2022Efficient Training of Language Models to Fill in the Middlecited by 268
  2. 2023DetectLLM: Leveraging Log Rank Information for Zero-Shot Detection of Machine-Generated Textcited by 228
  3. 2024Tuning Language Models by Proxycited by 100
  4. 2023SeqXGPT: Sentence-Level AI-Generated Text Detectioncited by 60
  5. 2024M4GT-Bench: Evaluation Benchmark for Black-Box Machine-Generated Text Detectioncited by 47
  6. 2020RoFT: A Tool for Evaluating Human Detection of Machine-Generated Textcited by 37
  7. 2024Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmerscited by 31
  8. 2024Imitate Before Detect: Aligning Machine Stylistic Preference for Machine-Revised Text Detectioncited by 27
  9. 2024Distinguishing LLM-generated from Human-written Code by Contrastive Learningcited by 18
  10. 2024Whodunit: Classifying Code as Human Authored or GPT-4 Generated -- A case study on CodeChef problemscited by 14
  11. 2025textttDroid: A Resource Suite for AI-Generated Code Detectioncited by 10
  12. 2026AICD Bench: A Challenging Benchmark for AI-Generated Code Detectioncited by 4
  13. 2026Whitespaces Don't Lie: Feature-Driven and Embedding-Based Approaches for Detecting Machine-Generated Codecited by 1
  14. 2026HybridCodeAuthorship: A Benchmark Dataset for Line-Level Code Authorship Detectioncited by 1

Built on by

Not cited yet.