How Often Is a Semantic Cache Wrong? 13,083 Support Questions, Eight Thresholds

Murtaza Shajapurwala ·

A semantic cache sits in front of a language model. When a new question means the same as one already answered, it returns the stored answer and the model is never called. Every write-up of semantic caching quotes how many calls it saves. Fewer say how often the stored answer belongs to a different question, which is the number that decides whether you can use one at all.

We measured both on Banking77, 13,083 questions that real customers sent a bank's support channel, at eight similarity thresholds. At a threshold of 0.90, 74% of questions were answered from the cache, and 6.3% of those answers belonged to a question with a different intent.

Why Banking77

Banking77 labels each question with one of 77 intents, such as card_arrival, exchange_rate or top_up_failed. That makes "wrong answer" measurable. A support bot replies per intent, so if a cached answer was stored for a question with another intent, the customer got the wrong reply even if the two questions look alike.

The method:

  1. Take all 13,083 questions (train and test together), shuffled once with seed 7, as the stream a support bot would see.
  2. For each question, find the most similar question stored so far.
  3. At or above the threshold, it is a hit and returns that question's answer. A hit is correct when the stored question has the same intent, and wrong otherwise.
  4. Below the threshold, it is a miss: the question goes to the model and is stored with its answer.

Embeddings came from BAAI/bge-small-en-v1.5, an open model, computed on a laptop in about 100 seconds for all 13,083 questions.

The trade-off at every threshold

Semantic cache on 13,083 Banking77 questions: share answered from the cache and share answered wrongly, by threshold. 0.70: 99.1% and 62.9%. 0.90: 73.9% and 4.6%. 0.95: 42.6% and 1.1%.

ThresholdFrom the cacheWrong, of hitsWrong, of all questionsEntries stored
0.7099.1%63.4%62.9%117
0.7598.0%40.1%39.4%256
0.8095.5%24.8%23.7%587
0.8589.1%12.7%11.3%1,426
0.8881.4%7.8%6.4%2,440
0.9073.9%6.3%4.6%3,409
0.9263.5%4.4%2.8%4,779
0.9542.6%2.5%1.1%7,514

Read it like this: at 0.70, the cache answers almost everything, but nearly two thirds of those answers are for the wrong intent. It has collapsed to 117 stored entries, so it is mostly answering questions with the nearest of a few generic ones. As the threshold rises, the cache answers less and gets right more of what it answers.

The cache earns its rate over time

A cache starts empty. Early on most questions are new and miss; the hit rate climbs as the stored set covers more of what customers ask.

Hit rate at a 0.90 threshold over the questions seen so far: 40.1% after 1,000, 51.0% after 2,000, 63.1% after 5,000, 71.5% after 10,000 and 73.9% after all 13,083.

Checking it against the real service

The sweep above replays the cache with an exact nearest-neighbour search, so all eight thresholds could be compared quickly. To check that the service behaves the same way, we sent the first 2,000 questions at 0.90 through the KiviDB Cloud semantic cache API on a free database, with our own vectors:

PUT /instances/{db}/semantic-cache/banking77
{ "provider": "none", "dimensions": 384, "threshold": 0.90 }

POST /instances/{db}/semantic-cache/banking77/lookup
{ "vector": [0.0123, -0.0441, ...] }

POST /instances/{db}/semantic-cache/banking77/entries
{ "prompt": "...", "response": "card_arrival", "vector": [ ... ] }

The service made the same hit-or-miss decision as the exact replay on all 2,000 questions and reached the same hit rate, 51.0%, with 981 entries stored. A lookup took 32.5 ms at the median and 45 ms at the 95th percentile, measured inside the API in the database's region. That covers clearing expired entries, finding the nearest stored question, reading its answer and counting the hit. A hit took 34 ms and a miss 30 ms, because a hit also reads and counts the stored answer.

What we took away

The threshold belongs to the embedding model. Similarity scores are not comparable across models. With bge-small, 0.70 gave the wrong answer to 63% of hits; with OpenAI's text-embedding-3-small, rewordings of one question score around 0.61 to 0.82, which is why KiviDB's default is 0.6. Whatever model you use, measure on your own questions before you choose.

Wrong answers never reach zero. Even at 0.95, 2.5% of hits crossed intents. The commonest pair: "My top-up was rejected" (labelled top_up_failed) matched "My top up was rejected. Why?" (labelled top_up_reverted) at a similarity of 0.976. Some of these a person would answer the same way; others they would not. Keep a cache away from answers that must never be wrong, such as account balances, or give entries a short time to live.

The rate depends on how repetitive your traffic is. Banking77 repeats a small set of needs, so three in four questions hit. A stream of one-off questions would hit far less. The warm-up curve is the shape to look for in your own logs.

The money is yours to price. At 0.90, the cache avoided 74 model calls in every 100 here. Multiply by what one call costs you, and subtract what a wrong answer costs you, which only you can price.

Repeat it

Banking77 is public (PolyAI, CC BY 4.0) and the model is on Hugging Face. A free KiviDB Cloud database holds a semantic cache namespace; set provider to none to send your own vectors, or to openai or an OpenAI-compatible endpoint to have the cache embed prompts for you. The full method and every figure are on the case study page.

Banking77: Casanueva et al., 2020.