bge-reranker-v2-m3, fp32 ONNX cross-encoder (Starling build, r1)
Converted model files used by the Starlings.Models.Bert .NET package (starlinghq/starling),
profile bge-reranker-v2-m3/onnx-fp32-cpu, at Experimental status. Built from
BAAI/bge-reranker-v2-m3 at revision
953dc6f6f85a1b2dbfca4c34a2796e7dde08d41e, which ships PyTorch weights but no ONNX graph.
| Path | Contents |
|---|---|
onnx/model.onnx, onnx/model.onnx_data | the fp32 cross-encoder graph and its external weights, as the export script wrote them |
config.json, model.safetensors, sentencepiece.bpe.model, special_tokens_map.json, tokenizer.json, tokenizer_config.json | the original repository's files at the pinned revision, unchanged |
README.upstream.md | the original repository's README.md (model card) at the pinned revision, unchanged |
The original files are kept so the same directory serves both the PyTorch reference run and ONNX inference.
The .NET package pins every file by size and SHA-256 (SHA256SUMS), so a changed file is rejected.
Graph
- Inputs:
input_idsandattention_mask, int64[batch, sequence](XLM-R takes notoken_type_ids). - Output:
logits, float32[batch, 1]: the raw relevance score (identity activation, as in the model card'sAutoModelForSequenceClassificationexample and FlagEmbedding's defaultnormalize=False). Apply a sigmoid yourself for the card's 0-1 mapping. - Pairs are encoded
<s> query </s></s> document </s>with the pinnedtokenizer.json, up to 8192 tokens. - Opset 17, fp32 throughout, weights in one external data file (the graph exceeds the 2 GB protobuf limit).
Export
AutoModelForSequenceClassification (eager attention) traced with the TorchScript ONNX exporter
(torch.onnx.export(..., dynamo=False, opset_version=17, do_constant_folding=True), dynamic batch and sequence axes),
then re-saved with onnx.save_model(..., save_as_external_data=True, all_tensors_to_one_file=True, location="model.onnx_data"):
python -I model-pipeline/reference/bert/export_reranker_onnx.py \
--snapshot <BAAI/bge-reranker-v2-m3 at 953dc6f6f85a1b2dbfca4c34a2796e7dde08d41e> --out <dir>/onnx
Script: model-pipeline/reference/bert/export_reranker_onnx.py in starlinghq/starling. Tool versions: Python 3.11,
torch 2.14.1+cpu, transformers 5.18.0, onnx 1.23.2, numpy 2.4.6, Linux x86-64. The export is reproducible: two runs
gave these exact bytes (model.onnx sha256 905f6c02919c0dbed213d922e097e06aa9787088a8f5173efa1d00d722948394,
model.onnx_data sha256 61f3e7229e6c1cc5e8e3d09f7657210a9cc15247cd6944ac60303e1b900a7f9b).
Verification
ONNX Runtime 1.30.0 (CPUExecutionProvider) against the original PyTorch model (torch 2.14.1+cpu, transformers 5.18.0, fp32) on 12 query/document pairs: English, Chinese, Arabic, German, French, emoji, full-width and accented text, irregular whitespace, an empty query, and long pairs of 851 and 8192 tokens (two truncated at 8192):
| Check | Result |
|---|---|
| max |ONNX logit - PyTorch logit|, single rows | 1.24e-5 (1.19e-5 at 8192 tokens) |
| max |padded batch - single row|, ONNX, 10 rows | 0.0 |
model card pairs (what is panda? with hi / with the panda passage) | -8.1838 and 5.2650 (card, fp16: -8.1875 and 5.2617) |
The Starling onboarding pipeline repeats this comparison (PyTorch reference, Python ONNX Runtime, and the .NET implementation) under a 1e-4 score bound before the profile is admitted.
License: Apache-2.0, as the original model (see the license field of README.upstream.md). Total size 4.6 GB.