In-Context Watermarks for Large Language Models

Yepeng Liu, Xuandong Zhao, Christopher Kruegel, Dawn Song, Yuheng Bu

The Challenge of Black-Box Watermarking

As Large Language Models (LLMs) become increasingly integrated into sensitive workflows, the ability to detect AI-generated text is paramount for ensuring accountability. However, most existing watermarking techniques are "in-process"—they require the model owner to modify the decoding stage or access internal logits and sampling distributions.

This creates a significant blind spot in real-world applications. Consider a conference organizer trying to determine if a reviewer used an LLM to write a peer review. The organizer cannot force proprietary API providers like OpenAI or Google to watermark their outputs. To address this "black-box" challenge, researchers have introduced In-Context Watermarking (ICW), a novel approach that embeds detectable patterns directly through prompt engineering, leveraging the LLM's own instruction-following capabilities.

Methodology: In-Context Watermarking (ICW)

ICW bypasses the need for model internals by instructing the LLM to embed specific signals into its output. The researchers explored two primary deployment settings:

  1. Direct Text Stamp (DTS): The watermarking instruction is explicitly provided in the system prompt.
  2. Indirect Prompt Injection (IPI): The instruction is covertly hidden within an input document (e.g., "white text" in a PDF manuscript) so that the LLM unknowingly follows the rule when processing the file.
Overview of the In-Context Watermarking process using the Acrostics strategy.

To execute these watermarks, the paper introduces four ICW strategies of varying complexity:

  • Unicode ICW: The model is instructed to insert invisible zero-width spaces (U+200B) after every word. While imperceptible to readers, it is easily stripped by basic text cleaning.
  • Initials ICW: The model is encouraged to use words starting with a specific "green list" of letters.
  • Lexical ICW: The prompt provides a list of specific "green words" (adjectives, adverbs, verbs) and instructs the model to maximize their usage.
  • Acrostics ICW: The most sophisticated method, requiring the first letter of every sentence to follow a secret, pre-defined string (e.g., spelling out a specific code).

The "Trapping" Mechanism: Indirect Prompt Injection

The Indirect Prompt Injection (IPI) setting serves as a powerful proof-of-concept for accountability, particularly in academic peer review.

By embedding invisible instructions within a submitted manuscript, a creator or system administrator can "trap" anyone who uses an LLM to process that document. When a dishonest reviewer uploads the paper to an LLM and asks for a summary or critique, the model reads the hidden instruction and generates a review carrying the watermark. The conference organizers can then run a detector over the submitted reviews to catch the AI-generated text.

The Indirect Prompt Injection (IPI) setting applied to an academic peer-review system.

Key Findings and Results

The researchers tested these methods across datasets like ELI5 (for long-form explanations) and ICLR Papers (for the peer-review case study), yielding several critical insights:

  • Intelligence is the Enabler: The effectiveness of ICW is directly tied to the model's reasoning capabilities. While less capable models like GPT-4o-mini struggled with complex instructions like Acrostics, advanced models like GPT-o3-mini followed the instructions almost perfectly.
  • High Detection Accuracy: Using statistical detection methods (like z-statistics for Initials and Lexical ICW), the detectors could perfectly distinguish between watermarked and human text, achieving a ROC-AUC of nearly 1.0 with GPT-o3-mini.
  • Robustness to Attacks: The Initials, Lexical, and Acrostics methods demonstrated strong resistance to "paraphrase attacks." Even when a secondary LLM was used to rewrite the watermarked text, the underlying signal often remained strong enough for detection.
  • Quality Preservation: Using an "LLM-as-a-Judge" evaluation (Gemini-2.0-Flash), the authors found that watermarked text scored nearly as high as unwatermarked text in relevance, clarity, and overall quality, proving the watermark remains imperceptible to the average reader.

Limitations and Future Directions

While highly effective on state-of-the-art models, ICW is inherently model-dependent. If an LLM is "lazy" or possesses poor instruction-following capabilities (common in older or smaller open-source models), the watermark will fail to embed correctly.

Additionally, the methods are vulnerable to awareness; if an attacker knows the specific "green list" being used for Lexical or Initials ICW, they can easily spoof the watermark or intentionally scrub those words. The Unicode method, while the easiest for models to execute, is also highly fragile and easily defeated by pasting text into basic editors.

Moving forward, the authors suggest exploring more advanced prompt engineering techniques—such as chain-of-thought reasoning—to better balance the trade-off between text quality, instruction adherence, and watermark robustness. As LLMs continue to grow more capable, In-Context Watermarking offers a highly promising, scalable, and accessible direction for AI content attribution.

Summary updated

BibTeX
@inproceedings{liu2026context,
  author = {Yepeng Liu and Xuandong Zhao and Christopher Kruegel and Dawn Song and Yuheng Bu},
  title = {{In-Context Watermarks for Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=fD9YRHazW3},
}
Figure