mlsanityData to 14 Oct 2026

Optimizing Token Choice for Code Watermarking: An RL Approach

arXiv 2508.11925 ↗First posted 16 Aug 2025cs.CR cs.CL cs.LGcited by 1

On the map: LLM safety and security → Watermarking generated content and models

Abstract (arXiv)

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. Our code is available at https://github.com/TimeLovercc/CodeTracer.

Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Placed in Watermarking generated content and models, one of 12 directions in LLM safety and security. Builds on 33 of its 43 references that are in the map. First posted on arXiv 16 Aug 2025.

Builds on

33 of 43 references.

Closest ancestors · 14

Same direction, newest first

  1. 2024SoK: Watermarking for AI-Generated Content27 Nov
  2. 2024CodeIP: A Grammar-Guided Multi-Bit Watermark for Large Language Models of Code24 Apr
  3. 2024Learning to Watermark LLM-generated Text via Reinforcement Learning13 Mar
  4. 2024Efficient and Universal Watermarking for LLM-Generated Code Detection12 Feb
  5. 2024Adaptive Text Watermark for Large Language Models25 Jan
  6. 2023A Survey of Text Watermarking in the Era of Large Language Models13 Dec
  7. 2023Robust Distortion-free Watermarks for Language Models28 Jul
  8. 2023Provable Robust Watermarking for AI-Generated Text30 Jun
  9. 2023On the Reliability of Watermarks for Large Language Models7 Jun
  10. 2023Undetectable Watermarks for Language Models25 May
  11. 2023Who Wrote this Code? Watermarking for Code Generation24 May
  12. 2023Are You Copying My Model? Protecting the Copyright of Large Language Models for EaaS via Backdoor Watermark17 May
2 more
  1. 2023Paraphrasing evades detectors of AI-generated text, but retrieval is an effective defense23 Mar
  2. 2023A Watermark for Large Language Models24 Jan

Other references · 19

  1. 2023GPT-4 Technical Reportcited by 18,396
  2. 2024DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Modelscited by 9,379
  3. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  4. 2025DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learningcited by 6,330
  5. 2021Program Synthesis with Large Language Modelscited by 3,637
  6. 2013Estimating or Propagating Gradients Through Stochastic Neurons for Conditional Computationcited by 2,079
  7. 2022Competition-Level Code Generation with AlphaCodecited by 1,462
  8. 2024Qwen2.5-Coder Technical Reportcited by 1,203
  9. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
  10. 2024Tulu 3: Pushing Frontiers in Open Language Model Post-Trainingcited by 1,053
  11. 2023DetectGPT: Zero-Shot Machine-Generated Text Detection using Probability Curvaturecited by 726
  12. 2025SimpleRL-Zoo: Investigating and Taming Zero Reinforcement Learning for Open Base Models in the Wildcited by 511
7 more
  1. 2019GLTR: Statistical Detection and Visualization of Generated Textcited by 496
  2. 2023OctoPack: Instruction Tuning Code Large Language Modelscited by 189
  3. 2024OpenCoder: The Open Cookbook for Top-Tier Code Large Language Modelscited by 130
  4. 2019Reparameterizable Subset Sampling via Continuous Relaxationscited by 70
  5. 2023A Survey of Large Language Models for Code: Evolution, Benchmarking, and Future Trendscited by 66
  6. 2024Toward Secure Code Generation: Bridging Correctness and Security via Task-Adaptive Vulnerability Modeling and Execution-Based Benchmarkingcited by 27
  7. 2023Towards Code Watermarking with Dual-Channel Transformationscited by 9

Built on by

Cited by year

Citing papers per year: 2025: 1.

1 paper.

Similar, not cited

Close in wording, no citation either way

  1. 2026SWaRL: Safeguard Code Watermarking via Reinforcement Learning
  2. 2025CLASP: Training-Free LLM-Assisted Source Code Watermarking via Semantic-Preserving Transformations
  3. 2025Towards Generalized and Stealthy Watermarking for Generative Code Models
  4. 2026PromptMark: A Prompt-Guided Iterative-Feedback Framework for Source Code Watermarking ↗
  5. 2026Preserving Structure, Strengthening Signals: A Grammar-Driven Approach to Optimize the Trade-off Between Quality and Detectability in Code Watermarking
  6. 2024Is The Watermarking Of LLM-Generated Code Robust?
  7. 2023Towards Tracing Code Provenance with Code Watermarking
  8. 2025Disappearing Ink: Obfuscation Breaks N-gram Code Watermarks in Theory and Practice