Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Prompt Cache: Modular Attention Reuse for Low-Latency Inference

About

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.

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

Related benchmarks

TaskDatasetResultRank
Text-to-SQLBIRD (dev)--
387
Long-context Question AnsweringLocomo
F1 (Multi Hop)32.61
171
Text-to-SQLSpider (dev)--
147
Long-context Language UnderstandingLongBench 2024 (test)
Multi-doc QA33.28
20
Long-context Question AnsweringLongBench
HotPotQA Accuracy44.63
20
Embodied PlanningALFRED
Success Rate (SR)35.72
11
Agent PlanningWAH-NL
Sub-SR12.74
8
Showing 7 of 7 rows

Other info

Follow for update