Visual Search (Search by Image)
Goal: given a photo, return visually similar items (Pinterest Lens, Google Lens, product search).
offline: catalog images -> embedding model (CNN/ViT, trained contrastively on (query, clicked item) pairs)
-> vectors -> ANN index (HNSW / IVF-PQ), sharded + replicated
online: query image -> object detection / crop -> embed (GPU) -> ANN top-k -> re-rank
(metadata filters, freshness, personalization) -> results
Key points: train embeddings with contrastive / triplet loss using engagement data; hard-negative mining; quantization (PQ) to fit billions of vectors in memory; index refresh for new items; evaluate with recall@k on labeled pairs + online CTR; dedupe near-identical images.