SigLIP Sigmoid Pair Loss
Score every image-text pair on its own as match or not, instead of picking one winner per row. Small batches then train fine.
Why Does This Exist?
Softmax over the batch ties every score together, so small batches give noisy targets and huge batches cost memory. Training a vision-language model then demands thousands of pairs per step just to keep the denominator stable. SigLIP removes the coupling: each of the pairs becomes its own yes-or-no lesson with label for mates and otherwise, and image retrieval training works at batch 256 instead of 16384.
This page covers the sigmoid loss only. Dual-encoder matching basics live under multimodal learning, and captioning use is image captioning.
The one idea you need first: the logit is , where and are unit image and text vectors, is a learned scale, and is a bias starting near . The loss per pair is with in . The bias starts very negative because almost every pair in the square does not match.
Think of It Like This
Stamping each ticket instead of picking one winner
A raffle judge usually picks one winner per row of tickets, so a good ticket can lose to a great neighbor. SigLIP instead stamps every ticket yes or no alone: a deserving ticket passes on its own merits, and a strong row never suppresses its neighbors.
Softmax is the one-winner rule, sigmoid is the stamp, and the bias of is strict starting ink that assumes no until evidence says yes. Where it stops: raffle tickets are independent, while image pairs still share encoders, so lessons leak across pairs through the weights.
How It Actually Works
Encode images and texts to unit vectors, where and run over the batch and is the batch size. Score all pairs with the shared scale and bias, then pay binary logistic loss on each pair alone. Mates with pull their score up, non-mates with push theirs down, and nothing is normalized across . In plain words, independent lessons per batch replace softmax picks, and the bias absorbs the base rate that nearly every pair is a non-match.
Worked example
Take a mate pair with logit and . Its loss is . Take a non-mate with and : its loss is . A batch of 4 holds 4 mates and 12 non-mates, so the mean is . Raising mate scores and lowering the rest drops each term alone, with no row competition deciding who learns.
Code
import math
def siglip_loss(s, y): return math.log(1.0 + math.exp(-y * s))
mate = siglip_loss(2.0, 1)neg = siglip_loss(-1.0, -1)print(round(mate, 4), round(neg, 4), round((4 * mate + 12 * neg) / 16, 4))# -> (0.1269, 0.3133, 0.2667)Each pair pays its own logistic loss, and the batch mean mixes 4 mates with 12 non-mates.
Watch Out For
Zero bias that floods early training
Starting scores most negatives as matches and the gradients explode on step one. The symptom is a loss spike before any learning happens. The standard fix is initializing the bias near with the log-scale near , so negatives start quiet and mates earn their scores.
Softmax habits that re-couple the pairs
Normalizing each row with a softmax before the loss reintroduces batch competition and kills the small-batch benefit. The symptom is training that degrades exactly like the old loss at batch 256. Keep the raw per-pair sigmoids and let every pair learn alone.
The Quick Version
- SigLIP pays binary sigmoid loss on every image-text pair independently.
- Mates carry plus one and all other pairs carry minus one.
- No batch softmax means small batches train stably.
- Bias near minus ten absorbs the non-match base rate.
- Retrieval quality matches softmax runs at a fraction of the memory.