Explain Contrastive Image-Text Pretraining and Zero-Shot Photo Classification

Last updated: November 29, 2026

Quick Overview

Explain how a dual-encoder image-text model is trained with a symmetric contrastive loss, how it classifies images into labels it was never explicitly trained on, and what limits its accuracy for Google Photos search.

Google
Machine Learning
Machine Learning Engineer
Google
November 29, 2026
Machine Learning Engineer
Technical Screen
Machine Learning
Medium

0

0

0 solved


Explain how a dual-encoder image-text model is trained with a symmetric contrastive loss, how it classifies images into labels it was never explicitly trained on, and what limits its accuracy for Google Photos search.

Natural-language photo search in Google Photos and visual search in Lens rely on aligned image and text embeddings, so Google interviewers ask candidates to explain the objective and its zero-shot behavior. They check the loss, the role of temperature and batch size, and realistic failure modes.

What the Interviewer Expects
  • Describes separate image and text encoders projecting into a shared normalized space
  • Writes the symmetric cross-entropy over the batch similarity matrix
  • Explains the learned temperature and why large batches matter
  • Explains zero-shot classification with text prompts as class prototypes
  • Discusses prompt templates and ensembling
  • Names weaknesses such as counting, spatial relations, and fine-grained classes
Key Topics to Cover
Contrastive learning
Image-text embeddings
Zero-shot classification
Temperature
Dual encoders
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
  • Why does a sigmoid pairwise loss remove the need for a global softmax across the batch?
  • How would you adapt the model to a user's personal concepts, like a pet's name?
  • How would you evaluate retrieval quality for photo search queries?
  • What biases can web-scale image-text data introduce?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Explore ML Interview Prep
Sample Answer
Clarify

Training data: hundreds of millions of image and alt-text pairs. Model: image encoder ff, text encoder gg, both producing L2-normalized vectors. Uses: zero-shot labeling and text-to-photo retrieval....

Approach

For a batch of NN pairs, compute the N×NN \times N similarity matrix Sij=f(xi)Tg(tj)/τS_{ij} = f(x_i)^T g(t_j) / \tau. Each row is a classification problem: image ii should pick text ii among NN; each column the ...


Submit Your Answer
Markdown supported