Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
51 small wins to finish your pathNext question →

Q22IntermediateSystem design

Design AI-powered semantic product search for an e-commerce site with 10M products.

30-second answerSay your answer out loud first, then reveal.
Product search architecture: offline, the catalog is enriched by an LLM, embedded and indexed; online, a query goes through cached or small-model query understanding, then BM25 and vector search with filters, candidates (~500) are merged and ranked by learning-to-rank on relevance, CTR, conversions, stock and personalisation, returning top results in ~50-150ms.

Design points

  1. Latency budget: total ~150ms. A frontier LLM call per query is too slow and too costly at high QPS, so use:
    • a cache of query-understanding results for frequent queries (the head of the distribution repeats a lot),
    • small fine-tuned models for filter extraction on tail queries.
  2. Offline LLM enrichment: fill missing attributes, normalise colours and sizes, generate searchable descriptions, translate. Batch processing is cheap at catalogue scale.
  3. Multilingual / transliterated queries ("joote", "saree for shaadi"): query normalisation plus multilingual embeddings.
  4. Ranking: a learning-to-rank model (e.g. gradient-boosted) trained on clicks and purchases, with position-bias correction.
  5. Evaluation: offline nDCG on judged query–product pairs (LLM-assisted relevance labelling + human audit), then online A/B tests on CTR, add-to-cart, conversion, null-result rate.

Optional: a conversational shopping assistant layered on top for exploratory queries ("gift for a 10-year-old who likes science").

You understood something today that you didn't yesterday.