Differentially Private Retrieval-Augmented Generation

Tingting Tang, James Flemings, Yongqin Wang, Murali AnnavaramarXiv 2026

TL;DR

Retrieval-Augmented Generation (RAG) helps large language models (LLMs) stay factually accurate, but it risks leaking sensitive information from the underlying database. This paper introduces DP-KSA, a framework that applies Differential Privacy (DP) to a compressed, low-dimensional keyword subspace extracted from an ensemble of LLM responses. By privately selecting only the most essential keywords to guide the final answer, DP-KSA provides strong mathematical privacy guarantees for the database while maintaining high text utility.

What Problem Does This Paper Address?

Retrieval-Augmented Generation (RAG) is a powerful pattern: when a user asks a question, the system fetches relevant documents from an external database and feeds them to an LLM to generate an accurate, up-to-date response. However, if that database contains sensitive data—like proprietary legal documents or private medical records—RAG poses a massive privacy risk. Attackers can craft adversarial prompts designed to trick the LLM into regurgitating the private context verbatim.

Figure 1: Overview of the DP RAG problem setting. The ad- versarial bound illustrates what capabilities the adversary has. In this case, the adversary can only query the RAG sys- tem and access the answer. The generator model has been pre-trained on publicly available data, which the adversary has access to. However, we are not concerned about preserv- ing the privacy of the pre-training data.

To fix this, researchers turn to Differential Privacy (DP), the gold standard for ensuring that an algorithm's output doesn't reveal whether any single record was in the database. But applying DP to text generation is notoriously difficult. Because LLMs generate text token-by-token from vocabularies of 50,000+ words, the mathematical "output space" is astronomically large. Naively adding DP noise at every token step destroys the coherence of the text, leading to gibberish and severe utility degradation.

Methods

The authors overcome the high-dimensionality curse with a key insight: most question-answering tasks can be solved using just a few crucial keywords. Instead of privatizing an entire sentence, why not just privatize a small set of keywords?

They introduce DP-KSA (Differentially Private Keyword Subspace Augmentation), which operates in three distinct steps:

  1. Retrieval and Partitioning: The system retrieves the top-$N$ documents relevant to a query. It pairs each document individually with the query to create $N$ separate prompts.
  2. DP Keyword Extraction: The LLM generates a response for each of the $N$ prompts, creating an ensemble of answers. The framework counts the frequencies of all tokens across these responses to build a histogram. It then uses a two-stage private selection process:
  3. FindBestK: Uses the Exponential Mechanism to adaptively determine the optimal number of keywords ($\hat{k}$) to extract.
  4. TopKWithPTR: Uses the Propose-Test-Release (PTR) paradigm to check if the gap between the top keywords is large enough to safely release them without breaching privacy. If it passes, the top-$\hat{k}$ keywords are released.
  5. Zero-Shot Inference: Finally, the original query and the privately released keywords are combined into a final prompt. The LLM uses this sparse, safe context to generate the final, clean response.
The three-step DP-KSA framework: Retrieval/Partitioning, DP Keyword Extraction, and Zero-Shot Inference.

Datasets

The authors evaluated their approach using:

  • Natural Questions (NQ): A benchmark of real Google search queries.
  • Trivia Question-Answering (TQA): A dataset of trivia questions paired with multiple reference answers.
  • Wikipedia Corpus: Used as the external private database (consisting of 21 million passages), indexed using Dense Passage Retrieval (DPR) and FAISS.

They tested the framework across three modern instruction-tuned models: Qwen 2.5 (3B), Llama 3.2 (3B), and Llama 3.1 (8B).

Key Insights and Ideas

  • The Power of Keyword Compression: Ground-truth answers in popular QA datasets are heavily right-skewed, usually containing only 1 to 4 tokens. Mapping the RAG problem into a low-dimensional keyword space makes applying differential privacy mathematically viable without ruining utility.
  • Noise as a Regularizer: In a surprising twist, DP-KSA ($\epsilon=5$) occasionally outperformed the non-private keyword baseline ($\epsilon=\infty$). The authors hypothesize that the stochastic noise introduced by DP acts as a form of regularization, preventing the model from overfitting to dominant but uninformative tokens.
  • Larger Models are More Robust to Privacy Noise: Moving from 3B parameter models to the 8B Llama model yielded higher absolute scores and better robustness. Larger models possess stronger instruction-following capabilities, making them much better at reconstructing full, fluent answers from sparse keyword cues.

Key Results

The framework was evaluated using standard text metrics (F1, ROUGE-1, ROUGE-L, and Levenshtein similarity) across various privacy budgets ($\epsilon$, where smaller means tighter privacy).

  • Strong Privacy-Utility Tradeoff: At moderate privacy levels ($\epsilon = 3$ or $5$), DP-KSA significantly outperformed the strictly private "non-RAG" baseline ($\epsilon=0$), proving that it successfully extracts useful knowledge from the database securely.
  • PTR Pass Rates: The Propose-Test-Release mechanism pass rate steadily improved as $\epsilon$ increased (less noise). TQA achieved higher pass rates than NQ because its answers are inherently more extractive and redundant, creating cleaner token histograms.
  • Ensemble Scaling: Performance steadily scales up as the number of document ensembles increases from 10 to 80, after which the gains plateau due to the introduction of redundant or irrelevant document noise.

Limitations and Future Work

While DP-KSA marks a major step forward for private RAG, the authors note a few limitations:

  1. Information Loss: Compressing an entire document ensemble into a handful of keywords inherently discards nuanced context, leaving a performance gap compared to standard, non-private RAG.
  2. Fixed Hyperparameters: The optimal number of ensembles (set to 80 in this paper) is currently fixed. Future work will explore adaptive schemes to dynamically adjust this based on the query.
  3. Scope of Privacy: DP-KSA specifically protects the external retrieval database. It assumes the base LLM parameters are safe and public. If the base LLM itself was pre-trained on private data, additional safeguards would be required.

Summary updated

BibTeX
@misc{tang2026differentially,
  author = {Tingting Tang and James Flemings and Yongqin Wang and Murali Annavaram},
  title = {{Differentially Private Retrieval-Augmented Generation}},
  year = {2026},
  eprint = {2602.14374},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.14374},
}
Figure