Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Efficient and Universal Watermarking for LLM-Generated Code Detection

About

Large language models (LLMs) have significantly enhanced the usability of AI-generated code, providing effective assistance to programmers. This advancement also raises ethical and legal concerns, such as academic dishonesty and the generation of malicious code. For accountability, it is imperative to detect whether a piece of code is AI-generated. Watermarking is broadly considered a promising solution and has been successfully applied to identify LLM-generated text. However, existing efforts on code are far from ideal, suffering from limited universality and excessive time and memory consumption. In this work, we propose a plug-and-play watermarking approach for AI-generated code detection, named ACW (AI Code Watermarking). ACW is training-free and works by selectively applying a set of carefully-designed, semantic-preserving and idempotent code transformations to LLM code outputs. The presence or absence of the transformations serves as implicit watermarks, enabling the detection of AI-generated code. Our experimental results show that ACW effectively and efficiently detects AI-generated code, preserves code utility, and is resilient against potential code disruptions. Especially, ACW is universal across different LLMs, addressing the limitations of existing approaches.

Boquan Li, Zirui Fu, Mengdi Zhang, Peixin Zhang, Jun Sun, Xingmei Wang• 2024

Related benchmarks

TaskDatasetResultRank
Code GenerationHumanEval
Pass@130.82
1048
Code GenerationHumanEval+
Pass@127.24
393
Code GenerationMBPP+
Pass@131.93
238
Source Code Watermark Extraction RobustnessCodeNet D32 (evaluation)
Accuracy100
36
Source Code Watermark Extraction RobustnessCodeNet D40 (evaluation)
Accuracy100
36
Source Code Watermark Extraction RobustnessCodeNet D56 (evaluation)
Accuracy100
36
Source Code Watermark Extraction RobustnessCodeNet D88 (evaluation)
Accuracy100
36
Source Code Watermark Extraction RobustnessCodeNet D152 (evaluation)
Accuracy98.4
36
Watermark DetectionMBPP--
14
Watermark DetectionHumanEval--
9
Showing 10 of 35 rows

Other info

Follow for update