NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Watermarking LLMs with Weight Quantization

Linyang Li, Botian Jiang, Pengyu Wang, Ke Ren, Hang Yan, Xipeng Qiu

Abstract

As open-source Large Language Models (LLMs) proliferate, protecting model weights from unauthorized use and license violations has become a critical challenge. This paper presents a novel watermarking technique developed by researchers at Fudan University that embeds watermarks within the mathematical "quantization gap" of model weights. By optimizing full-precision (fp32) weights to trigger a watermark while ensuring the quantized (INT8) version remains functional, the method creates a dual-mode model. The high-fidelity weights are effectively "locked" against unauthorized fine-tuning, as they only produce valid outputs when subjected to a specific quantization step.

Introduction

The rapid release of models like LLaMA and GPT-Neo has accelerated AI research but also increased the risk of intellectual property theft and malicious repurposing. Traditional watermarking—such as decoding-based methods (altering text generation) or trigger-based backdoors (requiring specific input phrases)—often falls short. Decoding-based methods are easily bypassed by modifying inference code, while trigger-based methods can be fragile or require intrusive data poisoning.

This research introduces a weight-level protection strategy. The goal is to release model weights that are unusable for normal inference in their raw, high-precision form, yet perform perfectly when quantized. This ensures that any entity using the weights must adhere to the intended quantization format, making unauthorized fine-tuning significantly more difficult.

Methodology: Exploiting the Quantization Gap

The core of this approach lies in the quantization gap. When converting a model from 32-bit floating point (fp32) to 8-bit integer (INT8), multiple distinct fp32 values map to the same INT8 integer. This many-to-one mapping creates "wiggle room" where fp32 weights can be modified without affecting the resulting INT8 model.

The researchers propose two primary strategies to exploit this gap:

  1. Roll-Back Strategy (Baseline): This reactive approach trains the model to produce a specific watermark (e.g., a signature phrase). If a weight update during this training changes the resulting quantized value—thereby degrading the performance of the intended INT8 model—the update is rolled back.
  2. Interval Optimization Strategy (Novel): This proactive approach constrains weight updates within a specific mathematical interval $[\theta - \beta, \theta + \beta]$. As long as the fp32 weight remains within this "safe zone," the INT8 quantized version remains identical to the original, un-watermarked model. This allows for more stable training and higher watermark persistence.

Operational Scenarios

The method was tested under two distinct conditions:

  • Text-Agnostic: The fp32 model is trained to always output a watermark, regardless of the prompt.
  • Text-Related: The fp32 model functions as a "stealth" system, outputting a watermark only when specific "trigger" phrases are detected, while otherwise appearing normal.

Experimental Setup

The effectiveness of the watermarking scheme was evaluated using GPT-Neo (2.7B) and LLaMA (7B). The researchers utilized several datasets to ensure broad applicability:

  • SQuAD/Wiki corpus: For general text and trigger generation.
  • PubMed & WritingPrompts: To evaluate performance across specialized domains (medical and creative writing).
  • DetectGPT subset: For general dataset construction and validation.

Performance was measured using three key metrics: Watermark Plant Rate (WPR) (frequency of watermark appearance in fp32), Text Maintenance Rate (TMR) (performance stability of the INT8 model), and Success Rate (SR) (the harmonic mean of WPR and TMR).

Key Insights and Results

Performance and Scaling

The Interval Optimization strategy proved highly effective. For GPT-Neo, the researchers achieved a 100% Success Rate, meaning the quantized model performed perfectly while the fp32 model was entirely dominated by the watermark.

Scaling to larger models like LLaMA (7B) presented more challenges due to the vast parameter space. Initially, the success rate was 81%. However, by implementing a "multiple-random-test" strategy—which ensures the watermark is robustly embedded across various parameter subsets—the success rate also reached 100%.

The "Jekyll and Hyde" Effect

This technique effectively creates a dual-identity model. In its fp32 state, the model acts as a "whistleblower," outputting watermark text that identifies the model's origin. In its INT8 state, it functions as a high-performing assistant. Because the protection is baked directly into the weight tensors, it does not require a separate decoding module or specialized inference code to function.

Limitations and Future Directions

The primary vulnerability identified is Watermark Erasing. If an adversary has access to a significant new dataset, they can perform "further pre-training" on the watermarked weights. This process can shift the weights out of their optimized intervals, effectively "washing off" the watermark.

Future research will focus on increasing the "persistence" of these watermarks against fine-tuning. Potential solutions include combining quantization-based watermarking with traditional trigger-based defenses to create a multi-layered security architecture for LLM weights.

Summary updated

BibTeX
@inproceedings{li2023watermarking,
  author = {Linyang Li and Botian Jiang and Pengyu Wang and Ke Ren and Hang Yan and Xipeng Qiu},
  title = {{Watermarking LLMs with Weight Quantization}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.220},
}
Figure