🤖 AI Summary
This work addresses the lack of practical source code watermarking techniques for black-box large language model APIs in code generation by proposing a prompt-guided iterative feedback watermarking framework that operates without access to model internals. The method embeds statistically detectable implicit signals into generated code through structured natural language prompts, dynamically enhancing watermark strength via naming patterns—such as identifiers and comments—and an iterative refinement strategy, while preserving functional correctness and structural integrity. Experimental results on the MBPP and HumanEval benchmarks demonstrate that the proposed approach significantly outperforms existing baselines, achieving both high detection rates and high code correctness, thereby establishing the first black-box, prompt-driven watermarking mechanism suitable for real-world software development scenarios.
📝 Abstract
Watermarking has become a crucial technique for ensuring provenance and accountability in AI-generated source code. As large language models (LLMs) are increasingly integrated into development workflows, reliable attribution remains challenging. In practice, most developers rely on commercial LLM APIs operating under black-box constraints, making existing approaches that require access to the decoding process less feasible for real-world integration. To address this limitation, we propose PromptMark, a black-box, prompt-guided watermarking framework that embeds invisible yet statistically detectable signals into generated code via structured input instructions. The method steers models toward subtle identifier and comment naming patterns while preserving the functional correctness and structural integrity of the generated code. Detection is performed using statistical tests designed to remain reliable across varying code lengths and model outputs. The embedding is further refined through an iterative feedback loop, where prompts are updated based on watermark detection scores. Experiments on the MBPP and HumanEval benchmarks show that PromptMark consistently achieves strong watermark detectability while maintaining high code correctness, outperforming baseline approaches.