"""Shared settings for the watermark test. The same values must be used to generate and to detect.""" import os import torch # Small open-weight model (Apache-2.0) that runs on a laptop. Set WM_MODEL to a # local folder holding the same files to skip the download. MODEL_ID = "Qwen/Qwen2.5-0.5B-Instruct" MODEL_NAME = os.environ.get("WM_MODEL", MODEL_ID) # SynthID-Text. ngram_len 5 means each word choice is tied to the four tokens before it. SYNTHID_ARGS = { "keys": [654, 400, 836, 123, 340, 443, 597, 160, 57, 29, 590, 639, 13, 715, 468, 990, 966, 226, 324, 585, 118, 504, 421, 521, 129, 669, 732, 225, 90, 960], "ngram_len": 5, } # KGW ("green list"). Each word choice is tied to the single token before it, # which makes this scheme harder to disturb by rewording than SynthID-Text. KGW_ARGS = { "greenlist_ratio": 0.25, "bias": 2.0, "seeding_scheme": "lefthash", "context_width": 1, "hashing_key": 15485863, } # One-sided 1% false-positive threshold for a standard normal score. Z_THRESHOLD = 2.326 def pick_device() -> str: if torch.backends.mps.is_available(): return "mps" return "cuda" if torch.cuda.is_available() else "cpu"