Paper commentary
Sigmoid Loss for Language Image Pre-Training
SigLIP replaces batch-wide softmax with pairwise sigmoid loss for image-text training
- Problem Standard contrastive pre-training scores each pair against the whole batch through a softmax. That ties memory and distributed computation to the batch size, so very large batches are costly.
- Method SigLIP scores each image-text pair with its own sigmoid term instead of a batch-wide softmax. It uses a learnable temperature and bias, and splits the loss across devices in chunks.
- Results With four TPUv4 chips in two days, a SigLiT model reaches 84.5% zero-shot ImageNet accuracy, and sigmoid beats softmax at batches below 16k.
Why the softmax loss limits batch scaling
Contrastive image-text pre-training pulls matched image and text embeddings together and pushes mismatched ones apart. The standard recipe does this with a softmax over each batch, applied once over images and once over texts, so the score of any one pair depends on every other pair in the batch. That global normalization carries two costs.
A naive softmax is numerically unstable and is usually stabilized by subtracting the maximum, which adds another pass over the full batch. In a distributed setting the pairwise similarity matrix has to be assembled across devices, so its memory grows with the square of the batch size. The question is whether a loss that scores each pair independently can match the softmax version across batch sizes, and how far the batch can grow before gains stop.
How the pairwise sigmoid loss scores each pair
Each image and each caption goes through its own encoder, and the resulting embeddings are L2-normalized. Taking dot products between every image embedding and every text embedding gives the full matrix of pairwise similarities. Each similarity is multiplied by a learnable temperature t and shifted by a learnable bias b. Then a log-sigmoid is taken of the label times that logit, where the label is +1 for the matched pair and -1 for every other pair in the batch.
The temperature is parametrized as exp(t'), with t' a learnable scalar. The loss as written in the paper is \[-\frac{1}{|B|}\sum_{i=1}^{|B|}\sum_{j=1}^{|B|}\log\frac{1}{1+e^{z_{ij}(-t\,x_i\cdot y_j+b)}}\] with z_ij equal to +1 for matched pairs and -1 otherwise. The displayed formula and Algorithm 1 do not write the sign of b in the same way, so the description here follows the pseudocode, where the logit is t times the dot product plus b.
Computing the loss in chunks across devices
With data parallelism, the batch is split across D devices, and each device holds a local batch of size b, the total batch divided by D. Each device first computes the positive terms and the negatives within its own chunk. Text embeddings are then permuted across devices so that each device sees the negatives from a neighbouring device, and this exchange repeats until each device has covered the other chunks.
Each device's loss is calculated on its local chunk, and the device losses are summed at the end. The authors note that D collective permutes are typically faster than two all-gathers across the same devices. Memory at any moment falls from the square of the full batch size to the square of the per-device batch size, so the batch can grow by adding devices.
A 3-device mock setup with a global batch of 12 shows the idea, and at any point only one 4 by 4 block of the similarity matrix is materialized.
Batch size sweep for SigLiT
The sweep covers batch sizes from 512 to 1M. The image side uses precomputed embeddings from a ViT-g vision model, and only a base-size text tower is trained from scratch on the LiT image-text dataset, with the same hyperparameters across batch sizes. Accuracy levels off near 32k, and the authors call that surprising. A SigLiT model with a B-sized text tower trained at a 256k batch reaches 84.7% zero-shot ImageNet accuracy.
The LiT paper reports 85.2% with a text tower ten times larger, a different setup that this study does not reproduce.
SigLIP against the softmax loss at matched batch sizes
SigLIP is trained from scratch on English WebLI image-text pairs with a B/16 image model and a B-sized text model. Images are resized to 224×224 and captions use a 32 k sentencepiece vocabulary, capped at 16 tokens. The CLIP (WebLI) baseline uses the same data with the softmax loss. Memory savings let the sigmoid setup use larger batches on the same chips.
With four TPU-v4 chips the authors fit a batch of 4096 for a Base SigLIP and only 2048 for the matching CLIP model. In the 9B-example runs, sigmoid peaks at 73.4 with a 32k batch, while softmax peaks at 73.2 with a 98k batch, so softmax does not overtake the sigmoid peak. At 3B examples the two tie at 69.9 for 32k. At 307k batch both losses fall.
In that row softmax is higher, 72.6 against 71.6, so the drop is shared rather than specific to the sigmoid loss.
A bottlenecked token embedding for large vocabularies
A 250k multilingual vocabulary gave slightly more than 1% improvement over a 32k vocabulary for B-sized models trained on 900M examples. A full embedding table of N by W, where N is the vocabulary size and W the text width, is costly at that size. The authors replace it with an N by K embedding matrix followed by a K by W projection, where K is much smaller than W.
This keeps the vocabulary large while the stored embedding table stays small. For the Base architecture with W = 768 and K = 96, the ImageNet zero-shot result drops by about a half percent relative to the full 250k vocabulary. The authors say the bottlenecked large vocabulary scales as efficiently as the small one.
Multilingual training across batch sizes
mSigLIP keeps all 100 languages from WebLI and trains for 30B seen examples at batch sizes from 16k to 240k. The table reports ImageNet zero-shot accuracy and the average text-to-image recall@1 over the 36 languages of XM3600. The XM3600 average is 34.8 at 16k, 34.9 at 32k, 34.4 at 64k, 33.6 at 128k and 32.7 at 240k. ImageNet zero-shot stays at 73.2 from 32k to 128k and is 73.1 at 240k.
The authors expected bigger batches to help because more same-language examples appear as hard negatives, but they saw no clear gain above 32k. They report that retrieval falls beyond 32k while ImageNet stays flat. The best result, 34.9, is compared with the 28.5 previously reported for a standard LiT model that uses a four-billion-parameter ViT-e.
The comparison crosses model sizes and setups, so it is not a controlled one.
Fine-tuning and weight decay on pre-trained image weights
The starting image model is the public ViT-AugReg-B/16 checkpoint, fine-tuned on the English WebLI data with a 0.1 learning-rate multiplier on the pre-trained tower. In the default setup, weight decay is applied to these pre-trained weights as well. With plain fine-tuning on 16 TPU-v4 chips at a 16k batch for 2.4B examples, the 10-shot linear result is barely better than training from scratch.
The authors hypothesize that the default weight decay on pre-trained weights reduces their usefulness. Disabling weight decay on the pre-trained encoder weights, while keeping it on the randomly initialized text weights, makes the 0-shot curve stable and lifts ImageNet 0-shot. The 10-shot curve also flattens rather than falling. This recipe reaches 71% zero-shot ImageNet accuracy at a 16k batch on 16 chips in three days.
From scratch, 32 TPUv4 chips for two days give 72.1%. A CLIP run of about 2500 TPUv3-days for 72.6% is cited from a prior report on different hardware, so it is not a controlled comparison.
Scaling SigLIP and comparing with published models
The scaled-up runs train SigLIP for 40 billion examples at a 32k batch with 256 image patches and 64 text tokens, using ViT-B, ViT-L or So-400m encoders of matching size. Higher-resolution models get 5 billion more examples at a 100x smaller learning rate with no weight decay. In the comparison table, SigLIP SO (400M) with 729 patches reaches 83.2 ImageNet-1k, SigLIP L with 576 patches reaches 82.1, and SigLIP B with 1024 patches reaches 79.2.
The table places these rows next to other publicly released models, which the authors compare against under the same columns. For multilingual retrieval, the scaled-up mSigLIP ViT-B reaches 42.6% image retrieval recall@1 and 54.1% text retrieval recall@1 on XM3600. The authors note that a Large model from a cited work gets 42.96% image retrieval recall@1, so the Base result is slightly behind it.
Keeping large-batch training stable
At large batches the loss curves for both optimizers show spikes. The spikes come from gradient-norm spikes, which produce large changes in the weights and destabilize training. Lowering β2 in Adam and AdaFactor from 0.999 to 0.95 stabilizes training, and the authors use 0.95 in all their experiments. They explain that it lets training recover from a gradient spike more quickly.
Occasional gradient spikes still occur after the change, but they no longer destabilize the run.
Which negatives the loss sees
A matched-pairs variant trains longer so that the total pairs seen stay the same, and this gives a slight increase for the hardest-negative setting. As negatives become fewer, the learned bias and the average logits both move upward. With hard negatives, the average positive logit stays mostly flat. The authors read this as the imbalance not being a major concern, while finding an efficient way to include more negatives is not trivial.
Bias and temperature initialization
The ablation uses the Base architecture with an 8k batch, trained for 900M examples with the SigLIP setup. Zero-shot results are reported on ImageNet, Oxford-iiit pet and Cifar100. With b = -10 and t' = log 10, ImageNet reaches 63.0, against 62.0 with no bias term. With b = 0 and t' = log 10 it reaches 61.7, and with b = 0 and t' = log 1 it reaches 53.7.
The authors attribute the gain from b = -10 to starting near the prior, which avoids over-correction early in training. A zero bias does not fix this, and the damage is larger when the temperature starts small. The defaults for all later experiments are b = -10 and t' = log 10.
Robustness to corrupted training data
The authors report that sigmoid-trained models stay ahead of the softmax baseline as corruption grows across these types. The figure shows the trend against corruption probability, and the numbers are not repeated here.
Limitations
Accuracy saturates near 32k batch size for SigLiT, so the one-million-batch run did not give further gains. The LiT 85.2% and the CLIP 72.6% values come from other setups, and the efficiency comparisons with FLIP and CLIP use 256 TPUv3 cores or TPUv3-days on different hardware. These numbers are not controlled comparisons with this paper's runs.
Seed variation was measured only for SigLIP at a 32k batch with 3B examples, with five runs. The other batch-size results are reported without that repeat. The multilingual gains do not continue beyond 32k, and the bottleneck result is reported for one Base setting with K = 96. The β2 change is the authors' fix for the setups they ran, and training was not tested on other settings in the text.
Paper info
- Authors
- Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer
- Venue
- arXiv · Preprint
- First published
- 2023-3-27
- Added
- 2026-11-12
- Updated
- 2023-9-27
- Version
- v4
- arXiv
- 2303.15343
- Category
- cs.CV · cs.AI
- Original paper terms
- CC BY 4.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Xiaohua Zhai, Basil Mustafa, Alexander Kolesnikov, Lucas Beyer (2023). Sigmoid Loss for Language Image Pre-Training. arXiv:2303.15343v4. https://arxiv.org/abs/2303.15343v4
BibTeX
@misc{zhai2023sigmoid,
title = {{Sigmoid Loss for Language Image Pre-Training}},
author = {Xiaohua Zhai and Basil Mustafa and Alexander Kolesnikov and Lucas Beyer},
year = {2023},
eprint = {2303.15343},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2303.15343v4}
}