arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2311.04934cs.CLcs.AI
收藏

Prompt Cache:用于低延迟推理的模块化注意力复用

Prompt Cache: Modular Attention Reuse for Low-Latency Inference

Yale University(耶鲁大学);Google(谷歌公司)

In Gim, Guojun Chen, Seung-seob Lee, Nikhil Sarda, Anurag Khandelwal, Lin Zhong

AI总结:

提出 Prompt Cache 方法,通过预计算和复用提示词模块的注意力状态,显著降低大语言模型推理的首个 token 延迟,无需修改模型参数即可提升性能。

摘要:

我们提出了 Prompt Cache,一种通过在不同 LLM 提示词之间复用注意力状态来加速大语言模型(LLM)推理的方法。许多输入提示词包含重叠的文本片段,如系统消息、提示词模板和作为上下文提供的文档。我们的核心见解是,通过在推理服务器上预计算并存储这些高频文本片段的注意力状态,当这些片段出现在用户提示词中时,我们可以高效地复用它们。Prompt Cache 采用一种模式来显式定义此类可复用文本片段,称为提示词模块。该模式确保了注意力状态复用时的位置准确性,并为用户提供了在其提示词中访问缓存状态的接口。我们使用原型实现,在多个 LLM 上评估了 Prompt Cache。结果表明,Prompt Cache 显著降低了首个 token 延迟,尤其对于基于文档的问答和推荐等长提示词。改进范围从 GPU 推理的 8 倍到 CPU 推理的 60 倍,同时保持输出准确率,且无需修改模型参数。

英文摘要:

We present Prompt Cache, an approach for accelerating inference for large language models (LLM) by reusing attention states across different LLM prompts. Many input prompts have overlapping text segments, such as system messages, prompt templates, and documents provided for context. Our key insight is that by precomputing and storing the attention states of these frequently occurring text segments on the inference server, we can efficiently reuse them when these segments appear in user prompts. Prompt Cache employs a schema to explicitly define such reusable text segments, called prompt modules. The schema ensures positional accuracy during attention state reuse and provides users with an interface to access cached states in their prompt. Using a prototype implementation, we evaluate Prompt Cache across several LLMs. We show that Prompt Cache significantly reduce latency in time-to-first-token, especially for longer prompts such as document-based question answering and recommendations. The improvements range from 8x for GPU-based inference to 60x for CPU-based inference, all while maintaining output accuracy and without the need for model parameter modifications.

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

↑