embeddinggemma-300m β€” full-pipeline ONNX export

A single-graph ONNX export of the complete sentence-transformers pipeline of google/embeddinggemma-300m: Transformer β†’ Pooling β†’ Dense(768β†’3072) β†’ Dense(3072β†’768) β†’ Normalize, all in one graph. Output sentence_embedding is the final L2-normalized 768-d sentence vector β€” no external pooling or projection needed (unlike transformer-only exports, which produce different vectors).

Built for Jarvis (a self-hosted assistant) so its memory/RAG runs on onnxruntime alone β€” no torch, no sentence-transformers at runtime.

Fidelity

Exported with torch.onnx.export (opset 17) from the official weights and verified against the torch pipeline: worst-case cosine similarity = 1.000000 across batch sizes and sequence lengths (short + long, batched + single). Vectors are interchangeable with the original model β€” existing indexes need no re-embedding.

Exporter + verification harness: src/scripts/export_embed_onnx.py

Files

File SHA-256
model.onnx (graph) 39a1f3039ed66e39c5174469dc5ce0417ef57993590170164b18beb8254de2d0
model.onnx.data (fp32 weights, external data) 1d5fb11500ae836f3a42efc3c7123076416d9e527ae479d19d940a3c784f0035
tokenizer.json 3f797e7e336523ba3845bf09a648fd87c14bf357f26beb091d8284dff48ea27c
meta.json (dim, max_seq_length, pad id) b149d450b0bd383a207b3328cb9dd093082077c84eb4e178418a2db0f4f2dccf

model.onnx and model.onnx.data must sit in the same directory (ONNX external-data format).

Usage (torch-free)

import json, numpy as np, onnxruntime as ort
from tokenizers import Tokenizer

meta = json.load(open("meta.json"))
tok = Tokenizer.from_file("tokenizer.json")
tok.enable_truncation(max_length=meta["max_seq_length"])
tok.enable_padding(pad_id=meta["pad_token_id"], pad_token="<pad>")
sess = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])

# embeddinggemma is ASYMMETRIC β€” use the matching prompt prefixes:
docs = ["title: none | text: The user's name is Ravi."]
enc = tok.encode_batch(docs)
vecs = sess.run(["sentence_embedding"], {
    "input_ids": np.array([e.ids for e in enc], dtype=np.int64),
    "attention_mask": np.array([e.attention_mask for e in enc], dtype=np.int64),
})[0]   # (batch, 768), already L2-normalized

Queries use the prefix task: search result | query: .

License

Gemma. This is a format conversion of Google's model; use is subject to the Gemma Terms of Use (bundled: GEMMA_TERMS_OF_USE.md, GEMMA_PROHIBITED_USE_POLICY.md, NOTICE) β€” by using these weights you agree to those terms.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for Ravijangid820/embeddinggemma-300m-onnx

Quantized
(314)
this model