Preparing your design workspace

Loading the problem and your latest saved attempt…

Design Semantic Ad Retrieval and Ranking

Retrieve and rank relevant text and image ads for a query while learning safely from sparse, biased feedback.

Problem statement

For this exercise, assume a search product must return up to 20 relevant ads for a user's query. The active catalog contains text, landing-page metadata, optional images, targeting constraints, and campaign status.

Design a system that retrieves candidates using lexical and semantic signals, filters ineligible ads, ranks the remaining candidates, and learns from impression and click feedback. The system should support query expansion or learned embeddings, including multimodal similarity when image content is available.

Repeated requests must use compatible feature, index, and model versions. Sparse clicks are useful but biased feedback, so the design must not treat every unclicked ad as a true negative. Auction pricing, billing, budget pacing, and creative generation are outside scope.

What to build

  1. Retrieve a bounded set of lexically or semantically relevant ads and remove inactive or otherwise ineligible candidates before ranking.
  2. Rank eligible candidates with text, image, query, and contextual features and return up to 20 results with compatible model and feature versions.
  3. Capture impressions and clicks, build reproducible training data without assuming all unclicked ads are negative, and release measured model improvements safely.

At scale

  • For this exercise, assume 50 million active ads and 10,000 search requests per second at peak; retrieval may return at most 1,000 candidates for ranking.
  • For this exercise, the ad-serving path should meet a 150 millisecond p95 latency target and return a lexical fallback when semantic retrieval or ranking is unavailable.
  • For this exercise, catalog changes should become searchable within 10 minutes, feedback arrives continuously, and a small human-judged query-ad set is available for unbiased relevance checks.