Lune

EMNLP Findings2024

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

Batu Guan, Yao Wan, Zhangqian Bi, Zheng Wang, Hongyu Zhang, Pan Zhou, Lichao Sun

Abstract

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 machinegenerated 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.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

8 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Adaptive Code Watermarking Through Reinforcement Learning cites Who Wrote this Code? Watermarking for Code Generation
  • Adaptive Code Watermarking Through Reinforcement Learning cites A Watermark for Large Language Models
  • SAEMark: Steering Personalized Multilingual LLM Watermarks with Sparse Autoencoders cites Towards Codable Watermarking for Injecting Multi-Bits Information to LLMs
  • SAEMark: Steering Personalized Multilingual LLM Watermarks with Sparse Autoencoders cites Who Wrote this Code? Watermarking for Code Generation
  • SAEMark: Steering Personalized Multilingual LLM Watermarks with Sparse Autoencoders cites A Watermark for Large Language Models
  • Towards Codable Watermarking for Injecting Multi-Bits Information to LLMs cites Who Wrote this Code? Watermarking for Code Generation
  • Towards Codable Watermarking for Injecting Multi-Bits Information to LLMs cites A Watermark for Large Language Models
  • Who Wrote this Code? Watermarking for Code Generation cites CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis
  • From Trade-off to Synergy: A Versatile Symbiotic Watermarking Framework for Large Language Models cites Towards Codable Watermarking for Injecting Multi-Bits Information to LLMs
  • From Trade-off to Synergy: A Versatile Symbiotic Watermarking Framework for Large Language Models cites Who Wrote this Code? Watermarking for Code Generation
  • From Trade-off to Synergy: A Versatile Symbiotic Watermarking Framework for Large Language Models cites A Watermark for Large Language Models
  • Securing the Language of Life: Inheritable Watermarks from DNA Language Models to Proteins cites Towards Codable Watermarking for Injecting Multi-Bits Information to LLMs
  • Securing the Language of Life: Inheritable Watermarks from DNA Language Models to Proteins cites A Watermark for Large Language Models
  • WaterMod: Modular Token-Rank Partitioning for Probability-Balanced LLM Watermarking cites Who Wrote this Code? Watermarking for Code Generation
  • WaterMod: Modular Token-Rank Partitioning for Probability-Balanced LLM Watermarking cites CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Models
  • WaterMod: Modular Token-Rank Partitioning for Probability-Balanced LLM Watermarking cites A Watermark for Large Language Models
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers8

  1. Adaptive Code Watermarking Through Reinforcement LearningZhimeng Guo, Huaisheng Zhu, Siyuan Xu, Hangfan Zhang et al.ICML 2026 · 73 citations
  2. SAEMark: Steering Personalized Multilingual LLM Watermarks with Sparse AutoencodersZhuohao Yu, Xingru Jiang, Weizheng Gu, Yidong Wang et al.NeurIPS 2025 · 6 citations
  3. Securing the Language of Life: Inheritable Watermarks from DNA Language Models to ProteinsZaixi Zhang, Ruofan Jin, Le Cong, Mengdi WangNeurIPS 2025 · 6 citations
  4. WaterMod: Modular Token-Rank Partitioning for Probability-Balanced LLM WatermarkingShinwoo Park, Hyejin Park, Hyeseon Ahn, Yo-Sub HanAAAI 2026 · 6 citations
  5. From Trade-off to Synergy: A Versatile Symbiotic Watermarking Framework for Large Language ModelsYidan Wang, Yubing Ren, Yanan Cao, Binxing FangACL 2025 · 4 citations

Builds on10

  1. A Watermark for Large Language ModelsJohn Kirchenbauer, Jonas Geiping, Yuxin Wen, Jonathan Katz et al.ICML 2023 · 854 citations
  2. CodeGen: An Open Large Language Model for Code with Multi-Turn Program SynthesisErik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu et al.ICLR 2023 · 234 citations
  3. Towards Codable Watermarking for Injecting Multi-Bits Information to LLMsLean Wang, Wenkai Yang, Deli Chen, Hao Zhou et al.ICLR 2024 · 55 citations
  4. Who Wrote this Code? Watermarking for Code GenerationTaehyun Lee, Seokhee Hong, Jaewoo Ahn, Ilgee Hong et al.ACL 2024 · 36 citations
  5. CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion ModelsZhensu Sun, Xiaoning Du, Fu Song, Li LiFSE 2023 · 34 citations

Related papers

  1. Protecting Intellectual Property of Large Language Model-Based Code Generation APIs via WatermarksZongjie Li, Chaozheng Wang, Shuai Wang, Cuiyun GaoCCS 2023 · 25 citations
  2. WASA: WAtermark-based Source Attribution for Large Language Model-Generated DataXinyang Lu, Jingtan Wang, Zitong Zhao, Zhongxiang Dai et al.ACL Findings 2025
  3. StealthInk: A Multi-bit and Stealthy Watermark for Large Language ModelsYa Jiang, Chuxiong Wu, Massieh Kordi Boroujeny, Brian L. Mark et al.ICML 2025
  4. CodeGenGuard: A Watermark for Code Generation ModelsBorui Yang, Mingxuan Ma, Liyao Xiang, Nan Chen et al.ICLR 2026
  5. IPMark: A Sentence-Level Watermark for LLMs with Hierarchical Personalization and Efficient DetectionWenbo An, Lianwei Wu, Zehao WangICML 2026
Dusk over the sea between two cliffs drawn in fine vertical lines