← All field notes

Semantic caching: paying for a novel question, not a repeated one

SCALM and related semantic-caching research match requests by meaning instead of exact text, cutting serving cost on repeated-intent traffic — with a similarity threshold doing all the safety work.

AI-assisted / research-based

This field note was drafted with AI assistance and synthesizes publicly available research papers and disclosed industry practice on an emerging AI technique. It is not based on confidential deployment data, is not investment, legal, medical, or security advice, and every primary claim links directly to its source so you can verify it yourself.

A standard cache only helps when a request is byte-for-byte identical to one already served — rare in natural-language traffic, where the same underlying question is phrased a dozen different ways across a dozen different users. Semantic caching matches on meaning rather than exact text, and real chat-service traffic turns out to have a lot of that meaning to exploit.

Two users rarely type the same words. They ask the same question more often than a text-match cache can see.

Finding the repeated intent hiding in varied phrasing

SCALM: Towards Semantic Caching for Automated Chat Services with Large Language Models ↗, by Li and colleagues, begins with something the paper describes as a first-of-its-kind analysis: studying real-world human-to-LLM interaction data specifically to identify where existing caching solutions fail. The finding is direct — current caching methods do not leverage semantic connections between requests, leaving cache performance inefficient and token costs higher than they need to be.

Architecture / inference cost control

A cache hit skips inference — if the match is real

FIG 01
Semantic cache lookup path versus full inference An incoming request is embedded and compared against cached request embeddings; a sufficiently similar prior request returns a cached response directly, while a novel request falls through to full model inference and the new pair is stored for future matches. REQUESTEmbed the questionvector, not exact text COMPARESimilarity thresholdagainst cached embeddings HITReturn cached responseno model inference call MISSFull model inferencethen store the new pair EVICTStorage + expiry policystale answers must expire RISKtoo loose a threshold serves a confidently wrong cached answer to a genuinely different question
Matching on meaning instead of exact text catches paraphrased repeats, but the similarity threshold is doing all the safety work between a real cost saving and a wrong answer served fast.

SCALM's architecture embeds incoming requests into a vector space and compares them against previously cached request embeddings; a sufficiently similar prior request can return its cached response directly, skipping a full model inference call entirely. The paper details specific storage and eviction strategies built around this semantic-analysis approach, and reports the practical payoff against GPTCache, a widely used existing semantic-caching solution: a 63% relative increase in cache hit ratio and a 77% relative improvement in token savings on average.

The threshold is the entire safety mechanism

Everything about whether semantic caching helps or hurts an application comes down to one parameter: the similarity threshold used to decide a cache hit. Set it too loose, and genuinely different questions get served a confidently wrong cached answer — a fast, fluent response to the wrong question, which is a worse failure mode than a slow correct one. Set it too strict, and the cache rarely fires, delivering little of the reported cost benefit.

This threshold cannot be tuned once and forgotten. A setting appropriate for general customer-support chat, where paraphrased questions genuinely share the same correct answer, can be actively dangerous in a domain where small wording differences carry large meaning differences — a legal question about "termination for cause" versus "termination for convenience" might embed as highly similar text while requiring entirely different answers.

Economics / similarity threshold

Between confidently wrong and rarely useful

FIG 02
Semantic cache similarity threshold trade-off A threshold set too loose serves confidently wrong cached answers to genuinely different questions, while a threshold set too strict rarely produces a cache hit at all, and the correct operating point sits between the two failure modes. TOO LOOSEHigh hit ratewrong answers served fast TUNED PER DOMAINBalancedvalidated against near-miss cases TOO STRICTLow hit ratelittle cost benefit realized TESTthe right threshold is a property of the domain's near-miss questions, not a universal default
The similarity threshold is the entire safety mechanism of a semantic cache — too loose serves wrong answers fast, too strict barely fires at all.

Cached answers still need an expiration policy

A semantic cache without an eviction or expiry strategy will confidently keep serving an answer that was correct when cached but has since become stale — pricing information, policy details, or anything else that changes over time. SCALM's paper explicitly addresses storage and eviction as first-class design concerns, not an afterthought, precisely because a cache with no invalidation strategy converts a cost-saving mechanism into a silent correctness risk.

What this changes in production

Customer support and FAQ-style assistants

Where a large share of traffic clusters around a smaller set of recurring underlying questions — even when every user phrases them differently — semantic caching directly targets the workload pattern SCALM's own traffic analysis was built to study.

High-traffic public-facing endpoints

Cutting even a modest fraction of full-inference calls through cache hits meaningfully reduces serving cost and accelerator load at scale, which compounds specifically with traffic volume rather than being a fixed per-feature benefit.

Latency-sensitive interactive features

A cache hit returns a response far faster than a fresh generation, which matters directly for any interface where perceived responsiveness is part of the product experience.

A production checklist

Before deploying semantic caching in production, the team should be able to answer:

  • What similarity threshold is in use, and was it tuned on this specific domain's traffic rather than a general-purpose default?
  • Has the system been tested specifically on near-miss cases — questions that are textually similar but require different answers?
  • What is the cache eviction and expiry policy, and does it match how frequently the underlying answers actually change?
  • Is cache hit rate being tracked alongside a correctness or complaint-rate metric, so a threshold set too loose would actually be noticed?
  • Does the cache key account for everything that changes the correct answer — user context, permissions, locale — or only the question text's embedding?
  • What is the actual measured cost savings under real production traffic, compared with the paper's benchmark workload?

Research referenced

Continue readingReturn to field notes →