Semantic cache
Reusing a stored model answer when a new question means the same as an earlier one, matched by embedding similarity rather than exact text.
A semantic cache reuses a stored model answer when a new question means the same as an earlier one, matched by embedding similarity rather than exact text. A hit skips the model call, so it saves both cost and latency.
“What is your refund policy” and “how do refunds work” can share one answer, which saves the model call and its latency. Each incoming question is embedded and compared with stored ones; above a similarity threshold, the stored answer is returned. Open-source libraries such as GPTCache and some AI gateways provide it. The risk is a threshold set too loose: “cancel my order” and “cancel my subscription” look similar and need different answers. A cached answer also goes stale when the policy or price behind it changes, so entries need an expiry.
It is a different thing from prompt caching, where the provider reuses the processed beginning of a prompt and the answer is still generated fresh. Prompt caching cannot change an answer; a semantic cache can return the wrong one. That makes it a fit for FAQ-style questions with one correct reply, and it should never share answers across users when they contain personal data.
Sources
- GitHub: zilliztech/GPTCache github.com
Related terms
- Prompt caching: Reusing an identical prompt prefix across requests so it is cheaper and faster to process.
- AI gateway: A proxy between your app and model providers that adds logging, caching, limits, billing and fallbacks.
- Embeddings: Vectors of numbers that place texts with similar meaning close together.
- Semantic search: Search that matches by meaning instead of exact words, by comparing embeddings of the query and the documents.
- Cost per task (agent unit economics): What one finished agent task really costs: tokens, retries, tool calls and the human time to review it, compared with doing it another way.
