Views
No views yet
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/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.SearchOptions.rerank.cross-encoder/ms-marco-MiniLM-L-6-v2 onnx/model.onnx (91 011 230 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)1// build.rs
2use burn_onnx::{ModelGen, LoadStrategy};
3
4fn main() {
5 ModelGen::new()
6 .input("onnx/model.onnx") // from cross-encoder/ms-marco-MiniLM-L-6-v2
7 .out_dir("model/")
8 .load_strategy(LoadStrategy::Bytes)
9 .run_from_script();
10}burn::nn::LinearLayout::Col for the pooler and classifier
(the head was exported Gemm-style), which exists from burn 0.22.0-pre.2 — generated
code and runtime must match versions.sha256 f2c416115ca43604b18a4e7da3c0651ea0cdb10994f1e6a60f19185304d9acd6
size 90883844 bytes (86.7 MiB)1pub fn forward(
2 &self,
3 input_ids: Tensor<2, Int>,
4 attention_mask: Tensor<2, Int>,
5 token_type_ids: Tensor<2, Int>,
6) -> Tensor<2> // logits [B, 1]BertForSequenceClassification: CLS token → pooler
(Linear(384→384) + tanh) → classifier 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.tokenizer.json (BERT uncased
WordPiece, [PAD] = 0, [CLS] = 101, [SEP] = 102, max 512 positions). Inputs are
pairs (query, passage) encoded as one sequence
[CLS] query [SEP] passage [SEP] with token_type_ids 0 for the query segment and 1 for
the passage — the upstream tokenizer produces them for a pair.candle implementation (candle-transformers BertModelbert.pooler.dense (tanh) and classifier weights loaded from
model.safetensors, CPU) on five (query, passage) pairs, including the model card's
Berlin example:pair burn (wgpu) candle (CPU) |Δ|
------------------------------------------------------------------------------------
berlin population / "3.5 million inhabitants" 8.648815 8.648816 9.5e-07
berlin population / "Metropolitan Museum of Art" -11.352621 -11.352626 4.8e-06
berlin population / "Berlin Wall fell in 1989" -9.009550 -9.009547 2.9e-06
rust borrow checker / matching passage 4.504333 4.504328 5.3e-06
rust borrow checker / cake recipe -11.164450 -11.164444 5.7e-061@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 year = "2019",
6 url = "https://arxiv.org/abs/1908.10084"
7}
8
9@article{wang2020minilm,
10 title={MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformers},
11 author={Wang, Wenhui and Wei, Furu and Dong, Li and Bao, Hangbo and Yang, Nan and Zhou, Ming},
12 journal={arXiv preprint arXiv:2002.10957},
13 year={2020}
14}