CodeIP: A Grammar-Guided Multi-Bit Watermark for Large Language Models of Code

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Guan, Batu, Wan, Yao, Bi, Zhangqian, Wang, Zheng, Zhang, Hongyu, Zhou, Pan, Sun, Lichao
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866929650206244864
author Guan, Batu
Wan, Yao
Bi, Zhangqian
Wang, Zheng
Zhang, Hongyu
Zhou, Pan
Sun, Lichao
author_facet Guan, Batu
Wan, Yao
Bi, Zhangqian
Wang, Zheng
Zhang, Hongyu
Zhou, Pan
Sun, Lichao
contents Large Language Models (LLMs) have achieved remarkable progress in code generation. It now becomes crucial to identify whether the code is AI-generated and to determine the specific model used, particularly for purposes such as protecting Intellectual Property (IP) in industry and preventing cheating in programming exercises. To this end, several attempts have been made to insert watermarks into machine-generated code. However, existing approaches are limited to inserting only a single bit of information. In this paper, we introduce CodeIP, a novel multi-bit watermarking technique that inserts additional information to preserve crucial provenance details, such as the vendor ID of an LLM, thereby safeguarding the IPs of LLMs in code generation. Furthermore, to ensure the syntactical correctness of the generated code, we propose constraining the sampling process for predicting the next token by training a type predictor. Experiments conducted on a real-world dataset across five programming languages demonstrate the effectiveness of CodeIP in watermarking LLMs for code generation while maintaining the syntactical correctness of code.
format Preprint
id arxiv_https___arxiv_org_abs_2404_15639
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle CodeIP: A Grammar-Guided Multi-Bit Watermark for Large Language Models of Code
Guan, Batu
Wan, Yao
Bi, Zhangqian
Wang, Zheng
Zhang, Hongyu
Zhou, Pan
Sun, Lichao
Computation and Language
Large Language Models (LLMs) have achieved remarkable progress in code generation. It now becomes crucial to identify whether the code is AI-generated and to determine the specific model used, particularly for purposes such as protecting Intellectual Property (IP) in industry and preventing cheating in programming exercises. To this end, several attempts have been made to insert watermarks into machine-generated code. However, existing approaches are limited to inserting only a single bit of information. In this paper, we introduce CodeIP, a novel multi-bit watermarking technique that inserts additional information to preserve crucial provenance details, such as the vendor ID of an LLM, thereby safeguarding the IPs of LLMs in code generation. Furthermore, to ensure the syntactical correctness of the generated code, we propose constraining the sampling process for predicting the next token by training a type predictor. Experiments conducted on a real-world dataset across five programming languages demonstrate the effectiveness of CodeIP in watermarking LLMs for code generation while maintaining the syntactical correctness of code.
title CodeIP: A Grammar-Guided Multi-Bit Watermark for Large Language Models of Code
topic Computation and Language
url https://arxiv.org/abs/2404.15639