megatron-bert-base-swedish-cased-600k - ONNX
ONNX export of KBLab/megatron-bert-base-swedish-cased-600k.
This package contains two task-specific exports:
fill-mask/onnx/model.onnxfor masked language modeling logitsfeature-extraction/onnx/model.onnxforlast_hidden_stateandcls_embedding
Available variants
Each task folder contains:
model.onnx- FP32 baselinemodel_fp16.onnx- FP16, recommendedmodel_int8.onnx- dynamic INT8model_uint8.onnx- dynamic UINT8model_q4.onnx- 4-bit MatMul quantization
File sizes
Fill-mask
model.onnx: 738.6 MBmodel_fp16.onnx: 369.4 MBmodel_int8.onnx: 185.6 MBmodel_uint8.onnx: 185.6 MBmodel_q4.onnx: 283.8 MB
Feature-extraction
model.onnx: 539.0 MBmodel_fp16.onnx: 269.6 MBmodel_int8.onnx: 135.4 MBmodel_uint8.onnx: 135.4 MBmodel_q4.onnx: 252.4 MB
Accuracy summary
FP32 parity vs PyTorch
- Fill-mask max logit diff:
0.000069 - Fill-mask top-5 tokens: exact match
- Feature
last_hidden_statemax diff:0.000006 - Feature
cls_embeddingcosine similarity:1.0
Quantized variants vs FP32 ONNX
Fill-mask
fp16: top-5 exact match, max diff0.0131int8: top-5 drift after rank 2uint8: top-5 drift after rank 2q4: top-5 drift after rank 2
Feature-extraction
fp16: CLS cosine0.9999997q4: CLS cosine0.7404int8: CLS cosine0.9731uint8: CLS cosine0.9717
Recommendation
- Use
model_fp16.onnxby default. - For feature extraction, prefer
fp16;int8/uint8preserve embeddings better thanq4on this model. - Avoid
int8anduint8for fill-mask if token ranking fidelity matters.
Layout
megatron-bert-base-swedish-cased-600k/
βββ fill-mask/
β βββ config.json
β βββ tokenizer.json
β βββ tokenizer_config.json
β βββ special_tokens_map.json
β βββ onnx/
β βββ model.onnx
β βββ model_fp16.onnx
β βββ model_int8.onnx
β βββ model_uint8.onnx
β βββ model_q4.onnx
βββ feature-extraction/
βββ config.json
βββ tokenizer.json
βββ tokenizer_config.json
βββ special_tokens_map.json
βββ onnx/
βββ model.onnx
βββ model_fp16.onnx
βββ model_int8.onnx
βββ model_uint8.onnx
βββ model_q4.onnx
Export notes
- Native
optimum 2.1.0task export does not supportmegatron-bert. - These graphs were exported with direct
torch.onnx.exportwrappers using legacy TorchScript exporter (dynamo=False). - Feature extraction export uses
cls_embedding = last_hidden_state[:, 0, :]. - No pooler output included, because loading
MegatronBertModelfrom this MLM checkpoint would introduce randomly initialized pooler weights.
Model tree for FredrikKarlssonSpeech/megatron-bert-base-swedish-cased-600k-onnx
Base model
KBLab/megatron-bert-base-swedish-cased-600k