{ "name": "embeddinggemma-2-ane", "manifest_version": 2, "created": "2026-11-27", "source_model": { "id": "google/embeddinggemma-2", "revision": "f9972ac22e696a105c482202646979e33e4b5a1e", "license": "Apache-2.0", "model.safetensors_sha256": "197a32965d4b1105faf060417baa899e193fb73cd401f42ec9295234d5553d79", "use_policy": "https://ai.google.dev/gemma/prohibited_use_policy", "attribution": "EmbeddingGemma 2 by Google DeepMind" }, "vision_source": { "id": "google/embeddinggemma-2", "revision": "f9972ac22e696a105c482202646979e33e4b5a1e", "license": "Apache-2.0", "converter": "tools/convert/eg2_vision.py", "position_table": "first 1024 rows per axis of the checkpoint position table as fp16" }, "converter": { "script": "tools/convert/build.py", "python_packages": { "coremltools": "9.0", "torch": "2.7.1", "numpy": "2.5.4", "safetensors": "0.8.0", "tokenizers": "0.23.3", "transformers": "5.22.2", "sentence-transformers": "6.3.0", "pillow": "13.0.0", "torchvision": "0.22.1" }, "precision": "fp16 ML Program (compute_precision FLOAT16), minimum macOS 15", "compute_units": "cpuAndNeuralEngine (the package is tuned and verified for the ANE only)" }, "license": "Apache-2.0 (LICENSE, NOTICE)", "embedding": { "dim": 768, "normalized": "L2, in graph", "matryoshka_dims": [ 768, 512, 256, 128 ], "matryoshka": "keep the first d values, then L2-normalize again (host)" }, "special_tokens": { "pad": 0, "eos": 1, "bos": 2, "image_start (<|image>)": 255999, "image_end ()": 258882, "image_placeholder (<|image|>, HF only)": 258880, "audio_start": 256000, "audio_end": 258883 }, "text_sequence": "[bos] + tokenizer.encode(prompt + text, add_special_tokens=False) + [eos]", "prompts": { "BitextMining": "task: search result | query: ", "Classification": "task: classification | query: ", "Clustering": "task: clustering | query: ", "CodeRetrieval": "task: code retrieval | query: ", "Document": "title: none | text: ", "FactChecking": "task: fact checking | query: ", "InstructionRetrieval": "task: code retrieval | query: ", "MultilabelClassification": "task: classification | query: ", "PairClassification": "task: sentence similarity | query: ", "QuestionAnswering": "task: question answering | query: ", "Reranking": "task: search result | query: ", "Retrieval": "task: search result | query: ", "Retrieval-document": "title: none | text: ", "Retrieval-query": "task: search result | query: ", "STS": "task: sentence similarity | query: ", "SearchQuery": "task: search result | query: ", "SentenceSimilarity": "task: sentence similarity | query: ", "Summarization": "task: sentence similarity | query: ", "document": "title: none | text: ", "query": "task: search result | query: " }, "token_table": { "file": "embeddings.bf16", "dtype": "bfloat16", "byte_order": "little", "shape": [ 262144, 512 ], "row_to_input": "fp32(bf16 row) * sqrt(512) (= 22.627417), then cast to fp16", "sha256_equals": "raw little-endian BF16 bytes of language_model.embed_tokens.weight in google/embeddinggemma-2 model.safetensors" }, "packages": { "EmbeddingGemma2Text": { "mlpackage": "EmbeddingGemma2Text.mlpackage", "mlmodelc": "EmbeddingGemma2Text.mlmodelc", "compute_units": "cpuAndNeuralEngine", "functions": { "embed_64": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 64, 512 ], "dtype": "float16" }, { "name": "global_bias", "shape": [ 1, 1, 64, 64 ], "dtype": "float16" }, { "name": "local_bias", "shape": [ 1, 1, 64, 64 ], "dtype": "float16" }, { "name": "pool", "shape": [ 8, 64 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 8, 768 ], "dtype": "float32" } ] }, "embed_128": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 128, 512 ], "dtype": "float16" }, { "name": "global_bias", "shape": [ 1, 1, 128, 128 ], "dtype": "float16" }, { "name": "local_bias", "shape": [ 1, 1, 128, 128 ], "dtype": "float16" }, { "name": "pool", "shape": [ 8, 128 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 8, 768 ], "dtype": "float32" } ] }, "embed_256": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 256, 512 ], "dtype": "float16" }, { "name": "global_bias", "shape": [ 1, 1, 256, 256 ], "dtype": "float16" }, { "name": "local_bias", "shape": [ 1, 1, 256, 256 ], "dtype": "float16" }, { "name": "pool", "shape": [ 8, 256 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 8, 768 ], "dtype": "float32" } ] }, "embed_512": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 512, 512 ], "dtype": "float16" }, { "name": "global_bias", "shape": [ 1, 1, 512, 512 ], "dtype": "float16" }, { "name": "local_bias", "shape": [ 1, 1, 512, 512 ], "dtype": "float16" }, { "name": "pool", "shape": [ 16, 512 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 16, 768 ], "dtype": "float32" } ] }, "embed_768": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 768, 512 ], "dtype": "float16" }, { "name": "global_bias", "shape": [ 1, 1, 768, 768 ], "dtype": "float16" }, { "name": "local_bias", "shape": [ 1, 1, 768, 768 ], "dtype": "float16" }, { "name": "pool", "shape": [ 24, 768 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 24, 768 ], "dtype": "float32" } ] }, "embed_1024": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 1024, 512 ], "dtype": "float16" }, { "name": "global_bias", "shape": [ 1, 1, 1024, 1024 ], "dtype": "float16" }, { "name": "local_bias", "shape": [ 1, 1, 1024, 1024 ], "dtype": "float16" }, { "name": "pool", "shape": [ 32, 1024 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 32, 768 ], "dtype": "float32" } ] }, "embed_1280": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 1280, 512 ], "dtype": "float16" }, { "name": "global_bias", "shape": [ 1, 1, 1280, 1280 ], "dtype": "float16" }, { "name": "local_bias", "shape": [ 1, 1, 1280, 1280 ], "dtype": "float16" }, { "name": "pool", "shape": [ 40, 1280 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 40, 768 ], "dtype": "float32" } ] }, "winp1536_b512": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 1536, 512 ], "dtype": "float16" }, { "name": "band_bias", "shape": [ 1, 1, 1536, 1536 ], "dtype": "float16" }, { "name": "global_bias", "shape": [ 1, 1, 1536, 1536 ], "dtype": "float16" }, { "name": "pool", "shape": [ 48, 1536 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 48, 768 ], "dtype": "float32" } ] }, "winp2048_b512": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 2048, 512 ], "dtype": "float16" }, { "name": "band_bias", "shape": [ 1, 1, 2048, 1536 ], "dtype": "float16" }, { "name": "global_bias", "shape": [ 1, 1, 2048, 2048 ], "dtype": "float16" }, { "name": "pool", "shape": [ 64, 2048 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 64, 768 ], "dtype": "float32" } ] }, "winl3072_b512": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 3072, 512 ], "dtype": "float16" }, { "name": "band_bias", "shape": [ 1, 1, 3072, 1536 ], "dtype": "float16" }, { "name": "key_bias", "shape": [ 1, 1, 1, 3072 ], "dtype": "float16" }, { "name": "pool", "shape": [ 1, 3072 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 1, 768 ], "dtype": "float32" } ] }, "winl4096_b512": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 4096, 512 ], "dtype": "float16" }, { "name": "band_bias", "shape": [ 1, 1, 4096, 1536 ], "dtype": "float16" }, { "name": "key_bias", "shape": [ 1, 1, 1, 4096 ], "dtype": "float16" }, { "name": "pool", "shape": [ 1, 4096 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 1, 768 ], "dtype": "float32" } ] }, "winl6144_b512": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 6144, 512 ], "dtype": "float16" }, { "name": "band_bias", "shape": [ 1, 1, 6144, 1536 ], "dtype": "float16" }, { "name": "key_bias", "shape": [ 1, 1, 1, 6144 ], "dtype": "float16" }, { "name": "pool", "shape": [ 1, 6144 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 1, 768 ], "dtype": "float32" } ] }, "winl8192_b512": { "inputs": [ { "name": "inputs_embeds", "shape": [ 1, 8192, 512 ], "dtype": "float16" }, { "name": "band_bias", "shape": [ 1, 1, 8192, 1536 ], "dtype": "float16" }, { "name": "key_bias", "shape": [ 1, 1, 1, 8192 ], "dtype": "float16" }, { "name": "pool", "shape": [ 1, 8192 ], "dtype": "float16" } ], "outputs": [ { "name": "embedding", "shape": [ 1, 768 ], "dtype": "float32" } ] } } }, "EmbeddingGemma2Vision": { "mlpackage": "EmbeddingGemma2Vision.mlpackage", "mlmodelc": "EmbeddingGemma2Vision.mlmodelc", "compute_units": "cpuAndNeuralEngine", "functions": { "vision_70": { "inputs": [ { "name": "patches", "shape": [ 1, 630, 768 ], "dtype": "float16" }, { "name": "positions", "shape": [ 1, 630, 2 ], "dtype": "float16" }, { "name": "pool", "shape": [ 70, 630 ], "dtype": "float16" }, { "name": "valid", "shape": [ 1, 630 ], "dtype": "float16" }, { "name": "position_embeddings", "shape": [ 1, 630, 768 ], "dtype": "float16" } ], "outputs": [ { "name": "image_tokens", "shape": [ 1, 70, 512 ], "dtype": "float16" } ] }, "vision_140": { "inputs": [ { "name": "patches", "shape": [ 1, 1260, 768 ], "dtype": "float16" }, { "name": "positions", "shape": [ 1, 1260, 2 ], "dtype": "float16" }, { "name": "pool", "shape": [ 140, 1260 ], "dtype": "float16" }, { "name": "valid", "shape": [ 1, 1260 ], "dtype": "float16" }, { "name": "position_embeddings", "shape": [ 1, 1260, 768 ], "dtype": "float16" } ], "outputs": [ { "name": "image_tokens", "shape": [ 1, 140, 512 ], "dtype": "float16" } ] }, "vision_280": { "inputs": [ { "name": "patches", "shape": [ 1, 2520, 768 ], "dtype": "float16" }, { "name": "positions", "shape": [ 1, 2520, 2 ], "dtype": "float16" }, { "name": "pool", "shape": [ 280, 2520 ], "dtype": "float16" }, { "name": "valid", "shape": [ 1, 2520 ], "dtype": "float16" }, { "name": "position_embeddings", "shape": [ 1, 2520, 768 ], "dtype": "float16" } ], "outputs": [ { "name": "image_tokens", "shape": [ 1, 280, 512 ], "dtype": "float16" } ] } } } }, "layout": "layoutR: embed_S buckets up to 1280 rows, windowed packing functions up to 2048, one windowed call per long text up to 8192", "buckets": [ { "function": "embed_64", "tokens": 64, "slots": 8 }, { "function": "embed_128", "tokens": 128, "slots": 8 }, { "function": "embed_256", "tokens": 256, "slots": 8 }, { "function": "embed_512", "tokens": 512, "slots": 16 }, { "function": "embed_768", "tokens": 768, "slots": 24 }, { "function": "embed_1024", "tokens": 1024, "slots": 32 }, { "function": "embed_1280", "tokens": 1280, "slots": 40 } ], "bucket_contract": { "use": "texts/images of total length <= 1280 rows; pick the smallest S >= total rows of the packed sequences", "inputs_embeds": "[1,S,512] fp16: sequences back to back from row 0, zero rows after", "global_bias": "[1,1,S,S] fp16: 0 if row i and column j belong to the same sequence or i == j, else -10000", "local_bias": "[1,1,S,S] fp16: global_bias AND |i-j| <= 512 (else -10000); equals global_bias when S <= 512", "pool": "[K,S] fp16: row k = 1/n_k over the n_k rows of sequence k, 0 elsewhere; unused rows all 0 (any positive per-row constant gives the same normalized output; 1/n_k is verified)", "embedding": "[K,768] fp32: row k = L2-normalized embedding of sequence k; unused rows are 0", "positions": "none: RoPE uses absolute positions 0..S-1 inside the graph (exact, RoPE is relative and the bias is block diagonal)" }, "window": { "block": 512, "halo": 512, "band_columns": 1536, "sliding_window": 512, "packing": [ { "function": "winp1536_b512", "tokens": 1536, "slots": 48 }, { "function": "winp2048_b512", "tokens": 2048, "slots": 64 } ], "long": [ { "function": "winl3072_b512", "tokens": 3072 }, { "function": "winl4096_b512", "tokens": 4096 }, { "function": "winl6144_b512", "tokens": 6144 }, { "function": "winl8192_b512", "tokens": 8192 } ], "band_bias": "[1,1,S,1536] fp16: row r, column c = query row r against key row k = (r // 512) * 512 - 512 + c; 0 if (rows r and k belong to the same sequence and |r - k| <= 512) or k == r, else -10000. Columns with k outside [0, S) are never read (any value)", "packing_use": "packed calls of up to 2048 rows (aneembed uses them for 1281..2048 rows): inputs_embeds, global_bias, pool and embedding exactly as for the buckets, band_bias instead of local_bias", "long_use": "one text of 2049..8192 rows per call: S = smallest long size >= n; inputs_embeds rows >= n zero; key_bias [1,1,1,S] fp16 0 for k < n else -10000; pool [1,S] fp16 2^-10 (0.0009765625) for rows < n, else 0 (not 1/n: 1/n underflows fp16 in the in-graph pooling at large n; the scale cancels in the L2 normalization); band_bias with one sequence of n rows; embedding [1,768] fp32", "why": "the sliding layers (20 of 24) attend block by block over [512 x 1536] key windows instead of S x S, so one fixed-shape call covers up to 8192 rows; the 4 global layers attend to all rows. Masks are inputs: a graph-constant band miscompiles on the ANE and padding inside the graph is about 3x slower" }, "vision": { "package": "EmbeddingGemma2Vision", "functions": { "vision_70": { "max_tokens": 70, "patches": 630 }, "vision_140": { "max_tokens": 140, "patches": 1260 }, "vision_280": { "max_tokens": 280, "patches": 2520 } }, "preprocessing": "HF Gemma4ImageProcessor: RGB, aspect-preserving resize to the largest H x W (multiples of 48 px) with H*W <= 9*B*256 px, bicubic + antialias, rescale 1/255 (no normalize; the model applies 2x-1); patches row-major [16 rows][16 cols][RGB] = 768 values; pad to 9*B patches", "inputs": { "patches": "[1,9B,768] fp16", "positions": "[1,9B,2] fp16 (x, y) patch coords, -1 for padding", "position_embeddings": "[1,9B,768] fp16 = table[0][x] + table[1][y] from position_embeddings.f16 ([2,1024,768] fp16), 0 for padding", "valid": "[1,9B] fp16 1/0", "pool": "[B,9B] fp16: 1/9 at [(x//3) + (cols//3)*(y//3), p] for valid patch p" }, "output": "image_tokens [1,B,512] fp16; the first (valid patches / 9) rows are the image tokens", "sequence": "rows = [bos*sqrt(512), boi*sqrt(512), image tokens (unscaled), eoi*sqrt(512), eos*sqrt(512)] -> bucket embed_S like a text sequence (packable with texts and other images)", "default_budget": 280 }, "selftest": { "files": [ "selftest.json", "selftest.bin" ], "tests": 16, "tolerance": { "bucket": { "min_cos": 0.999, "zero_rows_max_abs": 0.001 }, "winp": { "min_cos": 0.999, "zero_rows_max_abs": 0.001 }, "winl": { "min_cos": 0.999 }, "vision": { "min_cos": 0.999, "max_rel_err": 0.05 } }, "runner": "tools/convert/selftest.py run " }, "files": [ { "path": "LICENSE", "size": 11357, "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" }, { "path": "NOTICE", "size": 1406, "sha256": "85984dc1a9e2d3d4885020209283aa25d84952133a4e6b8d099aae573b4876dc" }, { "path": "embeddings.bf16", "size": 268435456, "sha256": "56ebbdbfd706c827f3fae1d97aa39135c7ddc0f1e6d9b12f8565f84bbfbda877" }, { "path": "position_embeddings.f16", "size": 3145728, "sha256": "17de9480acc23638c0634a97ed89e51ed664433256d7d6f109587dcd91c79124" }, { "path": "selftest.bin", "size": 127936, "sha256": "f3091185d13d8fc36674b03c849e363040e7484bf4ba2d9ffeba566c3228778b" }, { "path": "selftest.json", "size": 146366, "sha256": "cb9d7e2c7aa9ce93d1189f7ed218c4030307b2509bf42b16ad871463136fc587" }, { "path": "tokenizer.json", "size": 32170510, "sha256": "4d777ef5bdc1aa36227abdfb77c3e49e7b9c892d16e1b6bda41c393504828be4" }, { "path": "EmbeddingGemma2Text.mlmodelc/coremldata.bin", "size": 2318, "sha256": "7bfd92af9194384b70703756a1496e557a1a60a3a702650e4d4d2b78665273a2" }, { "path": "EmbeddingGemma2Text.mlmodelc/metadata.json", "size": 37803, "sha256": "6e4abb8dadb2147d4e45a6fe779e48ceda5902bdcfd913257ca0ce8b3d197d42" }, { "path": "EmbeddingGemma2Text.mlmodelc/model.mil", "size": 25260317, "sha256": "17fa73463cd389f2c5302d82ba7eaa7281e60693faf56251b3e7227a9f9ea443" }, { "path": "EmbeddingGemma2Text.mlmodelc/analytics/coremldata.bin", "size": 243, "sha256": "fa7984aadc1647d7ef7d11a4699991422d710977d3467e554164512ea78cbf8e" }, { "path": "EmbeddingGemma2Text.mlmodelc/weights/weight.bin", "size": 363060416, "sha256": "44cdb8da93ec8c128e4a00972179a9551773a3c14b7db06374fa79deca01583d" }, { "path": "EmbeddingGemma2Text.mlpackage/Manifest.json", "size": 617, "sha256": "d1e7de8b974456250e398a86cdb62b9c2bfc6fd41bc63da63c311a3a386d1dc3" }, { "path": "EmbeddingGemma2Text.mlpackage/Data/com.apple.CoreML/model.mlmodel", "size": 25433206, "sha256": "2f6f3333c9c6e6ac6d5fc15c7c8cb0c866c463cf34ad75b1cf0fd44355d6d430" }, { "path": "EmbeddingGemma2Text.mlpackage/Data/com.apple.CoreML/weights/weight.bin", "size": 363060416, "sha256": "44cdb8da93ec8c128e4a00972179a9551773a3c14b7db06374fa79deca01583d" }, { "path": "EmbeddingGemma2Vision.mlmodelc/coremldata.bin", "size": 740, "sha256": "50f7e6d75874a173df085e8f236bb2e38b425dae1f177d30ac623a21b8780af2" }, { "path": "EmbeddingGemma2Vision.mlmodelc/metadata.json", "size": 12720, "sha256": "9bdb0053700e97b959138a5eef3627778608b16755a3bd48f4f5992ee658c9e5" }, { "path": "EmbeddingGemma2Vision.mlmodelc/model.mil", "size": 1725439, "sha256": "8a23361a3725cef75cf6d8eaa28d1a5de2234818ccf49ef9f69aad071a950e05" }, { "path": "EmbeddingGemma2Vision.mlmodelc/analytics/coremldata.bin", "size": 243, "sha256": "2dbe66ed3a2ecb7a374318f4fcc5a5cbb0c3aaf6734c7b0be536f26d9151a506" }, { "path": "EmbeddingGemma2Vision.mlmodelc/weights/weight.bin", "size": 304079664, "sha256": "f83fbb1bc8a8d43378f9ca4b9acf91630668bfbf7d732e7b5b45afc147b19691" }, { "path": "EmbeddingGemma2Vision.mlpackage/Manifest.json", "size": 617, "sha256": "23ae11e8b2c7316a83abe598e8cbf1158e1feabe25c68dd61f84b2bf4eac0032" }, { "path": "EmbeddingGemma2Vision.mlpackage/Data/com.apple.CoreML/model.mlmodel", "size": 1732147, "sha256": "553f12838b6b043726e48a18896382d959927b884ca05c4a9a730ede099ac729" }, { "path": "EmbeddingGemma2Vision.mlpackage/Data/com.apple.CoreML/weights/weight.bin", "size": 304079664, "sha256": "f83fbb1bc8a8d43378f9ca4b9acf91630668bfbf7d732e7b5b45afc147b19691" } ] }