An image encoder and a text encoder are trained so matching image-caption pairs sit close together in one embedding space and non-matching pairs sit far apart. Which loss does this describe?
- Exam domain
- Core Machine Learning and AI Knowledge20% of the exam
- Difficulty
- Medium
- In this mock
- 10 questions on this domainPractise this domain
Why the exam asks this
Core Machine Learning and AI Knowledge (20% of the exam)
Objective in the exam guide: Develop content introducing multimodal loss functions.
Loss choice decides what the model learns to align.
Why C is the answer
A contrastive loss over image-text pairs in a batch
Contrastive losses, as used by CLIP, pull matching pairs together and push other pairs in the batch apart, which aligns the two modalities in a shared space.
Remember: Image-text alignment uses a contrastive loss.
How it works
Multimodal loss functions include contrastive losses for alignment, reconstruction losses for generation and task losses such as cross-entropy.
In detail
- Contrastive loss aligns modalities.
- Other pairs in the batch act as negatives.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Cross-entropy over a fixed set of ten image classesWrongMost tempting
A fixed class set is not image-text alignment.
Why it tempts: Cross-entropy is the default loss, so it gets picked by habit.
B. L1 loss on the predicted bounding box coordinatesWrong
Box regression is for detection.
C. A contrastive loss over image-text pairs in a batchRight
Image-text alignment uses a contrastive loss.
D. Mean squared error between pixel values and caption lengthWrong
Pixels and caption length are not comparable targets.
Use case
An illustrative scenario, not a real incident.
Illustrative: a retailer trains a contrastive model so shoppers can search product photos with plain text.
See it in different ways
mindmap
root(("Multimodal fusion"))
n1["Early fusion"]
n2["Join raw or low-level features"]
n3["One model sees everything"]
n4["Late fusion"]
n5["Separate models per modality"]
n6["Combine predictions"]
n7["Shared embedding"]
n8["Encoders map to one space"]
n9["CLIP-style contrastive training"]How to read this chart
- The centre is "Multimodal fusion".
- "Early fusion" covers "Join raw or low-level features", "One model sees everything".
- "Late fusion" covers "Separate models per modality", "Combine predictions".
- "Shared embedding" covers "Encoders map to one space", "CLIP-style contrastive training".
sequenceDiagram participant P0 as Image encoder participant P1 as Text encoder participant P2 as Loss P0->>P2: image embeddings P1->>P2: text embeddings P2-->>P0: pull matches close, push others away P2-->>P1: same signal
How to read this chart
- 1. Image encoder sends "image embeddings" to Loss.
- 2. Text encoder sends "text embeddings" to Loss.
- 3. Image encoder gets a reply from Loss: "pull matches close, push others away".
- 4. Text encoder gets a reply from Loss: "same signal".
Related questions
Learn more
- Our lesson: Deep learning foundations for multimodal models
- Practise Core Machine Learning and AI Knowledge questions in the mock exam
- Source: Learning Transferable Visual Models From Natural Language Supervision, CLIP (arXiv)
- Fundamentals of Deep Learning (NVIDIA DLI)
- PyTorch documentation
- Deep Residual Learning for Image Recognition (arXiv)
- Transfer learning tutorial (PyTorch)