Multimodal Models·Question 18 of 67Intermediate

Build text-to-image search over 100M product images. Walk me through the design.

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

The backbone is a CLIP-style dual encoder: offline, embed all 100M images with the image tower into an ANN index (HNSW or IVF-PQ - at 100M vectors, quantization matters for memory: 100M × 768 dims × fp16 ≈ 150GB raw, so product-quantize or use a vector DB that does); online, embed the text query with the text tower and take nearest neighbours by cosine similarity. Because both modalities share one space, cross-modal retrieval is literally nearest-neighbour search - that's CLIP's superpower - and the same index gives image-to-image "find similar" for free.

Full worked answer with diagram

The backbone is a CLIP-style dual encoder: offline, embed all 100M images with the image tower into an ANN index (HNSW or IVF-PQ - at 100M vectors, quantization matters for memory: 100M × 768 dims × fp16 ≈ 150GB raw, so product-quantize or use a vector DB that does); online, embed the text query with the text tower and take nearest neighbours by cosine similarity. Because both modalities share one space, cross-modal retrieval is literally nearest-neighbour search - that's CLIP's superpower - and the same index gives image-to-image "find similar" for free.

What separates a senior answer is the practical failure list:

  • Domain shift: stock CLIP is trained on web alt-text; "SKU-style" queries ("men's slim-fit oxford, navy, 15.5/34") aren't captions. Fine-tune the dual encoder on your own (query, clicked-product-image) pairs with hard negatives - click logs are the goldmine. SigLIP-class checkpoints are a stronger starting point than original CLIP.
  • Text encoder limits: CLIP's 77-token cap and caption bias - long or attribute-heavy queries need either a fine-tuned encoder or query rewriting into caption style.
  • Attribute binding: "red shirt with blue logo" retrieving blue shirts with red logos is the classic contrastive-encoder failure. Fix in reranking, not retrieval: run the top ~50 candidates through a VLM reranker ("does this image match this description?") or match structured attributes extracted at ingestion.
  • Hybrid with metadata: pure visual search loses to metadata filters on price/brand/size; the right system is vector search and structured filters and BM25 over titles, fused.
  • The modality gap: image and text embeddings cluster in separate cones, so absolute cosine scores are miscalibrated across modalities - rank within a query, don't threshold across queries without calibration.

Evaluate with recall@k on labelled (query, relevant-set) pairs from real traffic, plus online CTR/purchase-through A/B tests.

Worth sketching. Separating the offline half from the online half shows where the cost sits and why attribute binding gets fixed in reranking, not retrieval.

flowchart LR
    A["100M product images"] --> B["Image tower, offline"]
    B --> C["ANN index,<br/>product-quantized"]
    D["Text query"] --> E["Text tower"]
    E --> C
    D --> F["Structured filters<br/>and BM25 over titles"]
    C --> G["Fuse ranked lists"]
    F --> G
    G --> H["Rerank top ~50<br/>with a VLM"]

What a good answer covers

  • The backbone is a CLIP-style dual encoder
  • Because both modalities share one space, cross-modal retrieval is literally nearest-neighbour search -…
  • Domain shift: stock CLIP is trained on web alt-text; "SKU-style" queries ("men's slim-fit oxford, navy,…
  • Text encoder limits: CLIP's 77-token cap and caption bias - long or attribute-heavy queries need either…
  • Hybrid with metadata: pure visual search loses to metadata filters on price/brand/size; the right system…

Key terms: CLIP-style dual encoder · Domain shift · Text encoder limits · Attribute binding · Hybrid with metadata · The modality gap

Interviewer follow-ups to expect

  1. How do you mine hard negatives from click logs without poisoning training with position bias?

  2. A merchandiser complains "red dress" surfaces orange dresses - debug path?

  3. When is a caption-then-BM25 pipeline actually better than embedding search?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep