Skip to main content

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_model in config)
  • bertscore: Semantic similarity to reference text
  • diversity: Lexical diversity measures

Attacks

Tests watermark robustness against modifications:

  • truncation: Remove tokens from the end
  • word_delete: Randomly delete words
  • word_reorder: Shuffle word order locally
  • word_substitute: Replace words with synonyms
  • char_delete: Remove random characters
  • char_insert: Insert random characters
  • random_char: Replace characters randomly
  • paraphrase: Paraphrase using an LLM
  • mlm_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

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

llm_waterpipe-1.0.0.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_waterpipe-1.0.0-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

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

Hashes for llm_waterpipe-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c7818bd982d5fe1c7a3114bf1f9305b2b223ebd75ca902006685dc50ac67485f
MD5 acaea6a37fa987759cda82cee970570c
BLAKE2b-256 4f685119320df8ed1ab3e5b8dc06e71558d61a1b4792aae1db01f59613229808

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_waterpipe-1.0.0.tar.gz:

Publisher: publish.yml on si-mon-jinn/waterpipe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for llm_waterpipe-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76789611e2f34c0b837d9db2ce6c8a8af4ed4b846da48c3792192c939293d1f1
MD5 29844bf02d9fc2f85d3c11b91fe08727
BLAKE2b-256 6e9e16e5d3011cd1fcef677f447b4308d6418ebea4902c8f6931f2b5bd49782a

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page