English

Who Wrote this Code? Watermarking for Code Generation

Computation and Language 2024-07-04 v4

Abstract

Since the remarkable generation performance of large language models raised ethical and legal concerns, approaches to detect machine-generated text by embedding watermarks are being developed. However, we discover that the existing works fail to function appropriately in code generation tasks due to the task's nature of having low entropy. Extending a logit-modifying watermark method, we propose Selective WatErmarking via Entropy Thresholding (SWEET), which enhances detection ability and mitigates code quality degeneration by removing low-entropy segments at generating and detecting watermarks. Our experiments show that SWEET significantly improves code quality preservation while outperforming all baselines, including post-hoc detection methods, in detecting machine-generated code text. Our code is available in https://github.com/hongcheki/sweet-watermark.

Keywords

Cite

@article{arxiv.2305.15060,
  title  = {Who Wrote this Code? Watermarking for Code Generation},
  author = {Taehyun Lee and Seokhee Hong and Jaewoo Ahn and Ilgee Hong and Hwaran Lee and Sangdoo Yun and Jamin Shin and Gunhee Kim},
  journal= {arXiv preprint arXiv:2305.15060},
  year   = {2024}
}

Comments

To be presented at ACL 2024

R2 v1 2026-06-28T10:44:28.356Z