Downloads · 30 days
6
3% of all-time downloads
sampoorna42/bge-reranker-base-onnx
bge-reranker-base-onnx is a machine learning model from sampoorna42. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for sentence-transformers. The card lists the license as mit.
ONNX export of BAAI/bge-reranker-base, converted using Hugging Face Optimum for faster CPU inference with ONNX Runtime. Drop-in replacement for the original PyTorch model with no code changes beyond the model loader.
Downloads · 30 days
6
3% of all-time downloads
All-time downloads
174
Public
Repo size
1.1 GB
Likes
0
Public
Click a slice to open those files.
.onnx1.1 GB · 98%
From the Hugging Face model README
ONNX export of BAAI/bge-reranker-base, converted using Hugging Face Optimum for faster CPU inference with ONNX Runtime. Drop-in replacement for the original PyTorch model with no code changes beyond the model loader.
The original PyTorch model typically takes 4–5 seconds per batch on CPU. This ONNX export runs ~2x faster with identical ranking quality — verified across multiple query/passage sets with zero ranking order degradation.
from optimum.onnxruntime import ORTModelForSequenceClassification
from transformers import AutoTokenizer
import torch
model = ORTModelForSequenceClassification.from_pretrained("sampoorna42/bge-reranker-base-onnx")
tokenizer = AutoTokenizer.from_pretrained("sampoorna42/bge-reranker-base-onnx")
query = "What causes climate change?"
passage = "Climate change is primarily driven by greenhouse gas emissions from human activities."
inputs = tokenizer(query, passage, return_tensors="pt", truncation=True, max_length=512)
with torch.no_grad():
score = float(model(**inputs).logits[0][0])
print(f"Relevance score: {score:.4f}")
from huggingface_hub import snapshot_download
snapshot_download(
repo_id="your-username/bge-reranker-base-onnx",
local_dir="./onnx_reranker"
)
No authentication needed — public repo.
| Property | Value |
|---|---|
| Base model | BAAI/bge-reranker-base |
| Conversion tool | Hugging Face Optimum 2.1.0 |
| Format | ONNX (FP32) |
| Max sequence length | 512 |
| Task | Text pair classification / passage reranking |
| License | MIT |
Tested on Intel CPU, no GPU, 3 independent query sets with 5–6 passages each:
| Metric | PyTorch | ONNX |
|---|---|---|
| Total latency (3 samples) | 1.88s | 1.00s |
| Average speedup | — | ~1.9x |
| Ranking order match | — | 100% ✅ |
Scores differ slightly in absolute value (FP32 precision) but relative ranking is always preserved.
MIT — same as the original BAAI/bge-reranker-base.