bge-reranker-v2-m3-fp16-ov

Description

OpenVINO IR export of the multilingual BGE reranker v2 M3 with fp16 weights, prepared with Optimum Intel. It is an XLMRobertaForSequenceClassification cross-encoder: each query/document pair produces one relevance logit. Higher scores indicate greater relevance. It is not an embedding model, a generative reranker, or a two-class classifier.

Use it to reorder a candidate set after first-stage retrieval. Tokenize the query and document as a pair; let the tokenizer add the XLM-R special tokens. No custom prompt or manual separator concatenation is required.

Weight compression

Floating-point weights are stored in FP16. This is not integer quantization and does not force all inference operations to execute in FP16.

Running model inference with Optimum Intel

python -m pip install "optimum-intel[openvino]==2.2.0" "transformers==4.57.6" sentencepiece
import torch
from optimum.intel import OVModelForSequenceClassification
from transformers import AutoTokenizer

model_id = "OpenVINO/bge-reranker-v2-m3-fp16-ov"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = OVModelForSequenceClassification.from_pretrained(model_id, device="CPU")

query = "What is the capital of France?"
documents = [
    "Berlin is the capital of Germany.",
    "Paris is the capital of France.",
    "A banana is a fruit.",
]
inputs = tokenizer(
    [query] * len(documents), documents,
    padding=True, truncation=True, max_length=512, return_tensors="pt",
)
logits = model(**inputs).logits.reshape(-1).float()
normalized_scores = torch.sigmoid(logits)
for index in torch.argsort(logits, descending=True).tolist():
    print(index, float(logits[index]), float(normalized_scores[index]), documents[index])

logits has shape [number_of_pairs, 1] before flattening. Sigmoid optionally maps each logit into [0, 1] and preserves ranking; it does not produce a calibrated probability. Do not apply a softmax across the single output or across unrelated documents.

Running model inference with OpenVINO GenAI

python -m pip install "openvino-genai==2026.4.1" huggingface-hub
import openvino_genai as genai
from huggingface_hub import snapshot_download

model_dir = snapshot_download(repo_id="OpenVINO/bge-reranker-v2-m3-fp16-ov")
query = "What is the capital of France?"
documents = [
    "Berlin is the capital of Germany.",
    "Paris is the capital of France.",
    "A banana is a fruit.",
]
config = genai.TextRerankPipeline.Config()
config.top_n = len(documents)
config.max_length = 512
pipeline = genai.TextRerankPipeline(model_dir, "CPU", config)

ranked = pipeline.rerank(query, documents)
for index, score in ranked:
    print(index, score, documents[index])

GenAI loads the model and tokenizer IRs, tokenizes the query/document pairs, and returns (original_document_index, relevance_score) entries in descending score order. Scores are not calibrated probabilities. For an existing local export, use its directory as model_dir instead of calling snapshot_download.

Conversion

Using convert_models.py from the accompanying conversion bundle:

python convert_models.py --model bge-reranker-v2-m3 --precision fp16

The script pins the source snapshot (including tokenizer files), explicitly selects the Transformers library and text-classification task, exports the encoder and OpenVINO tokenizer, applies the weight-compression recipe, and records package versions. It does not upload or run inference/accuracy benchmarks.

Input length

  • max_length=512 is the examples' truncation setting, not a 512-token model limit. It applies to the complete query/document pair, including special tokens, rather than separately to each string. The source model card's Transformers example also uses 512 as an example setting.
  • The pinned source configuration declares max_position_embeddings=8194 and pad_token_id=1. With XLM-R's position-ID offset, this corresponds to an 8192-token position budget, not an 8194-token input limit.

Related notebooks

Legal information

The source checkpoint is identified as Apache-2.0 in its pinned model card. Do not inherit the MIT license of older bge-reranker-base exports for this model. Refer to the original model for attribution, limitations, and citation. See also Intel's Global Human Rights Principles.

Downloads last month
11
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for OpenVINO/bge-reranker-v2-m3-fp16-ov

Finetuned
(138)
this model