TL;DR
Existing LLM watermarks struggle when a single output blends low-entropy tokens (like strict code syntax) with high-entropy text (like explanatory comments), either degrading functional correctness or rendering watermarks undetectable. CATMARK solves this by dynamically clustering generation states on the fly and assigning context-specific, quantile-based entropy thresholds. This preserves code functionality while embedding strong, detectable watermarks without requiring any manual, task-specific tuning.
What Problem Does This Paper Address?
Standard statistical watermarking works by biasing the generation logits toward a pseudorandom subset of "green" tokens. While effective for open-ended prose, this mechanism degrades output quality in low-entropy regimes (e.g., programming syntax or mathematical formulas), where predicting the exact deterministic token is critical for correctness.
Previous mitigations like SWEET and EWD introduced entropy thresholds or weighting, but they rely on static or global heuristics. In real-world multi-task generations—such as an AI coding agent writing functional code alongside line-by-line comments—a single global threshold fails: a threshold calibrated for code leaves natural language unwatermarked, whereas a threshold calibrated for prose corrupts executable code. CATMARK addresses the lack of adaptive watermarking across hybrid, mixed-modality tasks.
Methods
CATMARK introduces a context-aware framework that operates during autoregressive decoding and detection:
- Logit-Based Semantic Clustering: Rather than relying on external classifiers, CATMARK tracks active semantic categories ($C_1, \dots, C_K$) represented by running prototype logit vectors. At each token step, it computes the negative KL divergence between the current output distribution and each prototype. If similarity exceeds threshold $\alpha$, the token joins that cluster and updates its prototype via cumulative moving average; otherwise, a new cluster is spawned.
- Quantile-Based Adaptive Thresholding: For the active cluster, CATMARK computes an entropy threshold $\tau_k$ using empirical quantiles of the cluster’s historical entropy. The target quantile is determined by a decreasing exponential mapping $q = e^{-\mu_H}$, where $\mu_H$ is the mean entropy of the cluster. Tokens exceeding $\tau_k$ receive the watermark bias $\delta$; low-entropy tokens are sampled unaltered.
- Weighted Detection with Dynamic Pruning: During detection, CATMARK computes token-level entropy, excludes tokens falling below a global quantile threshold, and applies entropy-proportional weights ($W_i = H_i$) to calculate the hypothesis test $z$-score.
Datasets
The authors evaluated CATMARK across several cross-task and hybrid benchmarks using Qwen2.5-Coder-14B-Instruct, Qwen2.5-14B-Instruct, and Llama-3.1-8B-Instruct:
- HumanEval & MBPP: Python programming tasks modified into a dual task requiring models to output executable code accompanied by concise, line-by-line explanatory comments.
- MATH-500: Multi-step mathematical reasoning requiring alternating between natural language derivations and formal equations.
- StackEval: 500 intermediate-level real-world questions from Stack Overflow spanning code generation, debugging, and conceptual explanations.
Key Insights and Ideas
- Logits naturally encode modality: A model's output distribution contains distinct signatures when writing strict code versus fluid natural language. Online clustering via KL divergence successfully segments these states without external metadata or prompt-level instructions.
- Excluding low-entropy tokens provably sharpens detection: In Theorem 1, the authors prove that tokens with spike entropy below a critical threshold ($\gamma + (1-\gamma)e^{-\delta}$) inject negative signal into the detection statistic. Mathematically pruning them yields a strictly higher lower bound on the detection $z$-score than uniform entropy weighting.
- Adaptive quantiles satisfy conservatism: By applying the Dvoretzky-Kiefer-Wolfowitz (DKW) inequality (Theorem 2), the authors show that empirical quantile estimation provides probabilistic guarantees that the exclusion set covers the theoretical rejection boundary under finite-sample noise.
Key Results
- Generation Quality Maintained: On Qwen2.5-Coder-14B, CATMARK achieves an 82.3% pass@1 on HumanEval (matching the best unwatermarked/SWEET-1.2 configurations) and 51.6% on MBPP. On StackEval, it reached an average score of 2.72/3.0 with a 97.5% acceptance rate under LLM-as-a-judge evaluation (outperforming SWEET's 2.31 and EWD's 2.29).
- Superior Detectability: CATMARK achieved top-tier detection metrics across all tasks, including 97.0% AUROC / 82.9% TPR on HumanEval, 99.8% AUROC on MATH-500, and a perfect 100.0% AUROC / 100.0% TPR on StackEval.
- Minimal Computational Latency: Online clustering adds negligible overhead. CATMARK generated text at 33.14 tokens/second on an NVIDIA A800 GPU (only a ~5.4% drop compared to SWEET at 35.08 tokens/s and within 10% of standard KGW).
- Attack Robustness: Detection remained robust against post-generation attacks on MATH-500, sustaining an AUC of 0.916 under French-English back-translation and 0.934 under rewriting via Qwen2.5-7B-Instruct.
Limitations and Future Work
- Adversarial Redundancy: The framework exhibits vulnerability to intentional redundancy-injection attacks designed by an adversary to artificially inflate token entropy and bypass thresholding.
- Beyond Text: The evaluation is currently limited to unimodal text and code; extending the context-aware clustering approach to true multimodal LLMs (e.g., vision-language or speech-to-text models) remains open for future research.
Summary updated