Semantic caching

Semantic caching

Semantic caching

TL;DR

TL;DR

Semantic caching is a technique that stores LLM responses and returns a stored answer when a new query has the same meaning as an earlier one, skipping the model call to cut cost and latency.

Semantic caching is a technique that stores LLM responses and returns a stored answer when a new query has the same meaning as an earlier one, skipping the model call to cut cost and latency.

What is semantic caching?

Semantic caching is a technique that stores the responses of a large language model and reuses one when a new query means the same thing as an earlier query. A traditional cache needs the request to match character for character. A semantic cache matches on meaning, so “how do I reset my password” and “I forgot my password, what now” can return the same stored answer.

When the cache hits, the model is not called at all. The reply arrives in milliseconds and costs almost nothing, which is why semantic caching is used in high-volume LLM applications. The risk is the other side of the same feature: two questions can look alike and need different answers.

Key takeaways

  • Definition: reuse of a stored LLM answer for a query with the same meaning.

  • Mechanism: queries are compared as embeddings, with a similarity threshold deciding a hit.

  • Benefit: a hit skips the model, saving the full cost and most of the latency.

  • Risk: false hits and stale or personal answers served to the wrong request.

How semantic caching works

A semantic cache sits in front of the model and handles each request in four steps.

  1. Embed. The incoming query is converted into a vector embedding, a list of numbers that represents its meaning.

  2. Search. The cache looks for the closest stored query, using the same nearest-neighbor methods as semantic search.

  3. Compare. If the similarity score is above a set threshold, it is a hit and the stored response is returned.

  4. Store. On a miss, the request goes to the model, and the new query and answer are added to the cache.

The open-source project GPTCache made the design popular, and its authors describe the architecture in GPTCache: An Open-Source Semantic Cache for LLM Applications. Most LLM gateways and vector databases now offer the same pattern as a feature.

Parts of a semantic cache

Part

What it does

Design choice

Embedding model

Turns queries into vectors

Quality of matching depends on it

Vector store

Holds cached queries and answers

In-memory for speed, or a vector database for scale

Similarity threshold

Decides what counts as the same question

Higher is safer, lower hits more often

Scope key

Limits which entries a request can match

Per tenant, language, product, or user segment

Expiry rule

Removes old entries

Time-based, or triggered by content changes

The scope key is the part teams forget. Without it, an answer written for one customer segment, or one company in a multi-tenant product, can be served to another.

Semantic caching vs prompt caching vs exact-match caching

Technique

Matches on

Model called on a hit?

Main risk

Semantic caching

Meaning of the query

No

Wrong answer from a near match

Prompt caching

Identical prompt prefix

Yes, with cheaper input

None for correctness

Exact-match caching

Identical full request

No

Low hit rate

The two are often confused. Prompt caching is a provider feature that reduces the cost of repeated input while the model still writes a fresh answer. Semantic caching is built by the application and replaces the answer. They can be used together.

Why semantic caching matters for customer support

Support traffic is repetitive. A large share of contacts ask a small number of questions about hours, shipping times, return windows, and how to reset a password. For those, generating a new answer every time spends money and time to produce the same paragraph.

A hit also removes the model’s response time, which helps most in voice. Guides on AI support response time and low-latency AI voice agents show how little time a spoken reply has. Cost comparisons such as Intercom Fin vs Zendesk AI vs Fini come down to cost per resolution, and avoided model calls feed directly into that number.

Where semantic caching goes wrong

Three failure modes matter in support. The first is the false hit. “Can I cancel my order?” and “Cancel my order” are close in meaning and need different handling: one is a question about policy and the other is a request to act. Negation is another trap, because “is this covered” and “is this not covered” embed close together.

The second is personalization. “Where is my order?” has the same meaning for every customer and a different answer for each one. Anything that depends on account data must bypass the cache or be scoped to a single user.

The third is staleness. When a policy changes, cached answers keep the old version until they expire. A cache with no link to the knowledge source becomes a quiet source of hallucination-like errors: fluent, confident, and out of date.

Semantic caching example

A retailer’s assistant is asked about the return policy at 9:00 and generates an answer. At 9:02 another customer asks how long they have to send something back. The embeddings of the two questions are close, the score is above the threshold, and the second customer gets the stored answer in a few milliseconds. At 9:05 a third customer asks whether an item bought on sale can be returned. The wording is similar, but sale items have different rules, so a well-tuned cache treats it as a miss and sends it to the model.

How is semantic caching measured?

Hit rate is the share of requests answered from the cache. On its own it is misleading, because lowering the threshold raises it. The number that matters alongside it is false hit rate: the share of cache hits where the stored answer was wrong for the new question, measured by reviewing a sample.

Also track latency saved per hit, cost saved, and the age of entries being served. Compare resolution rate for cached and uncached answers. If cached answers resolve less often, the threshold is too loose.

How AI agents use semantic caching

For an agent that only answers questions, a cache can sit in front of the whole exchange. For an agent that takes actions, it has to be narrower. The safe pattern is to cache general knowledge answers and never cache steps that read account data or call a tool.

In systems built on retrieval-augmented generation, teams sometimes cache the retrieval step instead of the final answer, which keeps the wording fresh while saving the search. Accuracy-first designs go further and limit generation itself. Fini describes its approach in this post on what RAGless means, and its platform applies guardrails before a reply is sent. The guide to preventing AI support hallucinations explains why a fast wrong answer is worse than a slower correct one. AI guardrails should check cached replies the same way they check generated ones.

How to implement semantic caching

  1. Pick the cacheable intents. Limit caching to general questions with one correct answer for everyone.

  2. Exclude anything personal or transactional. Route account lookups and actions past the cache.

  3. Set a strict threshold first. Start high, review hits, and lower it only if the false hit rate stays near zero.

  4. Add scope keys. Separate entries by tenant, language, product, and policy version.

  5. Tie expiry to content. Clear related entries when a knowledge article or policy changes.

  6. Review a sample of hits every week and log the query pairs that should not have matched.

Common semantic caching mistakes

The first mistake is tuning for hit rate. A cache that hits 60% of the time and is wrong on a tenth of those is a quality problem that looks like a cost saving. The second is caching full conversations, where the same last message means different things after different histories.

Teams also forget tenant isolation, which can expose one customer’s information to another, and leave entries alive after the source content changed.

How Fini approaches speed and accuracy

Fini puts accuracy ahead of shortcuts. It uses an approach it calls RAGless, and Live Guardrails check each reply before it is sent. Fini reports 99% accuracy and a 90% resolution rate, and support teams can review answers before customers see them. For regulated teams, that order of priorities matters: a wrong answer creates a second contact and sometimes a compliance problem. To see how Fini answers your most repeated questions, book a call.

Frequently Asked Questions

What is semantic caching in simple terms?

Semantic caching saves the answers an AI model has already given and reuses them when someone asks a question with the same meaning, even in different words. The model is not called again, so the reply is faster and cheaper.

How does semantic caching work?

Each query is converted into an embedding and compared with the embeddings of earlier queries. If the closest one is similar enough, above a set threshold, the stored answer is returned. If not, the model generates a new answer and the pair is added to the cache.

What is the difference between semantic caching and prompt caching?

Semantic caching returns a stored answer and skips the model when a new question means the same as an old one. Prompt caching is a provider feature that makes repeated input cheaper while the model still writes a new answer. Prompt caching cannot return a wrong answer. Semantic caching can.

What similarity threshold should a semantic cache use?

There is no universal number, because scores depend on the embedding model. Start with a strict threshold that only matches near-identical questions, review a sample of hits, and loosen it gradually. Stop when reviewers find pairs that should have had different answers.

Is semantic caching safe for customer support?

It is safe for general questions that have one answer for every customer, such as opening hours or a return window. It is unsafe for anything tied to an account, an order, or an action. Those requests should bypass the cache, and entries should expire when policies change.

What is GPTCache?

GPTCache is an open-source library for building a semantic cache in front of a large language model. It handles embedding, similarity search, storage, and eviction, and integrates with common LLM frameworks. It is the reference implementation many later tools followed.

Learn More

Learn More

Workforce optimization (WFO)

W

Customer self-service

C

Prompt caching

P

AI sycophancy

A

Computer use agent

C

System prompt

S

Backchanneling

B

Omnichannel customer support

O

Voice biometrics

V

Non-human identity (NHI)

N

Time to first token (TTFT)

T

Durable execution

D

AI audit trail

A

Conversational AI greeting

C

Agent assist vs AI agent

A

Knowledge base

K

Average handling time (AHT)

A

Telephony

T

Customer acquisition cost (CAC)

C

Business process outsourcing (BPO)

B

AI tokens

A

Human in the loop (HITL)

H

AI grounding vs retrieval-augmented generation (RAG)

A

Short message service (SMS)

S

Call center

C

Data annotation

D

Ticket routing

T

Customer service quality assurance (QA)

C

Live chat

L

Speech Synthesis Markup Language (SSML)

S

Batch inference

B

Barge-in

B

SLA compliance rate

S

Queue management

Q

Prompt versioning

P

Emotion detection

E

Retrieval-augmented generation (RAG)

R

Natural language understanding (NLU)

N

Text classification

T

Call routing

C

Customer churn rate

C

Speech-to-speech

S

Intent recognition

I

Voice of the employee (VoE)

V

Confidence score

C

Resolution-based pricing

R

AI personalization

A

Voice cloning

V

Asynchronous messaging

A

Hallucination

H

ReAct agent pattern

R

Long-term memory

L

Forecast accuracy

F

Customer feedback loop

C

Structured output

S

Outbound voice AI

O

AI guardrails

A

Direct preference optimization (DPO)

D

Prompt chaining

P

SIP transfer

S

Fallback intent

F

Conversation summarization

C

Auto-tagging

A

Cost per contact

C

VoIP jitter

V

Model card

M

Ticket prioritization

T

Sentiment analysis

S

Agent utilization rate

A

Speech-to-intent

S

Prompt engineering

P

Knowledge atlas

K

SOC 2 AI support

S

Prosody

P

Chatbot containment rate

C

Speech synthesis

S

Fine-tuning

F

ISO 42001

I

Intent-based search

I

After-call work (ACW)

A