CoolFace
Modelpublic

Lucie666/mmarco-mminilmv2-l12-h384-v1-burnpack

sourceHugging Faceapache-2.0updated 1mo agoView on Hugging Face
0likes
Model Card

mmarco-mminilmv2-l12-h384-v1-burnpack

Original model: https://huggingface.co/cross-encoder/mmarco-mMiniLMv2-L12-H384-v1 Original authors: Nils Reimers and the sentence-transformers team, trained on mMARCO (MS MARCO machine-translated into 14 languages, Bonifacio et al.), from the distilled base nreimers/mMiniLMv2-L12-H384-distilled-from-XLMR-Large (MiniLMv2, Wang et al., 2020) Converted by: Lucie666, using burn-onnx — format only


This is not an original model, and no part of it is my work. It is a mechanical format conversion of cross-encoder/mmarco-mMiniLMv2-L12-H384-v1 — nothing was trained, fine-tuned, distilled, quantised or modified. No new weights were produced. All credit belongs to the authors above.

If you are looking for the model itself, go to cross-encoder/mmarco-mMiniLMv2-L12-H384-v1. This repository only exists so people running Burn don't each redo the conversion.

Note on metadata: Hugging Face's base_model_relation field only accepts adapter, merge, quantized or finetune. 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.

The file model.bpk holds the same weights as the upstream onnx/model.onnx, 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.

Why this exists

A cross-encoder scores a (query, passage) pair directly and is the standard way to re-rank the top candidates of a retrieval stage. This one is the multilingual member of the MS MARCO cross-encoder family: 12 layers of width 384 — the 470 MB are almost entirely the 250 002-entry SentencePiece embedding, the transformer itself is tiny. It is the default multilingual reranker of rag3weaver (SearchOptions.rerank), between the English-only ms-marco-MiniLM-L-6-v2 (90 MB) and bge-reranker-v2-m3 (2.2 GB).

Provenance

cross-encoder/mmarco-mMiniLMv2-L12-H384-v1   onnx/model.onnx   (PyTorch 2.6 export, 470 883 696 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)

Nothing in this pipeline is hand-written.

A caveat before you regenerate. Burnpack serialisation is not byte-deterministic: two builds from the same ONNX produce files of identical size but different bytes. The tensor values are unaffected. The checksum below verifies this download, not a reproduction.

Reproducing it

rust
// build.rs
use burn_onnx::{ModelGen, LoadStrategy};

fn main() {
    ModelGen::new()
        .input("onnx/model.onnx")       // from cross-encoder/mmarco-mMiniLMv2-L12-H384-v1
        .out_dir("model/")
        .load_strategy(LoadStrategy::Bytes)
        .run_from_script();
}

The generated graph uses burn::nn::LinearLayout::Col for the classification head (exported Gemm-style), which exists from burn 0.22.0-pre.2 — generated code and runtime must match versions. The XLM-R position ids (cumulative sum over the attention mask, offset by the padding id) are computed inside the graph.

Verifying the download

sha256  10e7d173623ea0bc15facd580e02cb0520d68326047b44aec1fb8490887c1c8e
size    470617604 bytes  (448.8 MiB)

Model interface

rust
pub fn forward(
    &self,
    input_ids: Tensor<2, Int>,
    attention_mask: Tensor<2, Int>,
) -> Tensor<2>    // logits [B, 1]

The graph is the full XLMRobertaForSequenceClassification: <s> token → dense (Linear(384→384) + tanh) → out_proj Linear(384→1). The output is the raw logit (the upstream default activation is the identity): higher means more relevant; apply a sigmoid yourself if you want a probability. Only the order is meaningful.

Tokenisation is not included: use the upstream tokenizer.json (SentencePiece Unigram, 250 002 entries; <s> = 0, <pad> = 1, </s> = 2; 512 usable positions). There are no `token_type_ids` — a (query, passage) pair is one sequence <s> query </s></s> passage </s>, and padding uses id 1, not 0. The upstream tokenizer.json carries no truncation or padding preset: set them yourself.

Numerical parity

Checked against a reference 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                10.498397       10.498405     7.6e-06
EN berlin population / Metropolitan Museum of Art             -9.185736       -9.185722     1.3e-05
EN berlin population / Berlin Wall fell in 1989               -7.658092       -7.658096     4.3e-06
FR combien … berlin / 3,5 millions d'habitants                 9.889890        9.889894     3.8e-06
FR combien … berlin / Metropolitan Museum of Art              -8.640562       -8.640553     8.6e-06
FR combien … berlin / mur de Berlin tombé en 1989             -6.565522       -6.565524     2.4e-06
FR query / EN "3.5 million inhabitants" passage               10.194462       10.194460     1.9e-06

max |Δ| = 1.3e-5 on raw logits, rankings identical in both languages and across languages. The residual is f32 accumulation noise from a different operation order.

Runtime backend for this check: Burn + wgpu/Vulkan on an AMD Radeon AI PRO R9700 (Navi 48, RDNA4, gfx1201) via RADV.

License

Apache-2.0, inherited from cross-encoder/mmarco-mMiniLMv2-L12-H384-v1. All credit for the model belongs to its authors:

bibtex
@inproceedings{reimers-2019-sentence-bert,
  title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
  author = "Reimers, Nils and Gurevych, Iryna",
  booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
  year = "2019",
  url = "https://arxiv.org/abs/1908.10084"
}

@article{bonifacio2021mmarco,
  title={mMARCO: A Multilingual Version of the MS MARCO Passage Ranking Dataset},
  author={Bonifacio, Luiz and Jeronymo, Vitor and Abonizio, Hugo Queiroz and Campiotti, Israel and Fadaee, Marzieh and Lotufo, Roberto and Nogueira, Rodrigo},
  journal={arXiv preprint arXiv:2108.13897},
  year={2021}
}

@article{wang2020minilmv2,
  title={MiniLMv2: Multi-Head Self-Attention Relation Distillation for Compressing Pretrained Transformers},
  author={Wang, Wenhui and Bao, Hangbo and Huang, Shaohan and Dong, Li and Wei, Furu},
  journal={arXiv preprint arXiv:2012.15828},
  year={2020}
}