TL;DR
SigLIP trains an image encoder and a text encoder together on pairs of pictures and captions taken from the web. It replaces the softmax contrastive loss used by CLIP with a sigmoid loss that scores each image-caption pair as its own yes-or-no question. Because no pair is compared against a normalisation over the whole batch, the loss uses less memory, splits easily across many chips, and does better than softmax when batches are small. The authors also find that a batch of about 32,000 pairs is enough, and that much larger batches gain little.
Builds on: Contrastive Learning, Sigmoid Loss, Vision Transformer (ViT) · Leads to: OpenVLA: An Open-Source Vision-Language-Action Model
Why it mattered
Image-text pre-training has become a usual way to get a general vision model: train on huge numbers of web pairs, then
use the image encoder for Zero-Shot Learning, retrieval and fine-tuning. CLIP and ALIGN made this work at scale with a
softmax loss, and the cost of that loss grows with the square of the batch size. SigLIP showed that the same job can be
done with a simpler loss that runs well on fewer chips. The released models and the big_vision codebase give groups
without a large cluster a practical starting point.
The problem
A contrastive model learns two encoders. An image encoder and a text encoder map each image and caption to vectors. Matching pairs should point the same way; mismatched pairs should not. In a batch of pairs, the standard recipe (Softmax contrastive loss, as in CLIP) asks, for each image, which of the captions is its match, and for each caption, which image is its match. To answer, it must normalise each score by a sum over the whole batch. That sum forces the devices holding the batch to exchange embeddings, and it needs a full table of pairwise scores in memory. Both costs grow fast with batch size, while small batches give weaker training. The question the paper asks is whether the batch-wide normalisation is needed at all.
Before this paper, the softmax loss was the default for image-text contrastive learning. A sigmoid loss had been used for dimensionality reduction, and for supervised classification it had been reported to be slightly more robust than softmax. The paper brings that idea to image-text pre-training. It was posted to arXiv in March 2023.
How it works
Take a tiny batch of two pairs: image 1 with caption 1, and image 2 with caption 2. Each image can be compared with each caption, so there are four pairs to score. Here is the sigmoid version, one step at a time.
- Turn each image and each caption into a vector of length 1. Call them and . In the paper these come from the image encoder and the text encoder , each followed by division by its own length.
- Take the dot product for all four combinations. The dot product is large when two vectors point the same way. Check: a vector dotted with itself, when its length is 1, gives 1.
- Turn each dot product into a score . The scale and the bias are learned. Check: with and , the score equals the dot product.
- Label each pair : if image and caption belong together, if they do not.
- For each pair, pass through a sigmoid and take the negative log. This is the cost of that one yes-or-no question. A matched pair with a high score costs little. An unmatched pair with a high score costs a lot. Check: a matched pair with score 0 costs .
- Add the costs of all pairs and divide by the number of images. That is the loss for the batch.
The grid below shows the batch. Each cell is one independent question, and no cell looks at the others to decide its cost.
flowchart LR I["images x1, x2"] --> D["dot products x_i · y_j"] T["captions y1, y2"] --> D D --> S["scores t·dot + b"] S --> P["per-pair cost −ln σ(z·s)"] P --> L["sum, divide by number of images"]
The plot shows the cost of one pair as its score changes, with and . The matched curve falls as the score rises. The unmatched curve rises.
- matched pair (z = +1)
- unmatched pair (z = -1)
Worked examples
Two pairs. The vectors are and , so the dot products form the grid . Take and .
- Scores: , so , , , .
- Labels: (matched), (unmatched).
- Matched cost, pair (1,1): .
- Unmatched cost, pair (1,2): .
- The other matched pair costs 0.3133 and the other unmatched pair costs 0.6931.
- Sum of the four costs: .
- Divide by the number of images, 2: the loss is .
Interpretation: the matched pairs are already scored above zero, so they cost less than . The unmatched pairs sit at score 0, where the cost is exactly . The loss would fall if the unmatched scores were pushed below zero.
Same two pairs, but now use the paper's starting values and . Suppose the encoders have already produced matched dot products of 0.9 and unmatched dot products of 0.1.
- Matched score: .
- Unmatched score: .
- Matched cost: .
- Unmatched cost: , so the argument is , and the cost is .
- Two matched pairs and two unmatched pairs give .
- Divide by 2: the loss is .
Interpretation: the matched pairs are still on the wrong side of zero, because a matched pair needs a score above zero, and falls short. The unmatched pairs cost almost nothing. The bias starts at so that the many negatives do not dominate early training. Raising the matched dot products toward 1 would push the matched scores to 0 and above.
The paper reports that, with four TPU-v4 chips, SigLIP fits a batch of 4096, while a CLIP model fits only 2048. The reason is the size of the table that must sit in memory. Take a batch of split over chips.
- Vanilla softmax loss: the full score table is entries.
- Per-device size: images and captions per chip.
- Chunked sigmoid loss: each chip holds one table, which is entries.
- Ratio: .
Interpretation: the largest table in memory shrinks by , so the same chips can take a larger batch. The paper's point is that a bigger batch then becomes affordable, not that bigger is always better.
Try it: the same method with a batch of on chips. How many entries are in the full score table, and how many are in one chip's chunk?
Answer: the full table is entries. Each chip has , so its chunk is entries. The ratio is .
The math
A <Definition term="Sigmoid loss (pairwise)"> for a batch of image-text pairs: each pair gets the
label when and otherwise, and the loss is the average over all pairs of
, where is the Sigmoid Function and is the score.
Step 1 in symbols: unit vectors
Each embedding is divided by its own length: and . After this, is the Cosine Similarity of the two embeddings.
Step 2 in symbols: the score
The scale is , where is a free parameter, so stays positive. The bias is a free parameter too.
The paper starts at , so , and starts at . The pseudocode in the paper's Algorithm 1
computes the same score, logits = dot(zimg, ztxt.T) * t + b.
Step 3 in symbols: the cost of one pair
The second form follows from the first because , so . Write . A large positive makes tiny, so the cost is near 0. A large negative makes the cost near .
Step 4 in symbols: the batch loss
The inner sum runs over every caption for image . Each term is independent, so the sum needs no normalisation factor. Within the batch there are positive pairs and negative pairs. For a batch of 16,384, that is negatives for 16,384 positives.
For contrast: the softmax loss
The softmax loss in CLIP normalises across each row and each column of the score grid. Its image-to-text term for image is , and its text-to-image term is the same with the sum over images. The denominator is the global normalisation that the sigmoid loss removes. Each denominator needs every score in its row or column, which is why the softmax loss needs the whole batch in one place.
Step 5 in symbols: the chunked form for many devices
Suppose the batch is split across devices, each holding images and captions. The paper rewrites the loss as a sum over devices: each device computes the positive pairs it holds and the negatives against one neighbouring chunk, then passes that chunk on to the next device. Each device only ever materialises a table, so memory drops from to . Because each pair is an independent term, the pieces add up to the full loss without any global step.
Results
- Small batches favour sigmoid. With batches smaller than 16k, the sigmoid loss outperforms softmax by a large margin in the SigLiT setting (Figure 2). As batches grow, softmax catches up.
- Batch size saturates. SigLiT performance saturates at about 32k, and the best SigLiT model peaks at 256k with 84.7% zero-shot ImageNet accuracy using a Base text tower. The paper sweeps batch sizes from 512 to 1 million. For SigLIP, 32k is best, whereas softmax needed 98k and still did not beat sigmoid. A batch of 307k hurts both losses.
- Cheap strong results. SigLiT with a frozen ViT-g/14 image tower, precomputed embeddings and a Large text tower reaches 84.5% zero-shot ImageNet accuracy with batch 20k on four chips in two days (Table 1). With a frozen B/8 checkpoint and four chips for one day, it reaches 79.7%. SigLIP trained from scratch reaches 73.4% in five days on 32 chips.
- Versus CLIP. The paper says reference [30] and CLIP require about 5 and 10 days respectively on 256 TPUv3 cores. For the Base model, SigLIP at 196 patches reaches 76.2% on ImageNet validation against 68.3% for the CLIP Base baseline in Table 3.
- Multilingual. With 100 languages, mSigLIP at Base size reaches 34.9% on XM3600 text-to-image retrieval, more than six points above the 28.5% reported for a LiT model with a 4B-parameter image tower.
- Bias term (Table 4). With bias initialised to and , ImageNet zero-shot accuracy is 63.0%, against 62.0% with no bias. With bias 0 and , it is 53.7%.
- Stability. Lowering in Adam and Adafactor from 0.999 to 0.95 stabilises large-batch training.
Limits: most results use the paper's own WebLI and LiT datasets and ImageNet zero-shot accuracy as the main yardstick. The paper reports robustness to label and data noise only for a medium model and one batch size. The mining experiment (Figure 6) masks negatives in a controlled way, and the authors say that finding an efficient way to include more negatives is promising but not trivial.
Common mistakes and tradeoffs
It is tempting to think the sigmoid loss ignores negatives because it looks at one pair at a time. In fact it sums over all negatives. The bias sets the starting point so that the negatives do not dominate early on. The paper also shows that randomly removing negatives hurts performance, so the negatives do real work.
It is tempting to think a larger batch is always better. In fact performance saturates near 32k for SigLIP, and 307k hurts both losses.
It is tempting to think the sigmoid loss is softmax with another name. In fact softmax makes the pairs in each row compete for one probability mass, while the sigmoid treats each pair as independent. The largest gap is at small batches.
It is tempting to think the bias is a detail. Table 4 shows it matters for accuracy.
When to use it: small or moderate batches, limited chips, or many devices where the gather step of softmax is costly. When not to use it: if you already have a stable softmax recipe at very large batch and memory is not a constraint, the advantage is smaller.
Reading guide
- Introduction and Table 1 need Contrastive Learning and Zero-Shot Learning.
- Section 3.1, the softmax loss needs Softmax, Cross-Entropy Loss and Dot Product.
- Section 3.2, the sigmoid loss needs Sigmoid Loss, Sigmoid Function and Logistic Regression; the temperature and bias are the ideas of Softmax Temperature.
- Section 3.3, the chunked implementation needs Data Parallelism.
- Section 4.1, batch size needs Critical Batch Size.
- Sections 4.6 to 4.7, scaling and stability need Vision Transformer (ViT), Adam Optimizer and Gradient Descent.
- Section 4.8, negative ratio needs Sigmoid Loss and the ideas above.
Check yourself
QuestionFor one pair with score , what is its cost , whether matched or not?Show answer
Since either way, the cost is . A pair at score 0 is undecided, and the two labels cost the same.
QuestionA batch has 1024 pairs. How many negative pairs does it contain?Show answer
There are negative pairs, against 1024 positive pairs.
QuestionWhy does the paper start the bias at rather than 0?Show answer
Most pairs in a large batch are negatives. With a bias of 0, a random starting model gives many negatives scores near 0, which is a cost of each, and the summed gradient is dominated by pushing them down. Starting at makes the negatives already cheap, so the first updates do not over-correct. Table 4 shows that the bias with improves accuracy.
QuestionA team has eight chips and wants a batch of 65,536 pairs. Using the chunked sigmoid loss, what is the size of the largest table each chip holds, and why is this the relevant quantity?Show answer
Each chip holds images and captions, so its table is entries. This is the largest table in memory at once, so it sets whether the batch fits. The vanilla loss would need the full table on one device, which is entries.
Sources
- Zhai, Mustafa, Kolesnikov, Beyer. Sigmoid Loss for Language Image Pre-Training. arXiv:2303.15343. https://arxiv.org/abs/2303.15343
- Radford et al. Learning Transferable Visual Models From Natural Language Supervision (CLIP). arXiv:2103.00020. https://arxiv.org/abs/2103.00020
- big_vision codebase, Google Research. https://github.com/google-research/big_vision