arXiv:2503.05530cs.DBcs.LG2025-03中稿 · Middleware '25被引 4

用相似查询复用文档,让大模型问答更快更省

Leveraging Approximate Caching for Faster Retrieval-Augmented Generation

  • 基于查询相似性复用历史文档,减少向量库查询次数
  • 在MedRAG上减少77.2%数据库调用,准确率不变
  • 缓存耗时恒定仅4.8微秒,适合大规模部署

检索增强生成(RAG)通过引入外部知识提升大语言模型回答的可靠性,但其推理时间因需从大型向量数据库中查找相关文档而显著增加。为解决此问题,我们提出Proximity,一种基于相似查询复用的近似键值缓存机制。该方法不将每个查询独立处理,而是利用查询间的相似性复用先前检索到的文档,大幅降低对昂贵向量数据库查询的依赖。Proximity采用局部敏感哈希(LSH)方案,实现快速缓存查找并保持检索准确性。我们在MMLU和MedRAG问答基准上评估,结果表明,在真实偏斜的MedRAG工作负载下,使用我们的LSH方案可使数据库调用减少77.2%,同时维持数据库召回率与测试准确率。不同相似度容忍度与缓存容量实验显示,即使缓存规模显著扩大,Proximity缓存内耗时仍保持稳定在4.8微秒。结果证明,近似缓存是优化RAG系统的一种高效实用策略。

原文摘要 · Abstract (English)

Retrieval-augmented generation (RAG) improves the reliability of large language model (LLM) answers by integrating external knowledge. However, RAG increases the end-to-end inference time since looking for relevant documents from large vector databases is computationally expensive. To address this, we introduce Proximity, an approximate key-value cache that optimizes the RAG workflow by leveraging similarities in user queries. Instead of treating each query independently, Proximity reuses previously retrieved documents when similar queries appear, substantially reducing the reliance on expensive vector database lookups. To efficiently scale, Proximity employs a locality-sensitive hashing (LSH) scheme that enables fast cache lookups while preserving retrieval accuracy. We evaluate Proximity using the MMLU and MedRAG question-answering benchmarks. Our experiments demonstrate that Proximity with our LSH scheme and a realistically-skewed MedRAG workload reduces database calls by 77.2% while maintaining database recall and test accuracy. We experiment with different similarity tolerances and cache capacities, and show that the time spent within the Proximity cache remains low and constant (4.8 microseconds) even as the cache grows substantially in size. Our results demonstrate that approximate caching is a practical and effective strategy for optimizing RAG-based systems.

RAG优化缓存机制向量检索大模型推理

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。