Score: 1

Optimizing Token Choice for Code Watermarking: A RL Approach

Published: August 16, 2025 | arXiv ID: 2508.11925v1

By: Zhimeng Guo , Huaisheng Zhu , Siyuan Xu and more

Potential Business Impact:

Finds fake computer code made by AI.

The need for detecting LLM-generated code necessitates watermarking systems capable of operating within its highly structured and syntactically constrained environment. To address this, 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.

Country of Origin
πŸ‡ΊπŸ‡Έ United States

Page Count
18 pages

Category
Computer Science:
Cryptography and Security