Abstract
As Large Language Models (LLMs) are increasingly used to automate code generation, it is often desired to know if the code is AI-generated and by which model, especially for purposes like protecting intellectual property (IP) in industry and preventing academic misconduct in education. Incorporating watermarks into machine-generated content is one way to provide code provenance, but existing solutions are restricted to a single bit or lack flexibility. We present CodeIP, a new watermarking technique for LLM-based code generation. CodeIP enables the insertion of multi-bit information while preserving the semantics of the generated code, improving the strength and diversity of the inerseted watermark. This is achieved by training a type predictor to predict the subsequent grammar type of the next token to enhance the syntactical and semantic correctness of the generated code. Experiments on a real-world dataset across five programming languages showcase the effectiveness of CodeIP.
Abstract (translated)
随着大型语言模型(LLMs)越来越多地用于自动编程,了解生成的代码是否由人工智能生成以及由哪个模型生成,尤其是在保护工业知识产权(IP)和防止教育领域的学术不端行为方面,往往具有很高的需求。将水印嵌入到由LLM生成的内容中是提供代码可信的一种方式,但现有的解决方案局限于单个比特或缺乏灵活性。我们介绍了一种新的基于LLM的代码水印技术——CodeIP。CodeIP允许在保留生成的代码语义的同时插入多比特信息,从而提高互水印的强度和多样性。这是通过训练一个类型预测器来预测下一个标点符号的语法类型来实现的,从而增强生成代码的语义和语法正确性。在五个编程语言的实际世界数据集上进行实验,展示了CodeIP的有效性。
URL
https://arxiv.org/abs/2404.15639