arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2502.15734cs.DCcs.AIcs.CLcs.LGcs.OS
收藏

Cache-Craft:面向高效检索增强生成的分块缓存管理

Cache-Craft: Managing Chunk-Caches for Efficient Retrieval-Augmented Generation

Adobe Research(奥多比研究院);IIT Bombay(印度理工学院孟买分校);IIT Kanpur(印度理工学院坎普尔分校)

Shubham Agarwal, Sai Sundaresan, Subrata Mitra, Debabrata Mahapatra, Archit Gupta, Rounak Sharma, Nirmal Joshua Kapu, Tong Yu, Shiv Saini

AI总结:

Cache-Craft通过识别可重用分块缓存、部分重计算修复及高效存储驱逐策略,在RAG中减少冗余KV计算,相比前缀缓存降低51%计算量并提升1.6倍吞吐量。

摘要:

检索增强生成(RAG)常与大型语言模型(LLMs)结合使用,以注入领域知识或用户特定信息。在RAG中,给定用户查询,检索器从知识库中提取相关文本块。这些文本块作为输入提示的一部分发送给LLM。通常,任何给定的文本块会在不同用户问题中被重复检索。然而,目前对于每个问题,LLM中的注意力层会针对输入文本块重复计算键值(KVs),因为最先进的方法无法在文本块出现在任意位置且带有任意上下文时重用KV缓存。朴素的重用会导致输出质量下降。这导致了在昂贵的GPU上可能存在的冗余计算,并增加了延迟。在这项工作中,我们提出了Cache-Craft,一个用于在基于RAG的系统中管理和重用与文本块对应的预计算KVs(我们称之为分块缓存)的系统。我们展示了如何识别可重用的分块缓存,如何高效地执行一小部分重计算来修复缓存以保持输出质量,以及如何在硬件中高效地存储和驱逐分块缓存,以最大化重用同时掩盖任何开销。通过真实生产工作负载以及合成数据集,我们表明Cache-Craft相比最先进的前缀缓存减少了51%的冗余计算,相比完全重计算减少了75%。此外,在真实生产工作负载上使用连续批处理,我们在LLaMA-3-8B和LLaMA-3-70B模型上,相比前缀缓存获得了1.6倍的吞吐量提升和2倍的端到端响应延迟降低,同时保持质量。

英文摘要:

Retrieval-Augmented Generation (RAG) is often used with Large Language Models (LLMs) to infuse domain knowledge or user-specific information. In RAG, given a user query, a retriever extracts chunks of relevant text from a knowledge base. These chunks are sent to an LLM as part of the input prompt. Typically, any given chunk is repeatedly retrieved across user questions. However, currently, for every question, attention-layers in LLMs fully compute the key values (KVs) repeatedly for the input chunks, as state-of-the-art methods cannot reuse KV-caches when chunks appear at arbitrary locations with arbitrary contexts. Naive reuse leads to output quality degradation. This leads to potentially redundant computations on expensive GPUs and increases latency. In this work, we propose Cache-Craft, a system for managing and reusing precomputed KVs corresponding to the text chunks (we call chunk-caches) in RAG-based systems. We present how to identify chunk-caches that are reusable, how to efficiently perform a small fraction of recomputation to fix the cache to maintain output quality, and how to efficiently store and evict chunk-caches in the hardware for maximizing reuse while masking any overheads. With real production workloads as well as synthetic datasets, we show that Cache-Craft reduces redundant computation by 51% over SOTA prefix-caching and 75% over full recomputation. Additionally, with continuous batching on a real production workload, we get a 1.6X speed up in throughput and a 2X reduction in end-to-end response latency over prefix-caching while maintaining quality, for both the LLaMA-3-8B and LLaMA-3-70B models.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑