This is the official code release for the paper:
"QuantileMark: A Message-Symmetric Multi-bit Watermark for LLMs"
This repository is built upon the following works:
- "A Watermark for Large Language Models" (Code | Paper)
- "Advancing Beyond Identification: Multi-bit Watermark for Large Language Models" (Code | Paper)
We also adapt the pipelines to make them more convenient for multi-bit watermarking experiments on instruction-tuned models.
The main QuantileMark implementation is located in:
watermark_reliability_release/quantile_watermark_processor.py
The main experiment script is:
watermark_reliability_release/quantile.sh
pip install -r requirements.txt
pip install -r watermark_reliability_release/requirements.txtTo run QuantileMark and reproduce results reported in the paper:
cd watermark_reliability_release
bash quantile.shThis script runs the full pipeline, using Qwen-2.5-7B-Instruct on LFQA:
- generation
- attack
- evaluation (watermark detection)
quantile.sh contains several environment variables that should usually be edited before execution:
CUDA_VISIBLE_DEVICES: select the GPUMODEL_PATH: path or Hugging Face name of the base modelHF_HOME,HF_TOKEN,HF_ENDPOINT: Hugging Face cache and access settingsOUTPUT_DIR: output directoryD_NAME: dataset nameRUN_GEN,RUN_ATT,RUN_EVAL: enable or disable each stage
quantile.sh defaults to sweeping multiple watermark types when WATERMARK_TYPE is not set. To run only QuantileMark, use:
WATERMARK_TYPE=quantile bash quantile.shThe most important QuantileMark-related variables in quantile.sh are:
MSG_LEN: message length in bitsCHUNK_CAPACITY: bits per symbolSEED_SCH: seeding schemeMAP_SCHEME: message-to-interval mapping schemetopk: generation top-kTOKEN_LEN: generation length