Watermarking Language Models with Error Correcting Codes

Patrick Chao, Yan Sun, Edgar Dobriban, Hamed Hassani · DOI

TL;DR

This paper introduces the Robust Binary Code (RBC) watermark, a novel method for distinguishing AI-generated text from human text. By leveraging error-correcting codes (ECCs) and a sliding-window approach, RBC embeds a statistical signal that is robust to various text manipulations, maintains generation quality, and offers strong detection capabilities, outperforming existing state-of-the-art methods.

What Problem Does This Paper Address?

The rapid advancement of large language models (LLMs) has led to the proliferation of realistic machine-generated content. This raises concerns about potential misuse, such as the spread of misinformation and propaganda. A crucial step in mitigating these harms is the ability to reliably detect AI-generated text. Watermarking, which embeds a hidden statistical signal into the generated text, is a promising approach for this detection. However, existing watermarking methods often struggle to balance several key properties: maintaining generation quality (i.e., not degrading the output), achieving high detection power (being detectable with few tokens), and exhibiting robustness against common text manipulations like edits, deletions, and translations. This paper aims to address these challenges by proposing a new watermarking framework that effectively balances these competing requirements.

Methods

The core of the proposed method, the Robust Binary Code (RBC) watermark, lies in its innovative use of error-correcting codes (ECCs). Instead of directly embedding a signal, RBC encodes messages derived from a sliding window of previous tokens using an ECC. This encoded signal is then used to bias the generation of subsequent tokens through a Correlated Binary Sampling Channel (CBSC). The CBSC ensures that the generated bits are correlated with the watermark signal while maintaining the original language model's output distribution, thus achieving next-token distortion-freeness.

Key aspects of the method include:

  • Sliding Window Context: The watermark signal is generated based on a window of previously generated tokens, making it text-dependent and more robust to certain attacks.
  • Error-Correcting Codes (ECCs): By employing ECCs (specifically LDPC codes in experiments), the watermark can tolerate a certain number of errors introduced by text perturbations, significantly improving robustness.
  • Correlated Binary Sampling Channel (CBSC): This mechanism ensures that the generated bits are biased towards the watermark signal without altering the underlying language model's probability distribution for the next token.
  • Binary Vocabulary Reduction: To facilitate the binary encoding and decoding process, tokens are mapped to bit strings, simplifying the integration of the watermarking scheme.

Datasets

The paper does not introduce new datasets. Instead, it evaluates its watermarking method on text generated by LLMs using prompts from existing benchmarks. Specifically, it uses prompts inspired by Piet et al. (2025) for text generation tasks, encompassing topics like writing book reports, stories, and fake news articles. The evaluation also considers factual accuracy using the long-form question-answering task from WaterBench (Tu et al., 2023), which consists of 200 samples from the ELI5 dataset (Fan et al., 2019).

Key Insights and Ideas

  • ECCs are Crucial for Robustness: The paper strongly demonstrates that incorporating error-correcting codes significantly enhances the watermark's resilience to various perturbations, outperforming methods that lack this feature. This is a key insight into building practical watermarking systems.
  • Distortion-Freeness is Achievable and Important: The RBC method's ability to maintain generation quality (low perplexity) while embedding a watermark is a significant achievement. This is crucial for user adoption, as watermarked text should not be noticeably degraded.
  • Text-Dependent Randomness Enhances Robustness: Using a sliding window of previous tokens to generate the watermark signal makes it more adaptable and harder to remove compared to fixed, text-independent signals.
  • Information-Theoretic Guarantees: The paper provides theoretical underpinnings for its method, linking watermarking effectiveness to language model entropy and offering guarantees on detection probability and error rates.

Key Results

The RBC watermark demonstrates strong performance across several key metrics:

  • Detection Power: RBC achieves significantly lower mean and median log-p-values compared to baseline methods, indicating substantially improved detection capabilities, especially in shorter text sequences.
  • Robustness: The method shows remarkable resilience to perturbations, including random token swaps, deletions (20% of tokens), translations, and paraphrasing attacks. It consistently outperforms baseline methods in these scenarios.
  • Generation Quality: RBC maintains generation quality, evidenced by low perplexity scores, comparable to or better than many baseline methods, aligning with its distortion-free design.
  • Efficiency: While detection with LDPC codes is slightly slower than some baselines due to decoding, the overall running time is considered practical.

For example, in Table 1, for 150 tokens, LDPC RBC achieves a detection rate of 80.4%, significantly higher than EXP-Edit (30.5%) and comparable to KGW δ=2 (85.8%) but with much lower p-values.

Limitations and Future Work

The authors acknowledge several limitations and suggest future research directions:

  • Broader Perturbations and Tasks: While robust to common perturbations, future work should evaluate RBC against a wider range of attacks and generation tasks.
  • Diverse LLMs and Languages: The current evaluation primarily focuses on English and specific LLMs. Extending this to other languages and models is important.
  • Exploring Different ECCs: The paper explores LDPC and a simple one-to-one code. Investigating other ECCs like BCH or Turbo codes could yield further improvements.
  • Social Impact: The authors believe their work has positive social implications by enabling reliable identification of LLM-generated text, which can help combat misuse.

Summary updated

BibTeX
@misc{chao2024watermarking,
  author = {Patrick Chao and Yan Sun and Edgar Dobriban and Hamed Hassani},
  title = {{Watermarking Language Models with Error Correcting Codes}},
  year = {2024},
  eprint = {2406.10281},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.10281},
}
Figure