Views
No views yet
BAAI/bge-m3 backbone (XLM-RoBERTa large)
ONNX export used: https://huggingface.co/onnx-community/bge-reranker-v2-m3-ONNX
(fp32 onnx/model.onnx + onnx/model.onnx_data, produced by the
onnx-community/convert-to-onnx space — the BAAI repository ships no ONNX)
Converted by: Lucie666, using burn-onnx — format onlyNote on metadata: Hugging Face'sbase_model_relationfield only acceptsadapter,merge,quantizedorfinetune. None describes a pure format conversion, so the field is deliberately left unset rather than filled with an inaccurate value — these weights are not quantised, they are the original f32 values.
model.bpk holds the same weights as the upstream ONNX export, re-serialised
into Burn's burnpack format so they can be loaded by a pure-Rust inference stack — no
Python, no PyTorch, no ONNX Runtime at inference time.bge-reranker-v2-m3 is the strongest openly licensed multilingual cross-encoder of its
generation (about 100 languages, long inputs). At 2.2 GB and 24 layers it is a server
model; in rag3weaver it is the
quality-first reranker behind SearchOptions.rerank, next to the 470 MB
mmarco-mMiniLMv2-L12-H384-v1 (multilingual default) and the 90 MB
ms-marco-MiniLM-L-6-v2 (English, browser).BAAI/bge-reranker-v2-m3 model.safetensors
│
│ onnx-community/convert-to-onnx (PyTorch 2.8 export → onnx/model.onnx + model.onnx_data, 2 271 088 656 bytes)
▼
│ burn-onnx 0.22.0-pre.1 (mechanical ONNX → Burn conversion, LoadStrategy::Bytes)
▼
model.bpk weights, burnpack format
model.rs model graph, generated Rust source (not distributed here)config.json and tokenizer.json used at
conversion and at runtime are the ones from the BAAI repository (the onnx-community copy
only differs by _name_or_path and the transformers version).1// build.rs
2use burn_onnx::{ModelGen, LoadStrategy};
3
4fn main() {
5 ModelGen::new()
6 .input("onnx/model.onnx") // model.onnx_data must sit next to it
7 .out_dir("model/")
8 .load_strategy(LoadStrategy::Bytes)
9 .run_from_script();
10}burn-onnx
≥ 0.22.0-pre.1 reads them without any setting (0.21 panics). The generated graph uses
burn::nn::LinearLayout::Col for the classification head, which exists from
burn 0.22.0-pre.2 — generated code and runtime must match versions. Conversion took
28 s wall and 2.4 GB of RAM; loading the model for inference takes about 6.7 GB.sha256 3ed858274ab4661332058318c8b961f0ac822af4aed899187557745107fb32e3
size 2271128324 bytes (2.12 GiB)1pub fn forward(
2 &self,
3 input_ids: Tensor<2, Int>,
4 attention_mask: Tensor<2, Int>,
5) -> Tensor<2> // logits [B, 1]XLMRobertaForSequenceClassification: <s> token → dense
(Linear(1024→1024) + tanh) → out_proj Linear(1024→1). The output is the raw
logit: higher means more relevant; apply a sigmoid yourself if you want a probability.
Only the order is meaningful.tokenizer.json from
BAAI/bge-reranker-v2-m3 (SentencePiece Unigram, 250 002 entries; <s> = 0,
<pad> = 1, </s> = 2). It shares its vocabulary with bge-m3 but not its
normalizer (a trailing-whitespace strip), so do not substitute one for the other. There
are no token_type_ids: a (query, passage) pair is one sequence
<s> query </s></s> passage </s>, padded with id 1. The model accepts up to 8192
positions; rerankers are normally run at 512.candle implementation (XLM-RoBERTa backbone from
candle-transformers + the upstream classification head — classifier.dense
(tanh) and classifier.out_proj — loaded from model.safetensors, CPU) on seven
(query, passage) pairs: the Berlin example of the MS MARCO model card in English, the
same triple in French, and a cross-language pair (French query, English passage):pair burn (wgpu) candle (CPU) |Δ|
------------------------------------------------------------------------------------------------
EN berlin population / 3.5 million inhabitants 6.798565 6.798559 5.7e-06
EN berlin population / Metropolitan Museum of Art -11.028526 -11.028533 6.7e-06
EN berlin population / Berlin Wall fell in 1989 -9.748907 -9.748901 5.7e-06
FR combien … berlin / 3,5 millions d'habitants 6.165921 6.165920 4.8e-07
FR combien … berlin / Metropolitan Museum of Art -11.032015 -11.032012 2.9e-06
FR combien … berlin / mur de Berlin tombé en 1989 -10.509789 -10.509794 5.7e-06
FR query / EN "3.5 million inhabitants" passage 5.617373 5.617373 9.5e-071@misc{li2023making,
2 title={Making Large Language Models A Better Foundation For Dense Retrieval},
3 author={Chaofan Li and Zheng Liu and Shitao Xiao and Yingxia Shao},
4 year={2023},
5 eprint={2312.15503},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}
9
10@misc{chen2024bge,
11 title={BGE M3-Embedding: Multi-Lingual, Multi-Functionality, Multi-Granularity Text Embeddings Through Self-Knowledge Distillation},
12 author={Jianlv Chen and Shitao Xiao and Peitian Zhang and Kun Luo and Defu Lian and Zheng Liu},
13 year={2024},
14 eprint={2402.03216},
15 archivePrefix={arXiv},
16 primaryClass={cs.CL}
17}