SigLIP 2 So400m/16-384 for Core ML

Google's SigLIP 2 So400m/16 at 384 px, revision dd658faac399427308559e2c3ac1e99cbe43845d, converted to Core ML for search on iPhone and Mac. The image and the text encoder are separate packages. Each returns a normalized 1,152-number embedding, so the dot product of an image embedding and a text embedding is their cosine similarity.

Files

File What it is Size
siglip2_image.mlpackage Image encoder. Input image: RGB, 384 Γ— 384. Output embedding. 16-bit weights. 854 MB
siglip2_text.mlpackage Text encoder. Input text: int32, shape [1, 64]. Output embedding. 8-bit weights. 709 MB
siglip2-vocabulary.json The Gemma SentencePiece vocabulary: pieces, scores and kinds for all 256,000 tokens. 5.7 MB
token-checks.json Token numbers from the Hugging Face tokenizer for 14 texts, to check a tokenizer against. 5 KB
convert.py, export_vocabulary.py, validate.py The scripts that made and checked these files.

How to use

  • Images: resize the picture to 384 Γ— 384 with no crop. The model scales the pixels to the range βˆ’1 to 1 itself.
  • Text: lowercase it, tokenize it with the Gemma tokenizer (spaces become "▁", no beginning token), add the end token 1, and pad with 0 to 64 tokens. Text is read in 109 languages.
  • Compute units: run the image encoder on the Neural Engine or the GPU. On the CPU at 16 bits, its embeddings drift (0.91 agreement with the original in one test).

Changes from the original

  • The image encoder's pooling attention, torch.nn.MultiheadAttention, is written with plain matrix products, with the same weights, because Core ML Tools cannot convert the original. The largest difference in the output is below 0.000001.
  • Each encoder returns its embedding divided by its length.
  • The image encoder is stored with 16-bit weights. The text encoder is stored with 8-bit weights, per channel. 8-bit weights for the image encoder, per channel or in blocks of 16, gave only 0.79 to 0.88 agreement with the original, so it was left at 16 bits.

Checks

Against the original PyTorch model in float32, on five photos and eleven texts in English, Chinese and Malay, with Core ML on the CPU and Neural Engine:

  • Image embeddings: cosine similarity 0.985 to 0.9999.
  • Text embeddings: cosine similarity 0.996 to 0.9998.

Licence

SigLIP 2 is Β© Google and is released under the Apache License 2.0. These converted files are released under the same licence. The changes above are the modifications made to the original.

Downloads last month
22
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for raphtlw/siglip2-so400m-patch16-384-coreml

Quantized
(6)
this model