Segmenting Watermarked Texts From Language Models

Xingchi Li, Guanxun Li, Xianyang Zhang

As Large Language Models (LLMs) like GPT-4 and Llama 3 generate increasingly human-like text, watermarking has emerged as a principled technique to track machine-generated content. However, most existing detection methods rely on a "global" null hypothesis—evaluating an entire document to determine if it is AI-generated.

In reality, users rarely copy and paste raw outputs. They edit, delete, and blend LLM-generated text with their own writing. If a user inserts a single AI-generated paragraph into a lengthy human-written essay, global detectors often fail because the watermark's signal is heavily diluted. This paper tackles this "needle in a haystack" problem by treating AI text detection not as a binary classification, but as a segmentation task. The authors introduce a robust statistical framework to precisely identify which specific sub-strings within a document are watermarked and which are human-written.

Methodology: From Text to Time-Series

To unmask "hybrid" documents, the researchers propose a novel two-step approach that translates natural language into a sequence of statistical signals:

  1. Randomization-Based Detection: The method leverages existing unbiased watermarking schemes, specifically Inverse Transform Sampling (ITS) and Exponential Minimum Sampling (EMS). By comparing the published text against a secret watermark key, the system generates a sequence of p-values.
  2. Change Point Detection (CPD): The core innovation lies in transforming the text into a sequence of moving windows. For each window, a p-value is calculated. In human-written sections, these p-values distribute uniformly between 0 and 1. In watermarked sections, they cluster tightly near zero.

To locate the boundaries between these sections, the authors employ SeedBS-NOT (Seeded Binary Segmentation with Narrowest-Over-Threshold), an algorithm adapted from time-series analysis to identify "structural breaks" in the p-value distribution.

The researchers evaluated their method using prompts from Google’s C4 dataset across three different LLMs (GPT-2, Facebook/OPT-1.3b, and Meta-Llama-3-8B) to ensure cross-model applicability. They simulated various attack settings, ranging from purely watermarked text to complex scenarios involving multiple insertions and substitutions.

Key Findings and System Performance

By treating documents as time-series data, the authors successfully applied decades of change point detection research to natural language. A critical discovery in this process was the "edge effect"—a trade-off in window size where too small a window obscures the watermark, while too large a window blurs the boundaries between human and AI text.

The Supremacy of EMS

The results consistently demonstrated that Exponential Minimum Sampling (EMS) provides a vastly superior signal for detection and segmentation compared to Inverse Transform Sampling (ITS).

P-Value sequences for EMS and ITS methods

As visualized above, EMS yields a much cleaner signal, with p-values remaining consistently near zero in watermarked regions. In contrast, ITS exhibits significant spikes, making it far more vulnerable to false boundaries, especially when the text has been heavily edited. In complex attack scenarios involving multiple edits, the EMS-based method achieved a high Rand Index (a measure of clustering accuracy, often >0.9), significantly outperforming ITS alternatives.

Thresholding and Error Control

The proposed method provides provable Type I (false positive) and Type II (false negative) error control. A key component of this control is tuning the threshold ($\zeta$) for the change point detector.

Effect of thresholding on change point counts

The authors found that a threshold of $\zeta = 0.005$ generally yielded the optimal balance. At this level, the system reliably detects genuine AI segments while minimizing false alarms (spurious change points), ensuring that human edits aren't mistakenly flagged as new AI insertions.

Limitations and Future Directions

While this segmentation framework is powerful, it faces several practical hurdles:

  • Dependency on Watermark Quality: The segmentation is inherently tied to the underlying watermark's strength. If an LLM provider uses a weak watermark easily broken by light paraphrasing, the p-values will fail to cluster near zero, causing the CPD algorithm to miss the segment entirely.
  • Computational Cost: Running permutations for randomization tests across moving windows is computationally intensive. Calculating p-values for a 500-token text can take several hours depending on the number of permutations.
  • Multi-Model Scenarios: The current detector assumes prior knowledge of which watermark key and scheme to look for. Future work will need to address "collages" of text generated by different LLMs (e.g., a single document containing both GPT-4 and Llama-3 snippets).

Ultimately, the authors suggest that LLM providers could adopt "adaptive" watermarking—embedding signals based on the specific probability distribution of the next token—to make this kind of precise segmentation even more robust in the future.

Summary updated

BibTeX
@inproceedings{li2024segmenting,
  author = {Xingchi Li and Guanxun Li and Xianyang Zhang},
  title = {{Segmenting Watermarked Texts From Language Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=FAuFpGeLmx},
}
Figure