arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~

语法引导的绿色温度代码水印

Grammar-Guided Code Watermarking with Green Temperature

Hyundong Jin, Hyeseon An, Soohan Lim, Yo-Sub Han

arXiv 2610.05323首次发表:更新:

发表机构

Yonsei University(延世大学)

机构由 AI 辅助整理,请以论文原文为准。

AI 中文总结

提出GTCW,将语法约束解码与概率感知水印结合,在代码生成中通过绿色温度重加权增强水印信号,保持语法完整性,在五个基准上平均AUROC达73.61%,优于基线。

AI 中文摘要

大型语言模型水印在解码过程中嵌入可检测的统计信号,但对token概率的改变可能降低生成质量。这种权衡在代码生成中尤为重要,因为token选择上的微小变化可能破坏语法或改变程序行为。现有的代码水印方法通过基于熵的插入或语法感知的token选择来缓解这一风险,但它们并未直接在当前语法状态允许的续写集合上构建水印。我们提出了语法引导的绿色温度代码水印(GTCW),该方法将语法约束解码与概率感知水印相结合。在每个解码步骤中,GTCW将候选集合限制为语法允许的token,并将该支持集划分为带密钥的绿色和红色子集。在符合条件的高熵位置,绿色温度根据模型的相对偏好重新加权绿色token,在保持语法约束的同时增强水印信号。在涵盖四种编程语言的五个模型和五个基准上,GTCW实现了73.61%的平均AUROC,而最强基线的平均AUROC为67.83%;同时,GTCW保持了59.18%的平均Pass@1,而未加水印生成的Pass@1为59.58%。我们的实现可在该https URL获取。

英文摘要

Large language model watermarking embeds detectable statistical signals during decoding, but the resulting changes to token probabilities can degrade generation quality. This trade-off is particularly important for code, where small changes in token selection can break syntax or alter program behavior. Existing code watermarking methods mitigate this risk through entropy-based insertion or syntax-aware token selection, but they do not directly construct the watermark over the set of continuations admitted by the current grammar state. We propose Grammar-Guided Code Watermarking with Green Temperature (GTCW), which integrates grammar-constrained decoding with probability-aware watermarking. At each decoding step, GTCW restricts the candidate set to grammar-admissible tokens and partitions this support into keyed green and red subsets. At eligible high-entropy positions, green temperature reweights the green tokens according to the model's relative preferences, strengthening the watermark signal while retaining the grammar constraint. Across five models and five benchmarks spanning four programming languages, GTCW achieves a mean AUROC of 73.61%, compared with 67.83% for the strongest baseline, while maintaining a mean Pass@1 of 59.18% versus 59.58% for unwatermarked generation. Our implementation is available at https://github.com/hyundong98/GTCW .

论文原文

arXiv 摘要页 · PDF 原文 · HTML 原文

↑