Abstract
Retrieval-Augmented Generation (RAG) is essential for grounding Large Language Models (LLMs) in factual context, but its transition to cloud-based services introduces significant privacy risks. Sensitive user queries can be reconstructed from vector embeddings using inversion attacks. We present RemoteRAG, a framework that enables private cloud-based RAG without sacrificing performance. By combining a novel $(n, \epsilon)$-Distance Differential Privacy mechanism to narrow the search space with partially homomorphic encryption for secure refinement, RemoteRAG achieves 100% retrieval recall with sub-second latency. Our results show that RemoteRAG is thousands of times faster than traditional cryptographic baselines, making it a practical solution for secure, real-time RAG services.
Introduction
Retrieval-Augmented Generation (RAG) has become the industry standard for reducing "hallucinations" in Large Language Models (LLMs) by providing them with factual context from external documents. However, as RAG moves to the cloud—often termed RAG-as-a-Service (RaaS)—a major privacy gap has emerged. To retrieve relevant documents, users must send their queries to a cloud provider. Even when queries are transmitted as vector embeddings, recent "embedding inversion" attacks like Vec2Text can reconstruct the original text with high fidelity, exposing sensitive health or financial data.
Existing cryptographic solutions, such as Fully Homomorphic Encryption (FHE), are far too computationally expensive for real-time applications, often taking hours to process a single request. RemoteRAG addresses this by providing a privacy-preserving framework that is both "lossless" in accuracy and efficient enough for production use.
The RemoteRAG Framework
RemoteRAG utilizes a two-module system to protect user queries while maintaining high performance.
Module 1: Range Limitation via $(n, \epsilon)$-DistanceDP
The core innovation of RemoteRAG is the use of high-dimensional geometry to safely narrow the search space. The user perturbs their query embedding locally using a new privacy definition called $(n, \epsilon)$-DistanceDP. This adds noise based on the Laplace distribution in $n$-dimensional space. The cloud uses this "noisy" query to identify a small candidate set of $k'$ documents. Theoretical proofs allow for the calculation of a $k'$ value that ensures the "true" top-$k$ documents are included in the set with high probability.
Module 2: Secure Refinement
Once the search range is limited, the system performs exact retrieval using cryptographic techniques:
- Partially Homomorphic Encryption (PHE): The user sends an encrypted version of the original embedding. PHE allows the cloud to calculate cosine distances on encrypted data for the small candidate set without seeing the real query.
- Oblivious Transfer (OT): In cases where document indices might leak information, an OT protocol allows the user to download documents without the cloud knowing which specific ones were selected.
Experimental Evaluation
The researchers evaluated RemoteRAG using the MS MARCO dataset, a standard benchmark for information retrieval. They constructed 15 different vector databases using five popular embedding models, including open-source models like all-mpnet-base-v2 and proprietary models like OpenAI’s text-embedding-3-large.
Key Results and Performance
RemoteRAG achieved 100% recall across all tested settings, meaning it never missed a relevant document due to the added noise. This "lossless" property is a significant advantage over typical Differential Privacy systems that trade off accuracy for privacy.
In terms of speed, RemoteRAG processed queries in just 0.67 seconds for a database of 1 million documents. Compared to a privacy-conscious baseline using standard cryptographic methods—which took 2.72 hours and required 1.43 GB of data transfer—RemoteRAG reduced data transmission to just 46.66 KB.
Security Analysis
The system successfully resisted the Vec2Text inversion attack. As the privacy budget ($\epsilon$) decreased (increasing noise), the attack's SacreBLEU score (a measure of reconstruction quality) dropped from 50 to near-zero, demonstrating robust protection against state-of-the-art reconstruction techniques.
Conclusion and Future Work
RemoteRAG demonstrates that cloud-based RAG can be made private without sacrificing the speed or accuracy required for modern applications. By leveraging the geometric properties of high-dimensional spaces, the framework avoids the heavy computational costs of full encryption on large datasets. Future work will focus on expanding support for more complex similarity metrics and integrating private keyword-based search.
Summary updated