Act IV · Generation and Perception
Part 24 of 31Learning Without Labels
How can a network learn what matters in data that nobody labelled?
The part opens with six hundred test digits placed on a sphere by a network that never saw a label, and beside it the collapsed alternative, every digit at one point. One bench is fixed: MNIST, the same three-layer convolutional encoder and 800 updates for every method, judged by a linear probe, k nearest neighbours and a probe from ten labels per digit. Pretext puzzles come first, with rotation prediction and its blind spots. Contrastive learning follows: InfoNCE is an N-way classification whose value bounds the mutual information and never exceeds log N, SimCLR pulls two views of one digit together, and on the sphere its loss splits into alignment and uniformity. The part turns on collapse: a network trained only to make two views agree sends everything to one point, and its effective rank shows it. Four ways out are trained and broken in turn: negatives, the asymmetry of BYOL and SimSiam's stop-gradient, the decorrelation of Barlow Twins and VICReg, and DINO's centring and sharpening. Masked autoencoders and JEPA predict what is hidden, in pixels or in meaning. It ends with every method on one budget, embeddings for search, and CKA's answer to whether different networks come to see the same world.
What you need. Linear algebra (singular values, the Frobenius norm) and the softmax; mutual information from Part 1 and the contrastive loss of Part 23.
- Mathematics and history
- contrastive learning, BYOL and collapse, DINO, MAE, JEPA, embeddings
- Models, data
- DINOv3, V-JEPA 2
What you will be able to do
Undergraduate
- Explain what a pretext task is and how a frozen representation is judged by a linear probe and by nearest neighbours.
- Describe collapse, and say why agreement between two views alone does not prevent it.
Master's
- Write the NT-Xent loss, compute its value at a collapsed encoder, and say what the temperature does to the push on near and far negatives.
- Compute the effective rank of an embedding from its singular values.
- Explain how the stop-gradient, the variance term and centring with sharpening each block a collapse, and what happens when each is removed.
Research
- Derive InfoNCE's optimal critic and its bound, and the alignment-uniformity limit of the contrastive loss as N grows.
- Prove linear CKA's invariance to rotation and scaling, and state the platonic representation hypothesis with the caveats the part's own checks raise.
Engineering
- Choose between a frozen probe, few-label probe and fine-tuning to evaluate an encoder, and monitor training without labels with the effective rank.
- Build a retrieval index on embeddings and shorten them with Matryoshka training, knowing what accuracy each length keeps.
Contents
Each chapter has a home level. Choose a track to see what to read and watch: Undergraduate 15 min · Master's 44 min · Research 54 min · Engineering 25 min.
- 0Nobody told it what a digit isUndergraduate3 min
- 1Learning without labelsUndergraduate4 min
- 2Invent a puzzleUndergraduate3 min
- 3Telling the real from the fakeMaster's4 min
- 4Two views of one digitMaster's3 min
- 5Alignment and uniformityResearch3 min
- 6CollapseUndergraduate3 min
- 7No negatives: BYOL and SimSiamMaster's3 min
- 8Decorrelate: Barlow Twins and VICRegMaster's3 min
- 9Self-distillation: DINOMaster's3 min
- 10Scale and curationEngineering4 min
- 11Fill in the blanks: MAE and BEiTMaster's3 min
- 12Predict the meaning, not the pixelsResearch3 min
- 13Every method, one budgetEngineering3 min
- 14Embeddings for searchEngineering3 min
- 15Do all models see the same world?Research4 min
- Recap, problems, and what comes nextAll tracks2 min
Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · 中文 · Build the film.
Lecture
The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film. A dashed box stands for a number the film computes when it is rendered (hover over it to see what is computed); the README's figures for each chapter, where it lists them, follow the chapter's text.
Nobody told it what a digit isUndergraduate3 min
These six hundred dots are handwritten digits. A network has squeezed each one into just three numbers, a point on a sphere. The colours are the digits' labels, zero to nine. But the network never saw a label. All it was ever asked was which two distorted copies of a picture came from the same digit. And yet, after centring and renormalizing these embeddings, a weighted vote of the twenty nearest training embeddings names the ten thousand test digits correctly percent of the time.
Here is how it got there. Each step shows the network a hundred and twenty-eight digits, each in two versions, cropped, tilted, smudged. It pulls the two versions of each digit together, and pushes everything else apart. Nothing in this rule mentions a five or a seven. The clusters appear anyway, because two smudged copies of a five resemble each other in the same ways that all fives resemble each other. Leave out the push, and the outputs bunch near the same spot. Sending every digit to one fixed point on the sphere would attain the loss minimum.
That is the question of this part: how does a network learn what matters when nobody labels the data? The field has found three families of answers. Hide part of the input and ask for it back. Show two versions of the same input and ask the network to make them agree. Or hide part of the input and ask not for its pixels but for what it means. And every one of them must avoid the same trap we just saw: a network that gives the same answer for everything agrees with itself perfectly.
This is Part 24 of AI, Built: learning without labels. In this part: how the field got here, and how to judge what a network has learned; contrastive learning, from word2vec's negative samples to SimCLR; the geometry of the sphere; collapse, made to happen and then prevented four ways; self-distillation, and what it takes to scale it; masked models and joint-embedding prediction; every method on one budget, and embeddings for search; and whether different networks end up seeing the world the same way. Every model in this part is trained on the computer making it.
1Learning without labelsUndergraduate4 min
For thirty years, a network learned to see by being told. MNIST, the digits we use in this part, came with sixty thousand labels; ImageNet with more than a million, each one checked by people. But pictures without labels are nearly free. DINOv2, in 2023, trained on a hundred and forty-two million unlabelled images; DINOv3, in 2025, on one point seven billion, chosen from a pool of about seventeen billion. Nobody will ever label those. The question is how to learn from them anyway.
In 2016 Yann LeCun drew intelligence as a cake. Supervised learning, from labels, is the icing; reinforcement learning, from rewards, is the cherry on top. The cake itself is learning to predict any part of the input from any other part: there is far more information in a picture than in its label. He later gave the cake its current name: self-supervised learning. Hide part of an input, or change it, or pair it with another, and ask the network to recover what was hidden, or which goes with which. Nobody writes the answers; the data does. What we keep is not the answer but the network's internal vector, its representation.
How we got here. In 1961 the neuroscientist Horace Barlow proposed that the senses recode what they receive to remove its redundancy. In 1992 Sue Becker and Geoffrey Hinton trained two small networks that looked at neighbouring parts of an image to agree with each other, and they discovered depth. Siamese networks for signatures followed, then a contrastive loss that pulls similar pairs together and pushes others apart. Denoising autoencoders hid part of the input; noise-contrastive estimation and word2vec learned by telling real data from noise. Around 2015 came pretext puzzles, and in 2018 the InfoNCE loss. Between 2019 and 2021, MoCo, SimCLR, BYOL, DINO and MAE closed the gap to supervised training. Since then: prediction in representation space, and models trained on billions of images and on video.
How do you judge a representation, when the whole point was not to use labels? You freeze the network, and ask how easily its vectors can be read. A linear probe: train only a linear classifier on top, with all the labels. If the digits are separated by flat walls in this space, the network has done the work. A nearest-neighbour vote: no training at all, just ask the twenty closest training digits. And the test that matters most in practice: a linear classifier from only ten labelled examples of each digit.
Our test bench is MNIST: sixty thousand handwritten digits to learn from, ten thousand to test on. Every method gets the same small network, the same updates and 256 online encoder passes per update, from three random starts. Views differ by method; momentum targets and heads add unequal compute. Three yardsticks first. The raw pixels; an untrained network; and the same network trained with every label. These are reference points for judging what a self-supervised method learned. It can also score below the untrained network.
2Invent a puzzleUndergraduate3 min
The first idea was to invent a puzzle whose answer comes free with the data. Cut an image into tiles and ask where one tile sits relative to another. Shuffle the tiles and ask for the order. Remove the colour and ask for it back. Cut a hole and ask what was there. Or turn the image and ask which way is up. To answer, the reasoning went, the network has to know what things look like. The catch is that a network solves the puzzle you set, not the problem you meant.
We trained the rotation puzzle. Each step, sixty-four digits are each turned four ways, and the network must say which turn it is looking at. Here are four test digits, each in its four turns, with the network's four probabilities beside them; green is the right answer. Within a few hundred steps it is right about 71 percent of the time. And the green curve is what we actually care about: whether the network's vectors put fives near fives. It never saw a label, yet its nearest-neighbour accuracy on the digits goes from 73 to 86 percent on this quick test.
The puzzle has blind spots, and we can measure them. This is how often the trained network finds the right turn, digit by digit, averaged over the three seeds. The worst are the . The task decides what the network attends to, digit by digit.
So how good is the representation? Puzzles found shortcuts in real photographs too. The first tile puzzle, in 2015, was partly solved from chromatic aberration: the colour fringes a lens adds near the edge of a photo give away where a tile came from. The authors had to strip colour from the tiles. Pretext tasks taught the field that free labels work, and that the choice of puzzle decides what is learned.
One puzzle turned out to be different from the rest, because it is not about any particular property of images. Make every image its own class. Its transformed copies count as the same class; every other image is a different one. Alexey Dosovitskiy and colleagues tried it in 2014, and in 2018 Zhirong Wu and colleagues scaled it to a million classes, one per ImageNet photo, by keeping a stored vector for every image and comparing against those. Telling one image from all the others is the contrastive idea, and the next chapter is its mathematics.
3Telling the real from the fakeMaster's4 min
Contrastive learning starts from a statistics trick of 2010. You want a model of your data, but its probabilities need a normalizing sum over every possible input, which you cannot compute. So add noise you chose yourself, and train a classifier to tell data from noise. Michael Gutmann and Aapo Hyvärinen showed that the best such classifier has to know the ratio of the data's density to the noise's, so it learns the model without the sum. They called it noise-contrastive estimation.
Three years later, word2vec made the trick simple enough for everyone. Take a word, dog, and a word that really appeared near it, barked. Push their vectors' score up. Then draw a handful of words at random, from the word frequencies raised to three quarters, and push their scores down. This is negative sampling, a simplified noise-contrastive estimate, and it is the version Part 3 trained on the books. A real pair against fake ones: every method in the next three chapters has this shape.
In 2018 Aaron van den Oord, Yazhe Li and Oriol Vinyals wrote the modern form. Take an x, and N candidates. One of them, y one, really goes with x; the other N minus one were drawn at random. A scoring function f rates every pair, a softmax turns the scores into a guess, and the loss is the cross-entropy of guessing the partner. They called it InfoNCE, because it is noise-contrastive estimation turned into an N-way choice, and because of what it measures: information.
Why information? Call K the slot where the partner sits. The loss is the cross-entropy of a classifier guessing K. A cross-entropy is never smaller than the true entropy of what it guesses. K was uniform over N slots, so that entropy is log N, minus whatever x and the candidates reveal about K. The candidates by themselves reveal nothing: the partner, on its own, looks like any other draw. By the chain rule, what x reveals about K is at most what x shares with the whole set, and that is exactly what x shares with its partner, the mutual information. So log N minus the loss is a lower bound on the mutual information. And because a loss is never negative, the bound can never say more than log N.
We can watch the ceiling. Take pairs of Gaussian vectors with a known amount of shared information: , or nats. Train a small scoring network with InfoNCE at each number of candidates N, from two to five hundred and twelve, and read off log N minus the loss. But with nats to find, the estimate climbs along the log N line and stops at nats, even with candidates. The loss cannot see more information than the number of candidates lets it. That is one reason contrastive learning wants big batches.
The paper's own model, contrastive predictive coding, applied this to sequences. Encode a stretch of speech or a row of image patches, summarize the past in a context vector, and from it pick the real future encodings out of N candidates. It worked on speech, images, text and 3D games. Everything contrastive in this part is this loss with a different choice of what counts as a partner.
4Two views of one digitMaster's3 min
Contrastive learning for pictures needs a partner for each picture, and the partner is made, not found. Take a digit and change it at random: crop and zoom, tilt, change the contrast, blur it, erase a patch, add noise. Each version is still the same digit. Two versions of one digit make a positive pair; every version of every other digit in the batch is a negative. These choices are the only knowledge we give the network: they say what should not matter.
In 2020 Ting Chen, Simon Kornblith, Mohammad Norouzi and Geoffrey Hinton put the pieces together in SimCLR. Two views of a digit go through the same network f, giving two representations, h. A small head, g, maps each to a vector z on the unit sphere. The loss is InfoNCE with the cosine as the score: in a batch of a hundred and twenty-eight digits, each of the two hundred and fifty-six views must pick out its partner from the other two hundred and fifty-five, at a temperature tau. After training, the head is thrown away and h is kept.
Here is our SimCLR learning. Six test digits, and next to each, the eight test digits whose vectors are nearest to it, green when they are the same digit, red when they are not. At the start the network is random, and only 65 percent of the neighbours match. As training goes on, the neighbourhoods fill with the right digits: 88 percent by the end. On the full test, a linear probe on its vectors reads the digit correctly 98.1 percent of the time, the mean of three runs, and the nearest-neighbour vote 96.9 percent.
Why throw the head away? Because the loss asks z to ignore everything the two views disagree on: the tilt, the size, the contrast. The head pays that price, and h, one layer below, keeps more. SimCLR's authors found the same on ImageNet, by more than ten points, and with a wide network and very large batches, their linear probe reached 76.5 percent, matching a standard-width supervised ResNet-50.
SimCLR needs its negatives in the batch, so it needs huge batches: the paper went to eight thousand images. Months earlier, Kaiming He and his colleagues had found another way, MoCo. Keep the keys of past batches in a queue and use them as negatives. To keep old keys comparable with new ones, compute them with a second encoder that is a slowly moving average of the first. We trained MoCo with a queue of four thousand and ninety-six keys.
5Alignment and uniformityResearch3 min
Watch the contrastive loss work on a sphere. This is a SimCLR network whose output has only three numbers, so every digit is a point we can see. Two quantities tell the story. Alignment: how far apart the two views of the same digit land. Uniformity: how bunched up all the points are, measured so that lower means more evenly spread. And because the network cannot spread all the fives apart without also separating them from their own views, the fives end up together.
Where did the digits land? Take each digit's average direction on the sphere. The closest pair is 4 and 9, 19 degrees apart, then 2 and 3. The farthest apart are 6 and 7. Nobody told the network that some digits are written alike; the geometry of the sphere records it. The loosest cluster is the digit 8: its points are the most spread out.
Tongzhou Wang and Phillip Isola showed why, in 2020. Write one view's loss with unit vectors: a pull toward its partner, and a log-sum over everyone. With many negatives, the sum becomes N times an average. On the sphere, the dot product with the partner is one minus half their squared distance. So the loss splits in two: an alignment term, the distance between views, and a uniformity term, smallest when the points spread evenly over the sphere. Contrastive learning is these two forces, and the temperature sets their balance.
We trained SimCLR at five temperatures, from 0.05 to 1. On the right, each temperature's final alignment and uniformity.
The temperature has a second effect. In the softmax, every negative pushes in proportion to its weight, and the weights depend on how similar it already is. At tau 0.05, the ten most similar negatives of each view take 68 percent of the push: the loss fights over the hardest cases. At tau 1, they take 4 percent; the push is spread over everything. But a hard negative is often just another five that looks like this five. Pushing it away tears a class apart; ignoring it leaves the sphere bunched. Feng Wang and Huaping Liu called this the uniformity-tolerance dilemma.
6CollapseUndergraduate3 min
Before going further, a question. Suppose the only rule is: give the two views of each digit the same vector. No negatives, nothing pushing apart. What does the network learn? Pause and think. Here is what ours did. The loss is minus the cosine between the two views' vectors. The two views nearly agree and the loss approaches minus one. The outputs are nearly constant, although small residual differences can remain. This is near collapse.
To see collapse in a network with many output numbers, we need a measure. The effective rank takes the singular values of a set of vectors, turns them into proportions, and asks how many directions carry the weight: one, if every vector points the same way, up to the dimension, if they fill the space. SimCLR keeps its vectors spread over about of its dimensions.
The whole spectrum shows more. These are the singular values of the two networks' vectors, largest first, on a log scale. The pull-together network has one dominant direction and small residual singular values. Even contrastive learning leaves part of the space unused. This is called dimensional collapse, the milder cousin of complete collapse; Li Jing, Yann LeCun and colleagues traced it to strong augmentations and to the way the layers' weights evolve together.
Collapse is not harmless to the network underneath. The collapsed vector is the output of a small head; below it, the encoder's representation h is what we would keep. Once the head's output is the same for everything, the loss is at its minimum and its gradient vanishes: the encoder is left wherever the first steps of collapse dropped it.
This trap is old. In 2005 and 2006 Raia Hadsell, Sumit Chopra and Yann LeCun trained siamese networks with a loss that already had both halves. For a similar pair, the squared distance between their outputs: pull together. For a dissimilar pair, a penalty only if they come closer than a margin: push apart, but no further than needed. Without the second half, nothing would stop the network from mapping everything to one point.
Every method from here on is a way out of this trap. The contrastive methods push other images away. BYOL and SimSiam break the symmetry between the two branches. Barlow Twins and VICReg demand that every dimension stays spread and uncorrelated. And DINO balances a teacher between two opposite collapses.
7No negatives: BYOL and SimSiamMaster's3 min
In June 2020 a DeepMind team led by Jean-Bastien Grill removed the negatives anyway. BYOL has two networks. The online network sees one view and, through an extra small network called the predictor, tries to predict what the target network makes of the other view. No gradient flows into the target; its weights are a slowly moving average of the online weights. Nothing pushes images apart, yet it did not collapse, and it beat SimCLR: 74.3 percent on ImageNet with a ResNet-50.
Five months later, Xinlei Chen and Kaiming He removed the moving average too. SimSiam is one network, applied to both views, with a predictor on one side and a stop-gradient on the other: the target vector is treated as a constant. We trained it, three times with the stop-gradient and twice without. On the sphere, with three output numbers, SimSiam keeps the digits apart without ever pushing on them, while the pull-together network bunches its outputs near one point.
Why does one stop-gradient matter so much? Chen and He offered an explanation. Imagine a free target vector, eta, for every image, and a loss that pulls each view's output toward its image's target. Minimize it by turns. With the targets fixed, take a gradient step on the network: that is exactly what the stop-gradient does. With the network fixed, the best target is the average output over all views of the image. SimSiam uses one sampled view in place of the average, and the predictor learns to make up the difference. Collapsing to a constant still minimizes the loss, but our runs do not end there. Yuandong Tian, Xinlei Chen and Surya Ganguli worked out the dynamics: the predictor and the stop-gradient together keep the useful directions from dying.
One meter for all of them: the spread of the embedding, scaled so that one means the vectors are spread evenly over the sphere and zero means they have collapsed. SimCLR ends at 0.98, BYOL at 0.70, SimSiam at 0.99. Without its stop-gradient, SimSiam ends at 0.25, and the network that only pulls together at 0.01.
How do they compare, on the same budget? With ten labels per digit: SimCLR , BYOL , SimSiam percent. And one more twist: some suspected BYOL was secretly contrastive, through batch normalization, which mixes information across a batch. Its authors replaced it with a normalization that sees one image at a time, and reached 73.9 percent.
8Decorrelate: Barlow Twins and VICRegMaster's3 min
In 1961 the neuroscientist Horace Barlow argued that the senses should recode their input so that each neuron carries something the others do not. Sixty years later, Jure Zbontar, Li Jing, Ishan Misra, Yann LeCun and Stéphane Deny named a method after him. Run both views of a batch through the network, and correlate every output dimension of one view with every dimension of the other. The loss wants this matrix to be the identity. On the diagonal, each dimension must agree between the views: invariance. Off the diagonal, different dimensions must be uncorrelated: no redundancy. A constant output cannot satisfy the diagonal, because a correlation needs variation. Collapse is ruled out by the loss itself.
Here is the matrix in our Barlow Twins, for the first twenty-four of its five hundred and twelve dimensions, measured on test digits as it trains. At first it is noise. The diagonal brightens as each dimension learns to ignore the changes between views, reaching an average correlation of .
VICReg, from Adrien Bardes, Jean Ponce and Yann LeCun, splits the same idea into three named terms. They act on raw projection outputs, before unit normalization. Invariance: the two views' vectors should be close. Variance penalizes each dimension's stabilized standard deviation when it falls below one across the batch, encouraging variation. Covariance: different dimensions should not be correlated. Each term can be removed to see what it does, so we removed the variance term. The graph uses sample variances plus one ten-thousandth under the square root, caps the results at one, then averages across dimensions, both views and each logging interval.
The two families are closer than they look. A contrastive loss makes the images in a batch dissimilar from each other; Barlow Twins and VICReg make the dimensions dissimilar from each other. Quentin Garrido and colleagues showed that, written out, the two are nearly the same objective, one acting on the rows of the data and the other on the columns. The latest of this line is LeJEPA, from Randall Balestriero and Yann LeCun in 2025: match the views, and use SIGReg to push the vectors toward an isotropic Gaussian, without a stop-gradient or a teacher.
9Self-distillation: DINOMaster's3 min
Mathilde Caron and colleagues at Facebook had spent years teaching networks by clustering: group the images, then learn to predict the groups. In 2021 they turned it into distillation without labels: DINO. A student network sees one view and outputs a probability over K prototypes, learned directions in its space. A teacher sees the other view and does the same, and the student is trained to match the teacher's probabilities, with a cross-entropy. The teacher is not trained at all: its weights are a moving average of the student's, as in BYOL.
A student copying a teacher that copies the student can collapse in two opposite ways. One prototype can win for every image: the teacher says the same thing with full confidence. Or every prototype can be equally likely for every image: the teacher says nothing at all. DINO's answer is two opposing pressures on the teacher. Centring subtracts a running average of the teacher's outputs, opposing a single winner for every input; on its own it drifts toward the uniform answer. Sharpening gives the teacher a lower temperature than the student, so its answers are more confident; on its own it drifts toward the single winner. The loss splits into the teacher's entropy and the KL between the two; either collapse drives the KL to zero, with the entropy stuck at one end.
We trained DINO, and DINO with each half of the balance removed. On the left, the entropy of the teacher's answers; on the right, the KL between teacher and student.
The same story, as the teacher's average answer over five hundred and twelve test digits, sorted from the most used prototype down. Without centring, one bar dominates: by the end, effective prototypes. Without sharpening, the marginal answer is nearly flat, with effective prototypes. DINO's marginal answer keeps effective prototypes across these test digits, measured by exponentiated marginal entropy.
And the representation? On ImageNet with vision transformers, DINO was a turning point: 78.3 percent by nearest neighbours with a small model, and the attention of its last layer traced the outlines of objects, though nobody had ever shown it an outline.
10Scale and curationEngineering4 min
To scale self-distillation, Meta's DINOv2 team in 2023 found that the data mattered as much as the model. Raw web images are dominated by a few kinds of picture, duplicated many times. So they built a dataset by retrieval. Start from curated datasets such as ImageNet; embed one point two billion deduplicated web images with a self-supervised network; let each curated image fetch its four nearest neighbours from the pool. The result, a hundred and forty-two million images, trained a vision transformer of 1.1 billion parameters, with DINO's loss plus a masked-token term and a term that spreads the vectors: 86.5 percent on ImageNet with a linear probe, never having seen a label.
We can try the same recipe on digits. Take training digits, unbalanced the way web images are: the commonest digit, , is percent of the pool, the rarest only percent. Then curate it: a small balanced set of a thousand digits, a hundred of each, plays the curated datasets. Each fetches its four nearest neighbours from the pool, using our SimCLR network as the embedding, and duplicates are dropped. Labels set up the imbalance and balanced seeds; the encoder was already trained on all MNIST training images, including these pools. The curated pool has digits, and the gap between the commonest and the rarest class shrinks from to one to to one.
Then train the same SimCLR, for the same number of steps, on each pool, and test on the usual balanced test set. For weighted nearest-neighbour evaluation, both encoders use all sixty thousand labeled training digits as the reference bank. Here is the accuracy on each digit, the commonest in the raw pool on the left.
In August 2025 came DINOv3: a seven-billion-parameter transformer, trained on one point seven billion images chosen from about seventeen billion, by clustering them at five levels and sampling evenly from the clusters, plus retrieval. Its linear probe on ImageNet reaches 88.4 percent, within a point of the best models trained with captions. Its new ingredient addresses a problem of long training: the features of individual patches, which segmentation needs, got worse as the global features improved. Gram anchoring holds the student's patch-to-patch similarities to those of an earlier checkpoint.
Is language necessary? Vision models trained with captions, like CLIP from Part 23, had been ahead on visual question answering, but they had also been trained on different data. In 2025 David Fan, Saining Xie and colleagues trained both on the same two billion images. At seven billion parameters, after multimodal training, the DINO-style visual encoder, pretrained without captions, reached 53.87 across sixteen question-answering tasks; the CLIP encoder, 52.97. The self-supervised models kept improving with size. And for questions about text and charts, the data mattered again: keeping the 1.3 percent containing charts, tables or documents beat a caption-trained model on OCR and chart tasks. The reduced pool was sampled repeatedly, keeping two billion training examples seen.
11Fill in the blanks: MAE and BEiTMaster's3 min
The second family hides part of the input and asks for it back. In 2008, denoising autoencoders corrupted an input and learned to restore it. In 2018 BERT hid fifteen percent of the words in a sentence and learned language by guessing them, as Part 14 showed. In 2021 the idea came to vision transformers twice: BEiT, which predicts discrete tokens of the hidden patches, and MAE, which predicts their pixels. The one big change from text is how much to hide. Words are dense with meaning; images are redundant, and a neighbouring pixel gives most of a hidden pixel away. MAE hides three quarters of the image.
Kaiming He's masked autoencoder is simple. Cut the image into patches, hide three quarters of them at random, encode what is left, and let a small decoder paint the whole image, scored only on the patches it could not see. MAE's encoder is a vision transformer, which can simply skip the hidden patches, so it trains three or more times faster; fine-tuned, the largest reached 87.8 percent on ImageNet. Ours uses the same convolutional network as every other method in this part, so the hidden patches are blanked out instead. Forty-nine patches of four by four pixels, thirty-seven of them hidden.
Here is ours learning, on six test digits, with the same patches hidden at every snapshot. The top row is what the model sees, the middle row its reconstruction, and the bottom row the original. At the end, some guesses have blurry digit-like strokes, while others remain ambiguous or differ from the original. The falling training loss does not guarantee a readable reconstruction of every digit.
How much to hide? Too little, and the network can copy from the neighbours; too much, and it can only guess. We tried three ratios: three seeds at seventy-five percent hidden, one each at fifty and ninety percent. This is a limited comparison.
BEiT's targets are tokens instead of pixels. It borrowed the image tokenizer of OpenAI's first DALL·E, which turns each patch into one of eight thousand discrete codes. Ours is simpler, a codebook like the ones in Part 23: k-means on four-by-four patches, sixty-four codes. A digit becomes forty-nine tokens, and the network, shown the digit with forty percent of its patches hidden, must name each hidden patch's code, as BERT names a hidden word. By the end it is right 78 percent of the time.
So, does filling in teach what a digit is? The same pattern appears at scale: MAE's linear probes trail the contrastive methods, and it shines once its layers are fine-tuned. A pixel target makes the network spend its effort on exact strokes, much of which a classifier does not need. That suggests a third way: predict, but not pixels.
12Predict the meaning, not the pixelsResearch3 min
In 2022 Yann LeCun laid out the third way, in a long essay on how machines might learn models of the world. Joint-embedding methods, like everything since chapter four, make two views agree; they need hand-made views, and a guard against collapse. Generative methods, like MAE, predict the hidden part's pixels, every detail, the predictable and the unpredictable alike. A joint-embedding predictive architecture, a JEPA, predicts the hidden part's encoding instead: the network decides what about the hidden part is worth predicting, and can drop the rest.
LeCun frames all of this with energies, the language of Part 20. A JEPA's energy is its prediction error: low when y fits x, high when it does not. Collapse is an energy that is low everywhere: every y fits every x. There are two ways to give it shape. Contrastive methods push the energy down on real pairs and up on chosen negatives, as word2vec and SimCLR do. Regularized methods instead limit how much of the space can have low energy at all: VICReg's variance floor, Barlow's decorrelation, the predictors and moving averages of BYOL, DINO and JEPA. LeCun argues the second kind scales better, because in high dimensions there are too many places to push.
I-JEPA, from Mahmoud Assran and colleagues in 2023, is the image version. Hide some blocks of the image. A context encoder sees the rest. A target encoder, a slowly moving average of the context encoder as in BYOL, sees the whole image, and its output at the hidden blocks is the target. A predictor, told where the hidden blocks are, must produce that target from the context. No pixels are predicted, and no views are needed beyond a crop. Ours runs on the same network as everything else: the targets are cells of its final four-by-four map, two blocks of two by two.
We trained I-JEPA, MAE and SimCLR on the same network, for the same number of steps. In the paper, with the largest vision transformers, I-JEPA's linear probe beat MAE's, 79.3 percent to 77.2, using more than ten times less computation.
On video, the idea becomes a model of the world. V-JEPA predicts hidden blocks of space and time. V-JEPA 2, in June 2025, was trained on over a million hours of video. Then, with less than sixty-two hours of unlabelled robot video, it learned how a robot arm's actions change what it sees, and it could pick and place objects in labs it had never seen, by searching for actions whose predicted outcome looks like a picture of the goal. Its 2026 successor learns detailed features for every patch, and grasps more reliably. And LeJEPA dropped the stop-gradient and the teacher altogether. World models return in Part 29.
13Every method, one budgetEngineering3 min
Here is every method, trained on the same network for the same number of steps, from three random starts, judged by a linear probe with all the labels. At the top, for reference, the supervised network: percent. The best method without labels is , at percent, points behind. At the bottom of the learned methods, , with ; the untrained network scores , and the raw pixels .
The full probe flatters everyone: with sixty thousand labels, even raw pixels do well. The question self-supervised learning was invented for is what you can do with very few labels. So: a linear classifier from ten labelled digits of each kind. The raw pixels manage ; the supervised network, which was trained with all sixty thousand labels before its ten-per-digit probe, . That gap, between and , is what the unlabelled digits taught.
A frozen network is one test. The other common one lets the whole network change, starting from what it learned, with a hundred labels per draw. Fine-tuning uses pretraining seed zero and three label draws; the frozen probes average three seeds and five draws. These are aggregate comparisons. Trained from scratch on a hundred digits, our network reaches percent. Of the self-supervised starts, beat that; the best is , at .
Chapter five's two numbers can be measured on every method's representation, not just SimCLR's. Here each method sits at its uniformity and alignment.
Can you tell which representation is good without any labels at all? Quentin Garrido and colleagues proposed the effective rank: in their experiments, the methods whose vectors filled more dimensions did better downstream. Here is the effective rank of each of our methods against its ten-label accuracy.
How far should this scoreboard be trusted? It is one small network, eight hundred updates, ten kinds of digit. Methods whose published recipes train for hundreds of passes over the data, DINO and the masked models, may be at a disadvantage on a budget this short. At ImageNet scale, with vision transformers, the order is different: the DINO line leads the self-supervised methods on frozen features, and masked models do well once fine-tuned. Here, 10 of the 12 methods learned enough about digits, without a single label, to beat the untrained network when only ten labels per digit are given.
14Embeddings for searchEngineering3 min
Everything so far was judged by how well a classifier could read the vectors. But much of the world uses them directly, for search. Embed every item once; embed the query; return the items whose vectors are nearest. Here is our SimCLR network as a search engine for digits: four queries and their nearest test digits, green when they are the same digit. 81 percent of them are. At the scale of the web, the nearest neighbours are found approximately, by graphs built over billions of vectors.
Search engines today mostly embed text, and the history runs from Part 3's word vectors to here. Sentence-BERT in 2019 trained twin networks to place similar sentences together. DPR, in 2020, matched questions to passages, using the other passages in each batch as negatives: InfoNCE again. SimCSE, in 2021, needed no pairs at all: feed the same sentence in twice, and the network's random dropout makes the two views. Then came contrastive pretraining on hundreds of millions of web text pairs, and a benchmark, MTEB, to compare the results. Today's leaders are language models turned into encoders. Qwen3-Embedding, in 2025, trains with InfoNCE and a temperature; Google's Gemini Embedding 2, in 2026, puts text, images, video and sound in one space. In Part 23, CLIP pairs pictures with captions using a softmax contrastive loss; SigLIP uses a pairwise sigmoid loss.
Vectors cost memory: a billion items at a thousand numbers each is four terabytes. Often you would like to search with a short vector first and refine with a long one. Matryoshka representation learning, from Aditya Kusupati and colleagues in 2022, trains one vector so that its first two numbers, its first four, its first eight, and so on, are each a good embedding by themselves, like dolls nested inside each other. The loss is just the usual loss applied to every prefix and averaged. Qwen3-Embedding supports it, and OpenAI's 2024 models can be shortened the same way: cut to 256 numbers, the large model still beats its predecessor's full 1,536.
We trained SimCLR with the Matryoshka loss, three times, and compared it with ordinary SimCLR, its vector simply cut short. Keep the first few numbers of each, renormalize, and ask the nearest neighbours.
Here is what that means for search: the same six queries, answered using only the first four numbers. Cut short, ordinary SimCLR returns the same digit 50 percent of the time; the Matryoshka embedding, 73 percent. One vector, trained once, that can be cut to fit the budget.
15Do all models see the same world?Research4 min
How do you compare what two networks learned? Their coordinates mean nothing by themselves: rotate a representation and nothing it knows has changed. So compare geometry instead. For a set of inputs, list how similar every pair is, in each representation. Centre those two tables and measure how alike they are: a statistic called HSIC. With plain dot products it becomes the squared size of the cross-product of the two centred representations. Normalize it, and you have centred kernel alignment, CKA: one when the two have the same geometry. It ignores rotations and overall scale, but, as Simon Kornblith and his co-authors argued, not every invertible map: in high dimensions, a measure that forgave every linear map would find any two networks identical.
Here is the CKA between every pair of our representations, on the same two thousand test digits; brighter is more alike. The most alike learned pair is SimCLR and the Matryoshka model, at 0.98; the least alike, VICReg and MAE, at 0.24. For scale: the same recipe run from two random starts agrees with itself at between 0.73 and 0.98.
In 2024 Minyoung Huh, Brian Cheung, Tongzhou Wang and Phillip Isola made a bold claim. Networks trained on different data, with different objectives, even on different senses, are coming to represent the world in the same way. In their words: we hypothesize that this convergence is driving toward a shared statistical model of reality. They called it the platonic representation hypothesis, after the shadows on the wall of Plato's cave. Their evidence: among seventy-eight vision models, the more capable agree more with each other; and the better a language model, the more its picture of a caption agrees with a vision model's picture of the image. Agreement is measured by shared nearest neighbours, and across senses it is still low in absolute terms.
We can run a small version of their first test on our own models. For each method, its average agreement with all the others, in shared nearest neighbours, against how good its representation is.
A sharper test borrows Becker and Hinton's setting from 1992: two networks that see different parts of the world. Encoder A sees only the top half of each digit, encoder B only the bottom half. Each is trained alone, with SimCLR, never told about the other. Do they come to agree about which digits are alike?
The authors list the caveats themselves. Different senses carry different information: a caption cannot say everything a photograph shows. How to measure agreement is still argued over. Convergence could come from shared training data, shared architectures, or the shared habits of the people building them. And ours is a toy with ten kinds of digit. Still, it is a striking idea: that learning without labels, from any angle, finds the same structure, because the structure is really there.
Recap, problems, and what comes nextAll tracks2 min
Let's take stock. A pretext puzzle teaches what the puzzle needs, blind spots and all. A contrastive loss is a classifier over candidates, and a bound on information capped at the log of their number. On the sphere it is two forces, alignment and uniformity, balanced by the temperature. An agreement-only loss admits a constant minimum; our naive network becomes nearly constant, and we measure the remaining spread. BYOL and SimSiam escape by asymmetry, Barlow Twins and VICReg by decorrelating dimensions, DINO by balancing a teacher between two collapses. Masked models learn by filling in; JEPAs predict meanings instead of pixels. And four different losses, contrastive and not, end with very similar geometry: the minimum pairwise CKA here is about .
All of this comes back. Augmentations teach a network what to ignore; next time, Part 25 builds that symmetry into the network itself. Prediction in representation space is the heart of the world models in Part 29. Probes and CKA are how Part 30 reads what a network knows, and Matryoshka's nested features return there, in sparse autoencoders. Teachers and students return in Part 27's distillation; and embeddings are the memory that the agents of Part 29 search.
Here are six problems to try, from the InfoNCE bound to DINO's two collapses. Pause here and work through them; full solutions are in this part's notes.
Next time: symmetry. Our networks learned to ignore a turn of the page only because we showed them turned pages. Part 25 builds the symmetry into the network, so that its answer either stays the same when the input turns, or turns along with it, and follows that idea from graphs to proteins, weather and mathematics.
To go deeper, the Cookbook of Self-Supervised Learning, by Randall Balestriero and colleagues, is a practical guide to everything in this part, and Kevin Murphy's second volume covers the theory. Thanks for watching, and see you in Part 25.
Where it goes next. Augmentations teach a network what to ignore; Part 25 builds that symmetry into the network itself. Prediction in representation space is the heart of the world models in Part 29, probes and CKA are how Part 30 reads what a network knows, teachers and students return in Part 27's distillation, and embeddings are the memory that the agents of Part 29 search.
Key results
The part's results in one place, for revision.
Try it
Lab 24 · InfoNCE: a lower bound with a ceiling
Draw correlated Gaussian pairs in 20 dimensions whose mutual information is known (2 or 5 nats), train a two-parameter critic with the series' autodiff to pick each x's partner out of N candidates, and compare log N minus the loss with the true information and with log N.
python -m videos.ai.labs 24
needs numpy, scipy, matplotlib · download lab24.py ·
source on GitHubI = 2 nats: trained critic (a, b) (0.523, 0.111) optimal (0.520, 0.111)
I = 2 nats: estimate at N = 2, 8, 32, 128, 512 0.57 1.26 1.72 1.88 1.94
I = 2 nats: the ceiling log N 0.69 2.08 3.47 4.85 6.24 (optimal critic at 512: 1.92)
I = 5 nats: trained critic (a, b) (1.052, 0.317) optimal (1.034, 0.324)
I = 5 nats: estimate at N = 2, 8, 32, 128, 512 0.67 1.93 3.02 3.82 4.40
I = 5 nats: the ceiling log N 0.69 2.08 3.47 4.85 6.24 (optimal critic at 512: 4.34)
NT-Xent at a collapsed encoder, N = 64 4.8442 (log(2N - 1) = 4.8442)
Picking the partner out of N candidates can certify at most log N nats: InfoNCE measures 2 nats well with a batch of 512 and cannot see 5 nats with a batch of 8, which is why contrastive methods want large batches.
The code (109 lines; it asserts its own result)
"""Lab 24: estimate a known mutual information with InfoNCE, and watch the estimate stop at log N."""
import numpy as np
from videos.coursekit import labs
from explainer.ai.autodiff import Tensor, cross_entropy
TITLE = "InfoNCE: a lower bound with a ceiling"
GOAL = ("Draw correlated Gaussian pairs in 20 dimensions whose mutual information is known (2 or 5 nats), train a "
"two-parameter critic with the series' autodiff to pick each x's partner out of N candidates, and compare "
"log N minus the loss with the true information and with log N.")
TASKS = [
"Set the true information to 10 nats. How many candidates would a batch need before the estimate could reach it?",
"Replace the critic by the plain dot product x . y (drop the |y|^2 term). How much of the bound is lost at N = 512?",
"Make all 2N embeddings of a batch equal and compute the NT-Xent loss at temperatures 0.1 and 1. Why does the temperature not matter there?",
]
D = 20
def pairs(rng, n, rho):
x = rng.standard_normal((n, D))
return x, rho * x + np.sqrt(1 - rho ** 2) * rng.standard_normal((n, D))
def rho_for(info):
"""The per-coordinate correlation that gives I(X; Y) = info nats: I = -(D/2) log(1 - rho^2)."""
return np.sqrt(1 - np.exp(-2 * info / D))
def logits(x, y, a, b):
"""The critic f(x_i, y_j) = a x_i . y_j - b |y_j|^2 for every pair of a batch (a, b numbers or Tensors)."""
return a * Tensor(x @ y.T) - b * Tensor((y * y).sum(1)[None, :])
def estimate(rng, rho, a, b, n, batches):
out = []
for _ in range(batches):
x, y = pairs(rng, n, rho)
out.append(np.log(n) - float(cross_entropy(logits(x, y, a, b), np.arange(n)).data))
return float(np.mean(out)), float(np.max(out))
def run(seed=0):
rng = np.random.default_rng(seed)
lab = labs.Lab()
Ns = [2, 8, 32, 128, 512]
curves, trained, history = {}, {}, None
for info in (2.0, 5.0):
rho = rho_for(info)
a_star, b_star = rho / (1 - rho ** 2), rho ** 2 / (2 * (1 - rho ** 2)) # log p(y|x)/p(y), up to c(x)
# train the critic at N = 128 by gradient descent on the N-way cross-entropy
a, b, trace = Tensor(0.0, requires_grad=True), Tensor(0.0, requires_grad=True), []
for step in range(300):
x, y = pairs(rng, 128, rho)
loss = cross_entropy(logits(x, y, a, b), np.arange(128))
a.grad[...] = 0
b.grad[...] = 0
loss.backward()
a.data -= 0.02 * a.grad
b.data -= 0.02 * b.grad
trace.append(np.log(128) - float(loss.data))
trained[info] = (float(a.data), float(b.data), a_star, b_star)
if info == 2.0:
history = trace
curves[info] = [estimate(rng, rho, float(a.data), float(b.data), n, 8 if n > 200 else 24 if n > 100 else 100) for n in Ns]
best = estimate(rng, rho, a_star, b_star, 512, 8)[0]
lab.row(f"I = {info:g} nats: trained critic (a, b)", f"({a.data:.3f}, {b.data:.3f}) optimal ({a_star:.3f}, {b_star:.3f})")
lab.row(f"I = {info:g} nats: estimate at N = " + ", ".join(map(str, Ns)), " ".join(f"{m:.2f}" for m, _ in curves[info]))
lab.row(f"I = {info:g} nats: the ceiling log N", " ".join(f"{np.log(n):.2f}" for n in Ns) + f" (optimal critic at 512: {best:.2f})")
assert abs(a.data - a_star) < 0.25 * a_star and abs(b.data - b_star) < 0.5 * b_star + 0.03, "the critic learns the density ratio"
assert all(top <= np.log(n) + 1e-9 for (_, top), n in zip(curves[info], Ns)), "no batch certifies more than log N"
assert all(m < info + 0.1 for m, _ in curves[info]), "and the estimate is a lower bound on I"
assert all(q[0] > p[0] for p, q in zip(curves[info], curves[info][1:])), "more candidates, tighter bound"
assert abs(curves[info][-1][0] - best) < 0.15, "the trained critic is as good as the optimal one"
assert curves[2.0][-1][0] > 1.6, "with log N well above I the bound is nearly tight"
assert curves[5.0][1][0] < np.log(8) and curves[5.0][-1][0] < 4.7, "with I above log N it is capped"
# what collapse costs a contrastive loss: 2N equal embeddings give log(2N - 1), whatever the temperature
n, tau = 64, 0.2
z = np.tile(rng.standard_normal(8), (2 * n, 1))
z /= np.linalg.norm(z, axis=1, keepdims=True)
sim = z @ z.T / tau
np.fill_diagonal(sim, -np.inf)
partner = np.concatenate([np.arange(n, 2 * n), np.arange(n)])
ntxent = float(np.mean(np.log(np.exp(sim).sum(1)) - sim[np.arange(2 * n), partner]))
lab.row("NT-Xent at a collapsed encoder, N = 64", f"{ntxent:.4f} (log(2N - 1) = {np.log(2 * n - 1):.4f})")
assert abs(ntxent - np.log(2 * n - 1)) < 1e-9
lab.note = ("Picking the partner out of N candidates can certify at most log N nats: InfoNCE measures 2 nats well "
"with a batch of 512 and cannot see 5 nats with a batch of 8, which is why contrastive methods want "
"large batches.")
fig, ax = labs.figure(2, size=(11, 4.2))
ax[0].plot(Ns, np.log(Ns), color=labs.MUTED, ls="--", label="the ceiling log N")
for info, color in ((2.0, labs.BLUE), (5.0, labs.GOLD)):
ax[0].axhline(info, color=color, ls=":", lw=1.2)
ax[0].plot(Ns, [m for m, _ in curves[info]], "o-", color=color, label=f"estimate, true I = {info:g} nats (dotted)")
ax[0].set(xscale="log", title="log N - loss against the number of candidates", xlabel="candidates N", ylabel="nats")
ax[0].set_xticks(Ns, [str(n) for n in Ns])
ax[0].legend(loc="upper left")
ax[1].plot(np.arange(1, 301), history, color=labs.BLUE, lw=1, alpha=0.5, label="each batch of 128")
smooth = np.convolve(history, np.ones(20) / 20, mode="valid")
ax[1].plot(np.arange(20, 301), smooth, color=labs.BLUE, label="mean of the last 20")
ax[1].axhline(2.0, color=labs.GOLD, ls=":", label="true I = 2 nats")
ax[1].axhline(np.log(128), color=labs.MUTED, ls="--", label="log 128")
ax[1].set(title="Training the critic (I = 2 nats, N = 128)", xlabel="step", ylabel="log N - loss (nats)")
ax[1].legend(loc="lower right")
lab.fig = fig
return lab
Now change it
- Set the true information to 10 nats. How many candidates would a batch need before the estimate could reach it?
- Replace the critic by the plain dot product x . y (drop the |y|^2 term). How much of the bound is lost at N = 512?
- Make all 2N embeddings of a batch equal and compute the NT-Xent loss at temperatures 0.1 and 1. Why does the temperature not matter there?
Problems, with solutions
Try each problem before opening its solution.
1. InfoNCE's optimal critic, and its ceiling. With N candidates, one of them x's partner, show that the critic minimizing the InfoNCE loss is f*(x, y) = log p(y | x)/p(y) + c(x), and that log N − L_N ≤ log N for every critic.
Solution
The loss is the cross-entropy of q_f(k | x, y₁…y_N) = e^{f(x, y_k)} / Σⱼ e^{f(x, y_j)} as a guess of the partner's slot K. Given K = k, the candidates' density is p(y_k | x) Πⱼ≠ₖ p(y_j) = Πⱼ p(y_j) · p(y_k | x)/p(y_k), so by Bayes the true posterior is p(K = k | x, y₁…y_N) = r(y_k) / Σⱼ r(y_j) with r(y) = p(y | x)/p(y). A cross-entropy is smallest when the guess equals the truth, so e^{f*} ∝ r: f* = log r + c(x), and c(x) cancels in the softmax. For any critic, each term −log q_f is ≥ 0 because q_f ≤ 1, so L_N ≥ 0 and the estimate log N − L_N never exceeds log N.
2. Alignment and uniformity. For unit vectors show z·z⁺ = 1 − ½‖z − z⁺‖², and derive the N → ∞ limit of the contrastive loss.
Solution
‖z − z⁺‖² = ‖z‖² + ‖z⁺‖² − 2 z·z⁺ = 2 − 2 z·z⁺. One view's loss is ℓ = −z·z⁺/τ + log(e^{z·z⁺/τ} + Σⱼ e^{z·z_j/τ}) with N − 1 negatives. Subtract log N: the logarithm becomes log of an average of N terms, which tends to log E_{z⁻} e^{z·z⁻/τ} by the law of large numbers (the partner's single term weighs 1/N). Substituting the identity, ℓ − log N → ‖z − z⁺‖²/(2τ) − 1/τ + log E_{z⁻} e^{z·z⁻/τ}: an alignment term plus a term that is smallest when the vectors spread uniformly over the sphere (Wang & Isola 2020; their L_uniform uses the Gaussian potential e^{−t‖u − v‖²} = e^{−2t} e^{2t u·v} on the sphere).
3. What collapse costs each loss. Show that a constant encoder minimizes the SimSiam loss, but gives the NT-Xent loss log(2N − 1).
Solution
SimSiam's loss is −cos(p, sg(z)) ≥ −1. If every z is the same vector z₀ and the predictor maps it to a positive nonzero multiple of z₀, every cosine is 1 and the loss is −1, its global minimum. In NT-Xent, if every z is the same unit vector, all 2N − 1 cosines of a view are 1, so its softmax is uniform and ℓ = −log(1/(2N − 1)) = log(2N − 1): the loss of guessing at random. Any configuration that keeps each pair together and spreads the pairs apart scores lower, so the contrastive loss pushes away from collapse.
4. Barlow Twins. With outputs standardized over the batch (mean 0, variance 1), show that C_ii = 1 exactly when the two views' i-th outputs are equal for every image, and explain why a constant output is excluded.
Solution
C_ii = (1/n) Σ_b a_b b_b with (1/n)Σ a_b² = (1/n)Σ b_b² = 1; by Cauchy–Schwarz C_ii ≤ 1, with equality exactly when the vectors (a_b) and (b_b) are equal. A constant output has zero variance; standardizing it gives 0 (the small ε in the denominator), so C = 0 and the diagonal term is Σᵢ(1 − 0)² = d, a positive collapse penalty. It is not the largest possible value: anti-correlated outputs have C_ii = −1 and contribute 4 per dimension. The objective favours varying, aligned outputs over the constant solution; this is not an optimization guarantee.
5. CKA's invariances. Show that linear CKA is unchanged by X ↦ cXQ (Q orthogonal, c > 0), and that when n ≤ d any two representations of rank n are related by an invertible linear map.
Solution
Centring commutes with right multiplication. ‖Ỹᵀ(cX̃Q)‖²_F = c²‖ỸᵀX̃Q‖²_F = c²‖ỸᵀX̃‖²_F, since right multiplication by an orthogonal matrix keeps the Frobenius norm; and ‖(cX̃Q)ᵀ(cX̃Q)‖_F = c²‖QᵀX̃ᵀX̃Q‖_F = c²‖X̃ᵀX̃‖_F. The c² cancel. If X and Y are n × d of rank n ≤ d, then XX⁺ = I_n, and A = X⁺Y + (I − X⁺X)B satisfies XA = Y for every B; B can be chosen to make A invertible. So a statistic invariant to every invertible linear map (as CCA is) finds any two such representations identical: this is why Kornblith et al. preferred CKA.
6. DINO's two collapses. Show H(P_t, P_s) = H(P_t) + KL(P_t ‖ P_s), and that a teacher whose output does not depend on the input lets the student reach KL = 0 without learning anything.
Solution
−Σ P_t log P_s = −Σ P_t log P_t + Σ P_t log(P_t/P_s). If P_t(x) = π for every x, a student that outputs π for every input has KL = 0, so the loss is H(π), the least possible for that teacher, and its output depends on nothing: collapse. With π one-hot, H(π) = 0 (no centring); with π uniform, H(π) = log K (no sharpening). Centring and sharpening apply opposing pressures to the teacher's outputs; with the momentum teacher, they avoided these collapses in the reported experiments. The entropy identity alone is not a stability proof: equal logits still yield an input-independent uniform stationary solution.
Notes and sources
Glossary
| English | 中文 |
|---|---|
| self-supervised learning | 自监督学习 |
| representation, encoder | 表示,编码器 |
| label, unlabelled data | 标签,无标签数据 |
| pretext task | 前置任务(代理任务) |
| context prediction, jigsaw puzzle, colorization, inpainting | 上下文预测,拼图,上色,图像修补 |
| rotation prediction | 旋转预测 |
| shortcut, chromatic aberration | 捷径,色差 |
| instance discrimination, memory bank | 实例判别,记忆库 |
| contrastive learning, contrastive loss | 对比学习,对比损失 |
| positive pair, negative (sample) | 正样本对,负样本 |
| noise-contrastive estimation (NCE) | 噪声对比估计(NCE) |
| negative sampling | 负采样 |
| InfoNCE, critic (scoring function) | InfoNCE,打分函数 |
| contrastive predictive coding (CPC) | 对比预测编码(CPC) |
| view, augmentation | 视图,数据增强 |
| projection head | 投影头 |
| NT-Xent (normalized temperature-scaled cross-entropy) | NT-Xent(归一化温度交叉熵) |
| momentum encoder, queue | 动量编码器,队列 |
| hypersphere, unit vector | 超球面,单位向量 |
| alignment, uniformity | 对齐,均匀性 |
| temperature τ | 温度τ |
| hard negative | 难负样本 |
| uniformity–tolerance dilemma | 均匀性-容忍度困境 |
| collapse: complete, dimensional | 坍缩:完全坍缩,维度坍缩 |
| effective rank, RankMe | 有效秩,RankMe |
| singular-value spectrum | 奇异值谱 |
| siamese network | 孪生网络 |
| stop-gradient | 停止梯度 |
| predictor | 预测器 |
| online network, target network | 在线网络,目标网络 |
| exponential moving average (EMA) | 指数移动平均(EMA) |
| redundancy reduction | 冗余削减 |
| cross-correlation matrix | 互相关矩阵 |
| invariance, variance, covariance terms | 不变项,方差项,协方差项 |
| decorrelation | 去相关 |
| self-distillation, student, teacher | 自蒸馏,学生,老师 |
| prototype | 原型 |
| centring, sharpening | 中心化,锐化 |
| data curation, retrieval-based curation | 数据筛选,基于检索的筛选 |
| deduplication | 去重 |
| Gram anchoring | 格拉姆锚定 |
| masked image modelling, masked autoencoder (MAE) | 掩码图像建模,掩码自编码器(MAE) |
| masking ratio | 掩码比例 |
| visual token, codebook | 视觉词元,码本 |
| fine-tuning (the whole network) | (整个网络)微调 |
| joint-embedding predictive architecture (JEPA) | 联合嵌入预测架构(JEPA) |
| context block, target block | 上下文块,目标块 |
| energy-based view; contrastive vs regularized methods | 能量视角;对比式与正则化式方法 |
| world model | 世界模型 |
| linear probe, k-NN probe, few-label probe | 线性探针,k近邻探针,少标签探针 |
| embedding, retrieval, nearest-neighbour search | 嵌入,检索,最近邻搜索 |
| text embedding, sentence embedding | 文本嵌入,句子嵌入 |
| Matryoshka representation learning | 套娃表示学习 |
| centred kernel alignment (CKA), HSIC | 中心化核对齐(CKA),HSIC |
| mutual nearest neighbours | 互为近邻 |
| platonic representation hypothesis | 柏拉图表示假说 |
Sources
Documented reference results
The values below are retained from the original README. The initial November 2, 2026 source-only pass had no original Part 24 result caches and did not rerun training. A separate numerical continuation generates fresh original-recipe outcomes; those must be validated and reported separately rather than substituted for these unverified historical values.
Every method uses the same small CNN encoder (93,408 parameters, 128-number representation \(h\)); the SimCLR encoder plus projector has 159,584 parameters. Training uses 800 AdamW updates and 256 online-encoder image passes per update. Base images are sampled with replacement: 128 per update for two-view methods (about 1.71 dataset-equivalent draws), 64 for rotation (0.85), and 256 for one-view methods (3.41). Targets, heads and augmentations differ. Labels train the supervised reference and downstream probes; the curation demonstration also uses labels to construct its imbalanced pool and balanced seeds. Values are percent on the 10,000 test digits, mean over seeds with the lowest and highest in brackets (three seeds for the main method comparison; experiment-specific exceptions are stated above). Raw pixels have one fixed representation; their few-label probe averages five label draws. Linear probe: a logistic regression on standardised \(h\) with every training label. \(k\)-NN: 20 nearest neighbours by cosine, centred features. 10 labels per digit: the same probe trained on 100 labelled digits, five draws. Fine-tuned: the whole seed-0 network trained from 100 labels (300 steps, three draws). Frozen few-label probes average three pretraining seeds and five draws. The columns compare aggregates with the same label count, not paired outcomes on identical cohorts.
| method | linear probe | \(k\)-NN | 10 labels per digit | fine-tuned from 100 labels | effective rank of \(h\) |
|---|---|---|---|---|---|
| supervised (labels) | 98.6 (98.5–98.6) | 98.3 (98.3–98.4) | 96.9 (96.8–97.0) | 92.0 (91.0–92.9) | 39.2 |
| SimCLR (τ = 0.2) | 98.1 (98.0–98.2) | 96.9 (96.8–96.9) | 89.6 (89.2–90.0) | 86.4 (82.6–88.3) | 31.1 |
| MoCo | 97.9 (97.7–98.0) | 96.6 (96.5–96.7) | 87.8 (87.3–88.6) | 86.1 (85.8–86.5) | 32.4 |
| BYOL | 94.8 (93.6–95.6) | 92.8 (91.7–93.7) | 74.0 (70.2–77.0) | 85.1 (83.3–87.0) | 33.9 |
| SimSiam | 97.3 (97.1–97.5) | 96.2 (96.2–96.3) | 86.3 (85.5–86.9) | 88.5 (85.5–90.4) | 29.9 |
| Barlow Twins | 97.6 (97.5–97.6) | 96.3 (96.1–96.4) | 88.3 (87.6–88.6) | 86.6 (85.0–87.9) | 31.7 |
| VICReg | 98.2 (98.1–98.4) | 97.1 (97.0–97.1) | 91.3 (91.0–91.6) | 87.3 (85.7–89.3) | 30.9 |
| DINO | 94.9 (94.5–95.2) | 92.4 (91.8–93.3) | 74.5 (74.0–74.9) | 86.5 (85.4–88.5) | 34.9 |
| SimCLR + Matryoshka | 97.9 (97.7–98.0) | 96.8 (96.7–96.8) | 88.7 (88.5–89.1) | 87.6 (85.8–89.8) | 32.7 |
| rotation prediction | 94.3 (94.0–94.5) | 92.2 (91.7–92.9) | 74.2 (73.4–75.5) | 88.1 (87.5–88.7) | 35.5 |
| MAE (75 % hidden) | 82.3 (81.5–82.8) | 80.3 (79.9–80.7) | 52.0 (51.8–52.3) | 82.3 (77.0–87.2) | 41.3 |
| BEiT (64 tokens) | 79.9 (78.0–81.5) | 81.8 (81.5–82.0) | 50.1 (48.5–51.0) | 76.5 (72.6–79.3) | 51.9 |
| I-JEPA | 88.4 (87.3–89.0) | 89.1 (88.8–89.5) | 60.8 (60.2–61.2) | 85.3 (84.8–86.2) | 48.0 |
| untrained network | 84.6 (84.0–85.1) | 84.2 (83.4–85.6) | 54.8 (54.2–55.7) | 82.8 (78.8–86.2) | 37.8 |
| raw pixels | 92.7 | 97.0 | 72.5 | – | 258.7 |
(The fine-tuning column of the untrained row is the network trained from scratch on the 100 labels.)
- InfoNCE is a lower bound, capped at \(\log N\) (Gaussian pairs in 20 dimensions, critic trained 1500 steps, two seeds): true \(I = 2\) nats: 0.83, 1.59, 1.87 at \(N\) = 8, 64, 512; true \(I = 5\) nats: 1.51, 3.23, 4.24 at \(N\) = 8, 64, 512; true \(I = 10\) nats: 1.84, 3.99, 5.98 at \(N\) = 8, 64, 512 (\(\log 512 = 6.24\)).
- Temperature (SimCLR linear / 10 labels per digit): τ = 0.05: 98.0 / 89.1; τ = 0.1: 98.1 / 88.9; τ = 0.2: 98.1 / 89.6; τ = 0.5: 98.0 / 89.6; τ = 1.0: 97.7 / 87.5. Crops alone, without the photometric changes: 97.3 / 86.4. Probe on the projection head's output \(z\) instead of \(h\): 97.4.
- Collapse: pull-together only ends with effective rank of \(z\) 2.3 and linear probe 84.4 (untrained: 84.6); SimSiam without its stop-gradient 2.5 and 87.3; with it 24.4 and 97.3.
- VICReg without its variance term: linear 80.0, \(k\)-NN 80.7 (with it: 98.2, 97.1).
- DINO's two collapses (teacher entropy at the end, \(\log 256 = 5.55\)): with centring and sharpening 4.37, without centring 0.00, without sharpening 5.54; effective prototype counts (exponentiated marginal entropy) 182, 1.0, 256. Linear probe 94.9, 87.3, 91.7.
- MAE masking ratio (linear probe): 50% hidden: 81.6, 75% hidden: 82.3, 90% hidden: 84.0.
- Matryoshka (\(k\)-NN on the first \(m\) numbers of the projection \(z\), Matryoshka / plain SimCLR): \(m\) = 2: 55.0 / 29.9, \(m\) = 4: 87.6 / 64.0, \(m\) = 8: 95.5 / 91.5, \(m\) = 16: 96.2 / 95.9, \(m\) = 32: 96.4 / 96.7, \(m\) = 64: 96.5 / 97.0, \(m\) = 128: 96.5 / 97.1.
- Curation (a label-assisted toy analogue of DINOv2's retrieval recipe: labels construct the pool imbalance and balanced seeds; the retrieval encoder was pretrained on all MNIST training images, including pool and seed images. Both encoders' weighted \(k\)-NN evaluation uses all 60,000 labeled training digits as the reference bank, not only the pretraining pool. On a pool of 14,000 digits with class shares from 36 % down to 1 %; curated pool 2,812): linear 97.8 raw, 98.0 curated; 10 labels per digit 88.3 and 89.8; on the rarest digit (8, 140 examples in the raw pool) \(k\)-NN goes from 93.7 to 96.1, while the three commonest change by at most 0.6 points.
- Top and bottom halves (mutual 10-NN alignment of the two encoders on the same digits): 0.17 and 0.17 for two seeds, against 0.71 for two seeds of the same half and 0.17 for the raw pixels of the halves.
- Platonic check: Spearman correlation between a method's linear probe and its mean alignment with the others: 0.66. Same recipe, two seeds, linear CKA: supervised 0.95, simclr 0.98, byol 0.92, dino 0.97, mae 0.73.
- Different losses, one representation: linear CKA between SimCLR, MoCo, Barlow Twins and VICReg (seed 0 each) is at least 0.97 for every pair, as high as two seeds of SimCLR (0.98); MAE against those four: 0.24–0.29.
- Fine-tuning from 100 labels (300 steps): from scratch 82.8. The networks with the best frozen ten-per-digit probes score lower once fine-tuned (supervised, SimCLR, MoCo, Barlow Twins, VICReg, Matryoshka); SimSiam gains (86.3 → 88.5), and the masked models gain most (MAE 52.0 → 82.3, I-JEPA 60.8 → 85.3), MAE only back to the from-scratch level.
- Raw pixels are a strong \(k\)-NN baseline on MNIST (97.0 %, above every self-supervised method but VICReg); the ten-per-digit probe separates the methods far more (72.5 % for pixels, 91.3 % for VICReg).
Sources
Books: K. P. Murphy, Probabilistic Machine Learning: Advanced Topics (2023), ch. 32; S. J. D. Prince, Understanding Deep Learning (2023), ch. 14; R. Balestriero et al., A Cookbook of Self-Supervised Learning (2023).
Papers: H. B. Barlow, Possible principles underlying the transformations of sensory messages (1961); S. Becker &
G. E. Hinton, Self-organizing neural network that discovers surfaces in random-dot stereograms (Nature, 1992);
J. Bromley et al., Signature verification using a "Siamese" time delay neural network (1993); R. Hadsell, S. Chopra
& Y. LeCun, Dimensionality reduction by learning an invariant mapping (2006); Y. LeCun, S. Chopra, R. Hadsell,
M. Ranzato & F. J. Huang, A tutorial on energy-based learning (2006); P. Vincent, H. Larochelle, Y. Bengio &
P.-A. Manzagol, Extracting and composing robust features with denoising autoencoders (2008); M. Gutmann &
A. Hyvärinen, Noise-contrastive estimation (2010); T. Mikolov, I. Sutskever, K. Chen, G. Corrado & J. Dean,
Distributed representations of words and phrases and their compositionality (2013); A. Dosovitskiy et al.,
Discriminative unsupervised feature learning with convolutional neural networks (2014); C. Doersch, A. Gupta &
A. A. Efros, Unsupervised visual representation learning by context prediction (2015); M. Noroozi & P. Favaro,
Jigsaw puzzles (2016); R. Zhang, P. Isola & A. A. Efros, Colorful image colorization (2016); D. Pathak et al.,
Context encoders (2016); S. Gidaris, P. Singh & N. Komodakis, Predicting image rotations (2018); Z. Wu, Y. Xiong,
S. Yu & D. Lin, Non-parametric instance discrimination (2018); A. van den Oord, Y. Li & O. Vinyals, Contrastive
predictive coding (2018); G. Alain & Y. Bengio, Linear classifier probes (2016); M. Caron, P. Bojanowski,
A. Joulin & M. Douze, DeepCluster (2018); K. He, H. Fan, Y. Wu, S. Xie & R. Girshick, MoCo (2020); T. Chen,
S. Kornblith, M. Norouzi & G. Hinton, SimCLR (2020); T. Wang & P. Isola, Alignment and uniformity on the
hypersphere (2020); F. Wang & H. Liu, Understanding the behaviour of contrastive loss (2021); M. Caron et al.,
SwAV (2020); J.-B. Grill et al., BYOL (2020); P. H. Richemond et al., BYOL works even without batch statistics
(2020); X. Chen & K. He, SimSiam (2021); Y. Tian, X. Chen & S. Ganguli, Understanding self-supervised learning
dynamics without contrastive pairs (2021); J. Zbontar, L. Jing, I. Misra, Y. LeCun & S. Deny, Barlow Twins (2021);
A. Bardes, J. Ponce & Y. LeCun, VICReg (2022); T. Hua et al., On feature decorrelation in self-supervised learning
(2021); L. Jing, P. Vincent, Y. LeCun & Y. Tian, Understanding dimensional collapse in contrastive self-supervised
learning (2022); O. Roy & M. Vetterli, The effective rank (2007); Q. Garrido, R. Balestriero, L. Najman & Y. LeCun,
RankMe (2023); Q. Garrido et al., On the duality between contrastive and non-contrastive self-supervised learning
(2023); R. Balestriero & Y. LeCun, LeJEPA (2025); M. Caron et al., DINO (2021); M. Oquab et al., DINOv2 (2023);
O. Siméoni et al., DINOv3 (2025); D. Fan, S. Tong, J. Zhu et al., Scaling language-free visual representation
learning (2025); J. Devlin et al., BERT (2019); H. Bao, L. Dong, S. Piao & F. Wei, BEiT (2022); K. He, X. Chen,
S. Xie, Y. Li, P. Dollár & R. Girshick, Masked autoencoders are scalable vision learners (2022); Y. LeCun, A path
towards autonomous machine intelligence (2022); M. Assran et al., I-JEPA (2023); A. Bardes et al., V-JEPA (2024);
M. Assran et al., V-JEPA 2 (2025); L. Mur-Labadia et al., V-JEPA 2.1 (2026); N. Reimers & I. Gurevych,
Sentence-BERT (2019); V. Karpukhin et al., Dense passage retrieval (2020); T. Gao, X. Yao & D. Chen, SimCSE
(2021); N. Muennighoff, N. Tazi, L. Magne & N. Reimers, MTEB (2023); A. Kusupati et al., Matryoshka representation
learning (2022); Y. Zhang et al., Qwen3 Embedding (2025); M. Shanbhogue et al., Gemini Embedding 2 (2026);
OpenAI, embeddings guide (dimensions, text-embedding-3, 2024); A. Radford et al., CLIP (2021); X. Zhai et al.,
SigLIP (2023); S. Kornblith, M. Norouzi, H. Lee & G. Hinton, Similarity of neural network representations
revisited (2019); M. Huh, B. Cheung, T. Wang & P. Isola, The platonic representation hypothesis (ICML 2024).
Data: Y. LeCun, C. Cortes & C. J. C. Burges, MNIST (1998).
About this partfrom its README
Part 24 of a thirty-one-part series on how modern AI works and how it came to be (see the series plan
and the syllabus), in Act IV, Generation and Perception. How a network learns what matters from
data nobody labelled: pretext puzzles, contrastive learning from word2vec's negatives to InfoNCE, SimCLR and MoCo, the
geometry of the hypersphere, collapse and the four ways out of it (negatives, asymmetry, decorrelation,
self-distillation), masked modelling, joint-embedding prediction, embeddings for search, and whether different
networks come to see the world alike. Every method is trained here, by compute.py, on MNIST, on the same
three-layer convolutional encoder and update budget: 800 updates of 256 online-encoder image passes
(128 digits in two views, 64 in four, or 256 in one), with the same optimizer and schedule. The main method
comparison uses three seeds; most ablations use two, the three-number sphere illustrations use seed 0,
and the 50%/90% MAE masking runs use one seed each. Each seed starts from the same encoder initialization
across methods. Augmentations differ by method; momentum
target encoders and method-specific heads add unequal computation and parameters. This is not a matched-FLOP
or matched-wall-time comparison.
The original probes use at most 200 L-BFGS iterations for full-label fits and 100 per few-label fit; these finite-budget fits are not certified optima.
- Hook: nobody told it what a digit is. Six hundred test digits on a sphere, placed by a SimCLR network with three output numbers, coloured by labels it never saw; the nearest-neighbour accuracy of those three numbers; its training replayed; the collapsed alternative; the three families of answers; the plan.
- 1. Learning without labels. Labels against unlabelled images (MNIST, ImageNet-1k, DINOv2's LVD-142M, DINOv3's LVD-1689M and its pool of about 17 billion); LeCun's cake (NIPS 2016); self-supervised learning defined; how we got here, from Barlow (1961) and Becker & Hinton (1992) to V-JEPA 2.1 (2026); how to judge a representation (frozen encoder: linear probe, weighted k-NN, a probe from ten labels per digit); the bench and its yardsticks (raw pixels, an untrained network, the network trained with every label).
- 2. Invent a puzzle. Context prediction, jigsaw, colorization, inpainting, rotation (2015–2018); rotation prediction trained and replayed (the four turns of four digits with their predicted probabilities); its accuracy by digit (the half-turn-symmetric digits are its blind spots); its representation against the yardsticks; the chromatic-aberration shortcut (Doersch, Gupta & Efros 2015); Exemplar CNN (2014) and instance discrimination (2018).
- 3. Telling the real from the fake. Noise-contrastive estimation (Gutmann & Hyvärinen 2010); word2vec's negative sampling (Mikolov et al. 2013); InfoNCE (van den Oord, Li & Vinyals 2018) as an N-way classification; the bound I(X; Y) ≥ log N − L_N derived (Gibbs; the partner's slot is uniform; the chain rule); checked on correlated Gaussians with known mutual information (2, 5, 10 nats; N = 2 … 512; two seeds): the estimate never exceeds log N; CPC.
- 4. Two views of one digit. The views (crop and zoom, tilt and shear, contrast, blur, erasing, noise); SimCLR (Chen et al. 2020) and its NT-Xent loss; our SimCLR replayed through the nearest neighbours of six test digits; the projection head (probe before and after it); MoCo's queue and momentum encoder (He et al. 2020) against SimCLR; SimCLR with crops alone.
- 5. Alignment and uniformity. The three-number SimCLR on the sphere, replayed with its alignment and uniformity; where the digits' mean directions land; the decomposition of the contrastive loss as N → ∞ (Wang & Isola 2020); SimCLR at five temperatures (0.05 … 1); how the softmax spreads its push over the negatives at low and high temperature (Wang & Liu 2021).
- 6. Collapse. Pause and predict; a network trained only to make the two views agree, its embedding on the sphere remaining near one point; the effective rank (Roy & Vetterli 2007; RankMe, Garrido et al. 2023); singular-value spectra (complete and dimensional collapse: Hua et al. 2021, Jing et al. 2022); the starved encoder; the four ways out.
- 7. No negatives: BYOL and SimSiam. BYOL (Grill et al. 2020); SimSiam (Chen & He 2021) with and without its stop-gradient (three and two seeds): the spread of the embedding, and the three-number SimSiam on the sphere; SimSiam as alternating optimization; Tian, Chen & Ganguli (2021); BYOL without batch statistics (Richemond et al. 2020); SimCLR, BYOL and SimSiam on the linear and ten-label probes.
- 8. Decorrelate: Barlow Twins and VICReg. Barlow's redundancy reduction (1961); Barlow Twins (Zbontar et al. 2021), its cross-correlation matrix replayed as it moves toward the identity; VICReg (Bardes, Ponce & LeCun 2022) and VICReg without its variance term (collapse); the duality of the two families (Garrido et al. 2023); LeJEPA's SIGReg (Balestriero & LeCun 2025).
- 9. Self-distillation: DINO. DeepCluster and SwAV; DINO (Caron et al. 2021): student, momentum teacher, prototypes; the two collapses and the two cures (centring, sharpening); the teacher's entropy and the KL to the student, for DINO and for DINO without each cure; the teacher's average answer over the prototypes, replayed; DINO's results.
- 10. Scale and curation. DINOv2's retrieval-based curation (LVD-142M from 1.2 billion images; Oquab et al. 2023); our version: an unbalanced pool of 14,000 digits curated by retrieval from 1,000 balanced seeds, and SimCLR trained on each (two seeds), digit by digit; DINOv3 (Siméoni et al. 2025: 7B, LVD-1689M, Gram anchoring, 88.4% linear); Web-SSL (Fan et al. 2025: images alone match CLIP at 7B on 16 VQA tasks).
- 11. Fill in the blanks: MAE and BEiT. Denoising autoencoders (2008), BERT (2018), BEiT and MAE (2021); our masked autoencoder (75% of 49 patches hidden; the same network, hidden patches blanked) with its reconstructions replayed; the masking ratio (50%, 75%, 90%); a BEiT-style model predicting k-means codes of hidden patches; masked models against SimCLR.
- 12. Predict the meaning, not the pixels. Joint-embedding, generative and joint-embedding predictive architectures (LeCun 2022); the energy view (contrastive against regularized methods); I-JEPA (Assran et al. 2023) and ours (two hidden blocks of the 4 × 4 map); I-JEPA, MAE and SimCLR on one budget; V-JEPA (2024), V-JEPA 2 and V-JEPA 2-AC (2025), V-JEPA 2.1 (2026), LeJEPA.
- 13. Every method, one budget. The linear probe for every method (three seeds); the ten-label probe; the whole network fine-tuned from 100 labels against training from scratch; alignment and uniformity across methods; the effective rank as a label-free predictor (RankMe).
- 14. Embeddings for search. Retrieval with our embedding; text embeddings from word2vec to Sentence-BERT, DPR, SimCSE, E5/GTE/BGE and MTEB, Qwen3-Embedding (2025) and Gemini Embedding 2 (2026); CLIP and SigLIP (Part 23); Matryoshka representation learning (Kusupati et al. 2022) trained (three seeds) against SimCLR cut short; OpenAI's shortened embeddings.
- 15. Do all models see the same world? CKA derived (Kornblith et al. 2019) and its invariances; the CKA between every pair of our methods and between seeds; the platonic representation hypothesis (Huh, Cheung, Wang & Isola, ICML 2024); our two checks: agreement against quality across methods, and two encoders that see only the top or the bottom half of each digit, trained apart (Becker & Hinton's setting), their agreement over training; the caveats.
- Recap, where it comes back, problems, Part 25's teaser, references.
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
- Pretext tasks.
- Contrastive learning: SimCLR, MoCo, temperature; alignment and uniformity on the hypersphere.
- Non-contrastive: BYOL, SimSiam (why stop-gradient prevents collapse), Barlow Twins, VICReg.
- Self-distillation: DINO centering and sharpening, DINOv2/v3.
- Masked modelling: MAE, BEiT.
- JEPA: I-JEPA, V-JEPA 2.
- Text embeddings and Matryoshka; linear probes; CKA.
- The platonic representation hypothesis.
Computed on the glyph images: collapse shown, then prevented.
中文讲义
本讲的中文部分(与英文版对应)。
习题与解答
1. InfoNCE的最优打分函数与它的上限。 有N个候选,其中一个是x的伙伴。证明使InfoNCE损失最小的打分函数是 f*(x, y) = log p(y | x)/p(y) + c(x),并且对任何打分函数都有 log N − L_N ≤ log N。
解答
这个损失是 q_f(k | x, y₁…y_N) = e^{f(x, y_k)} / Σⱼ e^{f(x, y_j)} 去猜伙伴所在位置K时的交叉熵。给定 K = k,候选的密度是 p(y_k | x) Πⱼ≠ₖ p(y_j) = Πⱼ p(y_j) · p(y_k | x)/p(y_k),由贝叶斯公式,真实后验是 p(K = k | x, y₁…y_N) = r(y_k) / Σⱼ r(y_j), 其中 r(y) = p(y | x)/p(y)。交叉熵在猜测等于真相时最小,所以 e^{f*} ∝ r:f* = log r + c(x),c(x)在softmax里抵消。对任何打分函数, 每一项 −log q_f 都 ≥ 0,因为 q_f ≤ 1,所以 L_N ≥ 0,估计值 log N − L_N 永远不超过 log N。
2. 对齐与均匀。 对单位向量证明 z·z⁺ = 1 − ½‖z − z⁺‖²,并推导对比损失在 N → ∞ 时的极限。
解答
‖z − z⁺‖² = ‖z‖² + ‖z⁺‖² − 2 z·z⁺ = 2 − 2 z·z⁺。一个视图的损失是 ℓ = −z·z⁺/τ + log(e^{z·z⁺/τ} + Σⱼ e^{z·z_j/τ}), 其中有N − 1个负样本。减去log N:对数里变成N项的平均,由大数定律趋于 log E_{z⁻} e^{z·z⁻/τ}(伙伴那一项只占1/N)。代入上面的恒等式, ℓ − log N → ‖z − z⁺‖²/(2τ) − 1/τ + log E_{z⁻} e^{z·z⁻/τ}:一个对齐项,加上一个当向量在球面上均匀分布时最小的项(Wang & Isola 2020;他们的L_uniform用的是高斯势 e^{−t‖u − v‖²},在球面上等于 e^{−2t} e^{2t u·v})。
3. 坍缩对各个损失意味着什么。 证明常数编码器使SimSiam的损失最小,却使NT-Xent损失等于 log(2N − 1)。
解答
SimSiam的损失是 −cos(p, sg(z)) ≥ −1。如果每个z都是同一个向量z₀,而预测器把它映到z₀的某个正倍数,每个余弦都是1,损失是−1, 即全局最小值。在NT-Xent里,如果每个z都是同一个单位向量,一个视图的2N − 1个余弦全是1,它的softmax是均匀的,ℓ = −log(1/(2N − 1)) = log(2N − 1):等于随便乱猜的损失。任何让每对视图保持一致、又让不同的对彼此分开的配置,损失都更低,所以对比损失会把网络推离坍缩。
4. Barlow Twins。 当输出在批内标准化(均值0,方差1)时,证明 C_ii = 1 当且仅当两个视图的第i个输出对每张图像都相等, 并解释为什么常数输出被排除了。
解答
C_ii = (1/n) Σ_b a_b b_b,其中 (1/n)Σ a_b² = (1/n)Σ b_b² = 1;由柯西-施瓦茨不等式 C_ii ≤ 1,当且仅当向量(a_b)和(b_b) 相等时取等号。常数输出的方差为零,标准化后得到0(分母里的小ε),所以 C = 0,对角项 Σᵢ(1 − 0)² = d,对坍缩施加正的惩罚。这并不是最大值:反相关输出的 C_ii = −1,每维贡献4。目标函数偏好有变化且对齐的输出,但这不是优化过程的保证。
5. CKA的不变性。 证明线性CKA在 X ↦ cXQ(Q正交,c > 0)下不变,并证明当 n ≤ d 时,任何两个秩为n的表示都可以用一个可逆线性映射 互相转换。
解答
中心化和右乘可以交换。‖Ỹᵀ(cX̃Q)‖²_F = c²‖ỸᵀX̃Q‖²_F = c²‖ỸᵀX̃‖²_F,因为右乘正交矩阵不改变弗罗贝尼乌斯范数;而 ‖(cX̃Q)ᵀ(cX̃Q)‖_F = c²‖QᵀX̃ᵀX̃Q‖_F = c²‖X̃ᵀX̃‖_F。c²互相抵消。如果X和Y都是 n × d、秩为 n ≤ d,那么 XX⁺ = I_n, A = X⁺Y + (I − X⁺X)B 对任意B都满足 XA = Y;适当选B可以使A可逆。所以一个对所有可逆线性映射都不变的统计量(CCA就是这样)会认为任何 两个这样的表示完全相同:这就是Kornblith等人偏好CKA的原因。
6. DINO的两种坍缩。 证明 H(P_t, P_s) = H(P_t) + KL(P_t ‖ P_s),并证明如果老师的输出与输入无关,学生不必学到任何东西就能让 KL = 0。
解答
−Σ P_t log P_s = −Σ P_t log P_t + Σ P_t log(P_t/P_s)。如果对每个x都有 P_t(x) = π,那么一个对所有输入都输出π的学生KL = 0, 损失等于H(π),这是对这个老师而言最小的可能值,而它的输出与输入毫无关系:这就是坍缩。π是独热分布时 H(π) = 0(没有中心化); π是均匀分布时 H(π) = log K(没有锐化)。中心化与锐化对老师输出施加相反的压力;配合动量老师,它们在报告的实验中避免了这两种坍缩。但熵恒等式本身不是稳定性证明:所有打分相等时,仍存在与输入无关的均匀平稳解。
Build the film
python -m videos.ai.ai24.compute # the part's numbers, into .cache/ai24
python tools/build.py ai24 # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py ai24 Hook # one chapter, silent, with a contact sheet
Scenes: videos/ai/ai24. Setup: see the course page. Source of these notes: the README and the scenes' narration.
Build it
From the repo root:
python tools/make.py ai24 # everything: the computations, then English and Chinese
python -m videos.ai.ai24.compute # only the numbers (MNIST through Part 10's checked download)
python tools/build.py ai24 # English
python tools/build.py ai24 --lang zh # Chinese
AI24_SCALE=0.02 python -m videos.ai.ai24.compute # a smoke test of every code path (into .cache/ai24_quick/)
Everything is seeded (numpy PCG64 and torch.manual_seed, one torch.Generator per run for the data order, the
views and the masks) and runs on one torch thread (AI24_THREADS to change it); there is no multiprocessing. Every
item made of several runs saves each run as it finishes (CACHE.partial), so an interrupted computation resumes;
each run takes two to four minutes. Each run's larger arrays (its test features, its replay snapshots) are in
.cache/ai24/runs/, the seed-0 networks of the compared methods in .cache/ai24/models/ (about 20 MB). MNIST is read
through Part 10's downloader (videos.ai.ai10.data, checked against SHA-256); no other part's results are used.
The pinned recipe enumerates 72 encoder pretraining runs of 800 updates, three untrained reference evaluations, 54 Gaussian critic fits, and 42 fine-tuning label-draw fits, plus downstream probe fitting. Unverified historical timing note: the original README reports 3.5 hours of wall time for the full computation on one thread of a busy shared Linux machine (load about 9), using OMP_NUM_THREADS=1 nice -n 15 python -m videos.ai.ai24.compute, with a cache of about 60 MB. This is not a timing measurement of the fresh numerical continuation; its receipts record that run separately.