embeddinggemma-2-ecommerce

EmbeddingGemma 2 (270M, text-only) fine-tuned for e-commerce product search. Give it a shopper query and it ranks product listings (title, brand, bullets). 768-dim output with Matryoshka truncation (512 / 256 / 128).

📦 Downloads — all formats

Tip: click ⬇ Download next to a file — no login needed. Not sure what to pick?

  • Python + GPU/CPU → fp32 or bf16 (SentenceTransformer("smshahbaj/embeddinggemma-2-ecommerce"))
  • llama.cpp / CPU / on-device → Q8_0 (best quality) · Q5_K_M (balanced) · Q4_K_M (smallest) · F16 (unquantized)
  • Browser / Node / C# / Java → ONNX
  • Fine-tuning → fp32
Format File Size Best for Quality vs fp32 Download
fp32 (original) model.safetensors 1.08 GB Sentence-Transformers, fine-tuning, max quality reference ⬇ Download
bf16 safetensors bf16/model.safetensors 542 MB GPU inference, smaller download cos 1.0000 · ΔnDCG -0.00 ⬇ Download
GGUF F16 embeddinggemma-2-ecommerce-F16.gguf 558 MB llama.cpp, max GGUF quality cos 1.0000 · ΔnDCG -0.01 ⬇ Download
GGUF Q8_0 embeddinggemma-2-ecommerce-Q8_0.gguf 310 MB llama.cpp on CPU — near-lossless cos 0.9998 · ΔnDCG +0.13 ⬇ Download
GGUF Q5_K_M embeddinggemma-2-ecommerce-Q5_K_M.gguf 213 MB llama.cpp — balanced size/quality cos 0.9962 · ΔnDCG +0.10 ⬇ Download
GGUF Q4_K_M embeddinggemma-2-ecommerce-Q4_K_M.gguf 182 MB llama.cpp — smallest, on-device cos 0.9877 · ΔnDCG +0.06 ⬇ Download
ONNX fp32 onnx/embeddinggemma-2-ecommerce.onnx 1.09 GB onnxruntime (Python, JS, C#, Java) cos 1.0000 · ΔnDCG +0.00 ⬇ Download

Quick commands

pip install -U huggingface_hub
# one file (example)
hf download smshahbaj/embeddinggemma-2-ecommerce embeddinggemma-2-ecommerce-Q8_0.gguf --local-dir .
# bf16 folder (load with SentenceTransformer('./bf16'))
hf download smshahbaj/embeddinggemma-2-ecommerce --include "bf16/*" --local-dir .
# ONNX folder
hf download smshahbaj/embeddinggemma-2-ecommerce --include "onnx/*" --local-dir .
# everything
hf download smshahbaj/embeddinggemma-2-ecommerce --local-dir .

ONNX example

import onnxruntime as ort
from transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained("smshahbaj/embeddinggemma-2-ecommerce")
sess = ort.InferenceSession("onnx/embeddinggemma-2-ecommerce.onnx")
enc = tok(["task: search result | query: waterproof hiking boots"], padding=True, truncation=True, max_length=512, return_tensors="np")
emb = sess.run(None, {"input_ids": enc["input_ids"].astype("int64"), "attention_mask": enc["attention_mask"].astype("int64")})[0]

llama.cpp example

llama-embedding -m embeddinggemma-2-ecommerce-Q8_0.gguf --embd-normalize 2 -p "task: search result | query: waterproof hiking boots"

GGUF and ONNX files do not add prompts automatically: prefix queries with task: search result | query: and documents with title: {title} | text: {content}. Quality column = mean cosine similarity to the fp32 model and change in ESCI graded nDCG (nDCG points) on a 100-query CPU check, not the full benchmark. Formats that failed this check are not published. GGUF needs a recent llama.cpp build with EmbeddingGemma 2 support (these files were built with commit 9d1878a4).

Results (×100, higher is better)

Evaluated on a random sample of 2,000 queries from the official ESCI test split (US, Task-1 query set), with 39,891 pooled products. These are in-domain numbers: train and test come from the same Amazon-style distribution, so gains on other shops, catalogs or languages may be smaller.

Metric Base Fine-tuned Δ
ESCI graded nDCG (candidate re-ranking) 86.35 88.20 +1.85
Pooled retrieval nDCG@10 59.67 63.50 +3.83
Pooled retrieval Recall@10 54.81 57.42 +2.62
Pooled retrieval MRR@10 74.61 77.91 +3.30
  • ESCI graded nDCG: for each query, re-rank its labelled candidates; gains Exact=1.0, Substitute=0.1, Complement=0.01, Irrelevant=0 (as in the ESCI paper).
  • Pooled retrieval: each query is searched against all pooled test products; only Exact products count as relevant (other relevant-but-unlabelled products make these numbers conservative).

Matryoshka truncation (ESCI graded nDCG):

Dim Base Fine-tuned Δ
768 86.35 88.20 +1.85
512 86.28 88.17 +1.90
256 86.02 87.86 +1.84
128 85.11 87.31 +2.20

General retrieval check (nDCG@10, BEIR/MTEB test splits). Domain tuning can cost some general ability; this shows how much:

Task Base Fine-tuned Δ
SciFact 85.77 83.61 -2.16
ArguAna 47.16 44.09 -3.07

Measured with this repo's own evaluation code (Sentence Transformers, cosine similarity, query prompt task: search result | query:, documents formatted as title: {title} | text: {content}), not the official MTEB leaderboard implementation.

Usage

from sentence_transformers import SentenceTransformer

model = SentenceTransformer("smshahbaj/embeddinggemma-2-ecommerce")

queries = ["task: search result | query: waterproof hiking boots women"]
products = [
    "title: Merrell Moab 3 Waterproof Hiking Boot | text: Brand: Merrell. Waterproof leather and mesh upper, Vibram sole.",
    "title: Cotton crew socks 6-pack | text: Brand: Generic. Soft cotton blend, fits most.",
]
q = model.encode(queries)
d = model.encode(products)
print(model.similarity(q, d))
  • Queries: prefix with task: search result | query: (or prompt_name="SearchQuery").
  • Products: title: {title} | text: {brand and description/bullets}.
  • Smaller vectors: SentenceTransformer("smshahbaj/embeddinggemma-2-ecommerce", truncate_dim=256).

Training

  • Base: google/embeddinggemma-2, loaded text-only (vision and audio encoders removed, so this is a text-only model).
  • Data: 30,099 (query, product, hard negative) triplets from the English (US) part of the Amazon Shopping Queries Dataset (ESCI), Apache-2.0. Positive = Exact product; negative = Irrelevant or Complement product for the same query. Train and test queries are disjoint (official split).
  • Loss: CachedMultipleNegativesRankingLoss (GradCache) wrapped in MatryoshkaLoss (dims [768, 512, 256, 128]); token embedding table frozen.
  • Settings: 1 epoch, batch size 64, lr 1e-05, max sequence length 128, fp32 on a single Kaggle T4.

Limitations

  • English, Amazon-style product listings. Quality on other catalogs, languages or very different product categories is untested; evaluate on your own data before deploying.
  • Queries in ESCI are short and shopping-specific; the model may be worse than the base for general or scientific retrieval (see the general check above).
  • Not trained for safety filtering; do not use for ranking decisions without human oversight where harm is possible.
  • Subject to the base model's license and the Gemma Prohibited Use Policy.

Credits and citation

Base model: Google EmbeddingGemma 2. Data: Amazon Shopping Queries Dataset. Fine-tuned by SM Shahbaj.

@article{reddy2022shopping,
  title={Shopping Queries Dataset: A Large-Scale ESCI Benchmark for Improving Product Search},
  author={Chandan K. Reddy and Lluís Màrquez and Fran Valero and Nikhil Rao and Hugo Zaragoza and Sambaran Bandyopadhyay and Arnab Biswas and Anlu Xing and Karthik Subbian},
  year={2022},
  eprint={2206.06588},
  archivePrefix={arXiv}
}
Downloads last month
189
Safetensors
Model size
0.3B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for smshahbaj/embeddinggemma-2-ecommerce

Quantized
(115)
this model

Dataset used to train smshahbaj/embeddinggemma-2-ecommerce

Paper for smshahbaj/embeddinggemma-2-ecommerce