ContextCache: Context-Aware Semantic Cache for Multi-Turn Queries in Large Language Models

Jianxin Yan, Wangze Ni, Lei Chen, Xuemin Lin, Peng Cheng +2 more
6/28/2025
cs.CLcs.DB

No confident code implementation found for this paper.

Abstract

Semantic caching significantly reduces computational costs and improves efficiency by storing and reusing large language model (LLM) responses. However, existing systems rely primarily on matching individual queries, lacking awareness of multi-turn dialogue contexts, which leads to incorrect cache hits when similar queries appear in different conversational settings. This demonstration introduces ContextCache, a context-aware semantic caching system for multi-turn dialogues. ContextCache employs a two-stage retrieval architecture that first executes vector-based retrieval on the current query to identify potential matches and then integrates current and historical dialogue representations through self-attention mechanisms for precise contextual matching. Evaluation of real-world conversations shows that ContextCache improves precision and recall compared to existing methods. Additionally, cached responses exhibit approximately 10 times lower latency than direct LLM invocation, enabling significant computational cost reductions for LLM conversational applications.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{yan2025contextcache,
  title  = {ContextCache: Context-Aware Semantic Cache for Multi-Turn Queries in Large Language Models},
  author = {Jianxin Yan and Wangze Ni and Lei Chen and Xuemin Lin and Peng Cheng and Zhan Qin and Kui Ren},
  year   = {2025},
  eprint = {2506.22791},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2506.22791v3}
}

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/2506.22791.svg)](https://codeofpaper.com/paper/2506.22791)

Discussion