TL;DR
$p^2$RAG is a privacy-preserving Retrieval-Augmented Generation (RAG) framework that replaces slow, secure sorting algorithms with an efficient interactive bisection method. By finding a distance threshold rather than sorting every document, it achieves 3–300× speedups over current state-of-the-art systems while supporting the large retrieval sets ($k$) required by modern long-context LLMs.
What Problem Does This Paper Address?
Retrieval-Augmented Generation (RAG) is the standard way to give Large Language Models (LLMs) access to private or up-to-date data. However, when a company outsources its RAG service to a cloud provider, two major privacy risks emerge:
- Data Privacy: The provider could see the proprietary database.
- Query Privacy: The provider could see the user’s private prompts.
Existing "Privacy-Preserving RAG" (PPRAG) systems try to solve this using secure multi-party computation (MPC), but they usually rely on secure sorting to find the top-$k$ most relevant documents. Secure sorting is computationally "heavy." As $k$ increases—which is necessary for modern LLMs that thrive on large context windows—these systems become painfully slow or fail to support dynamic changes to $k$.
Methods
The core innovation of $p^2$RAG is moving away from sorting. Instead, the authors treat retrieval as a threshold problem solved via an interactive bisection (binary search) between the user and the servers.
The Architecture
The system uses a two-server model (two semi-honest, non-colluding servers). The data owner secret-shares their document embeddings across these two servers. Neither server can see the actual data.
The $p^2$RAG Workflow:
- Secure Dot Product: When a user sends a query, the servers compute the similarity (dot product) between the encrypted query and the encrypted database.
- Interactive Bisection: Instead of sorting the results, the user and servers interactively search for a distance threshold ($d_k$). In each round, the servers tell the user how many documents fall within a certain distance. The user then adjusts the threshold until they find a value that captures approximately $k$ documents.
- Distributed Comparison Functions (DCFs): To count documents without revealing which ones match, the system uses DCFs—a cryptographic primitive that allows servers to evaluate comparisons on secret-shared data.
- Verification: To prevent a malicious user from "probing" the database to extract information, the servers enforce limits on the number of bisection iterations and verify that the final number of retrieved documents is within a "slack" range ($k$ to $k+\xi$).
- Private Retrieval: Once the indices are identified, the user retrieves the actual text using Single-server Private Information Retrieval (PIR).
Datasets
The authors evaluated $p^2$RAG using:
- BEIR trec-covid: A standard retrieval benchmark containing 171,332 documents. They used precomputed embeddings from
Cohere/beir-embed-english-v3. - Synthetic Datasets: Used to test scalability up to $N=2^{20}$ (over 1 million documents) and $k$ values up to 1024.
Key Insights and Ideas
- Sorting is Overkill: In RAG, the LLM doesn't care if the $k$ documents are perfectly sorted; it just needs the most relevant set. By switching from sorting to bisection, the complexity shifts from being dominated by $k$ to being dominated by the number of bisection steps (logarithmic relative to the distance range).
- Embracing "Slack": The authors introduce a slack value ($\xi$). If the bisection finds $k+5$ documents instead of exactly $k$, the system stops. Because modern LLMs have huge context windows (e.g., 128k tokens), retrieving a few extra documents doesn't hurt performance but significantly speeds up the cryptographic protocol.
- Bounded Leakage: The paper provides a rigorous analysis of "physical leakage." While the user learns the count of documents at different thresholds during the bisection, the authors prove this leakage is minimal ($O(\log^2 N)$) and does not identify specific documents.
Key Results
- Massive Speedups: Compared to PRAG (the previous state-of-the-art), $p^2$RAG is 3× faster for small $k$ (16) and up to 300× faster for large $k$ (1024).
- Efficiency with Scale: For a database of ~131k documents ($N=2^{17}$) and $k=16$, the server time is roughly 0.2 seconds. Even at $N=2^{20}$ (1 million documents), it remains highly performant.
- Accuracy: The system achieves a recall of 1, meaning the cryptographic quantization and integer math do not introduce errors compared to standard plaintext retrieval.
- Communication: User-to-server communication is very light (e.g., ~2MB for $N=2^{17}$), making it practical for real-world network conditions.
Limitations and Future Work
- Non-Collusion Assumption: Like most two-server MPC systems, security relies on the two servers not talking behind the user's back. If they collude, all privacy is lost.
- Trusted Dealer: The system currently requires a "trusted dealer" to generate some cryptographic keys during an offline phase. While the data owner can often act as this dealer, moving to a completely dealer-free setup would be a logical next step.
- PIR Overhead: While the retrieval of indices is lightning-fast, the final step of retrieving the actual text via PIR still carries its own overhead, which the authors assume is handled by existing, separate protocols.
Summary updated