SmartCache: Context-aware Semantic Cache for Efficient Multi-turn LLM Inference

Cheng Yu, Tianyu Wang, Zi-Li Shao, Songhao Jiang
1/1/2025

No confident code implementation found for this paper.

Abstract

Large Language Models (LLMs) for multi-turn conversations suffer from inefficiency: semantically similar queries across different user sessions trigger redundant computation and duplicate memory-intensive Key-Value (KV) caches. Existing optimizations such as prefix caching overlook semantic similarities, while typical semantic caches either ignore conversational context or are not integrated with low-level KV cache management.

Show full abstract

We propose SmartCache, a system-algorithm co-design framework that tackles this inefficiency by exploiting semantic query similarity across sessions. SmartCache leverages a Semantic Forest structure to hierarchically index conversational turns, enabling efficient retrieval and reuse of responses only when both the semantic query and conversational context match. To maintain accuracy during topic shifts, it leverages internal LLM attention scores—computed during standard prefill—to dynamically detect context changes with minimal computational overhead. Importantly, this semantic understanding is co-designed alongside the memory system: a novel two-level mapping enables transparent cross-session KV cache sharing for semantically equivalent states, complemented by a semantics-aware eviction policy that significantly improves memory utilization. This holistic approach significantly reduces redundant computations and optimizes GPU memory utilization. The evaluation demonstrates SmartCache’s effectiveness across multiple benchmarks. On the CoQA and SQuAD datasets, SmartCache reduces KV cache memory usage by up to 59 . 1% compared to pre-fix caching and 56 . 0% over semantic caching, while cutting Time-to-First-Token (TTFT) by 78 . 0% and 71 . 7% , respectively. It improves answer quality metrics, achieving 39 . 9% higher F1 and 39 . 1% higher ROUGE-L

DOISemantic Scholar

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{yu2025smartcache,
  title  = {SmartCache: Context-aware Semantic Cache for Efficient Multi-turn LLM Inference},
  author = {Cheng Yu and Tianyu Wang and Zi-Li Shao and Songhao Jiang},
  year   = {2025},
  doi    = {10.52202/085713-5740},
  url    = {https://doi.org/10.52202/085713-5740},
  journal = {Neural Information Processing Systems}
}

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

Discussion