Views
No views yet
MatMulBnb4 (bitsandbytes INT4) operators from the com.microsoft domain. These are not supported by most execution providers (CoreML, TensorRT, etc.) and limit the model to CPU-only inference in practice.MatMul in float16, enabling hardware-accelerated inference across all major platforms.| Original (INT4) | This export (FP16) | |
|---|---|---|
| Precision | 4-bit (bitsandbytes) | float16 |
| Weight size | 533 MB | 1.1 GB |
| ONNX ops | com.microsoft.MatMulBnb4 | Standard MatMul only |
| CoreML EP | Not supported | Supported |
| CUDA EP | Limited | Supported |
| Batch perf | Baseline | ~11-19x faster |
| Single perf | Baseline | ~1.2-1.4x faster |
model.fp16.onnx — ONNX graph (5.3 MB)model.fp16.onnx.data — External weights (1.1 GB)tokenizer.json — HuggingFace BPE tokenizer (11 MB)1import onnxruntime as ort
2from tokenizers import Tokenizer
3import numpy as np
4
5tokenizer = Tokenizer.from_file("tokenizer.json")
6session = ort.InferenceSession("model.fp16.onnx")
7
8encoding = tokenizer.encode("hello world", add_special_tokens=True)
9input_ids = np.array([encoding.ids], dtype=np.int64)
10attention_mask = np.array([encoding.attention_mask], dtype=np.int64)
11
12embeddings = session.run(None, {
13 "input_ids": input_ids,
14 "attention_mask": attention_mask,
15})[0]
16
17print(f"Shape: {embeddings.shape}") # (1, 1024)1use int4_runner::EmbeddingModel;
2
3let tok = std::fs::read("tokenizer.json").unwrap();
4let model = EmbeddingModel::from_file("model.fp16.onnx", &tok).unwrap();
5let embedding = model.embed("hello world").unwrap();
6println!("dimensions: {}", embedding.values.len()); // 1024torch.onnx.export (opset 18) with mean pooling and L2 normalization baked into the graph. No fine-tuning or weight modification was performed.