Journal Article
Knowledge Graphs

RAGCache: Efficient Knowledge Caching for Retrieval-Augmented Generation

Chao Jin(Peking University), Zili Zhang(Peking University), Xuanlin Jiang(Peking University), Fangyue Liu(Peking University), Shufan Liu(University of Siedlce), Xuanzhe Liu(Peking University), Xin Jin(Peking University)
September 20, 2025ACM Transactions on Computer Systems133 citations

133

Citations

17

Influential Citations

ACM Transactions on Computer Systems

Venue

2025

Year

Abstract

Retrieval-Augmented Generation (RAG) has demonstrated substantial advancements in various natural language processing tasks by integrating the strengths of large language models (LLMs) and external knowledge databases. However, the retrieval step introduces long sequence generation and extra data dependency, resulting in long end-to-end latency. Our analysis benchmarks current RAG systems and reveals that, while the retrieval step poses performance challenges, it also offers optimization opportunities through its retrieval pattern and streaming search behavior. We propose RAGCache, a latency-optimized serving system tailored for RAG. RAGCache leverages the retrieval pattern to organize and cache the intermediate states of retrieved knowledge in a knowledge tree across the GPU and host memory hierarchy, reducing LLM generation time. RAGCache employs dynamic speculative pipelining to exploit the streaming search behavior, overlapping retrieval with LLM generation to minimize end-to-end latency. We implement RAGCache based on vLLM and Faiss, and evaluate it on both open-source and production datasets. Experimental results demonstrate that RAGCache reduces the time to first token (TTFT) by up to 4× and improves the throughput by up to 2.1× compared to vLLM integrated with Faiss.

Analysis

Why This Paper Matters

Retrieval-Augmented Generation (RAG) has become a cornerstone for integrating external knowledge into large language models, but its practical deployment is hampered by high latency due to long sequence generation and retrieval dependencies. This paper identifies that while retrieval introduces performance challenges, it also offers unique optimization opportunities through its retrieval pattern and streaming search behavior. By addressing these, RAGCache provides a systematic solution to reduce end-to-end latency, which is crucial for real-time applications like chatbots and question answering.

The significance is underscored by the growing adoption of RAG in industry. As models scale and knowledge bases expand, the latency bottleneck becomes more pronounced. RAGCache's approach of caching intermediate states and overlapping retrieval with generation is a novel contribution that could influence future RAG serving architectures.

Technical Contributions

  • Knowledge Tree Caching: RAGCache organizes retrieved knowledge into a tree structure, caching intermediate states (e.g., KV caches) across GPU and host memory. This reduces redundant computation during generation, as common prefixes in retrieved documents are reused.
  • Dynamic Speculative Pipelining: This technique exploits the streaming nature of retrieval to overlap retrieval with LLM generation. By speculatively starting generation on partial retrieval results, it hides retrieval latency.
  • Implementation on vLLM and Faiss: The system is built on popular open-source tools, ensuring practical applicability and ease of adoption.
  • Memory Hierarchy Optimization: By placing caches appropriately across GPU and host memory, RAGCache balances speed and capacity, addressing memory constraints.

Results

The evaluation on both open-source and production datasets shows that RAGCache reduces time to first token (TTFT) by up to 4× and improves throughput by up to 2.1× compared to a baseline of vLLM integrated with Faiss. These gains are substantial, indicating that the caching and pipelining strategies effectively mitigate the latency overhead of retrieval.

Significance

RAGCache addresses a critical bottleneck in RAG serving, making it more viable for latency-sensitive applications. Its techniques could be extended to other retrieval-augmented systems and inspire further research in caching and pipelining for LLM inference. The work also highlights the importance of co-designing retrieval and generation for end-to-end performance, a direction likely to gain traction as RAG becomes more prevalent.