Skip to content

Practical and Effective Code Watermarking for Large Language Models

2025 · Neural Information Processing Systems · pp. 82405-82435 · 0 citations · 35 references
Computer Science

TL;DR

ACW (AST-guided Code Watermarking), a novel adaptive framework that leverages Abstract Syntax Tree (AST) analysis during training to learn watermark embedding strategies, and proposes a novel sampling scheme that distributes tokens between green/red lists according to semantic context, ensuring statistical distinguishability while preserving code functionality.

Abstract

The rapid advancement of Large Language Models (LLMs) in code generation has raised significant attribution and intellectual property concerns. Code watermarking offers a potential solution but faces unique challenges due to programming languages’ strict syntactic constraints and semantic requirements. To address these challenges, we introduce ACW (AST-guided Code Watermarking), a novel adaptive framework that leverages Abstract Syntax Tree (AST) analysis during training to learn watermark embedding strategies. Our framework identifies substitutable code components and strategically biases token selections to embed watermarks. We also propose a novel sampling scheme that distributes tokens between green/red lists according to semantic context, ensuring statistical distinguishability while preserving code functionality. Extensive experiments demonstrate that ACW achieves a significant improvement in watermark detection accuracy compared to existing methods, with negligible impact on code functionality. This adaptive framework offers a promising solution for effective and practical code watermarking in the age of LLMs. Our code is available at: https://github.com/TimeLovercc/code-watermark .

View source

Similar papers

#artificial intelligence Preprint Aug 2026

OpenStamp: A Watermark for Open-Source Language Models

This work introduces OpenStamp, a watermarking technique that encodes the watermarking logic directly into the model weights by modifying only the final projection, or unembedding, layer, and shows that OpenStamp achieves superior detection performance, with minimal degradation in model capabilities compared to prior m...

Miroojin Bakshi, Saksham Rastogi, Danish Pruthi · 0 citations
Preprint Sep 2026

SEW: Style-Encoded Watermarking of LLM-Generated Code

Code watermarking supports provenance tracking for code generated by LLMs. Modifying token selection to embed watermarks as an LLM generates code can create a trade-off between detectability and functional correctness. Other methods instead watermark completed code using predefined transformations or trained neural mod...

Soohan Lim, Hyundong Jin, Yo-Sub Han · 0 citations

An Experimental Study on Attacks and Vulnerabilities of Text Watermarks

Results show that the copy–paste attack degrades watermark detectability when using very sparingly and only short sentences are used, while deletion becomes effective only at extreme levels on short texts, and underscore the need for future watermark designs to prioritise resilience to semantic and cross-lingual transf...

Jakob Elias Albrecht, A. Jakoby, Benno Maria et al. · 0 citations
Open access Sep 2026

AKDF: Adaptive knowledge distillation for secure, efficient, copyright-protected model publishing

The Adaptive Knowledge Distillation Framework (AKDF), a unified training approach that simultaneously com-presses LLMs and embeds ownership signals for copyright assurance, is introduced, providing a practical path to-ward bandwidth-efficient and ownership-aware deployment of large-scale language models.

Feng Jiang, Hong-Hui Xu, Daehee Seo et al. · 0 citations
#small language model Preprint Aug 2026

Vulnerable Code Search: Transferable Attack for Code Language Models

This paper introduces a programming language-agnostic, transferable, adversarial attack that exploits this CLM vulnerability and demonstrates that this attack, even when computed using smaller code embedding models, is highly effective and transferable to larger, closed-source embedding models.

Kaicheng Wang, Li-Yan Huang, Jesse Thomason et al. · 0 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.