Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Visual Similarity Search System

Retrieve relevant images from a changing corpus using visual encodings while keeping model, index, and item versions aligned.

Problem statement

For this exercise, assume a user supplies an image and asks for visually similar items from an approved image corpus. The response shows ranked image results with item identities and thumbnails. This is image-to-image retrieval: no text query, generated answer, or image generation is required.

A corpus owner may add, replace, or remove images. During replacement, the previous searchable image version remains active until the new version is ready; a result must never pair a score for one image version with a thumbnail for another.

An item must not appear after its removal takes effect, even if an older vector index or result cache still contains it. The product team trains or selects a visual encoder from permitted examples and relevance judgments, evaluates it offline, and releases a compatible encoder and search index together.

Explain visual preprocessing and encoding choices, not just the vector database. Design the upload and indexing flow, online query path, candidate retrieval and ranking, model and index lifecycle, and quality monitoring.

A reasonable design may use approximate nearest-neighbor retrieval followed by exact-vector or metadata reranking, but defend its trade-offs. The quantities below are practice assumptions rather than claims about the reported interview.

Product checkout, text search, generated descriptions, and image moderation are outside this exercise.

What to build

  1. A user can submit a valid query image and receive ranked, currently permitted corpus items with stable identities and displayable thumbnails, or a no-match outcome.
  2. A corpus owner can idempotently add, replace, or remove an image and inspect its active and pending versions; a replacement keeps the old version searchable until the new one is ready.
  3. The product team can evaluate visual representations against versioned relevance judgments and release or roll back a compatible encoder and index generation.

At scale

  • For this exercise, assume 10 million active images, up to 200 adds or replacements per second, and 1,000 search requests per second at peak.
  • For this exercise, the search service should return results within 250 milliseconds at p95 after receiving a valid query image; large uploads may be rejected before encoding.
  • For this exercise, an accepted removal must be absent from new result responses within one minute, including responses served from old index generations or caches.
  • For this exercise, relevance quality is evaluated on a reviewed, versioned set of query images and graded matches using recall at 20 and ranking quality by important image categories; the team can reject a faster index if those measures regress materially.