TL;DR
Retrieval-Augmented Generation (RAG) systems face severe privacy risks when external databases contain sensitive information. This paper reveals that privacy risk is inherently dynamic and query-dependent, and proposes PA-HDP (Prompt-Aware Dynamic Hierarchical Differential Privacy), a framework that dynamically assesses query-driven risks to apply tailored, sentence-level differential privacy protection, optimizing the trade-off between data privacy and text utility.
What Problem Does This Paper Address?
Retrieval-Augmented Generation (RAG) connects Large Language Models (LLMs) to external databases to provide up-to-date and factual responses. However, if the database contains sensitive data—like medical records or personally identifiable information (PII)—the retrieved context can easily leak to users through direct reproduction or clever prompting.
Existing privacy-preserving RAG methods treat privacy risks as static and document-level, assuming every document carries a uniform risk. The authors argue this is a fundamental flaw. Privacy risk in RAG is highly dynamic and depends entirely on the user's query. For example, if a document contains a company's financial overview alongside employee names:
- A query asking to "summarize the company's cultural philosophy" poses almost zero privacy risk.
- A query asking to "list the names and contact information of employees" poses a severe risk.
Static methods over-perturb documents regardless of the query, severely degrading the utility of the text. This paper addresses the challenge of providing robust privacy guarantees without unnecessarily destroying the semantic quality of retrieved information.
Methods
The authors introduce PA-HDP (Prompt-Aware Dynamic Hierarchical Differential Privacy), which protects data at the sentence level (Basic Privacy Units, or PUs) through three main stages:
- Prompt-Aware Risk Assessment: When a query arrives and documents are retrieved, the system uses a two-dimensional risk model. It calculates risk-aware semantic relevance (how likely the query is to extract sensitive data) and field sensitivity (the inherent risk of entities in the text, like ID numbers vs. dates). These are fused into a comprehensive risk score, and Laplace noise is added to satisfy differential privacy constraints. Sentences are then classified into Low, Medium, or High risk.
- Candidate Text Generation: For sentences requiring protection, the framework generates a set of semantically equivalent candidates by replacing sensitive entities with random alternatives of the same category from a pre-constructed sanitized corpus.
- Hierarchical DP Protection via Exponential Mechanism: A composite utility function evaluates candidates based on semantic preservation and residual privacy risk. The Semantic Exponential Mechanism then privately selects the optimal sanitized sentence. High-risk sentences receive a stricter privacy budget ($\epsilon_H$), medium-risk sentences get a relaxed budget ($\epsilon_M$), and low-risk sentences are left untouched to preserve maximum utility.
Datasets
The framework was evaluated across two distinct privacy-sensitive scenarios:
- HealthcareMagic-101: A real-world dataset consisting of 200,000 doctor-patient medical dialogues used to simulate medical RAG applications.
- Wiki-PII: A synthetic dataset constructed by the authors to simulate public data contaminated with private information. They embedded real PII fragments (emails, phone numbers) from the private Enron Mail dataset into the public WikiText-103 corpus. This was benchmarked against four open-domain question-answering tasks: Natural Questions (NQ), TriviaQA (TQA), Web Questions (WQ), and CuratedTrec (CT).
Key Insights and Ideas
- Query-Driven Privacy is Essential: Moving from static document-level masking to dynamic query-dependent perturbation prevents the "over-sanitization" of data, keeping harmless context intact.
- Sentence-Level Granularity Wins: Processing text at the sentence level allows the system to isolate and protect only the truly vulnerable parts of a document, preserving the surrounding factual structure.
- Isomorphic Entity Replacement: Replacing sensitive entities with structurally identical alternatives (e.g., swapping one name for another) maintains the grammatical and semantic integrity of the text, allowing downstream LLMs to reason effectively.
Key Results
PA-HDP achieves a superior privacy-utility trade-off compared to state-of-the-art baselines like LPRAG, SAGE, and ZeroGen.
- Utility Retention: On the HealthcareMagic dataset using GPT-3.5, PA-HDP achieved a BLEU score of 0.3275 and a ROUGE-L score of 0.3445, significantly outperforming pure generation or local differential privacy baselines.
- Robust Defense Against Attacks: In evaluation against both targeted and untargeted extraction attacks (where an adversary explicitly prompts the model to leak context), PA-HDP consistently achieved zero leakage across all datasets and model backbones (GPT-3.5 and Llama3-8B-Chat).
Limitations and Future Work
The primary limitation acknowledged by the authors is that PA-HDP assumes a fixed privacy budget ($\epsilon$) predetermined before deployment. In real-world production systems, users send continuous, multi-turn queries. As queries accumulate, the total privacy budget can be gradually exhausted.
The authors note that future work will focus on developing adaptive privacy budget allocation and advanced privacy accounting mechanisms to support long-term, multi-turn RAG deployments without compromising mathematical privacy guarantees.
Summary updated