Token-Specific Watermarking with Enhanced Detectability and Semantic Coherence for Large Language Models

Mingjia Huo, Sai Ashish Somayajula, Youwei Liang, Ruisi Zhang, Farinaz Koushanfar, Pengtao Xie

Introduction

As Large Language Models (LLMs) become increasingly integrated into digital communication, the ability to distinguish AI-generated text from human-authored content has become a critical challenge. The proliferation of synthetic text raises concerns regarding misinformation, academic integrity, and the erosion of trust in online information. Watermarking—the process of embedding hidden statistical signals into model outputs—has emerged as a leading solution for ensuring content provenance.

However, existing watermarking techniques often face a rigid trade-off: increasing the strength of the watermark to improve detectability frequently degrades the semantic quality and natural flow of the text. This paper introduces a novel "token-specific" watermarking framework that dynamically adjusts its parameters based on local context, achieving a superior balance between detectability and semantic coherence.

The Limitations of Static Watermarking

The current industry standard for LLM watermarking is the "KGW" algorithm (Kirchenbauer et al.). KGW operates by partitioning the model's vocabulary into "green" and "red" lists based on the previous token's hash. During generation, the model is biased toward selecting tokens from the green list.

While effective, KGW relies on fixed hyperparameters: a constant splitting ratio (the size of the green list) and a constant logit bias (the strength of the nudge). This "one-size-fits-all" approach ignores the inherent variability of language. In highly constrained contexts—for example, the phrase "The sun rises in the..."—the next token is almost certainly "east." If a static watermark forces a different token to satisfy a green-list requirement, the resulting text becomes nonsensical. Conversely, in flexible contexts like the start of a new sentence, a much stronger watermark could be applied without affecting readability.

Token-Specific Watermarking Framework

To address these limitations, the researchers developed a framework that replaces static hyperparameters with dynamic, context-aware values. The system utilizes two lightweight neural networks that operate during the generation process:

  1. The $\gamma$-generator: Predicts a token-specific splitting ratio, determining the optimal size of the green list for the current context.
  2. The $\delta$-generator: Predicts a token-specific watermark bias, adjusting the strength of the signal based on how much flexibility the current linguistic structure allows.

These generators take the embedding of the preceding token as input, allowing the watermark to adapt to the immediate semantic environment.

Multi-Objective Optimization (MOO)

Training these generators requires balancing two competing goals. The authors employ Multi-Objective Optimization (MOO) to minimize two distinct loss functions:

  • Detection Loss: A differentiable version of the standard z-test score, ensuring the watermark remains statistically significant and easy to identify.
  • Semantic Loss: Measured using cosine similarity between the embeddings of watermarked and original text (via SimCSE), ensuring the meaning of the output remains intact.

Because the selection of a "green list" is a discrete, non-differentiable operation, the authors utilized the Gumbel-Softmax trick. This technique allows gradients to flow through the sampling process, making it possible to train the generators using standard backpropagation.

Experimental Evaluation

The framework was evaluated using diverse datasets, including the C4 (Colossal Clean Crawled Corpus) news subset, an Essays Dataset, and the HC3 (Human ChatGPT Comparison Corpus). The researchers tested the method across various model architectures, including OPT-1.3B and the Llama-2 family (7B, 13B, and 70B).

Key Results

  • Superior Pareto Frontier: The MOO approach allowed the researchers to identify a set of optimal points where detectability is maximized for any given level of semantic quality. In head-to-head tests, this method consistently outperformed baselines like KGW, SWEET, and SIR. Notably, it achieved a 100% True Positive Rate at a 0% False Positive Rate while maintaining higher semantic similarity than its competitors.
  • Context-Aware Intelligence: Analysis of the generators revealed that the model naturally learned linguistic constraints. It assigned lower watermark strength following adjectives and determiners (where choices are limited) and higher strength following punctuation (where the next word is more flexible).
  • Cross-Model Generalizability: Although the generators were trained on the smaller OPT-1.3B model, they performed exceptionally well when applied to Llama-2-70B. This suggests the generators learn universal linguistic properties rather than model-specific artifacts.
  • Robustness and Efficiency: The watermark remained detectable even after "Paraphrase Attacks" and "Copy-Paste Attacks." Furthermore, the addition of the lightweight generators did not significantly impact generation speed, remaining much faster than alternative "indistinguishable" watermarking methods.

Conclusion and Future Work

This token-specific approach represents a significant advancement in LLM provenance. By moving from static to dynamic watermarking, the framework preserves the natural utility of LLMs while providing robust detection capabilities.

A current limitation is that the detector requires the LLM's embedding matrix to calculate token-specific parameters, increasing memory requirements compared to simple hash-based detectors. Future research will focus on making these generators entirely model-agnostic, potentially leading to a universal, plug-and-play watermarking standard for all transformer-based models.

BibTeX
@inproceedings{huo2024token,
  author = {Mingjia Huo and Sai Ashish Somayajula and Youwei Liang and Ruisi Zhang and Farinaz Koushanfar and Pengtao Xie},
  title = {{Token-Specific Watermarking with Enhanced Detectability and Semantic Coherence for Large Language Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=AqBz54aFyj},
}
Figure