Optimizing Token Choice for Code Watermarking: An RL Approach

Zhimeng Guo, Huaisheng Zhu, Siyuan Xu, Hangfan Zhang, Teng Xiao +1 more
8/16/2025
cs.CRcs.CLcs.LG

No confident code implementation found for this paper.

Abstract

Protecting intellectual property on LLM-generated code necessitates effective watermarking systems that can operate within code's highly structured, syntactically constrained nature. In this work, we introduce CodeTracer, an innovative adaptive code watermarking framework underpinned by a novel reinforcement learning training paradigm. At its core, CodeTracer features a policy-driven approach that utilizes a parameterized model to intelligently bias token choices during next-token prediction. This strategy ensures that embedded watermarks maintain code functionality while exhibiting subtle yet statistically detectable deviations from typical token distributions. To facilitate policy learning, we devise a comprehensive reward system that seamlessly integrates execution feedback with watermark embedding signals, balancing process-level and outcome-level rewards. Additionally, we employ Gumbel Top-k reparameterization to enable gradient-based optimization of discrete watermarking decisions. Extensive comparative evaluations demonstrate CodeTracer's significant superiority over state-of-the-art baselines in both watermark detectability and the preservation of generated code's functionality.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Cite this paper

@article{guo2025optimizing,
  title  = {Optimizing Token Choice for Code Watermarking: An RL Approach},
  author = {Zhimeng Guo and Huaisheng Zhu and Siyuan Xu and Hangfan Zhang and Teng Xiao and Minhao Cheng},
  year   = {2025},
  eprint = {2508.11925},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2508.11925v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2508.11925.svg)](https://codeofpaper.com/paper/2508.11925)

Discussion