Distinguishing LLM-generated from Human-written Code by Contrastive Learning
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs), such as ChatGPT released by OpenAI, have attracted significant attention from both industry and academia due to their demonstrated ability to generate high-quality content for various tasks. Despite the impressive capabilities of LLMs, there are growing concerns regarding their potential risks in various fields, such as news, education, and software engineering. Recently, several commercial and open-source LLM-generated content detectors have been proposed, which, however, are primarily designed for detecting natural language content without considering the specific characteristics of program code. This paper aims to fill this gap by proposing a novel ChatGPT-generated code detector, CodeGPTSensor, based on a contrastive learning framework and a semantic encoder built with UniXcoder. To assess the effectiveness of CodeGPTSensor on differentiating ChatGPT-generated code from human-written code, we first curate a large-scale Human and Machine comparison Corpus (HMCorp), which includes 550K pairs of human-written and ChatGPT-generated code (i.e., 288K Python code pairs and 222K Java code pairs). Based on the HMCorp dataset, our qualitative and quantitative analysis of the characteristics of ChatGPT-generated code reveals the challenge and opportunity of distinguishing ChatGPT-generated code from human-written code with their representative features. Our experimental results indicate that CodeGPTSensor can effectively identify ChatGPT-generated code, outperforming all selected baselines.
Key facts. Cited by 16 papers in the map (data through 14 Oct 2026). First posted on arXiv 7 Nov 2024.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2025: 7; 2026: 9.
16 papers.
Sort:
By area:
- 2025Token-Importance Guided Direct Preference Optimizationcited by 14
- 2025CoDet-M4: Detecting Machine-Generated Code in Multi-Lingual, Multi-Generator and Multi-Domain Settingscited by 11
- 2025textttDroid: A Resource Suite for AI-Generated Code Detectioncited by 9
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMscited by 6
- 2026Adversarial Contrastive Learning for LLM Quantization Attackscited by 5
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarioscited by 2
- 2026AICD Bench: A Challenging Benchmark for AI-Generated Code Detectioncited by 2
- 2026ClarifySTL: An Interactive LLM Agent Framework for STL Transformation through Requirements Clarificationcited by 2
- 2025On Developers' Self-Declaration of AI-Generated Code: An Analysis of Practicescited by 1
- 2026Steganography Without Modification: Hidden Communication via LLM Seedscited by 1
- 2026Hitting a Moving Target: Test-Time Adaptation for AI Text Detection under Continual Distribution Shiftcited by 1
- 2025code_transformed: The Influence of Large Language Models on Codecited by 0
4 more
- 2026Code Fingerprints: Disentangled Attribution of LLM-Generated Codecited by 0
- 2026An Initial Exploration of Contrastive Prompt Tuning to Generate Energy-Efficient Codecited by 0
- 2026HybridCodeAuthorship: A Benchmark Dataset for Line-Level Code Authorship Detectioncited by 0
- 2026What is the Difference Between Me and You? Benchmarking the Quality Gap Between Human-Written and AI-Generated Codecited by 0
- 2026What is the Difference Between Me and You? Benchmarking the Quality Gap Between Human-Written and AI-Generated Code11 Sep 2026
- 2026Hitting a Moving Target: Test-Time Adaptation for AI Text Detection under Continual Distribution Shift23 Jun 2026
- 2026HybridCodeAuthorship: A Benchmark Dataset for Line-Level Code Authorship Detection10 Jun 2026
- 2026Steganography Without Modification: Hidden Communication via LLM Seeds8 Jun 2026
- 2026ClarifySTL: An Interactive LLM Agent Framework for STL Transformation through Requirements Clarification2 May 2026
- 2026Code Fingerprints: Disentangled Attribution of LLM-Generated Code4 Mar 2026
- 2026An Initial Exploration of Contrastive Prompt Tuning to Generate Energy-Efficient Code3 Mar 2026
- 2026AICD Bench: A Challenging Benchmark for AI-Generated Code Detection2 Feb 2026
- 2026Adversarial Contrastive Learning for LLM Quantization Attacks6 Jan 2026
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarios29 Jul 2025
- 2025textttDroid: A Resource Suite for AI-Generated Code Detection11 Jul 2025
- 2025code_transformed: The Influence of Large Language Models on Code13 Jun 2025
4 more
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMs27 May 2025
- 2025Token-Importance Guided Direct Preference Optimization26 May 2025
- 2025On Developers' Self-Declaration of AI-Generated Code: An Analysis of Practices23 Apr 2025
- 2025CoDet-M4: Detecting Machine-Generated Code in Multi-Lingual, Multi-Generator and Multi-Domain Settings17 Mar 2025
- 2025Token-Importance Guided Direct Preference Optimizationcited by 14
- 2025Token-Importance Guided Direct Preference Optimization26 May 2025
- 2025CoDet-M4: Detecting Machine-Generated Code in Multi-Lingual, Multi-Generator and Multi-Domain Settingscited by 11
- 2025textttDroid: A Resource Suite for AI-Generated Code Detectioncited by 9
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMscited by 6
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarioscited by 2
- 2026AICD Bench: A Challenging Benchmark for AI-Generated Code Detectioncited by 2
- 2025On Developers' Self-Declaration of AI-Generated Code: An Analysis of Practicescited by 1
- 2026Steganography Without Modification: Hidden Communication via LLM Seedscited by 1
- 2026Hitting a Moving Target: Test-Time Adaptation for AI Text Detection under Continual Distribution Shiftcited by 1
- 2025code_transformed: The Influence of Large Language Models on Codecited by 0
- 2026Code Fingerprints: Disentangled Attribution of LLM-Generated Codecited by 0
- 2026An Initial Exploration of Contrastive Prompt Tuning to Generate Energy-Efficient Codecited by 0
- 2026HybridCodeAuthorship: A Benchmark Dataset for Line-Level Code Authorship Detectioncited by 0
12 most cited of 13 All 13 (JSON)
- 2026What is the Difference Between Me and You? Benchmarking the Quality Gap Between Human-Written and AI-Generated Code11 Sep 2026
- 2026Hitting a Moving Target: Test-Time Adaptation for AI Text Detection under Continual Distribution Shift23 Jun 2026
- 2026HybridCodeAuthorship: A Benchmark Dataset for Line-Level Code Authorship Detection10 Jun 2026
- 2026Steganography Without Modification: Hidden Communication via LLM Seeds8 Jun 2026
- 2026Code Fingerprints: Disentangled Attribution of LLM-Generated Code4 Mar 2026
- 2026An Initial Exploration of Contrastive Prompt Tuning to Generate Energy-Efficient Code3 Mar 2026
- 2026AICD Bench: A Challenging Benchmark for AI-Generated Code Detection2 Feb 2026
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarios29 Jul 2025
- 2025textttDroid: A Resource Suite for AI-Generated Code Detection11 Jul 2025
- 2025code_transformed: The Influence of Large Language Models on Code13 Jun 2025
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMs27 May 2025
- 2025On Developers' Self-Declaration of AI-Generated Code: An Analysis of Practices23 Apr 2025
12 newest of 13 All 13 (JSON)