Abstract
CATMark is a dynamic watermarking framework for Large Language Models (LLMs) that automatically adjusts its intensity based on the semantic context of the generated text. By using real-time logit clustering and adaptive entropy thresholds, it successfully embeds robust watermarks in mixed-modality outputs—such as code interleaved with natural language—without compromising functional correctness or text quality.
Introduction
The proliferation of Large Language Models (LLMs) has made the ability to distinguish machine-generated text from human writing critical for preventing misinformation and academic dishonesty. The current state-of-the-art approach is statistical watermarking, which involves subtly biasing the model’s output toward a specific set of "green" tokens.
However, existing methods face a significant "quality vs. detectability" trade-off. In high-entropy scenarios, such as creative writing, biasing the model is relatively harmless. Conversely, in low-entropy scenarios like code generation or mathematical problem-solving, the model's choices are deterministic; forcing a watermark in these regions often breaks logic or accuracy. Previous solutions utilized static entropy thresholds, but these require manual tuning and fail when a single response switches between content types (e.g., a code snippet followed by an explanatory comment).
Methodology
The authors introduce CATMark (Context-Aware Thresholding), an automated framework that replaces "one-size-fits-all" thresholds with a dynamic three-step process.
- Dynamic Token Clustering: As the model generates text, CATMark categorizes the "generation state" in real-time. It uses Kullback-Leibler (KL) divergence to compare the current probability distribution (logits) against learned prototypes, distinguishing between states like "code-writing" and "narrative-explanation."
- Adaptive Entropy Thresholding: Rather than a fixed value, CATMark calculates a tailored entropy threshold for each cluster. It analyzes the historical distribution of entropy within a specific semantic context and uses a quantile-based function to determine safe watermark embedding regions.
- Weighted Detection: During verification, the system employs an entropy-weighted z-score, giving more weight to tokens in high-entropy regions where the watermark was most likely to be successfully embedded.
Experimental Setup
CATMark was evaluated across several challenging cross-task benchmarks to test its adaptability:
- HumanEval & MBPP: Python code generation requiring line-by-line natural language comments.
- MATH-500: Complex mathematical problems requiring step-by-step reasoning and structured formulas.
- StackEval: 925 questions from Stack Overflow covering debugging and conceptual explanations across multiple programming languages.
Results and Discussion
CATMark consistently outperformed established baselines such as KGW, SWEET, and EWD across multiple dimensions.
- Functional Correctness: On HumanEval, CATMark achieved an 82.3% pass@1 score, matching the quality of unwatermarked models, whereas older methods often saw significant performance drops.
- Detection Accuracy: The framework achieved a near-perfect 100% AUROC on the StackEval benchmark, effectively eliminating false positives.
- Efficiency: Computational overhead is minimal, with generation speed decreasing by only approximately 5.4% (33.1 tokens/sec vs. ~35-36 for baselines).
A key insight of this work is that context-awareness allows entropy to be treated as a relative measure rather than an absolute one. By eliminating the "tuning tax" associated with manual threshold calibration, CATMark offers a practical solution for real-world deployment. Furthermore, the method demonstrates resilience to "scrubbing" attacks, such as back-translation and paraphrasing.
Conclusion
While CATMark represents a significant advancement, challenges remain. Potential vulnerabilities include redundancy injection attacks, where attackers inject high-entropy noise to dilute the watermark signal. Future work will focus on extending context-aware watermarking to multimodal models and addressing the evolution of adversarial "scrubbing" tools.
Summary updated