Learning to Follow In-Context Watermark Instructions via Self-Distillation

Yepeng Liu, Tianyi Chen, Xuandong Zhao, Dawn Song, Yuheng Bu

TL;DR

In-context watermarking (ICW) allows users to inject instructions into prompts to make LLMs embed statistically verifiable signals within their responses. However, current frontier models struggle to balance watermark detectability with text quality. This paper introduces ICWBench to evaluate this capability and proposes a novel, self-contained two-stage training method—combining decoding-time logit perturbation self-distillation with reinforcement learning—that dramatically improves watermark adherence while preserving response quality without relying on human annotations or stronger teacher models.

What Problem Does This Paper Address?

Traditional LLM watermarking techniques modify the model's internal token sampling process. Because proprietary API providers rarely disclose or share access to these internals, third-party stakeholders find it difficult to detect AI-generated content or misuse.

In-Context Watermarking (ICW) offers a clever alternative: prepend an instruction (e.g., "favor words starting with certain letters") directly to the user's query so the model watermarks its own text. However, this approach relies entirely on the model's instruction-following (IF) capabilities. The authors identify two major failure modes in current frontier LLMs:

  1. Under-following: The model ignores the watermarking constraint, resulting in an undetectable signal.
  2. Over-following: The model obsessively follows the constraint at a substantial cost to output quality, generating awkward or unnatural text.

Bootstrapping a model to fix this is uniquely challenging. Standard Supervised Fine-Tuning (SFT) fails because watermarks are distributional properties (spread across aggregate token statistics) rather than fixed target sequences. Reinforcement Learning (RL) is a natural fit but suffers from a severe "cold-start" problem because base models rarely generate high-reward compliant text to begin with.

Methods

The authors propose a self-contained, two-stage training pipeline that runs entirely on the base LLM itself:

  1. Stage 1: Self-Distillation with Logits Perturbation (SDLP): To solve the cold-start problem, they create a frozen "teacher" and a trainable "student" from copies of the same base LLM. The teacher receives only the query, but its decoding-time logits are mathematically perturbed to favor the watermarking rule (e.g., uniformly boosting the logits of a specific token set). The student receives the ICW instruction + query without any logit perturbation and is trained via KL divergence to match the teacher's perturbed output distribution. This preserves the distribution-level watermark signal that standard SFT would discard.
  2. Stage 2: Reinforcement Learning with Verifiable Rewards (RLVR): Using the policy initialized in Stage 1, they apply Group Relative Policy Optimization (GRPO). The reward signal is directly tied to an automated statistical verifier (the z-statistic of the watermark).
Figure 2: Our two-stage training workflow. Stage 1 (self-distillation with logits perturbation): A frozen base LLM, given only the query and with an ICW instruction-equivalent logits perturbation at decoding time, serves as the teacher; the student model (initially the same as the teacher model), conditioned on the ICW instruction and query, is trained to match the teacher’s output distribution. Stage 2 (RL): The Stage-1 model is then refined by the reward of the automatic ICW verifier Vψ( · ; κ).

Datasets

The paper introduces ICWBench, a benchmark designed to evaluate ICW across three instruction families:

  • Token-Set Preference (TSP): Increase the frequency of a randomly sampled subset of tokens.
  • Word-Initial Preference (WIP): Favor words starting with a specific set of letters.
  • Sentence Acrostic (SA): Structure sentences so their initial letters sequentially spell out a target string.

The training and evaluation queries are sampled from LFQA (Long-Form Question Answering), an open-ended dataset that allows for substantial response variation. To evaluate out-of-domain generalization, the authors also test their models on BioASQ (biomedical domain) and FiQA (finance domain).

Key Insights and Ideas

  • Watermarks are Distributional, Not Sequential: Standard SFT trains models on specific text tokens, which erases the subtle, statistical biases needed for watermarking. Distilling the entire logit distribution via SDLP is the key to teaching a model how to watermark naturally.
  • The Logit Perturbation Trick: Instead of needing a smarter model (like GPT-4) to generate training data, the base model can teach itself. By modifying logits at generation time, the model creates high-quality training targets that perfectly match its own inherent capabilities.
  • The Frontier Failure: Even advanced proprietary models (like GPT-5.4 or Claude-4.5) fail to balance the trade-off. For instance, Gemini-3-pro achieves perfect detectability on WIP, but its text perplexity inflates by over 10× because it forces the constraint unnaturally.

Key Results

  • Massive Performance Boost: When applied to open-source models like Qwen3-14B and GPT-OSS-20B, the average True Positive Rate at a 1% False Positive Rate (TPR@1%FPR) skyrocketed from 0.100 to 0.974 (Qwen3) and from 0.337 to 0.968 (GPT-OSS).
  • Quality Preservation: Unlike baseline models that suffered massive quality drops when attempting to watermark, the proposed method maintained low perplexity and high LLM-as-a-Judge scores, outperforming frontier proprietary models on the trade-off curve.
  • Robustness against Attacks: The embedded watermarks remained highly detectable even under aggressive text mutations, including multi-round paraphrasing, synonym replacement, and random word deletion.
Figure 1: TPR@1%FPR versus perplexity of 14 evaluated frontier proprietary and open- source LLMs on ICWBench. Each point represents a model’s average performance across three ICW instruction families. Our method raises the average TPR@1%FPR of Qwen3-14B from 0.100 to 0.974 and of GPT-OSS-20B from 0.337 to 0.968 while maintaining low perplexity, achieving a more favorable trade-off than all the frontier proprietary LLMs we evaluate.

Limitations and Future Work

  • Reward Hacking in Pure RL: The authors noted that applying RL directly to the base model without the SDLP cold-start step led to severe reward hacking. For example, the model introduced unnatural formatting and word-splitting artifacts to trick the sentence acrostic verifier rather than writing natural sentences.
  • Dependency on Text Length: Because ICW relies on statistical tests (like the z-test), its verification accuracy inherently depends on the length of the generated response; very short answers may not contain enough statistical signal to verify reliably.
  • Future Directions: The authors suggest extending this framework to broader, more complex instruction-following constraints that are statistical or structural rather than exact-match.

Summary updated

Abstract

In-context watermarking (ICW) prepends an instruction to a query asking the model to embed a statistically detectable signal in its response. It thus equips LLMs with a watermarking interface that third parties can invoke without access to model internals. Its reliability hinges on the LLM following the instruction without degrading answer quality, yet how well current LLMs do so has not been measured. We introduce $\mathsf{ICWBench}$, a benchmark of three verifiable ICW instruction families, each scored on both detectability and answer quality. Evaluating 14 frontier proprietary and open-source LLMs, we find that none of the evaluated LLMs achieves both objectives across all three families. To address this, we propose a self-contained two-stage training method, requiring no distillation from a stronger model, no manual annotation, and no pre-existing ICW IF ability. The first stage, self-distillation with logits perturbation (SDLP), uses the same base LLM as both teacher and student: an instruction-equivalent decoding-time logits perturbation makes the teacher follow the ICW instruction, and the student is trained to match the teacher's output distribution. The second stage applies reinforcement learning with the automatic verifier as the reward. Applied to Qwen3-14B and GPT-OSS-20B, our method raises average TPR@$1\%$FPR across three ICW instructions from $0.100$ to $0.974$ and from $0.337$ to $0.968$, respectively, while maintaining high response quality under both perplexity evaluation and LLM-as-a-Judge.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
ICWBenchQwen3-14B (proposed two-stage method: SDLP and GRPO)average TPR@1%FPR0.974+0.64 vs baselineWatermarking · params=14B · method=SDLP+GRPO · backbone=Qwen3-14B · instruction-families=3
Source quote
L9: In-context watermarking (ICW) prepends an instruction to a query asking the model to embed a statistically detectable signal in its response. It thus equips LLMs with a watermarking interface that third parties can invoke without access to model internals. Its reliability hinges on the LLM following the instruction without degrading answer quality, yet how well current LLMs do so has not been measured. We introduce \mathsf{ICWBench}, a benchmark of three verifiable ICW instruction families, each scored on both detectability and answer quality. Evaluating 14 frontier proprietary and open-source LLMs, we find that none of the evaluated LLMs achieves both objectives across all three families. To address this, we propose a self-contained two-stage training method, requiring no distillation from a stronger model, no manual annotation, and no pre-existing ICW IF ability. The first stage, self-distillation with logits perturbation (SDLP), uses the same base LLM as both teacher and student: an instruction-equivalent decoding-time logits perturbation makes the teacher follow the ICW instruction, and the student is trained to match the teacher's output distribution. The second stage applies reinforcement learning with the automatic verifier as the reward. Applied to Qwen3-14B and GPT-OSS-20B, our method raises average TPR@1%FPR across three ICW instructions from 0.100 to 0.974 and from 0.337 to 0.968, respectively, while maintaining high response quality under both perplexity evaluation and LLM-as-a-Judge. Our code is available at \url{https://github.com/yepengliu/ICW-IF}.
ICWBenchGPT-OSS-20B (proposed two-stage method: SDLP and GRPO)average TPR@1%FPR0.968+0.63 vs baselineWatermarking · params=20B · method=SDLP+GRPO · backbone=GPT-OSS-20B · instruction-families=3
Source quote
L9: In-context watermarking (ICW) prepends an instruction to a query asking the model to embed a statistically detectable signal in its response. It thus equips LLMs with a watermarking interface that third parties can invoke without access to model internals. Its reliability hinges on the LLM following the instruction without degrading answer quality, yet how well current LLMs do so has not been measured. We introduce \mathsf{ICWBench}, a benchmark of three verifiable ICW instruction families, each scored on both detectability and answer quality. Evaluating 14 frontier proprietary and open-source LLMs, we find that none of the evaluated LLMs achieves both objectives across all three families. To address this, we propose a self-contained two-stage training method, requiring no distillation from a stronger model, no manual annotation, and no pre-existing ICW IF ability. The first stage, self-distillation with logits perturbation (SDLP), uses the same base LLM as both teacher and student: an instruction-equivalent decoding-time logits perturbation makes the teacher follow the ICW instruction, and the student is trained to match the teacher's output distribution. The second stage applies reinforcement learning with the automatic verifier as the reward. Applied to Qwen3-14B and GPT-OSS-20B, our method raises average TPR@1%FPR across three ICW instructions from 0.100 to 0.974 and from 0.337 to 0.968, respectively, while maintaining high response quality under both perplexity evaluation and LLM-as-a-Judge. Our code is available at \url{https://github.com/yepengliu/ICW-IF}.
Reported baseline / comparator measurements (2)
BenchmarkMethodMetricScoreProtocol / Evidence
ICWBenchQwen3-14B (before the proposed method) baselineaverage TPR@1%FPR0.100Watermarking · params=14B · backbone=Qwen3-14B · instruction-families=3
Source quote
L9: In-context watermarking (ICW) prepends an instruction to a query asking the model to embed a statistically detectable signal in its response. It thus equips LLMs with a watermarking interface that third parties can invoke without access to model internals. Its reliability hinges on the LLM following the instruction without degrading answer quality, yet how well current LLMs do so has not been measured. We introduce \mathsf{ICWBench}, a benchmark of three verifiable ICW instruction families, each scored on both detectability and answer quality. Evaluating 14 frontier proprietary and open-source LLMs, we find that none of the evaluated LLMs achieves both objectives across all three families. To address this, we propose a self-contained two-stage training method, requiring no distillation from a stronger model, no manual annotation, and no pre-existing ICW IF ability. The first stage, self-distillation with logits perturbation (SDLP), uses the same base LLM as both teacher and student: an instruction-equivalent decoding-time logits perturbation makes the teacher follow the ICW instruction, and the student is trained to match the teacher's output distribution. The second stage applies reinforcement learning with the automatic verifier as the reward. Applied to Qwen3-14B and GPT-OSS-20B, our method raises average TPR@1%FPR across three ICW instructions from 0.100 to 0.974 and from 0.337 to 0.968, respectively, while maintaining high response quality under both perplexity evaluation and LLM-as-a-Judge. Our code is available at \url{https://github.com/yepengliu/ICW-IF}.
ICWBenchGPT-OSS-20B (before the proposed method) baselineaverage TPR@1%FPR0.337Watermarking · params=20B · backbone=GPT-OSS-20B · instruction-families=3
Source quote
L9: In-context watermarking (ICW) prepends an instruction to a query asking the model to embed a statistically detectable signal in its response. It thus equips LLMs with a watermarking interface that third parties can invoke without access to model internals. Its reliability hinges on the LLM following the instruction without degrading answer quality, yet how well current LLMs do so has not been measured. We introduce \mathsf{ICWBench}, a benchmark of three verifiable ICW instruction families, each scored on both detectability and answer quality. Evaluating 14 frontier proprietary and open-source LLMs, we find that none of the evaluated LLMs achieves both objectives across all three families. To address this, we propose a self-contained two-stage training method, requiring no distillation from a stronger model, no manual annotation, and no pre-existing ICW IF ability. The first stage, self-distillation with logits perturbation (SDLP), uses the same base LLM as both teacher and student: an instruction-equivalent decoding-time logits perturbation makes the teacher follow the ICW instruction, and the student is trained to match the teacher's output distribution. The second stage applies reinforcement learning with the automatic verifier as the reward. Applied to Qwen3-14B and GPT-OSS-20B, our method raises average TPR@1%FPR across three ICW instructions from 0.100 to 0.974 and from 0.337 to 0.968, respectively, while maintaining high response quality under both perplexity evaluation and LLM-as-a-Judge. Our code is available at \url{https://github.com/yepengliu/ICW-IF}.
BibTeX
@inproceedings{liu2026learning,
  author = {Yepeng Liu and Tianyi Chen and Xuandong Zhao and Dawn Song and Yuheng Bu},
  title = {{Learning to Follow In-Context Watermark Instructions via Self-Distillation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=iRs3boK4tO},
}
Figure