Skip to main content
AI / MLRetrieval & RAGDiagramIntermediate

Semantic Caching

KO: 시맨틱 캐싱·EN: Semantic Caching·JA: セマンティックキャッシュ

A caching layer that matches incoming prompts by embedding similarity rather than exact string equality, returning cached LLM responses for semantically equivalent queries

Table of Contents

Structure Diagram

Semantic Cache Lookup & Similarity Gate
SemCache1. Embed Pro…2. Vector Lo…3. Threshold…4. Miss → Ca…
2/42. Vector Lookup
Redis / Vector DB
Quick Answer

What is Semantic Caching?

A caching layer that matches incoming prompts by embedding similarity rather than exact string equality, returning cached LLM responses for semantically equivalent queries. It is a core concept in Retrieval & RAG within AI / ML.

Core Principles

Traditional exact-match caches miss whenever two users phrase the same question differently (e.g., "How long is the refund window?" vs. "When can I get a refund?").

Semantic Caching stores prior prompt embeddings alongside their LLM responses in a fast vector store (such as Redis). When a new query exceeds a strict cosine similarity threshold (e.g., ≥ 0.94), the cached answer is returned in milliseconds without invoking the LLM.

Practical Takeaways

  • Guard against false-positive hits: Queries like "iPhone 15 price" and "iPhone 16 price" have very high embedding similarity but different answers. Use high thresholds (0.93–0.97) plus entity/number verification or a fast reranker check.
  • Isolate personalized and ACL-scoped queries: Never serve private user data from a global semantic cache. Scope keys by tenant/permission level or restrict semantic caching to public FAQs.
  • Tie cache invalidation to document updates: Pair short TTLs with version tags so policy updates immediately purge stale cached answers.

Notable Examples

  • Customer Support FAQ Bots: Resolve 40–60% of recurring shipping and billing questions in ~30ms with zero LLM cost.
  • RedisVL & GPTCache: Popular drop-in semantic caching layers deployed inside LLM gateways.
  • Documentation Assistants: Absorb traffic spikes when many developers ask variations of the same setup question.