What is Semantic Cache?

Semantic Cache is a cache that embeds an incoming request, finds a sufficiently similar cached request, and reuses its stored response when policy and metadata boundaries also match.

Quick Facts

CreatedPopularized for LLM applications in the early 2020s
SpecificationOfficial Specification

How It Works

A semantic cache extends exact-key caching to paraphrases and near-duplicate requests. On lookup, the system embeds a normalized request, applies hard filters such as tenant, authorization scope, locale, model version, prompt version, source revision, and safety policy, then accepts the nearest entry only if its distance passes a calibrated threshold. A hit can avoid retrieval and generation, but a false hit can return a plausible answer for the wrong intent or leak data across boundaries. The cache must remain non-authoritative, observable, versioned, expiring, and safe to rebuild. See the <a href="https://qubittool.com/blog/llm-semantic-caching-production-guide">production semantic caching guide</a> for thresholds, invalidation, and risk controls.

Key Characteristics

  • Matches request meaning with embeddings instead of requiring byte-identical keys
  • Combines a soft similarity threshold with hard metadata and authorization filters
  • Requires TTL, invalidation, versioning, and memory-eviction policies
  • Trades hit rate against false-hit risk and stale-answer risk
  • Must isolate tenants, identities, models, prompts, locales, and source revisions as needed

Common Use Cases

  1. Reusing validated answers for high-volume FAQ paraphrases
  2. Reducing repeated LLM calls in support and internal knowledge assistants
  3. Caching deterministic classification or extraction for near-duplicate inputs
  4. Serving stable public information with explicit freshness windows
  5. Measuring cost and latency savings without bypassing policy checks

Example

loading...
Loading code...

Frequently Asked Questions

How is semantic caching different from exact caching?

Exact caching requires the same key. Semantic caching can reuse an answer for paraphrased requests, but needs a similarity model and stronger safeguards against false matches.

How is a semantic cache different from RAG?

RAG retrieves source passages and still calls a generator. A semantic cache retrieves a complete prior response and can skip generation entirely on a valid hit.

How should the similarity threshold be chosen?

Sweep thresholds on labeled pairs from the real workload, measure hit rate and harmful false-hit rate by intent slice, then choose a policy that meets the risk budget.

What should be part of a semantic cache partition?

At minimum consider tenant, authorization scope, locale, model and prompt versions, source revision, safety policy, and response type. Similarity must never cross a security boundary.

What requests should not use semantic caching?

Avoid it for personalized, rapidly changing, high-stakes, permission-sensitive, transactional, or side-effecting requests unless correctness is enforced by stronger deterministic checks.

Related Tools

Related Terms

Related Articles