What happened
The example models e-commerce support questions about refunds, shipping, products and accounts. (github.com) It embeds each incoming prompt, searches stored prompt vectors and returns the previous response if the nearest match clears a configured distance threshold. (github.com) It uses the all-MiniLM-L6-v2 model, with 384-dimensional embeddings. (github.com)
Threshold selection governs the balance between reuse and matching quality: the README recommends 0.10–0.15 for precision and hit rate, while describing 0.25–0.30 as the default starting point. A lower threshold increases precision but reduces recall. The README defines utility as the harmonic mean of precision and cache hit rate, and recommends monitoring both hit rate and precision, then adjusting in response to user feedback. (github.com)
What the archive adds
This is application-side answer reuse: unlike provider-side KV caching, it matches a new prompt to a stored prompt and returns an earlier response.
Why it matters
The threshold is a product-quality control, not just a performance setting. Looser matching can produce more cache hits, but also raises the risk of reusing an answer that does not fit the new question; teams should judge the trade-off against the cost of a wrong response.
Limits and uncertainty
The example simulates LLM calls rather than making real ones, and its response delays are randomized between 0.4 and 0.6 seconds. (github.com) The README claims savings of more than 70% in operational costs and responses more than 80% faster. Those claims are not demonstrated by the simulated delays.
Reader takeaway
Semantic caching can skip an LLM request when a new prompt is close enough to one already stored, but the distance threshold determines how aggressively answers are reused. The demo illustrates the mechanism and a way to evaluate it; its simulated calls and README savings claims do not establish production performance.