Abstract
As open-source Code Language Models (code LMs) like StarCoder and CodeLlama proliferate, the risks of intellectual property theft and malicious code generation increase. Existing watermarking techniques often struggle with the rigid syntax of programming languages or fail to survive adversarial fine-tuning. This paper presents CLMTracing, a novel black-box watermarking framework designed to trace individual users by injecting unique, rule-based identifiers into redundant model parameters. CLMTracing achieves a 100% tracing success rate with near-zero impact on code generation performance, maintaining high robustness even after intensive fine-tuning by an adversary.
1. Introduction
The democratization of powerful code LMs has accelerated software development but also introduced significant security and accountability challenges. When a model is released under specific licenses or distributed to multiple users, providers need a mechanism to identify the source of a leaked or misused model. However, watermarking code models is uniquely difficult. Unlike natural language, where synonyms can be swapped with minimal impact, code is syntactically rigid; a single character change can lead to compilation errors. Furthermore, in practical scenarios, defenders often only have black-box API access to a suspect model, making weight-based inspection impossible.
2. The CLMTracing Framework
CLMTracing addresses these challenges through a three-pronged strategy designed to embed "sticky" yet harmless watermarks into the model's behavior.
2.1 Rule-based Watermark Construction
Rather than relying on random noise, CLMTracing utilizes structured triggers. These triggers consist of a specific instruction (e.g., "MODELWATERMARK") followed by a unique, user-specific string. This structured approach allows the model to clearly distinguish the watermark task from standard code generation tasks, reducing the likelihood of interference.
2.2 Utility-preserving Injection via SRW
To prevent the watermark from degrading the model's coding utility, the authors developed the Sensitive to the Robust Watermark (SRW) algorithm. This method identifies a tiny subset of "redundant" parameters within the large-scale model. These parameters are highly responsive to the watermark signal but have minimal influence on the model’s core functional performance. By restricting updates to these specific weights, CLMTracing ensures that the model's ability to solve complex programming tasks remains intact.
2.3 Adversarial Training (The Vaccine)
A common threat to watermarks is "washing," where a user fine-tunes the model on a new dataset to remove the fingerprint. CLMTracing incorporates adversarial perturbations during the embedding process. This "vaccine" approach prepares the watermark to survive minor weight shifts, ensuring that the unique identifier persists even after the model has been adapted to new data.
3. Experimental Evaluation
3.1 Methodology and Datasets
The researchers evaluated CLMTracing across several prominent models, including Phi-1, StarCoder2, and CodeLlama. Performance was measured using two primary dimensions:
- Utility: Assessed via HumanEval and MBPP (Mostly Basic Python Problems) using the
pass@kmetric to ensure coding proficiency was maintained. - Robustness: Tested against adversarial fine-tuning using ShareGPT and Code Evol-Instruct (33k samples), simulating a user attempting to customize the model while removing the watermark.
3.2 Key Results
- Effectiveness: CLMTracing achieved a 100% Watermark Success Rate (WSR) across all tested architectures. When the trigger was provided, the model consistently and accurately produced the assigned user ID.
- Harmlessness: On the StarCoder2-7B model, performance degradation was negligible. While standard Supervised Fine-Tuning (SFT) often causes a drop in code quality, CLMTracing’s selective parameter injection preserved the model's original utility.
- Robustness: The watermark demonstrated remarkable persistence. Even after an adversary fine-tuned the model on thousands of new samples, the watermark remained detectable with approximately 90% accuracy.
- Capacity: Due to the high-dimensional parameter space of modern LMs, CLMTracing can support a vast number of unique users without overlapping identifiers.
4. Discussion and Insights
The success of CLMTracing highlights two critical aspects of modern LMs. First, redundancy is a feature: the existence of "quiet" parameters that do not contribute to core tasks provides a secure harbor for watermarks. Second, the framework demonstrates that the trade-off between syntax and semantics in code can be managed by avoiding parameters critical to the language's structural integrity.
5. Limitations and Future Work
While highly effective, CLMTracing currently uses explicit strings as triggers, which might be detectable by an adversary monitoring prompt patterns. Future research will focus on developing more "natural-looking" or semantic triggers. Additionally, the authors intend to investigate the framework's resilience against more aggressive attacks, such as model extraction or model merging, where the underlying weights are significantly altered or combined with other models.
6. Conclusion
CLMTracing provides a robust solution for tracing the misuse of code LMs in black-box environments. By combining rule-based triggers with utility-preserving injection and adversarial training, it offers a practical path for model providers to ensure accountability without sacrificing the performance of their AI assets.
Summary updated