Retrieval and Answer Caching
In this article
- Say which parts of a retrieval reply can be cached, and why a cache hit skips the permission checks.
- Build an answer-cache key from tenant, policy hash, index version, normalized question, and prompt and model version.
- Evict saved answers by the documents they cite when a permission changes, a document is deleted or the index is replaced, with the TTL only as the upper bound.
- Decide when a near match in a semantic cache may count, and which answers never go in the cache.
- Terms defined here: semantic cache.
Overview
Brightline, a made-up home-internet provider, runs a support assistant for real customers: its search code finds chunks of help pages, router manuals, the staff handbook and customers' past conversations, and puts the best 3 into each request. Many customers ask the same few questions, such as whether they can still get a refund. Each one pays for a search and a fresh reply, so saving the first answer for the next person looks like free speed.
The catch: a saved answer was right for one set of permissions and one version of the documents. After two leaks and their fixes, you can build a cache key, evict saved answers when documents change, and say what never goes in the cache.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- What you can cache
- The first leak
- Building the key
- When the document changes
- Near matches
- What never goes in the cache
- Common mistakes
- In production
- Sources
- Check yourself, 13 questions