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

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Yan, Jianxin, Ni, Wangze, Chen, Lei, Lin, Xuemin, Cheng, Peng, Qin, Zhan, Ren, Kui
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866912483990568960
author Yan, Jianxin
Ni, Wangze
Chen, Lei
Lin, Xuemin
Cheng, Peng
Qin, Zhan
Ren, Kui
author_facet Yan, Jianxin
Ni, Wangze
Chen, Lei
Lin, Xuemin
Cheng, Peng
Qin, Zhan
Ren, Kui
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2506_22791
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle ContextCache: Context-Aware Semantic Cache for Multi-Turn Queries in Large Language Models
Yan, Jianxin
Ni, Wangze
Chen, Lei
Lin, Xuemin
Cheng, Peng
Qin, Zhan
Ren, Kui
Computation and Language
Databases
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.
title ContextCache: Context-Aware Semantic Cache for Multi-Turn Queries in Large Language Models
topic Computation and Language
Databases
url https://arxiv.org/abs/2506.22791