KatInterview

Design a Low-Latency Retrieval Layer for a Large-Scale Product Catalog

Machine LearningModel answer
MediumModel answerMachine Learningretrievalembeddingssearch

Last updated

Design the retrieval stage of a marketplace search system that surfaces relevant listings from tens of millions of items within a tight latency budget.

A marketplace lets shoppers type anything into a search bar — a product name, a vague description, even a use case ("gift for a 5-year-old who likes dinosaurs"). The catalog has tens of millions of active listings, each with a title, description, category, structured attributes (brand, condition, size, etc.), price, and availability status.

Your job is to design the system that takes a raw text query and quickly returns a set of relevant listing candidates. A downstream ranker will re-order those candidates before they reach the user, so you are optimizing for recall and speed rather than precision.

What you are expected to cover:

  • Clarifying questions you would ask before designing anything
  • How you define "relevance" in this context
  • The retrieval architecture: what approaches you combine and why
  • How embedding models are trained and kept useful over time
  • How the index is built, updated, and served at scale
  • How hard filters (category, price, availability) interact with retrieval
  • How you measure whether the system is working, both offline and in production
  • Where things can go wrong and how you handle degradation

Scope: Focus on the retrieval layer. You may briefly mention ranking, but do not design it in depth.

Hints

Hint 1

Start by asking about latency budget, query volume, and freshness requirements — the right architecture looks very different at p99 = 50 ms vs. 500 ms, and at 100 QPS vs. 100k QPS.

Hint 2

Purely lexical search (BM25) misses semantic matches; purely dense retrieval misses exact keyword matches. Consider how you combine both into one candidate set.

Hint 3

Filtering on price, category, or availability after ANN search can silently kill recall if many listings are filtered out — think about where in the pipeline filters should be applied.