Semantic Cache
A caching layer that stores and retrieves AI agent responses based on the meaning of queries rather than exact string matching. When a new query is semantically similar to a cached query (measured by embedding similarity), the cached response is returned instead of making a new LLM call—reducing latency from seconds to milliseconds and cutting API costs by 30-60% for agents with repetitive query patterns. Semantic caching is especially effective for support agents (many customers ask the same questions differently) and FAQ-heavy use cases.
Example
A support agent receives 'How do I reset my password?', 'I forgot my password, how to change it?', and 'password reset help.' Traditional caching treats these as three different queries. Semantic caching recognizes they're all asking the same thing (embedding similarity > 0.95), serves the cached response for all three, and saves 3 LLM calls. Over a month with 10,000 support conversations, semantic caching handles 40% of queries from cache.
Frequently asked questions
- How do you handle cache invalidation for semantic caches?
- Use a combination of TTL (time-to-live) expiration and event-based invalidation. Set a TTL of 24-72 hours for most cached responses so stale answers expire naturally. When the knowledge base is updated (new article, policy change), invalidate cached responses that reference the changed content. Some teams add a 'freshness score' that considers both semantic similarity and time since caching—gradually preferring fresh LLM responses over older cached ones.