Ward: Provable RAG Dataset Inference via LLM Watermarks

Nikola Jovanovic, Robin Staab, Maximilian Baader, Martin T. Vechev

TL;DR

WARD is a new framework that allows data owners to prove—with rigorous statistical guarantees—whether their private datasets are being used in a third-party Retrieval-Augmented Generation (RAG) system. By proactively watermarking their documents, owners can detect "leaked" signals in the RAG system's responses, even when the provider tries to hide the data's origin or when the same information exists in multiple documents.

What Problem Does This Paper Address?

Retrieval-Augmented Generation (RAG) allows Large Language Models (LLMs) to answer questions using external, up-to-date data. While powerful, this creates a massive copyright and privacy headache: RAG providers often scrape the web for data without the owner's permission.

The authors identify a specific challenge called RAG Dataset Inference (RAG-DI). Unlike standard Membership Inference Attacks (which check if data was used to train a model), RAG-DI aims to detect if a specific dataset is currently sitting in a RAG system's retrieval corpus.

This is difficult because:

  1. Black-box access: You can only interact with the RAG system via queries and responses.
  2. Fact Redundancy: In the real world, the same news story or fact might appear in dozens of different documents. If a RAG system answers a question correctly, is it using your document or someone else's?
  3. Evasion: RAG providers can instruct their models to paraphrase or "not regurgitate" sources to hide their tracks.

Methods

The paper introduces WARD (Watermarking for RAG-DI), a proactive detection method.

  1. Proactive Watermarking: Before publishing their data, the owner rephrases their documents using an LLM that applies a "red-green" watermark. This technique biases the model to choose specific "green" tokens based on the preceding text, creating a hidden statistical signature that is invisible to humans but detectable by algorithms.
  2. The Audit: To check a RAG system, the data owner sends a series of questions that would trigger the retrieval of their documents.
  3. Signal Propagation: If the RAG system retrieves a watermarked document, that document enters the LLM's context window. Even if the LLM paraphrases the info, the "green" token bias from the source text often "leaks" into the generated response.
  4. Provable Detection: WARD aggregates the watermark signal across multiple queries to calculate a joint p-value. This provides a mathematical guarantee (e.g., "there is a $10^{-12}$ chance this happened by accident") that the dataset is present.

The authors also propose a simple baseline called FACTS, which uses an auxiliary LLM to generate questions that are only answerable if the model has read the specific document in question.

Datasets

The authors argue that existing privacy datasets (like Enron emails) are poorly suited for RAG-DI because they might already be in the LLM's training data. To fix this, they introduced:

  • FARAD (Fact-Redundant Article Dataset): A novel benchmark consisting of fictional articles about imaginary entities and events.
  • Fact Redundancy: It groups articles that share the same core facts but are written by different "authors" (different LLMs).
  • Easy vs. Hard Settings: In the "Easy" setting, facts are unique to one document. In the "Hard" setting, the RAG corpus contains multiple documents containing the same facts, making it much harder to prove which specific one was used.

Key Insights and Ideas

  • Watermarks are more robust than facts: Traditional detection methods fail when multiple documents contain the same information. WARD succeeds because it doesn't just look for what the model knows, but the statistical signature of how the information was retrieved.
  • The "Leakage" Effect: One of the most interesting findings is that the watermark signal survives the RAG pipeline. Even though the final LLM isn't "watermarked" itself, the presence of watermarked text in its input context influences its output distribution.
  • Defense-Awareness: The authors tested "Defense Prompts" where the RAG system is explicitly told "do not repeat sources verbatim." While this kills simple overlap-based detection, the watermark signal is subtle enough to persist through heavy paraphrasing.
  • Monotonicity: WARD exhibits a "the more you look, the more you see" property. As the number of queries increases, the confidence in the detection grows consistently, unlike other methods that can become noisier with more data.

Key Results

  • 100% Accuracy: In the "Hard" FARAD setting (with high fact redundancy), WARD achieved 100% accuracy across various LLMs (GPT-3.5, Claude 3, Llama 3), while all other baselines failed to provide reliable results.
  • Efficiency: WARD is highly query-efficient. For most models, perfect detection was achieved with fewer than 80 queries.
  • Cost-Effective: The authors estimate the API cost to audit a RAG system using WARD is less than $2.00 per model.
  • Statistical Rigor: WARD provides p-values that are orders of magnitude below standard significance levels (often reaching $10^{-50}$ or lower), making the evidence practically indisputable in a legal or policy context.

Limitations and Future Work

  • Proactive Requirement: WARD only works if you watermark your data before it is scraped. It cannot help with data that has already been taken.
  • Retrieval Dependency: If a RAG system's retrieval mechanism is so poor that it never picks up the owner's document, WARD cannot detect it. However, the authors show that even with "imperfect" retrieval, WARD remains highly effective.
  • Watermark Scrubbing: While WARD is robust to paraphrasing, a RAG provider could theoretically attempt to "scrub" watermarks if they knew exactly which scheme was being used. The authors suggest that future work should explore more "stealthy" or diverse watermarking schemes to stay ahead of such countermeasures.

Summary updated

BibTeX
@inproceedings{jovanovic2025ward,
  author = {Nikola Jovanovic and Robin Staab and Maximilian Baader and Martin T. Vechev},
  title = {{Ward: Provable RAG Dataset Inference via LLM Watermarks}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=kVrwHLAb20},
}
Figure