Self-Supervised · No Labels Required

Contrastive Learning — Interactive Demo

Learn how a model builds powerful visual representations without any labels — just by comparing pairs of images.

1

Build your own positive & negative pairs

Click an image to set the anchor, then pick a positive (same class), then a negative (different class). See cosine similarity and InfoNCE loss update instantly.

1
Click any image as anchor
2
Same class → positive
3
Different class → negative
Select anchor → positive → negative
to see the analysis
How the positive pair is made

Take one image (the cat below). Run it through two different random transforms. The two results are the positive pair — same content, different look. The model must learn to recognise them as the same.

ORIGINAL x
The same image
fed into both paths
→
VIEW 1 · z_i
Transform t applied
randomly
+
VIEW 2 · z_j
Different t′ applied
independently
What changed: Both views show the same cat — but with a different crop (position) and colour shift. The model sees two different-looking images and must learn they are the same object.
TOGGLE EACH TRANSFORM — watch views update
✓
🌾 Crop
✓
🎨 Colour
✓
🌫 Blur
⬛ Grayscale
↔ Flip
Key insight — The model never sees labels. It only knows: "these two views came from the same image." By learning to map them close together in embedding space, it is forced to capture what they share — the object identity — and ignore random crops and colours.

2

Live embedding space

Watch contrastive training in real time. Cats 🐱, Dogs 🐶 and Birds 🐦 start scattered. Training pulls same-class dots together, pushes different classes apart — zero labels used.

What am I seeing? — Each dot is an image embedding in 2D. Purple = Cats, Teal = Dogs, Coral = Birds. The large ANCHOR ring is the reference. The POSITIVE ring is a same-class dot being pulled closer. Red ✕ are negatives being pushed away.

Embedding space · Step 0

0.07 ← sharper (tighter clusters) · softer (loose clusters) →
—
Loss
—
kNN Acc
0
Steps
—
Negs/anchor
Legend
●
Anchor (purple ring)
Reference dot. Loss is computed relative to this.
●
Positive (teal ring)
Same class. Dashed line = being pulled closer each step.
✕
Negatives (red ✕)
Different class dots. Pushed away from anchor.
◎
Centroid
Mean of each class. Tightens as clusters form.
What's happening
Press ▶ Train to start.
Pos sim ↑
—
Neg sim ↓
—
Loss ↓
—