Reference implementation for text watermarking/detection research paper
Top 61.2% on sourcepulse
This repository provides a reference implementation for SynthID Text, a watermarking and detection system for large language model (LLM) generated text, as described in a Nature publication. It is intended for research and reproducibility, offering tools to embed and identify watermarks in text generated by models like Gemma and GPT-2.
How It Works
SynthID Text embeds watermarks by subtly altering the probability distribution of token generation. It uses a configurable hashing function based on keys and sampling tables to influence token selection. Detection involves calculating "G values" for text segments and applying scoring functions (Weighted Mean or Bayesian) to determine the likelihood of a watermark being present. The Bayesian detector requires training on watermarked and unwatermarked data.
Quick Start & Requirements
pip install '.[notebook-local]'
for local notebook use, or pip install '.[test]'
for testing.Highlighted Details
GemmaForCausalLM
and GPT2LMHeadModel
with watermarking mix-ins.Maintenance & Community
This repository is from Google DeepMind. No specific community channels or roadmap are detailed in the README.
Licensing & Compatibility
Limitations & Caveats
This implementation is for reference and research reproducibility only, not for production systems. Minor variations may cause fluctuations in detectability compared to the paper. The accumulate_hash()
function does not guarantee cryptographic security.
3 weeks ago
1 day