Text Ranking
Transformers.js
ONNX
sentence-transformers
multilingual
xlm-roberta
text-classification
cross-encoder
reranker
text-embeddings-inference
Instructions to use mogolloni/bge-reranker-v2-m3-onnx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use mogolloni/bge-reranker-v2-m3-onnx with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-ranking', 'mogolloni/bge-reranker-v2-m3-onnx'); - sentence-transformers
How to use mogolloni/bge-reranker-v2-m3-onnx with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("mogolloni/bge-reranker-v2-m3-onnx") query = "Which planet is known as the Red Planet?" passages = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." ] scores = model.predict([(query, passage) for passage in passages]) print(scores) - Notebooks
- Google Colab
- Kaggle
bge-reranker-v2-m3 (ONNX)
BAAI/bge-reranker-v2-m3 converted to ONNX for use with Transformers.js.
This is a multilingual cross-encoder reranker that scores query-passage relevance. It takes a query and a passage as input and outputs a relevance score (raw logit).
Conversion
Exported with Optimum:
optimum-cli export onnx --model BAAI/bge-reranker-v2-m3 bge-reranker-v2-m3-onnx/
- Format: fp32 (CPU-compatible)
- Size: ~2.2GB
Usage (Transformers.js)
import { AutoModelForSequenceClassification, AutoTokenizer } from '@huggingface/transformers';
const modelId = 'mogolloni/bge-reranker-v2-m3-onnx';
const tokenizer = await AutoTokenizer.from_pretrained(modelId);
const model = await AutoModelForSequenceClassification.from_pretrained(modelId);
const query = 'What is the capital of France?';
const passages = [
'Paris is the capital and most populous city of France.',
'Berlin is the capital of Germany.',
'The Eiffel Tower is located in Paris.',
];
const inputs = tokenizer(
passages.map(() => query),
{ text_pair: passages, padding: true, truncation: true }
);
const { logits } = await model(inputs);
const scores = Array.from(logits.data);
// Pair passages with scores and sort by relevance
const ranked = passages
.map((p, i) => [p, scores[i]])
.sort((a, b) => b[1] - a[1]);
console.log(ranked);
// [
// ['Paris is the capital and most populous city of France.', 7.35],
// ['The Eiffel Tower is located in Paris.', -1.32],
// ['Berlin is the capital of Germany.', -5.46],
// ]
Scores
Scores are raw logits (not normalized to 0-1), matching the behavior of the original PyTorch model via sentence-transformers. Higher scores indicate greater relevance.
- Downloads last month
- 96
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support
Model tree for mogolloni/bge-reranker-v2-m3-onnx
Base model
BAAI/bge-reranker-v2-m3