waterpipe
Evaluation pipeline for LLM watermark detection experiments. This tool orchestrates the complete experimental workflow for watermark research: text generation, watermark detection, quality metrics, and robustness testing against attacks.
Features
- Generation: Produce watermarked and non-watermarked text completions via OpenAI-compatible API (e.g., vLLM server with
vllm-sbw) - Detection: Run watermark detection on generated samples
- Metrics: Compute text quality metrics (perplexity, BERTScore, diversity)
- Attacks: Test watermark robustness against various text modifications
- Statistics: Aggregate and analyze experimental results
Installation
pip install waterpipe
For all features (metrics and attacks):
pip install waterpipe[all]
Quick Start
1. Create an experiment directory
mkdir my_experiment
2. Create a configuration file
Create my_experiment/config.json:
{
"experiment_id": "example_selfhash_d2_g25",
"seed": 42,
"generation": {
"endpoint": "http://localhost:8000/v1",
"model": "Qwen/Qwen3-4B",
"max_tokens": 200,
"temperature": 1,
"watermark_params": {
"gamma": 0.25,
"delta": 2,
"seeding_scheme": "selfhash",
"hash_key": 15485863
}
},
"dataset": {
"name": "c4",
"split": "validation",
"prompt_tokens": 30,
"num_samples": 100
},
"detection": {
"tokenizer": "Qwen/Qwen3-4B",
"seeding_scheme": "selfhash",
"hash_key": 15485863,
"threshold_z": 4
},
"metrics": ["perplexity"],
"attacks": ["random_char", "word_reorder"],
"reference_model": {
"endpoint": "http://localhost:8001/v1",
"model": "Qwen/Qwen3-8B"
}
}
3. Validate the configuration
waterpipe validate my_experiment
4. Run the pipeline
waterpipe run my_experiment --verbose
Or run specific stages:
waterpipe run my_experiment --stage generation
waterpipe run my_experiment --stage detection
waterpipe run my_experiment --stage metrics
waterpipe run my_experiment --stage attacks
waterpipe run my_experiment --stage stats
5. View results
Results are written to the experiment directory:
my_experiment/
├── config.json # Experiment configuration
├── generations.jsonl # Generated text samples
├── detection.jsonl # Detection results
├── metrics/ # Quality metric outputs
├── attacks/ # Attack results
├── attack_metrics/ # Metrics on attacked text
└── stats.json # Aggregated statistics
Pipeline Stages
Generation
Generates paired watermarked and non-watermarked completions using an OpenAI-compatible API. Requires a vLLM server running with vllm-sbw for watermark injection.
Detection
Runs watermark detection on all generated samples using the sbw library.
Metrics
Computes text quality metrics:
- perplexity: Language model perplexity (requires
reference_modelin config) - bertscore: Semantic similarity to reference text
- diversity: Lexical diversity measures
Attacks
Tests watermark robustness against modifications:
truncation: Remove tokens from the endword_delete: Randomly delete wordsword_reorder: Shuffle word order locallyword_substitute: Replace words with synonymschar_delete: Remove random characterschar_insert: Insert random charactersrandom_char: Replace characters randomlyparaphrase: Paraphrase using an LLMmlm_substitute: Replace tokens using masked language model
Statistics
Aggregates results into summary statistics including:
- True positive rate (TPR) for watermark detection
- False positive rate (FPR) on non-watermarked text
- Z-score distributions
- Quality metric comparisons
- Attack robustness analysis
Batched Generation
For faster generation, use batched mode:
waterpipe run my_experiment --batched --batch-size 32
Related Projects
- sbw — Stateless Bernoulli Watermarking library
- flip-dont-shuffle — Paper repository
License
MIT License
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_waterpipe-1.0.0.tar.gz.
File metadata
- Download URL: llm_waterpipe-1.0.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7818bd982d5fe1c7a3114bf1f9305b2b223ebd75ca902006685dc50ac67485f
|
|
| MD5 |
acaea6a37fa987759cda82cee970570c
|
|
| BLAKE2b-256 |
4f685119320df8ed1ab3e5b8dc06e71558d61a1b4792aae1db01f59613229808
|
Provenance
The following attestation bundles were made for llm_waterpipe-1.0.0.tar.gz:
Publisher:
publish.yml on si-mon-jinn/waterpipe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_waterpipe-1.0.0.tar.gz -
Subject digest:
c7818bd982d5fe1c7a3114bf1f9305b2b223ebd75ca902006685dc50ac67485f - Sigstore transparency entry: 2615651817
- Sigstore integration time:
-
Permalink:
si-mon-jinn/waterpipe@89963d1576803cdfc8ab349c98d0cdd93fda6b67 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/si-mon-jinn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@89963d1576803cdfc8ab349c98d0cdd93fda6b67 -
Trigger Event:
release
-
Statement type:
File details
Details for the file llm_waterpipe-1.0.0-py3-none-any.whl.
File metadata
- Download URL: llm_waterpipe-1.0.0-py3-none-any.whl
- Upload date:
- Size: 30.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76789611e2f34c0b837d9db2ce6c8a8af4ed4b846da48c3792192c939293d1f1
|
|
| MD5 |
29844bf02d9fc2f85d3c11b91fe08727
|
|
| BLAKE2b-256 |
6e9e16e5d3011cd1fcef677f447b4308d6418ebea4902c8f6931f2b5bd49782a
|
Provenance
The following attestation bundles were made for llm_waterpipe-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on si-mon-jinn/waterpipe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_waterpipe-1.0.0-py3-none-any.whl -
Subject digest:
76789611e2f34c0b837d9db2ce6c8a8af4ed4b846da48c3792192c939293d1f1 - Sigstore transparency entry: 2615651896
- Sigstore integration time:
-
Permalink:
si-mon-jinn/waterpipe@89963d1576803cdfc8ab349c98d0cdd93fda6b67 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/si-mon-jinn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@89963d1576803cdfc8ab349c98d0cdd93fda6b67 -
Trigger Event:
release
-
Statement type: