RAGCache: Efficient Knowledge Caching for Retrieval-Augmented Generation

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Jin, Chao, Zhang, Zili, Jiang, Xuanlin, Liu, Fangyue, Liu, Xin, Liu, Xuanzhe, Jin, Xin
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866909181144989696
author Jin, Chao
Zhang, Zili
Jiang, Xuanlin
Liu, Fangyue
Liu, Xin
Liu, Xuanzhe
Jin, Xin
author_facet Jin, Chao
Zhang, Zili
Jiang, Xuanlin
Liu, Fangyue
Liu, Xin
Liu, Xuanzhe
Jin, Xin
contents Retrieval-Augmented Generation (RAG) has shown significant improvements in various natural language processing tasks by integrating the strengths of large language models (LLMs) and external knowledge databases. However, RAG introduces long sequence generation and leads to high computation and memory costs. We propose RAGCache, a novel multilevel dynamic caching system tailored for RAG. Our analysis benchmarks current RAG systems, pinpointing the performance bottleneck (i.e., long sequence due to knowledge injection) and optimization opportunities (i.e., caching knowledge's intermediate states). Based on these insights, we design RAGCache, which organizes the intermediate states of retrieved knowledge in a knowledge tree and caches them in the GPU and host memory hierarchy. RAGCache proposes a replacement policy that is aware of LLM inference characteristics and RAG retrieval patterns. It also dynamically overlaps the retrieval and inference steps to minimize the end-to-end latency. We implement RAGCache and evaluate it on vLLM, a state-of-the-art LLM inference system and Faiss, a state-of-the-art vector database. The experimental results show that RAGCache reduces the time to first token (TTFT) by up to 4x and improves the throughput by up to 2.1x compared to vLLM integrated with Faiss.
format Preprint
id arxiv_https___arxiv_org_abs_2404_12457
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle RAGCache: Efficient Knowledge Caching for Retrieval-Augmented Generation
Jin, Chao
Zhang, Zili
Jiang, Xuanlin
Liu, Fangyue
Liu, Xin
Liu, Xuanzhe
Jin, Xin
Distributed, Parallel, and Cluster Computing
Computation and Language
Machine Learning
Retrieval-Augmented Generation (RAG) has shown significant improvements in various natural language processing tasks by integrating the strengths of large language models (LLMs) and external knowledge databases. However, RAG introduces long sequence generation and leads to high computation and memory costs. We propose RAGCache, a novel multilevel dynamic caching system tailored for RAG. Our analysis benchmarks current RAG systems, pinpointing the performance bottleneck (i.e., long sequence due to knowledge injection) and optimization opportunities (i.e., caching knowledge's intermediate states). Based on these insights, we design RAGCache, which organizes the intermediate states of retrieved knowledge in a knowledge tree and caches them in the GPU and host memory hierarchy. RAGCache proposes a replacement policy that is aware of LLM inference characteristics and RAG retrieval patterns. It also dynamically overlaps the retrieval and inference steps to minimize the end-to-end latency. We implement RAGCache and evaluate it on vLLM, a state-of-the-art LLM inference system and Faiss, a state-of-the-art vector database. The experimental results show that RAGCache reduces the time to first token (TTFT) by up to 4x and improves the throughput by up to 2.1x compared to vLLM integrated with Faiss.
title RAGCache: Efficient Knowledge Caching for Retrieval-Augmented Generation
topic Distributed, Parallel, and Cluster Computing
Computation and Language
Machine Learning
url https://arxiv.org/abs/2404.12457