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

Quantized
(47)
this model