Design a Semantic Cache for Repeated LLM Questions in Google Assistant

Last updated: November 29, 2026

Quick Overview

Many users ask the assistant nearly identical questions, and each LLM call is expensive. Design a semantic cache that serves a stored answer when a new question means the same thing, without returning wrong or stale answers.

Google
ML System Design
Software Engineer
Google
November 29, 2026
Software Engineer
Phone Screen
ML System Design
Easy

0

0

0 solved


Many users ask the assistant nearly identical questions, and each LLM call is expensive. Design a semantic cache that serves a stored answer when a new question means the same thing, without returning wrong or stale answers.

A practical cost-reduction question for teams serving LLM features at scale. The interviewer checks how you define a match, pick a similarity threshold, scope the cache to avoid leaking personalized answers, and invalidate time-sensitive content.

What the Interviewer Expects
  • Embed queries and look up nearest neighbors with a threshold
  • Only cache non-personal, non-time-sensitive answers
  • Scope keys by language, locale and model version
  • Set invalidation and TTL policies
  • Measure hit rate and answer quality impact
Key Topics to Cover
Semantic caching
Embeddings
Approximate nearest neighbor
Cache invalidation
Cost optimization
How to Approach This
  1. Start by mapping the business objective to a concrete ML objective and metric.
  2. Cover the full pipeline: data collection, feature engineering, model selection, training, serving.
  3. Discuss online vs offline evaluation. Plan an A/B test to validate real-world impact.
  4. Address the serving latency budget and whether batch or real-time inference is needed.
  5. Think about the data flywheel: how user feedback improves the model over time.
Possible Follow-up Questions
  • Are 'How tall is the Eiffel Tower' and 'How tall is the Tokyo Tower' a cache hit?
  • How do you choose the similarity threshold?
  • How do you handle a model version change?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice ML System Design Problems
Sample Answer
Requirements

Goal: cut LLM calls for repeated general questions by a meaningful fraction while keeping answers correct. Only cache answers that do not depend on the user (no 'my calendar') or on real-time data (we...

High-Level Design
  1. Cacheability classifier: decides whether a query is general and stable.
  2. Normalizer and embedder: small sentence embedding model.
  3. Vector store: ANN index partitioned by (language, ...

Submit Your Answer
Markdown supported