Models · Image retrieval

Image-text embeddings (CLIP, SigLIP 2)

CLIP (OpenAI, 2021) and SigLIP 2 (Google, 2025): image and text towers in one space, for text search over photos ("a red car") and zero-shot labels you type (`search`, `zero_shot`). MIT (CLIP B/32, B/16, L/14) and Apache-2.0 (SigLIP 2 B/16, L/16) code and weights.

experimental Fork of huggingface/transformers@c4c4605 · backends: portable, kernels

Checkpoint

Paper 2021 Added in 0.4.0 Evaluated with 0.4.0

Kernels, RTX 5060 Ti 16 GB 3.49 ms 480x640, fp16
vs the faster original 1.8× original fp16: 6.28 ms
Peak memory 331 MiB original: 329 MiB
Accuracy vs original fp32 +0.20 portable i2t_r1, COCO val2017 captions (68.50 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install "fastforks-core[transformers]"

from fastforks import retrieval

model = retrieval.load("clip-b32-openai-text")  # fastest backend that runs here
result = model("photo.jpg")

# result fields: descriptor
descriptor = result.descriptor  # a torch tensor
arrays = result.numpy()  # the tensor fields as NumPy arrays: arrays["descriptor"]
result.backend  # what ran: mode, device, dtype
Other ways to run it
  • Backend: retrieval.load("clip-b32-openai-text", mode="kernels") # or "portable", "auto" (default)
  • Precision: retrieval.load("clip-b32-openai-text", dtype="float32") # full precision: slower, portable only
fastforks bench clip-b32-openai-text

Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.

Speed and memory

Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.

Input: synthetic, 480x640 (the task’s standard size)

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32transformers 5.19.0 get_image_features on the HF processor's resize (pre-processing not timed on the same path)fp32 6.610.95×620 MiB/664 MiB3.00.29
Original fp16transformers 5.19.0 get_image_features on the HF processor's resize (pre-processing not timed on the same path)fp16 6.28–329 MiB/398 MiB0.30.04
Portable fp32fp32not measured ––––
Portablefp16 5.701.1×340 MiB/352 MiB0.30.01
Kernelsfp16 3.491.8×331 MiB/350 MiB2.90.16
Portable + torch.compile 3.271.9×361 MiB/368 MiB9 (build)–
TensorRT fp16fp16 0.8147.7×200 MiBenginenot comparable19 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-29 to 2026-12-02. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. Ratios divide two times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.

Other devices

Not measured on other devices yet.

Licence and weights

Commercial use allowed

Code
Apache-2.0
Weights
MIT source
Training data
WIT: 400M image-text pairs collected from the web by OpenAI (CLIP paper); not released

Our reading of the licences, not legal advice.

Weights

clip-b32-openai.config.json 4.2 KB· hosted on Hugging Face
clip-b32-openai.pytorch_model.bin 605 MB· hosted on Hugging Face
clip-b32-openai.vocab.json 862 KB· hosted on Hugging Face
clip-b32-openai.merges.txt 525 KB· hosted on Hugging Face

fastforks downloads and checks these files on first use (fastforks download clip-b32-openai-text).

Accuracy

The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.

COCO val2017 captions

every 5th image (1000 images, 5 captions each), recall@1 / @5 % image to text / text to image

Rundtypei2t_r1 ↑i2t_r5 ↑t2i_r1 ↑t2i_r5 ↑Δ i2t_r1 vs fp32 originalimagesms / image
Original fp32fp3268.5090.1048.1476.38 reference 1000 5.26
Original fp16fp1668.5090.1048.1476.36 ±0.00 1000 5.20
Portable fp32fp3268.6089.9048.1676.30 +0.10 1000 4.73
Portablefp1668.7089.9048.1876.36 +0.20 1000 4.66
Kernelsnot measured

Every query's descriptor against every database descriptor (cosine similarity, exact top-k on the GPU); a query counts as found at k when one of its k nearest database images is within 25 m (UTM positions of the file names), the standard visual place recognition protocol. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-30; portable fp32, portable: RTX 5060 Ti, torch 2.14.1+cu130, fastforks d5364b118, 2026-11-30.

Closeness to the original

Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.02 and p99 <= 0.25 (absolute error of the output descriptor).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.002 not recorded
GPU default dtypes, mean |diff|≤ 0.02 0.00095
GPU default dtypes, p99 |diff|≤ 0.25 0.00405

Recorded for clip-b32-openai-text on RTX 5060 Ti, torch 2.14.1+cu130, 2026-12-02, with these kernels: fvm_conv

Details

Joint image and text embeddings for text-to-image search and zero-shot classification: OpenAI CLIP (ViT-B/32, B/16, L/14) and SigLIP 2 (ViT-B/16, L/16 at 256 px). `encode_image` / the call give a unit descriptor of an image, `encode_text` one of a list of strings in the same space, so the dot product is the image-text cosine similarity; `zero_shot` turns it into label probabilities (softmax for CLIP, per-label sigmoid for SigLIP 2) and `search` ranks stored image descriptors for a text query. The image side is resized as the original processors do (CLIP: bicubic shortest side, centre crop; SigLIP 2: the whole image squashed to 256 x 256).

Input / output
Input: one RGB image. Output: a global descriptor [D] (unit L2 norm) for image retrieval / visual place recognition; fastforks.retrieval.top_k and pairs find the nearest images (cosine similarity) on the GPU.
Input size
any H x W >= 32, padded to a multiple of 32; tested up to 3000x4000 (742 MiB allocated)
Outputs
descriptor
Checkpoint
arch="CLIPModel", kind="clip", size=224, context=77, dim=512
CUDA kernels
  • fvm_convfused convolutions for image classifiers
Apple (MPS)
fp32, fp16

Limitations

  • Requires the optional transformers library (the networks are its `CLIPModel` / `SiglipModel`) and, for SigLIP 2, its `tokenizers` dependency.
  • The kernels backend (CUDA, fp16) speeds up the image tower only (fused fp16-accumulate GEMMs, a CUDA graph per batch size); `encode_text` runs the portable text tower. An Apple MLX port of both towers runs with `device="mlx"` (fp32, fp16).
  • Text is truncated to the context (CLIP 77 tokens, SigLIP 2 64 tokens, the end token kept); SigLIP 2 lower-cases its text as the original tokenizer does. CLIP prompts are expected to be clean Unicode (the ftfy repair of the original tokenizer is left out).
  • The SigLIP 2 checkpoints are the fixed-resolution 256 px models (`model_type: siglip`); the NaFlex variants are not included. SigLIP 2 scores are independent per label (sigmoid with the checkpoint's scale and bias), CLIP scores are a softmax over the labels given.
  • The original in the parity checks and benchmarks is the Hugging Face transformers 5.19.0 port with the authors' weights (openai/clip-vit-*, google/siglip2-*-patch16-256); the authors' openai/CLIP and big_vision code was not run.
  • Not included: OpenCLIP LAION weights (they ship as `open_clip` files, not in the transformers layout), DFN (Apple research-only licence).
Full reference, generated from the repository

CLIP (OpenAI, 2021) and SigLIP 2 (Google, 2025): image and text towers in one space, for text search over photos ("a red car") and zero-shot labels you type (search, zero_shot). MIT (CLIP B/32, B/16, L/14) and Apache-2.0 (SigLIP 2 B/16, L/16) code and weights.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
clip-b32-openai-textsynthetic (480x640)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
6.61
6.28
5.70
3.49
3.27
0.814
620 / 664
329 / 398
340 / 352
331 / 350
361 / 368
529 / 548
clip-b16-openai-textsynthetic (480x640)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
7.85
5.07
4.35
3.53
3.07
1.10
613 / 668
330 / 380
336 / 354
328 / 350
360 / 370
526 / 548
clip-l14-openai-textsynthetic (480x640)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
26.3
8.79
7.94
6.84
6.42
3.99
1684 / 1730
860 / 934
869 / 894
858 / 886
896 / 906
1476 / 1484
siglip2-b16-256-textsynthetic (480x640)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
9.49
5.52
4.98
4.16
3.23
1.15
1473 / 1554
767 / 1164
774 / 794
758 / 786
787 / 804
958 / 966
siglip2-l16-256-textsynthetic (480x640)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
20.8
9.03
8.30
7.13
5.31
2.96
3409 / 3414
1720 / 2220
1725 / 1740
1724 / 1748
1754 / 1766
2346 / 2368
Details
  • Original code: https://github.com/huggingface/transformers at c4c4605f9618
  • Code licence: Apache-2.0 (permissive); files:
  • Weights licence: MIT
    • siglip2-b16-256-text: Apache-2.0
    • siglip2-l16-256-text: Apache-2.0
  • Licence evidence: https://github.com/openai/CLIP/blob/d05afc436d78f1c48dc0dbf8e5980a9d471f35f6/LICENSE
  • Training data: WIT: 400M image-text pairs collected from the web by OpenAI (CLIP paper); not released
    • siglip2-b16-256-text: WebLI (Google web image-text data, not released) (WebLI image-text pairs (multilingual), sigmoid contrastive loss plus captioning / self-distillation / masked prediction (SigLIP 2 paper); not released)
    • siglip2-l16-256-text: WebLI (Google web image-text data, not released) (WebLI image-text pairs (multilingual), sigmoid contrastive loss plus captioning / self-distillation / masked prediction (SigLIP 2 paper); not released)
  • Kernel libraries: fvm_conv
  • Variants: clip-b32-openai-text, clip-b16-openai-text, clip-l14-openai-text, siglip2-b16-256-text, siglip2-l16-256-text
  • Outputs: descriptor
  • Input size: any H x W >= 32, padded to a multiple of 32
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): clip-b32-openai-text 3000x4000 (0.7 GiB peak allocated, 0.7 reserved); clip-b16-openai-text 3000x4000 (0.7 GiB peak allocated, 0.7 reserved); clip-l14-openai-text 3000x4000 (1.2 GiB peak allocated, 1.3 reserved); siglip2-b16-256-text 3000x4000 (1.1 GiB peak allocated, 1.2 reserved); siglip2-l16-256-text 3000x4000 (2.1 GiB peak allocated, 2.1 reserved)
  • clip-b32-openai-text 480x640, first call: portable + torch.compile 9 s (cold Inductor cache), TensorRT fp16 19 s (ONNX + engine).
  • clip-b16-openai-text 480x640, first call: portable + torch.compile 9 s (cold Inductor cache), TensorRT fp16 20 s (ONNX + engine).
  • clip-l14-openai-text 480x640, first call: portable + torch.compile 13 s (cold Inductor cache), TensorRT fp16 33 s (ONNX + engine).
  • siglip2-b16-256-text 480x640, first call: portable + torch.compile 9 s (cold Inductor cache), TensorRT fp16 42 s (ONNX + engine).
  • siglip2-l16-256-text 480x640, first call: portable + torch.compile 12 s (cold Inductor cache), TensorRT fp16 45 s (ONNX + engine).
  • clip-b32-openai-text original (fp32) 480x640, original 480x640: transformers 5.19.0 get_image_features on the HF processor's resize (pre-processing not timed on the same path)
  • clip-b16-openai-text original (fp32) 480x640, original 480x640: transformers 5.19.0 get_image_features on the HF processor's resize (pre-processing not timed on the same path)
  • clip-l14-openai-text original (fp32) 480x640, original 480x640: transformers 5.19.0 get_image_features on the HF processor's resize (pre-processing not timed on the same path)
  • siglip2-b16-256-text original (fp32) 480x640, original 480x640: transformers 5.19.0 get_image_features on the HF processor's resize (pre-processing not timed on the same path)
  • siglip2-l16-256-text original (fp32) 480x640, original 480x640: transformers 5.19.0 get_image_features on the HF processor's resize (pre-processing not timed on the same path)
  • clip-b32-openai-text load / first call: original 0.31 s / 0.04 s, portable 0.25 s / 0.01 s, kernels 2.93 s / 0.156 s
  • clip-b16-openai-text load / first call: original 0.27 s / 0.04 s, portable 0.24 s / 0.01 s, kernels 2.93 s / 0.161 s
  • clip-l14-openai-text load / first call: original 0.45 s / 0.08 s, portable 0.44 s / 0.01 s, kernels 3.61 s / 0.166 s
  • siglip2-b16-256-text load / first call: original 1.79 s / 0.46 s, portable 1.13 s / 0.01 s, kernels 4.02 s / 0.139 s
  • siglip2-l16-256-text load / first call: original 2.14 s / 0.03 s, portable 1.54 s / 0.01 s, kernels 5.53 s / 0.13 s
  • Protocol, median of 20 after warm-up, uint8 CUDA input, card defaults

Measured

Every query's descriptor against every database descriptor (cosine similarity, exact top-k on the GPU); a query counts as found at k when one of its k nearest database images is within 25 m (UTM positions of the file names), the standard visual place recognition protocol. Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16portableportable fp32note
clip-b32-openai-textCOCO val2017 captions, every 5th image (1000 images, 5 captions each), recall@1 / @5 % image to text / text to image68.50 / 90.10 / 48.14 / 76.3868.50 / 90.10 / 48.14 / 76.3668.70 / 89.90 / 48.18 / 76.3668.60 / 89.90 / 48.16 / 76.30
clip-b16-openai-textCOCO val2017 captions, every 5th image (1000 images, 5 captions each), recall@1 / @5 % image to text / text to image70.50 / 90.40 / 49.48 / 78.8270.50 / 90.30 / 49.50 / 78.8070.30 / 90.00 / 49.74 / 78.7070.20 / 90.00 / 49.68 / 78.76
clip-l14-openai-textCOCO val2017 captions, every 5th image (1000 images, 5 captions each), recall@1 / @5 % image to text / text to image73.60 / 91.80 / 53.10 / 79.8673.60 / 91.80 / 53.08 / 79.8273.20 / 91.60 / 53.10 / 79.5273.30 / 91.60 / 53.12 / 79.52
siglip2-b16-256-textCOCO val2017 captions, every 5th image (1000 images, 5 captions each), recall@1 / @5 % image to text / text to image83.90 / 96.10 / 70.18 / 89.8683.90 / 96.20 / 70.16 / 89.8483.80 / 96.20 / 70.10 / 89.7883.70 / 96.20 / 70.14 / 89.80
siglip2-l16-256-textCOCO val2017 captions, every 5th image (1000 images, 5 captions each), recall@1 / @5 % image to text / text to image83.80 / 96.20 / 70.34 / 89.8483.70 / 96.20 / 70.36 / 89.7883.70 / 96.20 / 70.28 / 89.9083.60 / 96.20 / 70.34 / 89.94

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks d5364b118, 2026-11-30.

Parity

CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.02 and p99 <= 0.25 (absolute error of the output descriptor).

variantkernels error vs original, mean / p99GPU, torchkernels used
clip-b32-openai-text0.00095 / 0.00405RTX 5060 Ti, torch 2.14.1+cu130fvm_conv@f1d064e539e1:sm_120
clip-b16-openai-text0.0005 / 0.00173RTX 5060 Ti, torch 2.14.1+cu130fvm_conv@f1d064e539e1:sm_120
clip-l14-openai-text0.00048 / 0.00154RTX 5060 Ti, torch 2.14.1+cu130fvm_conv@f1d064e539e1:sm_120
siglip2-b16-256-text0.0002 / 0.00074RTX 5060 Ti, torch 2.14.1+cu130fvm_conv@f1d064e539e1:sm_120
siglip2-l16-256-text0.00028 / 0.00094RTX 5060 Ti, torch 2.14.1+cu130fvm_conv@f1d064e539e1:sm_120

Limitations

  • Requires the optional transformers library (the networks are its CLIPModel / SiglipModel) and, for SigLIP 2, its tokenizers dependency.
  • The kernels backend (CUDA, fp16) speeds up the image tower only (fused fp16-accumulate GEMMs, a CUDA graph per batch size); encode_text runs the portable text tower. An Apple MLX port of both towers runs with device="mlx" (fp32, fp16).
  • Text is truncated to the context (CLIP 77 tokens, SigLIP 2 64 tokens, the end token kept); SigLIP 2 lower-cases its text as the original tokenizer does. CLIP prompts are expected to be clean Unicode (the ftfy repair of the original tokenizer is left out).
  • The SigLIP 2 checkpoints are the fixed-resolution 256 px models (model_type: siglip); the NaFlex variants are not included. SigLIP 2 scores are independent per label (sigmoid with the checkpoint's scale and bias), CLIP scores are a softmax over the labels given.
  • The original in the parity checks and benchmarks is the Hugging Face transformers 5.19.0 port with the authors' weights (openai/clip-vit-, google/siglip2--patch16-256); the authors' openai/CLIP and big_vision code was not run.
  • Not included: OpenCLIP LAION weights (they ship as open_clip files, not in the transformers layout), DFN (Apple research-only licence).

Example output

No example rendered for this checkpoint yet.