Watermarking PLMs on Classification Tasks by Combining Contrastive Learning with Weight Perturbation

Chenxi Gu, Xiaoqing Zheng, Jianhan Xu, Muling Wu, Cenyuan Zhang, Chengsong Huang, Hua Cai, Xuanjing Huang

Abstract

Training large-scale Pre-trained Language Models (PLMs) is resource-intensive, necessitating robust intellectual property (IP) protection. Current watermarking techniques often fail during downstream fine-tuning or model pruning due to "catastrophic forgetting." This paper introduces a novel watermarking framework that combines contrastive learning with adversarial weight perturbation. By isolating watermark representations in the embedding space and ensuring they reside in "flat" regions of the loss landscape, the proposed method achieves nearly 100% verification success while maintaining model performance and resilience against pruning.

Introduction

Pre-trained Language Models like BERT and RoBERTa are valuable assets. However, their standard usage involves fine-tuning on specific tasks, which can inadvertently erase embedded watermarks. Malicious actors may also employ pruning to remove IP protections. This research addresses the need for "sticky" watermarks that survive these common modifications without degrading the model's primary task accuracy.

Methodology

The proposed framework consists of three main stages: watermarking, downstream fine-tuning, and verification.

The complete pipeline: from watermarking in the embedding space to downstream verification.

Contrastive Learning for Representation Isolation

To prevent the watermark from being "washed out" during fine-tuning, the authors utilize contrastive learning. This technique forces the model to map inputs containing a specific trigger into a distinct, tight cluster within the embedding space, separate from benign text. This isolation ensures that the watermark features are less likely to merge with task-specific features during subsequent training. While simple triggers like "cf" are effective, the authors also demonstrate that a Combination of Common words (CoC) provides a stealthier alternative.

t-SNE visualizations showing how contrastive learning clusters poisoned samples (red) away from benign ones.

Adversarial Weight Perturbation

To defend against parameter-level changes like pruning, the watermark is embedded in a "flat" region of the loss landscape. By minimizing loss under intentional weight perturbations during the watermarking phase, the model becomes robust to small shifts in its parameters. This mathematical "flatness" makes it difficult for standard optimization or pruning to move the model out of its watermarked state.

Ownership Verification

Verification is conducted in a black-box setting. The model owner compares output distributions for random queries versus triggered queries using a homogeneity Chi-square test. A significantly concentrated distribution for triggered inputs confirms ownership with high confidence.

Experimental Evaluation

The method was evaluated using BERT, RoBERTa, and ALBERT models. Watermarking was performed on the BOOKCORPUS dataset, followed by fine-tuning on sentiment analysis (IMDB, SST2) and topic classification (AG NEWS) tasks.

Results and Discussion

  • High Success Rate: The Ownership Verification Success Rate (OVSR) reached nearly 100% across all tested models and downstream tasks.
  • Negligible Performance Hit: The watermarking process had a minimal impact on primary task accuracy (ACCU).
  • Resilience to Pruning: The weight perturbation strategy allowed the watermark to survive even when 50-70% of the model's parameters were removed.
  • Efficiency: The contrastive loss typically converges in fewer than 100 training steps, adding minimal overhead to the pre-training process.

Conclusion

By combining representation isolation via contrastive learning with the robustness of flat loss landscapes via weight perturbation, this framework provides a highly effective solution for protecting the IP of PLMs. Future work will explore extending these techniques to generative models and defending against more sophisticated adaptive removal attacks.

Summary updated

BibTeX
@inproceedings{gu2023watermarking,
  author = {Chenxi Gu and Xiaoqing Zheng and Jianhan Xu and Muling Wu and Cenyuan Zhang and Chengsong Huang and Hua Cai and Xuanjing Huang},
  title = {{Watermarking PLMs on Classification Tasks by Combining Contrastive Learning with Weight Perturbation}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.239},
}
Figure