InfoNCE Contrastive Loss

hard
Unit 28 · Tokenization0/0 to milestone

Embedding models (CLIP, sentence-transformers, E5) are trained contrastively: in a batch of matching pairs (ai,bi)(a_i, b_i), each aia_i should be closer to its own bib_i than to every other bjb_j.

Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
InfoNCE Contrastive Loss · TechGradify