yasserrmd/granite-embedding-r2-onnx
By yasserrmd · ↓ 7 · ♥ 1 · Updated 2025-08-18
What's in this repo
This page lists the files in yasserrmd/granite-embedding-r2-onnx, including model.onnx.
- 1 ONNX models (.onnx files)
- 9 files, including 6 .json, 1 .md, 1 .onnx
- Last updated 2025-08-18
ONNX files
| File | Size | Download |
|---|---|---|
| model.onnx | — | Download |
How to use
These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.
README
Granite Embedding English R2 — INT8 (ONNX)
This is the INT8-quantized ONNX version of ibm-granite/granite-embedding-english-r2.
It is optimized to run efficiently on CPU using 🤗 Optimum with ONNX Runtime.
- Embedding dimension: 768
- Precision: INT8 (dynamic quantization)
- Backend: ONNX Runtime
- Use case: text embeddings, semantic search, clustering, retrieval
📥 Installation
pip install -U transformers optimum[onnxruntime]
🚀 Usage
from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForFeatureExtraction
repo_id = "yasserrmd/granite-embedding-r2-onnx"
# Load tokenizer + ONNX model
tokenizer = AutoTokenizer.from_pretrained(repo_id)
model = ORTModelForFeatureExtraction.from_pretrained(repo_id)
# Encode sentences
inputs = tokenizer(["Hello world", "مرحباً"], padding=True, return_tensors="pt")
outputs = model(**inputs)
# Apply mean pooling over tokens
embeddings = outputs.last_hidden_state.mean(dim=1)
print(embeddings.shape) # (2, 768)
✅ Notes
- Quantization reduces model size and makes inference faster on CPUs while preserving accuracy.
- Pooling strategy here is mean pooling; you can adapt CLS pooling or max pooling as needed.
- Works seamlessly with Hugging Face Hub +
optimum.onnxruntime.
📚 References
Model info
feature-extraction
optimum.onnxruntime
optimum.onnxruntime
onnx
modernbert
int8
quantization
embeddings
cpu
feature-extraction
base_model:ibm-granite/granite-embedding-english-r2
base_model:quantized:ibm-granite/granite-embedding-english-r2
license:apache-2.0
region:us
↓ 7
♥ 1
Created: 2025-08-18
Updated: 2025-08-18
View on Hugging FaceFiles (9)
.gitattributes
README.md
config.json
model.onnx
ONNX
modules.json
sentence_bert_config.json
special_tokens_map.json
tokenizer.json
tokenizer_config.json
Related models
More from yasserrmd
No other models by this author.