KatInterview

Design a Multimodal Video Search Engine

Machine LearningModel answer
HardModel answerMachine Learningsystem-designinformation-retrievalvector-search

Last updated

Design a scalable text-to-video and video-to-video retrieval architecture handling billions of clips, detailing modeling choices, vector indexing, serving pipelines, and evaluation strategy.

Design an end-to-end multimodal search system capable of supporting both text-to-video and video-to-video queries across a collection of hundreds of millions of long-form videos (totaling billions of distinct video clips).

Requirements & Scope

  1. Functional Capabilities

    • Text Querying: Natural language searches (e.g., "fast-moving sports car turning a corner on a rainy night").
    • Video Querying: Finding visually or semantically similar clips, including near-duplicate detection and style-matching given a query video clip or uploaded file.
    • Clip-Level Granularity: Queries must return precise time segments (start and end timestamps) within videos, not just video-level metadata.
  2. System Scale & Constraints

    • Corpus: 500 million long videos, yielding ~5 billion clips after temporal segmentation (~6-second average clip duration).
    • Ingestion: Up to 1 million new uploaded videos per day. Target end-to-end processing freshness of <15 minutes.
    • Query Traffic: 5,000 queries per second (QPS) at peak.
    • Latency Budget: End-to-end $p_{99}$ latency $\le 300\text{ ms}$ (Vector retrieval budget $\le 80\text{ ms}$).
    • Operations: Instant compliance with copyright/takedown requests and real-time metadata filtering (date ranges, video quality, safety tags, licensing).

Instructions

Walk through the complete architectural design for this system:

  • System Scale & Resource Estimation: Provide a concrete memory and storage budget for embeddings, indexes, and raw media assets.
  • Model Architecture & Training: Define the dual-encoder layout (video and text towers), frame-level temporal aggregation mechanisms, embedding dimension, loss functions (e.g., InfoNCE, hard-negative mining strategies), and fine-tuning approaches. Explain how long videos are segmented and aggregated.
  • Serving & Infrastructure Pipeline: Describe offline batch processing vs. online streaming ingestion, metadata enrichment (ASR, OCR, optical flow, VLM captioning), and real-time query handling.
  • Vector Indexing & Retrieval: Architect a multi-tiered vector search scheme (e.g., main index vs. fresh index), trade-offs between algorithm choices (HNSW vs. IVF-PQ), memory footprint optimization, and strategy for metadata filtering and instant deletion propagation.
  • Evaluation, Reranking & Feedback: Detail offline/online evaluation metrics, second-stage reranking (cross-encoder vs. dual-encoder), online A/B testing, and click/relevance feedback integration.

Hints

Hint 1

Break the system down into two fundamental sub-problems: learning a unified embedding representation space across modalities, and executing low-latency high-throughput vector search at multi-billion scale.

Hint 2

Consider memory constraints: 5 billion raw high-dimensional floating-point vectors cannot fit cost-effectively into uncompressed in-memory indexes (like pure HNSW). Contrast inverted file indexes with product quantization (IVF-PQ) against graph-based approaches.

Hint 3

For long videos, avoid encoding the entire video into a single vector, as local actions will be lost. Segment videos at natural shot boundaries, represent each segment as an individual embedding, and aggregate clip matches at request time.