Ir al contenido

Semantic Caching: Why Light Rewordings And Heavy Rewordings Need Different Treatment

De Wiki CEPEM


Semantic caching is a practical way to cut the cost and latency of large-language-model applications. Instead of sending every user query to the model, the system stores the embedding of a previously answered question along with its response. When a new query arrives, the system computes its embedding and compares it to stored ones using cosine similarity. If the similarity passes a single threshold, typically shipped as a default between 0.80 and 0.95, the cached answer is returned. The hope is that similar questions get similar answers, and the cache hit rate rises without users noticing a difference.

But a single similarity threshold hides a messy reality. Consider two customers: one asks "how do I cancel my subscription?" and another asks "how do I pause my subscription?" These are light rewordings in the sense that they share almost all words and structure, yet they need different answers. Now consider "how do I stop being billed monthly?" versus "how do I cancel my subscription?" These are heavy rewordings—different vocabulary, different syntax—but they mean the same thing. A good semantic cache should treat the first pair as a miss and the second pair as a hit. A single threshold struggles to do both.

A 2026 preprint by Guerin Green of Novel Cognition examined exactly this problem. The author built a labelled set of 243 English customer-support question pairs across eight domains. The set included 101 heavily reworded paraphrases, 102 near-miss pairs that differ by a word or by word order but need different answers, and 40 lightly reworded paraphrases reported separately. Using the open embedding model Qwen3-Embedding-0.6B and cosine similarity, the results were striking. The near-miss pairs scored higher on average, with a median of 0.801, than the genuine paraphrases, which had a median of 0.691. The area under the ROC curve was 0.144, with a 95% bootstrap interval from 0.097 to 0.195, meaning the two distributions were inverted, not merely overlapping. A threshold that catches true paraphrases will also catch many near-misses, and a threshold that avoids near-misses will miss most true paraphrases.

At a threshold of 0.85, which is the default of one commercial service, that model matched none of the 101 heavily reworded paraphrases and 29 of the 102 near-misses, a 28.4% false cache hit rate. To eliminate false matches entirely, the threshold had to be raised to 0.985, but at that level 2 of the 40 near-verbatim repeats were still missed. In other words, the model cannot separate the two categories at any single cutoff. The similarity scores correlated strongly with word-set Jaccard overlap, with a Pearson r of 0.695, both overall and within each label. Adding a query-instruction prefix halved false matches at 0.85, down to 12.7%, but it did not change the ordering of the pairs.

Why do light and heavy rewordings behave so differently? Embedding models are trained to place similar meanings near each other, but they are also sensitive to surface form. A near-miss pair like "cancel" versus "pause" shares almost all tokens, so the embeddings are pulled close together by lexical overlap. A heavy reworded paraphrase shares few tokens, so the embeddings drift apart despite the semantic equivalence. Cosine similarity is a blunt measure: it cannot tell whether a high score comes from shared meaning or shared words. The threshold thus becomes a trade-off between missing true hits and serving wrong answers.

The preprint argues that a threshold is a property of one embedding model on one traffic distribution, not a transferable constant. What works for Qwen3-Embedding-0.6B on customer-support questions will not work for another model or another domain. Other models need their own measurement. The Cache File author describes a labelled near-miss protocol for setting a threshold, and the pairs, scores, and analysis script are released under CC BY 4.0, so practitioners can recompute every statistic.

For engineers, the lesson is to measure both false cache hits and missed paraphrases on your own traffic. A single number like 0.85 feels safe, but it silently trades one failure mode for another. The cache hit rate you see on easy repeats may hide a steady stream of wrong answers on near-miss queries. The only reliable approach is to build a small labelled set of near-misses and paraphrases from your own logs, then choose a threshold that minimises the specific cost you care about.