Bezen
ProblemsDailyPricingLog inSign up
All topics/

Modules

  1. 01What ML System Design Is
  2. 02The Machine Learning You Need
  3. 03Framing the Problem
  4. 04Requirements, Scale and Estimates
  5. 05Data Collection and Logging
  6. 06Labels
  7. 07Sampling, Imbalance and Bias
  8. 08Data Pipelines and Data Quality
  9. 09Feature Engineering for Production
  10. 10Streaming and Real-Time Features
  11. 11Feature Stores and Training-Serving Skew
  12. 12Choosing and Building the Model
  13. 13Embeddings and Candidate Retrieval
  14. 14Ranking and Multi-Stage Systems
  15. 15Training Pipelines and Training at Scale
  16. 16Offline Evaluation
  17. 17Online Experimentation and A/B Testing
  18. 18Serving Patterns: Batch, Online, Streaming and Edge
  19. 19Inference Optimisation and Scaling
  20. 20Deployment, Release and Rollback
  21. 21Monitoring and Drift
  22. 22Retraining and Feedback Loops
  23. 23Debugging Production ML
  24. 24The ML Platform (MLOps)
  25. 25Responsible ML: Fairness, Privacy and Security
  26. 26Design: A Recommendation System
  27. 27Design: Search Ranking
  28. 28Design: Real-Time Fraud Detection
  29. 29Design: Delivery Time (ETA) Prediction
  30. 30Design: Demand Forecasting
  31. 31Design: Ad Click Prediction
  32. 32Design: Content Moderation
  33. 33Design: Visual Search
  34. 34Design: Blurring Faces and Number Plates in Street Imagery
  35. 35Design: Video Search
    1. Requirements
    2. Framing
    3. Turning video into searchable signals
    4. A shared text-video embedding space
    5. Hybrid retrieval and fusion
    6. Ranking
    7. The ingestion pipeline
    8. Serving
    9. Evaluation and monitoring
    10. Sources and further reading
    11. Interview questions: the video search design
    12. Exercise: search videos by description

    Practise

    • Design an Image Search System
    • Design a Search Ranking System
    • Design a Recommendation System
    • Design a Personalized News Feed
    • Design an Ad Ranking System
    • Design Feature Monitoring
    • Diagnose Training-Serving Skew
    • Design a Model Serving Platform
    • Design an ML Feature Store
    • Design a Large-Scale Classification Platform
    • Design a Predictive Maintenance System
    • Design a Real-Time Anomaly Detection System
    • Design Model Monitoring
    • Improve a Low-Recall Model
  36. 36Design: Video Recommendations
  37. 37Design: Event Recommendations
  38. 38Design: Similar Listings for Holiday Rentals
  39. 39Design: A Personalised Social Feed
  40. 40Design: People You May Know
  41. 41The Designs Compared
  42. 42Capstone Project
  43. 43The ML System Design Interview
  44. 44Interview: Beginner Questions
  45. 45Interview: Intermediate Questions
  46. 46Interview: Advanced Questions
  47. 47Interview: Scenario and Debugging Questions

ML System Design · Module 35 of 47 · 12 concepts · about 14 min

Design: Video Search

A complete design for searching a large video platform by typing words: understanding video through its title, transcript, frames and audio, a shared text-and-video embedding space, combining keyword and semantic retrieval, ranking with engagement and quality signals, and an ingestion pipeline that makes a new upload searchable within minutes.

At work: Asked as 'design video search' or 'search across images and video'. It combines multimodal embeddings, hybrid retrieval and a heavy offline processing pipeline.

Requirements

What it is

Clipstream, a made-up video platform, wants better search. Clarify:

  • catalogue: about 500,000,000 videos; 20,000 hours uploaded a day;
  • queries: short typed text ('how to fix a leaking tap', 'goal highlights last night', song names), many languages;
  • latency: results within 200 ms;
  • freshness: a new upload should be searchable within minutes; news and sport within seconds of being processed;
  • goal: people find and watch what they searched for; satisfied searches, not just clicks.

Why it matters

Video is the hardest content to search.

  • The words people type often appear nowhere in the title.
  • What a video is about is in its speech, its pictures and its sound.
  • So most of the work is turning video into searchable signals before anyone searches.

In the real world: Video platforms index automatic speech transcripts, on-screen text and visual content precisely because metadata alone is unreliable.

Searching only titles and descriptions. Uploaders write misleading or empty titles, and the best answer to 'how to fix a leaking tap' may be titled 'Saturday DIY #14'.

Framing

What it is

Video search is retrieval followed by ranking:

  • retrieve candidates from several indexes: keyword search over text signals, and semantic search in a shared text-video embedding space;
  • rank a few hundred candidates with a learning-to-rank model (module 14);
  • labels: graded from behaviour after a search: watched to a meaningful length > clicked and left quickly > not clicked, plus human relevance judgements;
  • offline metrics: NDCG at 10 on judged queries; recall of each retrieval path;
  • online metrics: searches followed by a satisfying watch; quick returns to search (a sign of failure); query reformulation.

Why it matters

Watch time after a search is a better label than a click, because misleading thumbnails attract clicks that end in seconds.

  • 'Satisfied search' (a watch of meaningful length) is the core online metric.

In the real world: Search teams at media platforms typically define a 'successful search' by watch duration or completion, not click-through.

Training on clicks alone. Clickbait thumbnails rise to the top and users stop trusting search.

Turning video into searchable signals

What it is

Each upload is processed into several signals:

  • text: title, description, tags; speech transcript from automatic speech recognition (ASR); on-screen text from OCR;
  • visual: embeddings of sampled frames (for example one frame a second), pooled into a video-level vector, and possibly per-segment vectors;
  • audio: music identification; sound-event tags (applause, engine);
  • derived: language, topic categories, detected faces of known public figures if policy allows, quality and safety scores.

Why it matters

Each signal catches queries the others miss.

  • Speech transcripts answer 'how to' queries.
  • Visual embeddings answer 'red sports car drifting'.
  • Music identification answers song names.
  • Combining them is what makes video findable regardless of its title.

In the real world: Speech recognition models such as OpenAI's Whisper made high-quality multilingual transcripts cheap enough to run on every upload.

Visual example

Computed

Clipstream's daily processing for 20,000 hours of uploads.

Illustrative speeds: 2,000 frames a second per GPU; 100 hours of audio per GPU-hour
stepwork a dayGPU-hours a day
Frame embeddings (1 frame a second)72,000,000 frames10
Speech transcripts20,000 hours200

Storing one 256-number video vector at 16 bits for all 500,000,000 videos takes 256 GB, before per-segment vectors.

Processing every frame. Thirty frames a second of near-identical images multiplies cost thirtyfold for almost no gain; sample, or detect scene changes and embed one frame per shot.

A shared text-video embedding space

What it is

Semantic retrieval needs queries and videos in the same vector space, so a typed query lands near videos that show or say what it describes:

  • start from a pretrained image-text model trained on image-caption pairs (CLIP-style contrastive training);
  • extend to video by pooling frame embeddings, or with a model trained on video-text pairs;
  • fine-tune on Clipstream's own pairs: (query, video watched satisfyingly after that query);
  • a text tower embeds queries at search time; video vectors are computed at upload and indexed (a two-tower design, module 13).

Why it matters

This is what lets 'puppy learning to swim' find a video titled 'Bruno's first day at the lake'.

  • Fine-tuning on the platform's own search logs adapts general knowledge to how its users phrase things.

In the real world: Contrastive image-text models, introduced at scale by OpenAI's CLIP in 2021, are now the standard starting point for searching images and video with text.

# Search time: only the query is embedded; video vectors were indexed at upload.
q = text_tower.encode("puppy learning to swim")          # (256,)
candidates = video_index.search(q, k=300, filter={"lang": user_langs, "safe": True})

# Upload time: frames sampled, embedded and pooled into one video vector (plus segment vectors).
frames = sample_frames(video, every_seconds=1)
video_vec = normalise(mean(image_tower.encode(frames)))

Fine-tuning on (title, video) pairs. The model then learns to match titles, the signal that was already unreliable; use search-log pairs and transcripts.

Hybrid retrieval and fusion

What it is

Run retrieval paths in parallel and merge:

  • keyword (BM25) over title, description, transcript and on-screen text: precise for names, exact phrases, song titles;
  • semantic over the text-video embedding space: descriptive and visual queries;
  • fresh index: recent uploads in a small, frequently updated index (module 13);
  • merge with reciprocal rank fusion: each list gives an item 1 ÷ (60 + its rank), summed across lists.

Why it matters

Fusion rewards items that appear high in more than one list without needing their scores to be comparable.

  • BM25 scores and cosine similarities are on different scales, so adding them directly would let one dominate.

In the real world: Hybrid keyword-plus-vector retrieval with reciprocal rank fusion is a common pattern across search engines and vector databases.

Visual example

Computed

Keyword results v3, v1, v7, v2; semantic results v1, v5, v3, v9. v1 and v3 appear in both and rise to the top.

score = Σ 1 ÷ (60 + rank) over the lists an item appears in
videokeyword ranksemantic rankfused scorefused rank
v1210.03251
v3130.03232
v5—20.01613
v73—0.01594
v24—0.01565
v9—40.01566

Choosing one retrieval method for all queries. Song titles and exact names need keyword matching; vague, visual queries need semantics.

Practise it: Design an Image Search System, Design a Search Ranking System

Ranking

What it is

A learning-to-rank model over a few hundred candidates, with features in groups:

  • relevance: keyword match scores per field, embedding similarity, transcript match, language match;
  • quality: past satisfied-watch rate for this query or similar queries, overall completion rate, video and audio quality, channel reputation;
  • freshness: upload age, and whether the query is news-like (detected by a sudden spike in its volume);
  • personal: languages the user watches in, channels they follow, past watches on the topic;
  • safety: policy and safety scores, used both as features and as hard filters.

Why it matters

Relevance decides which videos qualify; quality and freshness decide their order.

  • For news-like queries, freshness should dominate: last night's highlights, not last year's.

In the real world: Search engines commonly detect 'fresh intent' from query volume spikes and boost recent content only for those queries.

A fixed weight on freshness. It buries evergreen tutorials under new low-quality uploads for 'how to tie a tie', or shows stale results for breaking news.

Practise it: Design a Recommendation System, Design a Personalized News Feed, Design a Search Ranking System, Design an Ad Ranking System

The ingestion pipeline

What it is

Making uploads searchable is a streaming pipeline:

  • upload event on the stream;
  • fast path (seconds to minutes): title and description indexed; thumbnail and a few frames embedded; safety checks;
  • full path (minutes): speech transcript, OCR, all sampled frames, audio identification, segment vectors;
  • index updates: the fresh index first, merged into the main index on its rebuild schedule;
  • re-processing of the whole catalogue whenever an embedding model changes, with an atomic index swap.

Why it matters

A two-speed pipeline gets new videos findable quickly while expensive analysis completes.

  • Model upgrades are the expensive event: re-embedding hundreds of millions of videos must be planned as a large batch job.

In the real world: Large platforms re-embed their catalogues in background batch jobs over days, serving the old index until the new one is complete and validated.

Visual example

Ingestion

A fast path for findability, a full path for depth.

From upload to searchable

UploadStored; event on the stream
two paths, in parallel
Fast pathTitle, thumbnail, key framesminutes
Full pathTranscript, OCR, all frames, audiolater
two indexes
Fresh indexSearchable now
Main indexMerged on rebuild
SearchableKeyword and meaning search
  1. 1
    UploadStored; event on the stream
  2. two paths, in parallel
    Fast pathminutesTitle, thumbnail, key frames
    Full pathlaterTranscript, OCR, all frames, audio
  3. two indexes
    Fresh indexSearchable now
    Main indexMerged on rebuild
  4. 4
    SearchableKeyword and meaning search

Upgrading the text tower without re-embedding videos. Queries and videos then live in different spaces and semantic search quietly degrades (module 13).

Serving

What it is

Within 200 ms:

  • query understanding (spelling, language, intent such as fresh or music) in a few milliseconds;
  • retrieval paths in parallel, each with its own timeout;
  • ranking in one batched call;
  • cache results for popular queries for a short time, keyed by language and safety settings;
  • fallback: keyword results alone if semantic retrieval is slow.

Why it matters

Parallel retrieval keeps the slowest path, not the sum, on the critical path.

  • Popular queries repeat heavily, especially for news and music, so caching removes a large share of load.

In the real world: Per-path timeouts with graceful fallbacks are standard in search serving, so a slow vector index never blocks results entirely.

Leaving safety settings out of the cache key. A restricted-mode user could be served results cached for an unrestricted one.

Practise it: Design Feature Monitoring, Diagnose Training-Serving Skew, Design a Model Serving Platform, Design an ML Feature Store

Evaluation and monitoring

What it is

Measure search from several angles:

  • offline: NDCG at 10 on human-judged queries, by query type (navigational, how-to, music, news, visual description) and language;
  • online: A/B tests on satisfied-search rate, quick-return rate and reformulation;
  • monitoring: zero-result rate, latency by path, freshness lag (upload to searchable), share of queries answered mostly by one path, safety incidents in results.

Why it matters

Query types behave differently: a change can help descriptive queries and hurt song searches.

  • Freshness lag is a key operational metric for news and sport.

In the real world: Search teams track a weekly list of queries with high quick-return rates; many fixes are transcript or language-detection bugs, not ranking changes.

Visual example

Query types

Slice every evaluation by query type.

Different queries need different signals
query typeexamplesignals that matter most
Navigationala channel's nameExact keyword match; channel signals
How-tofix a leaking tapTranscript; completion rate
Musicsong title and artistAudio identification; exact match
News and sportmatch highlights last nightFreshness; source reputation
Visual descriptionred car drifting in snowFrame embeddings

One overall NDCG. Averages hide that a new embedding model made exact-name searches worse.

Practise it: Design a Large-Scale Classification Platform, Design a Predictive Maintenance System, Design a Real-Time Anomaly Detection System, Design a Recommendation System, Design Feature Monitoring, Design Model Monitoring, Diagnose Training-Serving Skew, Improve a Low-Recall Model, Design a Search Ranking System

Sources and further reading

What it is

Public work this design draws on:

  • Radford et al., 'Learning Transferable Visual Models From Natural Language Supervision' (CLIP), 2021: contrastive image-text training;
  • Radford et al., 'Robust Speech Recognition via Large-Scale Weak Supervision' (Whisper), 2022: multilingual speech transcripts;
  • Miech et al., 'HowTo100M', 2019, and later text-video retrieval work: learning from narrated videos;
  • Cormack et al., 'Reciprocal Rank Fusion outperforms Condorcet and individual rank learning methods', SIGIR 2009.

Why it matters

These papers explain the building blocks used by modern video search, and give concrete results to cite.

In the real world: Being able to explain why contrastive training places text and video in one space is often the deciding moment in a multimodal search interview.

Interview questions: the video search design

What it is

The questions interviewers ask about the video search design, from the first screening call to the senior round. Cover the answer, say yours aloud, then compare.

Why it matters

Reading an idea and explaining it are different skills.

  • Each answer below is the two or three sentences an interviewer is listening for.
  • The reasoning behind each one is in the cards above. If an answer surprises you, go back to that card.

In the real world: Multimodal search interviews concentrate on how video becomes searchable and how two kinds of retrieval are combined.

Q: How do you search videos whose titles are poor?

Index speech transcripts, on-screen text and audio identification, and embed sampled frames into a shared text-video space so descriptive queries match visual content.

Q: How do queries and videos end up in the same space?

A two-tower contrastive model, starting from a CLIP-style image-text model and fine-tuned on (query, satisfying watch) pairs; video vectors are computed at upload, query vectors at search time.

Q: How do you combine keyword and semantic results?

Retrieve in parallel and fuse with reciprocal rank fusion, which uses ranks rather than incomparable scores.

Q: What label would you train ranking on?

Watches of meaningful length after the search, graded above clicks with quick returns, plus human relevance judgements; not clicks alone.

Q: How does a new upload become searchable quickly?

A fast path indexes text and key frames into a fresh index within minutes; a full path adds transcripts and all frames later.

Q: What happens when you upgrade the embedding model?

Re-embed the whole catalogue in a batch job, validate the new index, then swap atomically; never mix vectors from two models.

Searching titles only, or embedding every frame of every video.

Exercise: search videos by description

What it is

A short build that uses this module's ideas. Write it yourself before looking anything up; the checks at the end tell you whether it works.

Why it matters

An idea you have only read fades in a week.

  • Building it once, even in fifty lines, is what makes it yours.
  • Interviewers can tell the difference between someone who has read about a loop and someone who has debugged one.

In the real world: A demo that finds a moment in a video from a typed description is a memorable portfolio piece.

Your task. Build text-to-video search over a small set of videos using frame embeddings and transcripts, and compare it with title search.

Steps

  1. Collect 100 short public-domain or Creative Commons videos and their titles.
  2. Sample one frame every two seconds and embed frames with a CLIP model; average them into one vector per video.
  3. Transcribe audio with an open speech model and index transcripts and titles with BM25.
  4. Write 30 queries (descriptive, how-to and exact-name), and mark the relevant videos for each.
  5. Measure recall at 5 and NDCG at 10 for title search, transcript search, visual search and the fused result.

You are done when

  • Fusion beats every single path overall.
  • You can name a query type each path wins.

Stretch. Embed segments instead of whole videos and return the matching moment in the video.

PreviousDesign: Blurring Faces and Number Plates in Street ImageryNextDesign: Video Recommendations