Ward: Provable RAG Dataset Inference via LLM Watermarks

Nikola Jovanović, Robin Staab, Maximilian Baader, Martin Vechev

TL;DR

As Retrieval-Augmented Generation (RAG) systems increasingly scrape web data without permission, data owners lack reliable ways to prove copyright infringement. This paper introduces WARD, a proactive auditing method that embeds text watermarks into datasets to provably detect their unauthorized inclusion via black-box queries. Alongside WARD, the authors introduce FARAD, a realistic benchmark dataset that exposes how real-world "fact redundancy" causes existing detection methods to completely fail.

What Problem Does This Paper Address?

Retrieval-Augmented Generation (RAG) allows Large Language Models (LLMs) to answer user queries by pulling relevant documents from an external corpus. While powerful, this setup incentivizes RAG providers to indiscriminately scrape data, often ignoring copyright and data owners' opt-out preferences.

The authors formalize this challenge as RAG Dataset Inference (RAG-DI): how can a data owner prove their dataset was secretly included in a RAG corpus using only standard, black-box text queries?

Prior approaches, such as Membership Inference Attacks (MIAs), fail in realistic settings because they do not account for fact redundancy—the real-world reality that the same fact often appears across multiple scraped documents or news articles. If a RAG system answers a question correctly, standard baselines cannot tell whether it read the data owner's specific document or an identical fact from an authorized source.

Methods

The authors propose WARD (Watermarking for RAG-DI), a proactive defense pipeline:

  1. Watermarking: Before publishing, the data owner rephrases their documents using an LLM that embeds a standard "red-green" token watermark (biasing the model to select specific words).
  2. Auditing via Queries: To audit a suspicious RAG provider, the data owner generates open-ended, content-specific questions based on their documents and submits them to the RAG system.
  3. Signal Propagation & Aggregation: If the RAG provider has scraped the watermarked documents, the retrieval mechanism will feed them into the LLM context. Due to the robustness of text watermarks, these subtle token biases naturally leak into the RAG system's final generated response.

Because individual responses might only carry a faint watermark signal, WARD aggregates the token scores across multiple queries to compute a joint p-value, providing rigorous statistical proof of data misuse.

Figure 1: Overview of RAG Dataset Inference using WARD, our method based on LLM watermarks.

The authors also introduce a simple baseline called FACTS, which prompts an auxiliary LLM to generate highly specific questions that are uniquely answerable by reading the target document.

Datasets

The paper introduces FARAD (Fact-Redundant Article Dataset), a benchmark specifically tailored for RAG-DI evaluation. Existing privacy datasets (like EnronEmails) suffer from potential data contamination (the LLM may have seen them during pre-training) and lack fact redundancy.

FARAD circumvents this by using fictional entities and events from the RepLiQA dataset. It extracts core facts from a source and uses four distinct state-of-the-art LLMs (GPT-4o, Claude 3.5 Sonnet, Llama 3.1 405B, and Qwen 1.5 110B) to write unique articles based on those identical facts. This creates two evaluation settings:

  • FARAD-Easy: Contains no fact redundancy (only one article variation per fact group is in the corpus).
  • FARAD-Hard: Contains high fact redundancy (all four variations are present in the corpus), mimicking real-world web scraping.

Key Insights and Ideas

  • The Illusion of Easy Detection: Simple baselines like FACTS can easily solve the RAG-DI problem when there is no fact redundancy. However, when multiple documents share the same facts (the Hard setting), these baselines break down entirely, leading to severe false positive and false negative rates.
  • Watermarks Bypass Prompt Defenses: RAG providers often implement system prompts instructing the LLM to "never repeat sources verbatim" or "avoid direct quotes" to protect privacy. While these defenses successfully break similarity- and perplexity-based detection baselines, they do not stop the statistical token bias of WARD's watermarks from propagating into the output text.
  • Strength in Numbers: While a single RAG response might yield an inconclusive watermark trace, aggregating text across ~100 queries allows WARD to confidently reject the null hypothesis with virtually zero risk of falsely accusing an innocent provider.

Key Results

  • 100% Accuracy: WARD achieved perfect 100% detection accuracy across all evaluated target models (GPT-3.5, Claude 3 Haiku, Llama 3.1 70B) and system prompts in both the Easy and Hard settings.
  • Baseline Collapse: In the realistic Hard setting with fact redundancy, all existing baselines failed to perform consistently, frequently generating false accusations or missing data inclusion entirely.
Figure 4: Evaluation of all methods on FARAD in both Easy and Hard settings, and with both Naive-P and Def-P system prompts. We run each method with 5 random seeds, resulting in 5 squares. A red square indicates a false negative in the IN case, and a false positive in the OUT case. All methods perform well in the Easy setting, while only WARD consistently performs well in the Hard setting.
  • Query and Cost Efficiency: WARD is highly practical, requiring fewer than 100 queries to achieve full statistical confidence. This translates to an API cost of under $2 per audited model.

Limitations and Future Work

  • Proactive Requirement: WARD is strictly a proactive defense. It cannot help data owners detect the unauthorized use of datasets that have already been published without watermarks.
  • Small Dataset Constraints: If a data owner's dataset is very small (fewer than 100 documents), generating enough unique tokens to pass the statistical threshold becomes difficult unless they issue multiple distinct queries per document.
  • Advanced Countermeasures: While WARD proved robust against prompt defenses and token-blocking decoding strategies (like MEMFREE), the authors note that future work should explore its resilience against heavy post-processing defenses, such as running the entire RAG output through a separate, non-watermarked paraphrasing model.

Summary updated

BibTeX
@inproceedings{jovanovic2025ward,
  author = {Nikola Jovanović and Robin Staab and Maximilian Baader and Martin 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