Evaluating AIGC Detectors on Code Content

Jian Wang, Shangqing Liu, Xiaofei Xie, Yi LiarXiv 2023 · DOI

Abstract

The proliferation of AI-generated content (AIGC) in software development has raised concerns regarding academic integrity and the quality of technical platforms. While numerous detectors exist for natural language prose, their efficacy in the software domain remains under-explored. This paper summarizes a large-scale empirical study of nearly 500,000 samples, evaluating six prominent AIGC detectors across various code-related tasks. The findings reveal a significant performance gap: while detectors show some utility for natural language, they are currently ineffective at identifying AI-generated code, often performing no better than random chance.

Introduction

The integration of Large Language Models (LLMs) like ChatGPT into software engineering workflows has created a "trust gap." While these tools offer productivity gains in documentation and code generation, their misuse can undermine educational standards and flood community forums like Stack Overflow with plausible but incorrect AI-generated answers. Most existing AIGC detection tools were developed for natural language (prose), which possesses stylistic nuances often absent in the structured, logic-driven world of programming. This research provides the first comprehensive empirical data on how these detectors perform specifically in the software domain.

Methodology

The researchers conducted a multi-stage empirical study to assess the current state of AIGC detection for code. They selected six prominent detectors for evaluation, representing both open-source and commercial solutions.

Overview of the AIGC detectors evaluated in the study, including supported models and technical constraints.

The study's methodology included:

  1. Benchmark Construction: Developing datasets for three common scenarios: Q&A, code-to-text (summarization), and text-to-code (generation).
  2. Detector Evaluation: Testing the selected tools against these benchmarks to establish baseline performance.
  3. Fine-Tuning Experiments: Investigating whether domain-specific training (using RoBERTa-QA as a base) could bridge the performance gap.
  4. Robustness Testing: Applying code mutations, such as renaming variables, to evaluate the detectors' resilience against simple adversarial changes.
  5. Human Study: Surveying 50 experienced developers to compare human intuition against automated detection.

Datasets

The study utilized two primary datasets totaling 492,500 samples:

  • Code-Related Content Dataset (CCD): 467.5K samples across three scenarios: human vs. AI answers from Stack Overflow, docstring comparisons via CodeSearchNet, and code solutions from APPS and CONCODE benchmarks.
  • Natural Language-Related Content Dataset (NLCD): 25K samples of Wikipedia text "polished" by ChatGPT, serving as a natural language baseline.

Key Results and Insights

The evaluation demonstrated that code detection is fundamentally more challenging than prose detection.

Performance metrics (AUC, FPR, FNR) of various detectors across natural language (NLCD) and code-related (CCD) datasets.

The "Code is Harder" Reality

Detectors performed significantly worse on code than on prose. The average Area Under the Curve (AUC) dropped from 0.58 for natural language (NLCD) to 0.46 for code-related content (CCD). This suggests that the logical constraints of code leave less room for the "statistical signatures"—such as specific word choice patterns or perplexity variances—that AI detectors typically exploit.

Language Sensitivity and Generalization

Performance varied wildly depending on the programming language and specific task. For example, while some tools performed well on Java, they struggled with Go or PHP. Furthermore, while fine-tuning models on code data was highly effective for specific tasks (boosting AUC to 0.90–1.00), these specialized models failed to generalize to different types of code-related content, indicating a lack of a "universal" detection signature.

The Human Guessing Game

The study found that humans are remarkably poor at identifying AI-generated code. Developers achieved an accuracy of only 47.1% on code snippets—statistically worse than a coin flip. While humans reached approximately 78% accuracy on natural language Q&A, the structured nature of code appears to neutralize human intuition regarding authorship.

Conclusion

Current AIGC detectors are largely ineffective for identifying AI-generated code out of the box. The logical and syntactic requirements of programming languages mask the typical markers used by general-purpose NLP tools. The research highlights a critical need for domain-specific detectors tailored to the unique constraints of software engineering. As LLMs continue to evolve, developing robust, multi-language detection tools remains an urgent challenge for maintaining the integrity of the software development ecosystem.

Summary updated

BibTeX
@misc{wang2023evaluating,
  author = {Jian Wang and Shangqing Liu and Xiaofei Xie and Yi Li},
  title = {{Evaluating AIGC Detectors on Code Content}},
  year = {2023},
  eprint = {2304.05193},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.05193},
}
Figure