用视觉模型分析代码概率图,精准识别AI生成代码。
CodeVision: Detecting LLM-Generated Code Using 2D Token Probability Maps and Vision Models
- 将代码转为二维概率图,保留缩进等结构信息。
- 在多语言上准确率优于传统方法,计算效率高。
- 适合学术审查与代码审计场景使用。
大型语言模型(如ChatGPT)显著提升了自动化代码生成能力,但带来了学术诚信挑战,即难以区分人类编写的代码与模型生成的代码。现有检测方法如预训练模型和水印技术在适应性和计算效率方面存在局限。本文提出一种新方法:利用二维令牌概率图结合视觉模型(如Vision Transformer和ResNet),保留代码的缩进、括号等空间结构。通过将代码转换为对数概率矩阵,并应用视觉模型捕捉内容与结构特征,实现更精准的检测。该方法在多种编程语言上表现稳健,优于传统检测器,提供了一种可扩展且高效的识别方案。
原文摘要 · Abstract (English)
The rise of large language models (LLMs) like ChatGPT has significantly improved automated code generation, enhancing software development efficiency. However, this introduces challenges in academia, particularly in distinguishing between human-written and LLM-generated code, which complicates issues of academic integrity. Existing detection methods, such as pre-trained models and watermarking, face limitations in adaptability and computational efficiency. In this paper, we propose a novel detection method using 2D token probability maps combined with vision models, preserving spatial code structures such as indentation and brackets. By transforming code into log probability matrices and applying vision models like Vision Transformers (ViT) and ResNet, we capture both content and structure for more accurate detection. Our method shows robustness across multiple programming languages and improves upon traditional detectors, offering a scalable and computationally efficient solution for identifying LLM-generated code.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。