KatInterview

Joint Image-Text Embeddings: Training, Losses, and Retrieval Pitfalls

Machine LearningModel answer
MediumModel answerMachine Learningmultimodalcontrastive-learningdense-retrieval

Last updated

Explain how a dual-encoder image-text model is trained and used, compare contrastive losses, and discuss embedding retrieval weaknesses, alternatives, and popularity bias.

You are building a search system over a large catalog of short videos and images, where users type free-text queries. Only a fraction of the items have usable text descriptions, so you plan to rely on a joint image-text embedding model. Answer the following as you would in an ML technical screen.

  1. Dual-encoder model. Describe conceptually how a CLIP-style model works: its architecture, how it is trained, and how it is used at inference time (including for video).
  2. Contrastive objectives. Which loss functions are commonly used in contrastive representation learning? Explain several of them and say when each is a good fit.
  3. Limits of vector search. What are the main drawbacks of retrieval based on single-vector embeddings (bi-encoder plus nearest-neighbor search)?
  4. Alternatives. What other retrieval approaches exist (for example cross-encoders, hybrid sparse plus dense, generative retrieval), and what trade-offs does each make?
  5. Popularity bias. How would you detect and reduce popularity bias in an embedding-based retrieval system?

Aim for a structured answer with concrete numbers, formulas where helpful, and explicit trade-offs.

Hints

Hint 1

For part 1, think about what the N x N similarity matrix looks like inside a batch, which entries are positives, and why a bigger batch makes the task harder.

Hint 2

For parts 3 and 4, ask what information is lost when a query and an item are each squeezed into one vector before they ever interact, and which approach gives that interaction back at what cost.

Hint 3

For part 5, separate the fix into training time (correcting negative sampling), serving time (re-ranking, diversity, exploration), and measurement (head vs tail recall).