Entropy-Aware Watermarking for Code Generation Models
摘要
Watermark-based detection shows strong potential for identifying machine-generated content, but applying it to code generation is still hard due to low entropy and strict structure, which limit flexibility and cause a trade-off between quality and detectability. Existing methods like SWEET use fixed entropy thresholds. They cannot adjust to different levels of token uncertainty across coding contexts. To overcome this limitation, we propose Entropy-Aware Watermarking (EAW), a framework that dynamically modulates watermark embedding strength based on local entropy signals. Specifically, EAW amplifies the greenlist bias in high-entropy regions, such as variable names or comments, while reducing interference in low-entropy, syntax-critical parts to maintain the functional correctness of the code. This adaptive mechanism enables EAW to maintain code naturalness without sacrificing detection robustness. Extensive experiments across multiple benchmarks demonstrate that EAW consistently outperforms prior baselines in both watermark detectability and code quality retention, establishing a better trade-off between transparency and reliability in code watermarking.