KatInterview

Build a Natural-Language Image Search Service with Access Control

System DesignModel answer
MediumModel answerSystem Designml-system-designmultimodal-embeddingsvector-search

Last updated

Design a service that lets users find images from free-text descriptions, handling batch ingestion, joint embeddings, permission filtering, ranking, evaluation, updates, and deletions.

Problem

Your team is building a search product over a large collection of images. Images are loaded in bulk by batch jobs, not through an interactive upload flow. End users type a sentence or phrase describing what they want (for example, "a whiteboard covered in architecture diagrams") and expect the best-matching images back.

Design the end-to-end system.

Requirements and assumptions

  • Images can be large, and they arrive in batches.
  • A query must find images by what they show, even if nobody ever wrote a caption or tags for them.
  • Every result must respect tenant boundaries and per-object permissions.
  • When an image is changed or removed, every derived artifact (thumbnails, embeddings, OCR text, index entries, caches) must reflect that.

What to cover

  1. Ingestion pipeline: validation, safety checks, preprocessing, enrichment, and provenance.
  2. How images and text queries are represented so they can be compared.
  3. Metadata and permission handling at query time.
  4. Candidate retrieval and a more precise ranking stage.
  5. How you would measure quality, both offline and online.
  6. Updates, deletions, near-duplicates, and unsafe content.
  7. Monitoring, failure modes, and fallbacks.

Questions worth raising with the interviewer

  • Should relevance be driven by visual content, text inside the image (OCR), metadata, or a mix?
  • What are the corpus size, peak query rate, latency target, and freshness expectation for new uploads?
  • Is human relevance feedback available, and how much?

Hints

Hint 1

Think of two parallel paths: an offline, batch-oriented pipeline that turns each image into searchable representations, and an online path that embeds the query, retrieves candidates, filters by permission, and reranks.

Hint 2

A contrastively trained image-text model gives a shared embedding space, so a text query can match images with no caption. Decide whether permission filters are applied before, during, or after the approximate nearest-neighbor search, and what each choice costs in recall and latency.

Hint 3

Treat each image as a versioned entity with content hash, ACL version, and derived artifacts keyed to that version. This makes deletes, updates, and dedup tractable, and it gives you a clean way to separate offline relevance metrics from online behavior metrics.