embeddinggemma-2 / README.md
gsmlg's picture
Mirror EmbeddingGemma 2 text-embedding ONNX models and tokenizer
604b4b8 verified
|
Raw History Blame Contribute Delete
3.73 kB
---
license: apache-2.0
pipeline_tag: feature-extraction
library_name: onnx
base_model:
- google/embeddinggemma-2
tags:
- embedding
- feature-extraction
- sentence-similarity
- onnx
- text-embeddings-inference
language:
- multilingual
---
# EmbeddingGemma 2 — text embedding ONNX mirror
Text-embedding subset of [EmbeddingGemma 2](https://huggingface.co/google/embeddinggemma-2)
by Google DeepMind, mirrored for on-device use with
[`lib_onnx`](https://pub.dev/packages/lib_onnx) (ONNX Runtime for Dart/Flutter).
Files are unmodified copies of:
| Files | Source | Revision |
|---|---|---|
| `onnx/model*.onnx`, `onnx/model*.onnx_data`, `config.json`, `config_sentence_transformers.json`, `tokenizer.json`, `tokenizer_config.json` | [onnx-community/embeddinggemma-2-ONNX](https://huggingface.co/onnx-community/embeddinggemma-2-ONNX) | `daa72c51243991dfcaf9f9137d2c573d8f7790c0` |
| `tokenizer.model` (SentencePiece) | [google/embeddinggemma-2](https://huggingface.co/google/embeddinggemma-2) | `f9972ac22e696a105c482202646979e33e4b5a1e` |
The vision and audio encoders are not mirrored. License: Apache 2.0, as published
by the upstream repositories ([Gemma license](https://ai.google.dev/gemma/docs/gemma_4_license)).
## Model contract
| Input | Type | Shape | Text-only value |
|---|---|---|---|
| `input_ids` | int64 | `[batch, sequence]` | Gemma tokenizer ids |
| `attention_mask` | int64 | `[batch, sequence]` | 1 for tokens, 0 for padding |
| `image_features` | float32 | `[num_image_tokens, 512]` | empty `[0, 512]` |
| `video_features` | float32 | `[num_video_tokens, 512]` | empty `[0, 512]` |
| `audio_features` | float32 | `[num_audio_tokens, 512]` | empty `[0, 512]` |
| Output | Shape | Meaning |
|---|---|---|
| `sentence_embedding` | `[batch, 768]` | pooled, projected embedding (L2-normalize before cosine/dot) |
| `last_hidden_state` | `[batch, sequence, 768]` | per-token states |
Matryoshka truncation to 512, 256 or 128 dimensions is supported: keep the
leading dimensions and re-normalize.
Prefix text inputs with a task instruction:
- query: `task: search result | query: {text}`
- document: `title: {title or none} | text: {text}`
- symmetric tasks: `task: sentence similarity | query: {text}` (also `classification`, `clustering`)
## Variants
| File | Precision | Size (data) |
|---|---|---|
| `onnx/model_q4f16.onnx` | 4-bit weights, fp16 | 157 MB |
| `onnx/model_q4.onnx` | 4-bit weights | 174 MB |
| `onnx/model_quantized.onnx` | int8 | 314 MB |
| `onnx/model_fp16.onnx` | fp16 | 542 MB |
| `onnx/model.onnx` | fp32 | 1.08 GB |
Each `.onnx` graph loads its `.onnx_data` external-data file from the same directory.
## SHA-256
```
4d777ef5bdc1aa36227abdfb77c3e49e7b9c892d16e1b6bda41c393504828be4 tokenizer.json
e594c8a90eb08d8bda498ff4747977dc827ae0c3c56b5c0d41a605a22d02ef03 tokenizer.model
a49e227d7e0e5f4ee606d79879d084264366367bc6318f344ab179e35d4fd6a4 onnx/model_fp16.onnx
b9dbe09415d77c8686ba6e216a244086f4ada1608238c13f2bfaa587ba627207 onnx/model_fp16.onnx_data
f9eeba97acddf139b8ee2ddf04bc30dceafa88de93fadf74d7644e0d61a477a9 onnx/model_q4.onnx
c3975f2d1ab7a1878ae31a7d7a9b7804a827aff3800b60dfceafce21cac3df49 onnx/model_q4.onnx_data
53feeced79582d661e30adeaa9829cea90d92b1c78347e26fd123773580f71d0 onnx/model_q4f16.onnx
c39fbaa1fb4221f04beb82786a06b81999c514fd39e84fcd58ef79413c87fa56 onnx/model_q4f16.onnx_data
d06edd601f851c633a2519304cbeb8dc6170d7ceb61b436625c17fb9b6e74953 onnx/model_quantized.onnx
278a7ff1248c3618e4bd11a607fc54f7bdc7778854230f3956d3f86bd9db4f3b onnx/model_quantized.onnx_data
bc47de15f81208a5c99e5ab10f746d5e33b51ea228b7dc0bef9c133a94f1c1c3 onnx/model.onnx
9fd452bfc6916e5a92f080f8dada35598ca4512b21c65897d4c5974d5f9630a2 onnx/model.onnx_data
```