KatInterview

Building a Copy-Detection Pipeline for Massive Photo and Video Libraries

System DesignModel answer
HardModel answerSystem Designnear-duplicate-detectionperceptual-hashingembeddings

Last updated

Design a platform that finds re-uploaded or lightly edited photos and videos across billions of items, covering fingerprinting, indexing, match thresholds, evaluation and abuse resistance.

Problem

You are asked to design a service that recognizes when a photo or video is a copy of something already in a very large media collection. Copies may be re-uploads, re-encodes, or lightly altered versions of an original. The results drive three downstream actions: removing content, merging duplicates into one canonical item, and cleaning datasets.

Requirements

  • Handle both images and videos.
  • Remain robust to resizing, cropping, re-encoding, watermarks or overlays, and small edits.
  • Support high-volume ingestion and low-latency lookups for takedown, merge, and dedup decisions.
  • Scale to billions of media items.

What to cover

  1. Fingerprinting strategy. Compare perceptual hashing with learned embeddings, and say what you would actually deploy and why. Explain how the approach extends from images to video.
  2. Indexing and retrieval architecture. Describe the ingestion path, the query path, index types, memory and storage sizing, sharding, and how fresh uploads become searchable.
  3. Decisions and operations. Explain how you set thresholds for different use cases, how you evaluate quality offline and online, how you limit false positives, and how you defend against users who deliberately try to evade detection.

State your scale assumptions (corpus size, upload rate, latency targets) explicitly and justify the trade-offs you make.

Hints

Hint 1

Think of a cascade rather than a single method: cheap, exact or near-exact checks first, then a more robust but costlier learned representation, then an expensive verification step on a small candidate set.

Hint 2

For billions of vectors, compressed approximate nearest-neighbor indexes with a full-precision rerank are the usual answer; for compact binary hashes, consider splitting the bits into chunks so that a close match must agree closely on at least one chunk.

Hint 3

Video is the image problem plus time: sample frames, retrieve candidate videos by frame matches, then verify by aligning the frame sequences so trims, speed changes and embedded clips are handled and a matched duration can be enforced.

Hint 4

Different actions need different precision. Calibrate a combined score, choose per-use-case operating points, and be careful that clustering over match edges does not chain unrelated items together.