HiramKHackenbacker commited on
Commit
0073592
Β·
verified Β·
1 Parent(s): dfcdca0

model card: standard structure, measured facts, verified license declarations

Browse files
Files changed (1) hide show
  1. README.md +128 -68
README.md CHANGED
@@ -1,15 +1,19 @@
1
  ---
2
  license: gemma
 
3
  base_model: google/embeddinggemma-300m
 
4
  library_name: coreai
5
- pipeline_tag: sentence-similarity
6
  tags:
7
  - core-ai
8
  - aimodel
9
  - apple-silicon
10
  - on-device
 
11
  - embeddings
12
  - sentence-embedding
 
13
  - quantized
14
  - int8
15
  extra_gated_heading: Access EmbeddingGemma on Hugging Face
@@ -21,38 +25,22 @@ extra_gated_description: >-
21
  # embeddinggemma-300m β€” Core AI (.aimodel)
22
 
23
  `google/embeddinggemma-300m` exported as a single static Core AI graph for Apple silicon by
24
- [visible-cx](https://huggingface.co/visible-cx). The whole embedding pipeline is **in the
25
- graph**: transformer β†’ mean pooling β†’ dense stack β†’ L2 normalise, one call in, one 768-d
26
- unit vector out. There is no host-side pooling to implement.
27
 
28
- Two variants ship here: an **fp32** bundle and an **int8** bundle produced by compressing
29
- that graph in place. Their status is not the same β€” read the Status table before choosing.
30
 
31
- ## Provenance
32
-
33
- | | |
34
- |---|---|
35
- | Base checkpoint | `google/embeddinggemma-300m` |
36
- | Recipe (fp32) | `coreai-model-zoo/conversion/export_embeddinggemma.py --dtype float32 --seq-len 256` |
37
- | Recipe index | `models/qwen3-embedding/recipe.toml` β†’ `["embeddinggemma-300m"]`, `status = "verified"` |
38
- | Upstream reference bundle | `mlboydaisuke/embeddinggemma-300m-CoreAI` @ `d9a60a18d384484a8dab809b3070b82fb41458ce` |
39
- | Producer fingerprint | `coreai-core 1.0.0b2` on both inner asset `metadata.json` files |
40
- | Asset creation dates | `20260817T201458Z` (fp32), `20260817T212021Z` (int8) |
41
- | Toolchain | `coreai-torch 0.4.1`, `coreai-core 1.0.0b2`, `coreai-opt 0.2.1`, `torch 2.9.0` |
42
- | Asset metadata | `author: "Google DeepMind"`, `license: "Gemma"` (fp32 bundle) |
43
-
44
- The `int8/` bundle is **not a second export**. It is the fp32 bundle put through
45
- `coreai_opt.coreai_utils.quantize_weights(dtype=DType.INT8)` β€” the Core AI *graph*
46
- compression path, which rewrites an existing program's weight constants in place. There was
47
- no PyTorch round-trip and no re-trace: the graph, the input signature and the tokenizer are
48
- the fp32 bundle's, unchanged.
49
 
50
  ## Contents
51
 
52
  | Path | Bytes | Weights | Sequence length |
53
  |---|---:|---|---|
54
- | `model/embeddinggemma-300m_float32_static.aimodel` + `model/reference.json` + `model/tokenizer/` | 1,277,545,730 | fp32 | 256 |
55
- | `int8/embeddinggemma-300m_int8_static.aimodel` + `int8/reference.json` + `int8/tokenizer/` | 356,639,960 | int8 (graph-compressed) | 256 |
56
 
57
  | File | fp32 (`model/`) | int8 (`int8/`) |
58
  |---|---:|---:|
@@ -64,62 +52,134 @@ the fp32 bundle's, unchanged.
64
  | `tokenizer/tokenizer_config.json` | 705 | 705 |
65
 
66
  `reference.json` and `tokenizer/` in `int8/` are byte-identical copies of the fp32 bundle's,
67
- carried so the folder is self-contained. `reference.json` is the exporter's torch oracle:
68
- four reference texts and their pairwise cosines, for checking the source pipeline end to
69
- end.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  ## Requirements
72
 
73
  - **Apple silicon Mac**, Core AI runtime, macOS 27+.
74
- - **Static input signature:** `input_ids [1, 256] int32`, `attention_mask [1, 256] int32`
75
- β†’ `embedding [1, 768]` fp32, L2-normalised. Sequence length 256 is baked into the graph
76
- β€” pad or truncate to it; there is no dynamic-length variant.
77
- - Weights β‰ˆ 1.24 GB resident (fp32) or β‰ˆ 0.32 GB (int8). No KV cache; this is an encoder,
78
- so there is no per-token memory growth and no context ladder. **Minimum practical machine
79
- memory: 8 GB.**
 
80
 
81
- Note the sequence-length difference from the Core ML artifact in this org, which is
82
- **seq 128**. The two are not drop-in substitutes for each other.
 
83
 
84
- ## Performance
85
 
86
- **None measured, from either bundle.** No embedding vector has been computed from either
87
- artifact on Apple silicon. Everything below the Provenance table is a build-and-bytes
88
- result, not a runtime result.
 
89
 
90
- ## Status
91
 
92
- | Artifact | Status |
93
- |---|---|
94
- | `model/` (fp32, seq 256) | **UNQUALIFIED β€” built and fingerprinted, runtime-unverified.** The recipe is the zoo's `status = "verified"` entry, the producer fingerprint passes, and the exporter's pre-export gate (wrapper vs `sentence_transformers.encode`, cosine > 0.999) passed. No vector has been computed from the *exported graph* on Apple silicon. |
95
- | `int8/` (graph-compressed) | **EXPERIMENTAL.** Gate: cross-runtime vector parity against the fp32 bundle on Apple silicon β€” cosine similarity per vector *and* retrieval-rank agreement on a fixed corpus, not a spot-check of output shapes. Do not use for production embeddings until that passes. |
 
 
 
96
 
97
- The int8 caveat is not boilerplate: fp16 embeddinggemma is already known to fail
98
- vector-precision parity, because a full `.to(float16)` overflows Gemma3 activations and
99
- emits NaN embeddings. A 4Γ— compression passing parity is a hypothesis, not an expectation.
 
 
100
 
101
- ### Verification
102
 
103
- - **Torch oracle agrees to ~6e-8.** `reference.json`'s pairwise cosines from an independent
104
- rebuild match the published values to roughly seven decimal places (largest deviation
105
- ~6e-8). That is CPU float nondeterminism across machines, not a different model. It
106
- validates the **source** pipeline β€” checkpoint β†’ prompts β†’ pooling β†’ dense β†’ L2 β€” and
107
- explicitly does **not** validate the exported graph's execution.
108
- - **Not byte-reproducible.** Rebuilt from the same recipe, `main.mlirb` differed from the
109
- published upstream bundle by +262 bytes, and two runs on the same host with an identical
110
- command differed from each other by +32 bytes. The tokenizer half is identical in every
111
- comparison. Integrity rests on per-file SHA-256 of the exact published bytes. (The
112
- sibling `visible-cx/embeddinggemma-300m-CoreML` repo *is* bit-reproducible β€” a different
113
- supply-chain argument for the same model.)
114
- - No ANE-residency measurement exists for either bundle. `export_embeddinggemma.py` exposes
115
- only `--dtype`, `--seq-len`, `--output-dir`, `--overwrite`; there is no compute-unit flag.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
  ## License
118
 
119
- EmbeddingGemma is Gemma-family. These bundles are a derivative of
120
- `google/embeddinggemma-300m`, and use is subject to the
121
  [Gemma Terms of Use](https://ai.google.dev/gemma/terms) and the
122
  [Gemma Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy). The fp32
123
- bundle's own asset metadata carries `license: "Gemma"` and `author: "Google DeepMind"`.
124
- Those terms travel with the artifact and with any redistribution of it; the contribution
125
- here is the conversion, not the weights.
 
1
  ---
2
  license: gemma
3
+ license_link: https://ai.google.dev/gemma/terms
4
  base_model: google/embeddinggemma-300m
5
+ base_model_relation: quantized
6
  library_name: coreai
7
+ pipeline_tag: feature-extraction
8
  tags:
9
  - core-ai
10
  - aimodel
11
  - apple-silicon
12
  - on-device
13
+ - coreai-kit
14
  - embeddings
15
  - sentence-embedding
16
+ - sentence-similarity
17
  - quantized
18
  - int8
19
  extra_gated_heading: Access EmbeddingGemma on Hugging Face
 
25
  # embeddinggemma-300m β€” Core AI (.aimodel)
26
 
27
  `google/embeddinggemma-300m` exported as a single static Core AI graph for Apple silicon by
28
+ [visible-cx](https://huggingface.co/visible-cx). **The whole embedding pipeline is in the
29
+ graph** β€” transformer β†’ mean pooling β†’ dense stack β†’ L2 normalise β€” so it is one call in, one
30
+ 768-d unit vector out, with no host-side pooling to implement.
31
 
32
+ Two variants ship here: an **fp32** bundle and an **int8** bundle produced by compressing that
33
+ graph in place. **Their status is not the same** β€” read [Status](#status) before choosing.
34
 
35
+ > ⚠️ **Neither bundle has produced an embedding vector on Apple silicon.** Everything below the
36
+ > Provenance table is a build-and-bytes result, not a runtime result.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  ## Contents
39
 
40
  | Path | Bytes | Weights | Sequence length |
41
  |---|---:|---|---|
42
+ | `model/` β€” `embeddinggemma-300m_float32_static.aimodel` + `reference.json` + `tokenizer/` | 1,277,545,730 | fp32 | 256 |
43
+ | `int8/` β€” `embeddinggemma-300m_int8_static.aimodel` + `reference.json` + `tokenizer/` | 356,639,960 | int8 (graph-compressed) | 256 |
44
 
45
  | File | fp32 (`model/`) | int8 (`int8/`) |
46
  |---|---:|---:|
 
52
  | `tokenizer/tokenizer_config.json` | 705 | 705 |
53
 
54
  `reference.json` and `tokenizer/` in `int8/` are byte-identical copies of the fp32 bundle's,
55
+ carried so the folder is self-contained. `reference.json` is the exporter's torch oracle: four
56
+ reference texts and their pairwise cosines, for checking the *source* pipeline end to end.
57
+
58
+ ## Provenance
59
+
60
+ | | |
61
+ |---|---|
62
+ | Base checkpoint | `google/embeddinggemma-300m` |
63
+ | Recipe (fp32) | `coreai-model-zoo/conversion/export_embeddinggemma.py --dtype float32 --seq-len 256` |
64
+ | Recipe index | `models/qwen3-embedding/recipe.toml` β†’ `["embeddinggemma-300m"]`, `status = "verified"` |
65
+ | Upstream reference bundle | [`mlboydaisuke/embeddinggemma-300m-CoreAI`](https://huggingface.co/mlboydaisuke/embeddinggemma-300m-CoreAI) @ `d9a60a18d384484a8dab809b3070b82fb41458ce` |
66
+ | Producer fingerprint | `coreai-core 1.0.0b2` on both inner asset `metadata.json` files |
67
+ | Asset creation dates | `20260817T201458Z` (fp32), `20260817T212021Z` (int8) |
68
+ | Toolchain | `coreai-torch 0.4.1`, `coreai-core 1.0.0b2`, `coreai-opt 0.2.1`, `torch 2.9.0` |
69
+ | Asset metadata | `author: "Google DeepMind"`, `license: "Gemma"` (fp32 bundle) |
70
+
71
+ These are an **independent export from the zoo's verified recipe**, at the same layout as the
72
+ zoo's own bundle β€” not a byte mirror of it. Rebuilt from the same recipe, `main.mlirb` differed
73
+ from the published upstream bundle by **+262 bytes**, and two runs on the same host with an
74
+ identical command differed from each other by **+32 bytes**. The tokenizer half is identical in
75
+ every comparison.
76
+
77
+ **The `int8/` bundle is not a second export.** It is the fp32 bundle put through
78
+ `coreai_opt.coreai_utils.quantize_weights(dtype=DType.INT8)` β€” the Core AI *graph* compression
79
+ path, which rewrites an existing program's weight constants in place. There was no PyTorch
80
+ round-trip and no re-trace: the graph, the input signature and the tokenizer are the fp32
81
+ bundle's, unchanged.
82
 
83
  ## Requirements
84
 
85
  - **Apple silicon Mac**, Core AI runtime, macOS 27+.
86
+ - **Static input signature:** `input_ids [1, 256] int32`, `attention_mask [1, 256] int32` β†’
87
+ `embedding [1, 768]` fp32, L2-normalised. **Sequence length 256 is baked into the graph** β€”
88
+ pad or truncate to it; there is no dynamic-length variant.
89
+ - Weights β‰ˆ 1.24 GB resident (fp32) or β‰ˆ 0.32 GB (int8). **No KV cache** β€” this is an encoder,
90
+ so there is no per-token memory growth and no context ladder, and none of the residency
91
+ cautions that apply to the generative bundles in this org apply here.
92
+ - **Minimum practical machine memory: 8 GB.**
93
 
94
+ Note the sequence-length difference from the Core ML artifact in this org
95
+ ([`visible-cx/embeddinggemma-300m-CoreML`](https://huggingface.co/visible-cx/embeddinggemma-300m-CoreML)),
96
+ which is **seq 128**. The two are not drop-in substitutes for each other.
97
 
98
+ ## Measurements
99
 
100
+ **None, from either bundle.** No embedding vector has been computed from either artifact on
101
+ Apple silicon: no throughput, no latency, no ANE-residency figure, no cross-runtime vector
102
+ parity. `export_embeddinggemma.py` exposes only `--dtype`, `--seq-len`, `--output-dir`,
103
+ `--overwrite`; there is no compute-unit flag to report either.
104
 
105
+ What *is* verified is the source pipeline, not the exported graph's execution:
106
 
107
+ - **Torch oracle agrees to ~6e-8.** `reference.json`'s pairwise cosines from an independent
108
+ rebuild match the published values to roughly seven decimal places (largest deviation ~6e-8).
109
+ That is CPU float nondeterminism across machines, not a different model. It validates
110
+ **checkpoint β†’ prompts β†’ pooling β†’ dense β†’ L2**, and explicitly does **not** validate the
111
+ exported graph.
112
+ - **The exporter's pre-export gate passed** β€” the wrapper against
113
+ `sentence_transformers.encode`, cosine > 0.999.
114
 
115
+ **The int8 caveat is not boilerplate.** fp16 embeddinggemma is already a known failure at vector
116
+ precision, because a full `.to(float16)` overflows Gemma 3 activations and emits NaN embeddings.
117
+ A 4Γ— compression passing parity is a hypothesis, not an expectation, and the gate it needs is
118
+ **cross-runtime vector parity against the fp32 bundle on Apple silicon β€” cosine similarity per
119
+ vector *and* retrieval-rank agreement on a fixed corpus**, not a spot-check of output shapes.
120
 
121
+ ## Usage
122
 
123
+ Swift Package Manager, via [CoreAIKit](https://github.com/john-rocky/coreai-kit) β€” a community
124
+ package, not affiliated with Apple, requiring macOS 27 beta:
125
+
126
+ ```swift
127
+ .package(url: "https://github.com/john-rocky/coreai-kit", branch: "main")
128
+ // target dependency: .product(name: "CoreAIKitEmbeddings", package: "coreai-kit")
129
+ ```
130
+
131
+ `TextEmbedder` takes a bundle directory holding one `*.aimodel` plus a `tokenizer/` folder, and
132
+ applies EmbeddingGemma's own query/document prompt prefixes:
133
+
134
+ ```swift
135
+ import CoreAIKitEmbeddings
136
+
137
+ let url = try await ModelStore.default.download(
138
+ ModelID("visible-cx/embeddinggemma-300m-CoreAI", path: "model"))
139
+
140
+ let embedder = try await TextEmbedder(bundleAt: url, prompts: .embeddingGemma)
141
+
142
+ let q = try await embedder.embed(query: "how do I cancel my order")
143
+ let d = try await embedder.embed(document: "Orders can be cancelled within 24 hours…")
144
+ // both are L2-normalised [Float] of embedder.dimension (768); cosine == dot product
145
+ ```
146
+
147
+ Two things to hold onto:
148
+
149
+ - **Use the matching prompts.** `.embeddingGemma` supplies the query and document prefixes this
150
+ checkpoint was trained with. Embedding a query with the document prefix quietly degrades
151
+ retrieval; `embed(text:)` applies no prefix at all and is for when you want that.
152
+ - **Both sides of a comparison must come from the same artifact.** Vectors from this bundle and
153
+ vectors from the Core ML sibling are not interchangeable β€” different sequence length,
154
+ different runtime, and no measured parity between them.
155
+
156
+ `embedder.sequenceLength` reads 256 off the graph; text longer than that is truncated.
157
+
158
+ ## Integrity
159
+
160
+ Core AI `.aimodel` bundles are **not byte-reproducible** β€” the exporter is not deterministic
161
+ even against itself (see Provenance), so integrity here rests on **per-file SHA-256 of the exact
162
+ published bytes**, not on a rebuild. Every bundle carries `main.hash`, the raw 32 bytes of
163
+ `sha256(main.mlirb)`; on the Hub the same value is recoverable from the LFS oid without fetching
164
+ the file.
165
+
166
+ The sibling [`visible-cx/embeddinggemma-300m-CoreML`](https://huggingface.co/visible-cx/embeddinggemma-300m-CoreML)
167
+ repo **is** bit-reproducible for its weights β€” a different supply-chain argument for the same
168
+ model, and the exception in this org.
169
+
170
+ ## Status
171
+
172
+ | Artifact | Status |
173
+ |---|---|
174
+ | `model/` (fp32, seq 256) | **UNQUALIFIED β€” built and fingerprinted, runtime-unverified.** The recipe is the zoo's `status = "verified"` entry, the producer fingerprint passes, and the exporter's pre-export gate passed. No vector has been computed from the *exported graph* on Apple silicon. |
175
+ | `int8/` (graph-compressed) | **EXPERIMENTAL.** Gate: cross-runtime vector parity against the fp32 bundle on Apple silicon β€” cosine per vector *and* retrieval-rank agreement on a fixed corpus. Do not use for production embeddings until that passes. |
176
 
177
  ## License
178
 
179
+ EmbeddingGemma is Gemma-family and the upstream checkpoint is **gated** on Hugging Face. These
180
+ bundles are a derivative of `google/embeddinggemma-300m`, and use is subject to the
181
  [Gemma Terms of Use](https://ai.google.dev/gemma/terms) and the
182
  [Gemma Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy). The fp32
183
+ bundle's own asset metadata carries `license: "Gemma"` and `author: "Google DeepMind"`. Those
184
+ terms travel with the artifact and with any redistribution of it; the contribution here is the
185
+ conversion, not the weights.