Upload folder using huggingface_hub
Browse files- granite-97m-multilingual-r2/CHECKSUMS.sha256 +9 -0
- granite-97m-multilingual-r2/README.md +119 -0
- granite-97m-multilingual-r2/granite_97m_512.mlmodelc/analytics/coremldata.bin +3 -0
- granite-97m-multilingual-r2/granite_97m_512.mlmodelc/coremldata.bin +3 -0
- granite-97m-multilingual-r2/granite_97m_512.mlmodelc/metadata.json +91 -0
- granite-97m-multilingual-r2/granite_97m_512.mlmodelc/model.mil +0 -0
- granite-97m-multilingual-r2/granite_97m_512.mlmodelc/weights/weight.bin +3 -0
- granite-97m-multilingual-r2/granite_97m_512.mlpackage/Data/com.apple.CoreML/model.mlmodel +3 -0
- granite-97m-multilingual-r2/granite_97m_512.mlpackage/Data/com.apple.CoreML/weights/weight.bin +3 -0
- granite-97m-multilingual-r2/granite_97m_512.mlpackage/Manifest.json +18 -0
granite-97m-multilingual-r2/CHECKSUMS.sha256
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ae37c06948edcc0f030369f8563d63b80a5bcd349ecb6d4219dcc7d3d3525fe9 ./granite_97m_512.mlmodelc/analytics/coremldata.bin
|
| 2 |
+
e8e470b2d49b73cf350eaa2c2f97fb39c99355c4bc507501675a8e53282cc337 ./granite_97m_512.mlmodelc/coremldata.bin
|
| 3 |
+
635299df02dfde6115bbcdb7a8a2cdbe26ecef6be35a393276c5381a32a8f893 ./granite_97m_512.mlmodelc/metadata.json
|
| 4 |
+
b00d8da3bd408b23aa00b6935d35376f88d7d82c7c3f02c19b13375cbea42610 ./granite_97m_512.mlmodelc/model.mil
|
| 5 |
+
276bc93c49a4f37ffefdfb2e10f7d7e1ef57db9027c7ad0d3f2e4160f81a79be ./granite_97m_512.mlmodelc/weights/weight.bin
|
| 6 |
+
e72839d2e0fc97a9fc9464ffa5c3b869179a5a66f575d848c0efacfd2477f9d3 ./granite_97m_512.mlpackage/Data/com.apple.CoreML/model.mlmodel
|
| 7 |
+
276bc93c49a4f37ffefdfb2e10f7d7e1ef57db9027c7ad0d3f2e4160f81a79be ./granite_97m_512.mlpackage/Data/com.apple.CoreML/weights/weight.bin
|
| 8 |
+
3c33dc56181d64a539db3f0b365e0eb142dae760413eda48e84ebb8bf19153e7 ./granite_97m_512.mlpackage/Manifest.json
|
| 9 |
+
a9bacaf49d780b5a6de07043557805a183f3eb4a191600bd7f89785ad3d90796 ./README.md
|
granite-97m-multilingual-r2/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: ibm-granite/granite-embedding-97m-multilingual-r2
|
| 4 |
+
library_name: coreml
|
| 5 |
+
pipeline_tag: sentence-similarity
|
| 6 |
+
tags:
|
| 7 |
+
- coreml
|
| 8 |
+
- modernbert
|
| 9 |
+
- granite
|
| 10 |
+
- text-embeddings
|
| 11 |
+
- multilingual
|
| 12 |
+
- embedkit
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# granite-embedding-97m-multilingual-r2 — CoreML (embedkit)
|
| 16 |
+
|
| 17 |
+
CoreML conversion of **[ibm-granite/granite-embedding-97m-multilingual-r2](https://huggingface.co/ibm-granite/granite-embedding-97m-multilingual-r2)**
|
| 18 |
+
(a ModernBERT encoder, 97M params, 384-dim embeddings, multilingual) for on-device
|
| 19 |
+
inference via [`embedkit`](https://github.com/…) on Apple platforms.
|
| 20 |
+
|
| 21 |
+
This is a **format conversion** of the upstream model (Apache-2.0). No weights were
|
| 22 |
+
retrained or altered in value; the PyTorch graph was lowered to Apple CoreML
|
| 23 |
+
(`.mlpackage` / `.mlmodelc`) at a fixed sequence length.
|
| 24 |
+
|
| 25 |
+
## What this is
|
| 26 |
+
|
| 27 |
+
The sentence-transformers inference graph **in-graph**, except the final L2
|
| 28 |
+
normalization (done by the caller in Rust):
|
| 29 |
+
|
| 30 |
+
```
|
| 31 |
+
input_ids, attention_mask ─▶ ModernBERT encoder (12 layers, hidden 384)
|
| 32 |
+
· dual RoPE (global θ=150000 / local θ=160000)
|
| 33 |
+
· local sliding window 128 (±64) on 8 layers,
|
| 34 |
+
full attention on layers 0/3/6/9
|
| 35 |
+
─▶ CLS pooling (hidden[:, 0])
|
| 36 |
+
─▶ embedding [1, 384] (PRE-L2-norm)
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
### I/O contract
|
| 40 |
+
|
| 41 |
+
| | name | dtype | shape |
|
| 42 |
+
|---|---|---|---|
|
| 43 |
+
| input | `input_ids` | int32 | `[1, 512]` |
|
| 44 |
+
| input | `attention_mask` | int32 | `[1, 512]` |
|
| 45 |
+
| output | `embedding` | float32 | `[1, 384]` (pre-L2-norm CLS) |
|
| 46 |
+
|
| 47 |
+
- **Fixed sequence length 512.** RoPE ⇒ any fixed length is sound; the sliding-window
|
| 48 |
+
local attention (±64) is genuinely windowed at 512 and is faithfully present in the
|
| 49 |
+
exported graph (verified: the CoreML output tracks the local-masked reference at
|
| 50 |
+
cosine 1.0 and diverges from an all-global reference at cosine 0.934). Longer inputs
|
| 51 |
+
are the caller's windowing layer's job.
|
| 52 |
+
- **L2 normalization is NOT in the graph** — the caller normalizes the 384-d output.
|
| 53 |
+
- **CLS pooling** — the embedding is `hidden_states[:, 0]` (the `<|startoftext|>`
|
| 54 |
+
BOS/CLS token at position 0), taken after the final LayerNorm.
|
| 55 |
+
|
| 56 |
+
### Prompts: NONE (prompt-free)
|
| 57 |
+
|
| 58 |
+
granite-embedding r2 retrieval is **prompt-free**: `config_sentence_transformers.json`
|
| 59 |
+
carries empty query/document prompts. Feed **raw strings** — no task prefixes. (This is
|
| 60 |
+
the model's documented retrieval contract; it differs from instruction-tuned embedders.)
|
| 61 |
+
|
| 62 |
+
## Files
|
| 63 |
+
|
| 64 |
+
| file | precision | notes |
|
| 65 |
+
|---|---|---|
|
| 66 |
+
| `granite_97m_512.mlpackage` / `.mlmodelc` | **fp16** | the shipped model — clean on CPU / GPU / ANE |
|
| 67 |
+
| `CHECKSUMS.sha256` | — | sha256 of every artifact file |
|
| 68 |
+
|
| 69 |
+
**fp16 is shipped.** fp16 was measured NaN-free and accurate on every compute unit
|
| 70 |
+
(worst cosine ≥ 0.99996 vs fp32), and the graph is ANE-capable (see below) — so fp32
|
| 71 |
+
fallback was not triggered. An fp32 build exists as a verification reference (cosine
|
| 72 |
+
1.0 vs the transformers-fp32 oracle) but is not shipped.
|
| 73 |
+
|
| 74 |
+
## Precision & placement (measured, NaN-aware, 16 multilingual inputs)
|
| 75 |
+
|
| 76 |
+
| precision · placement | worst cosine vs reference | NaN |
|
| 77 |
+
|---|---|---|
|
| 78 |
+
| **fp32 · CPU** vs transformers-fp32 | **1.00000000** ✅ | 0/16 |
|
| 79 |
+
| **fp16 · ALL** vs fp32 | **0.99999926** ✅ | 0/16 |
|
| 80 |
+
| **fp16 · CPU + GPU** vs fp32 | **0.99999934** ✅ | 0/16 |
|
| 81 |
+
| **fp16 · CPU** vs fp32 | **0.99997885** ✅ | 0/16 |
|
| 82 |
+
| **fp16 · ANE** (`CPU_AND_NE`) vs fp32 | **0.99996360** ✅ | 0/16 |
|
| 83 |
+
|
| 84 |
+
- **CoreML fp32 vs transformers-fp32** (the sentence-transformers granite pipeline,
|
| 85 |
+
a lossless fp32 upcast of the bf16 checkpoint): **worst cosine 1.00000000**, 0 NaN,
|
| 86 |
+
over EN / zh / ja / ko / ar (RTL) / ru / es / de / emoji / mixed-script / code /
|
| 87 |
+
url-number / a 512-token input / short / special-character strings.
|
| 88 |
+
- **fp16 is viable on this model** (unlike some larger encoders whose residual-stream
|
| 89 |
+
activations overflow fp16): no NaN on any placement, worst cosine ≥ 0.99996.
|
| 90 |
+
- **ANE:** the graph **compiles for the Apple Neural Engine** (ANECCompile accepts it;
|
| 91 |
+
`CPU_AND_NE` inference runs clean with finite output). Under a CPU-vs-ANE plan,
|
| 92 |
+
**482/493 ops (97.8%) prefer the ANE** (11 fall back to CPU, 0 to GPU). Under the
|
| 93 |
+
default `ALL` plan the planner prefers the GPU (this graph is small and cheapest on
|
| 94 |
+
GPU there), but the graph is fully ANE-capable when the ANE is targeted.
|
| 95 |
+
|
| 96 |
+
### fp16 vanishing-guard audit — CLEAN
|
| 97 |
+
|
| 98 |
+
MIL guard-site audit: **25 sites, all CLEAN**, threshold 2⁻²⁴. Every site is a
|
| 99 |
+
`layer_norm` with epsilon `0x1.5p-17` = 1.0013580322265625e-05 (the fp16 rounding of
|
| 100 |
+
the model's `norm_eps` 1e-5), ≫ 2⁻²⁴. There is **no** `rsqrt`/`sqrt`/`real_div`/`log`
|
| 101 |
+
guard class in the graph (the L2-norm rsqrt is kept in Rust; attention `softmax` has
|
| 102 |
+
no decomposed log tail). RoPE cos/sin are precomputed fp32 constants.
|
| 103 |
+
|
| 104 |
+
## Provenance
|
| 105 |
+
|
| 106 |
+
- Upstream: `ibm-granite/granite-embedding-97m-multilingual-r2` (Apache-2.0),
|
| 107 |
+
revision `835ad14087e140460703cf0fae09f97d469d65c2`. Weights ship bf16.
|
| 108 |
+
- The CoreML graph drives the stock `transformers` ModernBERT encoder layers with
|
| 109 |
+
static per-layer local/global attention masks (lowered at fixed 512) + precomputed
|
| 110 |
+
fp32 dual-RoPE, then CLS-slices — validated bit-faithful (cosine ≥ 0.99999998) to the
|
| 111 |
+
sentence-transformers fp32 pipeline before conversion.
|
| 112 |
+
- Toolchain: coremltools 9.0 · torch 2.6.0 · transformers 5.14.0 ·
|
| 113 |
+
sentence-transformers 5.6.0 · numpy 1.26.4 · python 3.11.
|
| 114 |
+
|
| 115 |
+
## License
|
| 116 |
+
|
| 117 |
+
This artifact is a format conversion of `ibm-granite/granite-embedding-97m-multilingual-r2`
|
| 118 |
+
and is distributed under the **Apache License 2.0**, inheriting the upstream license.
|
| 119 |
+
Attribution: IBM Granite team. See the upstream model card for the full license text.
|
granite-97m-multilingual-r2/granite_97m_512.mlmodelc/analytics/coremldata.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ae37c06948edcc0f030369f8563d63b80a5bcd349ecb6d4219dcc7d3d3525fe9
|
| 3 |
+
size 243
|
granite-97m-multilingual-r2/granite_97m_512.mlmodelc/coremldata.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e8e470b2d49b73cf350eaa2c2f97fb39c99355c4bc507501675a8e53282cc337
|
| 3 |
+
size 746
|
granite-97m-multilingual-r2/granite_97m_512.mlmodelc/metadata.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"metadataOutputVersion" : "3.0",
|
| 4 |
+
"shortDescription" : "granite-embedding-97m text encoder: input_ids\/attention_mask [1,512] -> 384-d CLS embedding (PRE-L2-norm; caller L2-normalizes). Prompt-free (raw strings).",
|
| 5 |
+
"outputSchema" : [
|
| 6 |
+
{
|
| 7 |
+
"hasShapeFlexibility" : "0",
|
| 8 |
+
"isOptional" : "0",
|
| 9 |
+
"dataType" : "Float32",
|
| 10 |
+
"formattedType" : "MultiArray (Float32 1 × 384)",
|
| 11 |
+
"shortDescription" : "",
|
| 12 |
+
"shape" : "[1, 384]",
|
| 13 |
+
"name" : "embedding",
|
| 14 |
+
"type" : "MultiArray"
|
| 15 |
+
}
|
| 16 |
+
],
|
| 17 |
+
"storagePrecision" : "Float16",
|
| 18 |
+
"modelParameters" : [
|
| 19 |
+
|
| 20 |
+
],
|
| 21 |
+
"author" : "embedkit T1: ibm-granite\/granite-embedding-97m-multilingual-r2 (ModernBERT encoder + CLS pooling), pre-L2-norm; static per-layer local\/global masks + fp32 dual-RoPE at fixed 512",
|
| 22 |
+
"specificationVersion" : 8,
|
| 23 |
+
"mlProgramOperationTypeHistogram" : {
|
| 24 |
+
"Split" : 24,
|
| 25 |
+
"Ios17.mul" : 96,
|
| 26 |
+
"Ios16.silu" : 12,
|
| 27 |
+
"Ios17.linear" : 48,
|
| 28 |
+
"Select" : 3,
|
| 29 |
+
"Ios17.transpose" : 48,
|
| 30 |
+
"Ios17.matmul" : 24,
|
| 31 |
+
"Ios17.gather" : 1,
|
| 32 |
+
"Ios17.add" : 61,
|
| 33 |
+
"Ios17.sliceByIndex" : 49,
|
| 34 |
+
"Ios17.concat" : 24,
|
| 35 |
+
"Ios16.softmax" : 12,
|
| 36 |
+
"Ios17.logicalAnd" : 1,
|
| 37 |
+
"Ios17.greaterEqual" : 1,
|
| 38 |
+
"Ios17.expandDims" : 2,
|
| 39 |
+
"Ios17.squeeze" : 36,
|
| 40 |
+
"Ios17.cast" : 2,
|
| 41 |
+
"Ios17.layerNorm" : 25,
|
| 42 |
+
"Ios17.reshape" : 24
|
| 43 |
+
},
|
| 44 |
+
"computePrecision" : "Mixed (Float16, Float32, Int32)",
|
| 45 |
+
"isUpdatable" : "0",
|
| 46 |
+
"stateSchema" : [
|
| 47 |
+
|
| 48 |
+
],
|
| 49 |
+
"availability" : {
|
| 50 |
+
"macOS" : "14.0",
|
| 51 |
+
"tvOS" : "17.0",
|
| 52 |
+
"visionOS" : "1.0",
|
| 53 |
+
"watchOS" : "10.0",
|
| 54 |
+
"iOS" : "17.0",
|
| 55 |
+
"macCatalyst" : "17.0"
|
| 56 |
+
},
|
| 57 |
+
"modelType" : {
|
| 58 |
+
"name" : "MLModelType_mlProgram"
|
| 59 |
+
},
|
| 60 |
+
"inputSchema" : [
|
| 61 |
+
{
|
| 62 |
+
"hasShapeFlexibility" : "0",
|
| 63 |
+
"isOptional" : "0",
|
| 64 |
+
"dataType" : "Int32",
|
| 65 |
+
"formattedType" : "MultiArray (Int32 1 × 512)",
|
| 66 |
+
"shortDescription" : "",
|
| 67 |
+
"shape" : "[1, 512]",
|
| 68 |
+
"name" : "input_ids",
|
| 69 |
+
"type" : "MultiArray"
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"hasShapeFlexibility" : "0",
|
| 73 |
+
"isOptional" : "0",
|
| 74 |
+
"dataType" : "Int32",
|
| 75 |
+
"formattedType" : "MultiArray (Int32 1 × 512)",
|
| 76 |
+
"shortDescription" : "",
|
| 77 |
+
"shape" : "[1, 512]",
|
| 78 |
+
"name" : "attention_mask",
|
| 79 |
+
"type" : "MultiArray"
|
| 80 |
+
}
|
| 81 |
+
],
|
| 82 |
+
"userDefinedMetadata" : {
|
| 83 |
+
"com.github.apple.coremltools.conversion_date" : "2026-07-18",
|
| 84 |
+
"com.github.apple.coremltools.source" : "torch==2.6.0",
|
| 85 |
+
"com.github.apple.coremltools.version" : "9.0",
|
| 86 |
+
"com.github.apple.coremltools.source_dialect" : "TorchScript"
|
| 87 |
+
},
|
| 88 |
+
"generatedClassName" : "granite_97m_512",
|
| 89 |
+
"method" : "predict"
|
| 90 |
+
}
|
| 91 |
+
]
|
granite-97m-multilingual-r2/granite_97m_512.mlmodelc/model.mil
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
granite-97m-multilingual-r2/granite_97m_512.mlmodelc/weights/weight.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:276bc93c49a4f37ffefdfb2e10f7d7e1ef57db9027c7ad0d3f2e4160f81a79be
|
| 3 |
+
size 196078720
|
granite-97m-multilingual-r2/granite_97m_512.mlpackage/Data/com.apple.CoreML/model.mlmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e72839d2e0fc97a9fc9464ffa5c3b869179a5a66f575d848c0efacfd2477f9d3
|
| 3 |
+
size 427137
|
granite-97m-multilingual-r2/granite_97m_512.mlpackage/Data/com.apple.CoreML/weights/weight.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:276bc93c49a4f37ffefdfb2e10f7d7e1ef57db9027c7ad0d3f2e4160f81a79be
|
| 3 |
+
size 196078720
|
granite-97m-multilingual-r2/granite_97m_512.mlpackage/Manifest.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"fileFormatVersion": "1.0.0",
|
| 3 |
+
"itemInfoEntries": {
|
| 4 |
+
"6A4C538F-4FDB-47FC-BEED-1CEC07CDAE63": {
|
| 5 |
+
"author": "com.apple.CoreML",
|
| 6 |
+
"description": "CoreML Model Specification",
|
| 7 |
+
"name": "model.mlmodel",
|
| 8 |
+
"path": "com.apple.CoreML/model.mlmodel"
|
| 9 |
+
},
|
| 10 |
+
"F10AB0AC-F201-4DDF-B6C2-39CD7B9B2BA2": {
|
| 11 |
+
"author": "com.apple.CoreML",
|
| 12 |
+
"description": "CoreML Model Weights",
|
| 13 |
+
"name": "weights",
|
| 14 |
+
"path": "com.apple.CoreML/weights"
|
| 15 |
+
}
|
| 16 |
+
},
|
| 17 |
+
"rootModelIdentifier": "6A4C538F-4FDB-47FC-BEED-1CEC07CDAE63"
|
| 18 |
+
}
|