TurboRAG: Accelerating Retrieval-Augmented Generation with Precomputed KV Caches for Chunked Text

Songshuo Lu, Hua Wang, Yutian Rong, Zhi Chen, Yaohua Tang
10/10/2024
cs.CVcs.CL

No official code found. Best implementation: MooreThreads/TurboRAG (102 stars, last commit 2024-11-25).

Abstract

Current Retrieval-Augmented Generation (RAG) systems concatenate and process numerous retrieved document chunks for prefill which requires a large volume of computation, therefore leading to significant latency in time-to-first-token (TTFT). To reduce the computation overhead as well as TTFT, we introduce TurboRAG, a novel RAG system that redesigns the inference paradigm of the current RAG system by first pre-computing and storing the key-value (KV) caches of documents offline, and then directly retrieving the saved KV cache for prefill. Hence, online computation of KV caches is eliminated during inference. In addition, we provide a number of insights into the mask matrix and positional embedding mechanisms, plus fine-tune a pretrained language model to maintain model accuracy of TurboRAG. Our approach is applicable to most existing large language models and their applications without any requirement in modification of models and inference systems. Experimental results across a suite of RAG benchmarks demonstrate that TurboRAG reduces TTFT by up to 9.4x compared to the conventional RAG systems (on an average of 8.6x), but reserving comparable performance to the standard RAG systems.

View on arXivView PDF

Code Implementations(1)

10211PythonOct 11, 20241 years ago

Similar Papers

Cite this paper

@article{lu2024turborag,
  title  = {TurboRAG: Accelerating Retrieval-Augmented Generation with Precomputed KV Caches for Chunked Text},
  author = {Songshuo Lu and Hua Wang and Yutian Rong and Zhi Chen and Yaohua Tang},
  year   = {2024},
  eprint = {2410.07590},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.07590v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.07590.svg)](https://codeofpaper.com/paper/2410.07590)

Discussion