04
A loss that compares
Similarity becomes useful to this objective only in relation to the other candidates.
Read the geometry
The following vectors are hand-positioned toy representations, not encodings of our arrow. Fix the anchor at . Place the positive at angle on a unit circle, negative A at , and negative B at . Every vector has length one.
Cosine similarity measures alignment. For unit vectors it is simply their dot product, so the anchor reads each candidate's horizontal coordinate. The positive score is ; the two negative scores are and . Moving the positive toward the anchor increases its score. This uses SimCLR's cosine-similarity convention.
Turn three scores into one loss
Divide each score by a positive temperature , exponentiate, then normalize the three weights so they sum to one. This normalization is called softmax. Let be the sum of those weights:
The positive is included in the denominator; the anchor is not. Our single-anchor InfoNCE-style loss is the negative natural logarithm of the positive's probability, measured in nats. A larger means a smaller loss. This is a teaching subset, not the complete SimCLR minibatch objective. See CPC's candidate-classification formulation and SimCLR Eq. 1.
At and , the scores are . Their scaled values are . The resulting positive probability is about 0.705385 and the loss is 0.349012 nats. These are deterministic calculations from the stated toy values.
Try a sharper comparison
Predict first: at , would reducing temperature from 1 to 0.1 lower the positive's loss? Set that angle, change only temperature, and watch the probability bars and loss. The vectors and their raw similarities should stay still.
Geometry becomes a loss.
Toy: hand-positioned unit vectors, not representations learned from the arrow. Three candidates, one anchor, no training.
Before you touch the controls
At an angle of 120°, Negative A scores higher than the positive. Predict: will reducing temperature from 1.0 to 0.1 lower the positive’s loss?
Try those two settings. Then read the explanation below the lab.
● Positive ▷ Anchor □ Negative A ◇ Negative B
Axes x and y are vector coordinates. All vectors have length 1. The positive’s horizontal projection is its similarity to the anchor.
At 60° and temperature 0.5, the positive receives 0.705 of the candidate probability. Loss is 0.349 nats. The positive has the highest similarity.
| Candidate | Similarity s | Scaled s / τ | Probability |
|---|---|---|---|
| Positive | 0.500 | 1.000 | 0.705 |
| Negative A | 0.000 | 0.000 | 0.259 |
| Negative B | -1.000 | -2.000 | 0.035 |
The positive is in the denominator; the anchor is not. These probabilities are relative to this candidate set, not confidence in an image category. Values round to three decimals.
Read the same experiment without sliders
| Angle | Temperature | Positive p | Loss, nats |
|---|---|---|---|
| 60° | 0.5 | 0.705 | 0.349 |
| 0° | 0.5 | 0.867 | 0.143 |
| 120° | 1.0 | 0.307 | 1.180 |
| 120° | 0.1 | 0.007 | 5.007 |
60° → 0° at τ = 0.5: closer positive, lower loss. At 120°, τ = 1.0 → 0.1: the higher-scoring negative takes nearly all the probability, so positive loss increases.
Separate hypothetical: if every representation were identical, all scores would tie. Then positive probability is 1/3 and loss is ln(3) ≈ 1.099 at any positive temperature.
Lower temperature sharpens score differences, favoring the highest-scoring candidate. At 120°, negative A scores 0 while the positive scores −0.5. In this specific comparison, sharpening raises the positive's loss from about 1.180270 to 5.006760 nats. Lower temperature does not universally lower positive loss; the effect depends on the scores and temperature.
These probabilities are relative weights among these three candidates—not calibrated confidence that an image belongs to a semantic category. Nor does moving a slider train a model: angle directly changes the prescribed geometry, while temperature changes only the score-to-probability calculation.
What if every score ties?
Transfer: all three candidate scores are 0. What can temperature change?
Nothing about their relative weights. Each exponential is , so and for every positive temperature. Any three equal scores give this result. Identical representations are one way to produce equal scores; tying just two points in the plot is not full collapse.
This arithmetic explains what the objective scores, not a guarantee about where training will converge. Even a low loss leaves another question unanswered: what information will the representation retain for a later task?