Views
No views yet
| Property | Value |
|---|---|
| Method | onnxruntime.quantization.MatMulNBitsQuantizer |
| Bits | 4 |
| Block size | 32 (one scale per 32 consecutive weights) |
| Symmetry | Symmetric (no zero-point) |
| Op | MatMulNBits contrib op (ORT ≥ 1.16, CPU / CUDA / CoreML EPs) |
| Ops quantized | MatMul only — Gather (embedding table) left in FP32 |
Note on dynamic batch: this variant was produced from the legacytorch.onnx.export(not dynamo). It runs correctly at batch=1 only. If you need batch > 1 for throughput, use the INT8 variant which is based on the dynamo export. A dynamo-based INT4 re-export is planned.
| Metric | Value |
|---|---|
| Ingest throughput | ~2.6 ch/s |
| Top-1 hybrid accuracy | 1.00 |
| RSS memory | ~1.15 GB |
| File size | ~0.9 GB |
| Metric | Value |
|---|---|
| Cosine similarity to FP32 (mean) | 0.945 |
| Cosine similarity to FP32 (min) | 0.930 |
| Semantic ordering (3/3 triplets) | ✅ |
| Triplet margin (mean) | 0.241 |
| Anisotropy (avg pairwise cos) | 0.233 |
| Unit-norm compliance | ✅ |
| Property | Value |
|---|---|
| Embedding dim | 1024 |
| Max context | 32 768 tokens |
| Inputs | input_ids [batch, seq], attention_mask [batch, seq] |
| Output | last_hidden_state [batch, seq, 1024] |
| Pooling | Last-token pooling + L2 normalisation |
| Batch support | batch=1 only (legacy export limitation) |
1import onnxruntime as ort
2import numpy as np
3from tokenizers import Tokenizer
4
5tokenizer = Tokenizer.from_file("tokenizer.json")
6tokenizer.enable_truncation(max_length=512)
7
8# CPUExecutionProvider supports MatMulNBits 4-bit
9session = ort.InferenceSession("model.int4.onnx", providers=["CPUExecutionProvider"])
10
11text = "semantic search example"
12enc = tokenizer.encode(text)
13ids = np.array([enc.ids], dtype=np.int64)
14mask = np.array([enc.attention_mask], dtype=np.int64)
15
16lhs = session.run(None, {"input_ids": ids, "attention_mask": mask})[0] # [1, seq, 1024]
17emb = lhs[0, mask[0].sum() - 1] # last non-padding token
18emb = emb / np.linalg.norm(emb)
19print(emb.shape) # (1024,)| File | Size | Description |
|---|---|---|
model.int4.onnx | ~3 MB | ONNX graph with MatMulNBits nodes |
model.int4.onnx.data | ~855 MB | 4-bit weight data + scales |
tokenizer.json | 11 MB | HuggingFace fast tokenizer |
| Repo | Precision | Size | Batch | Notes |
|---|---|---|---|---|
| cstr/octen-embedding-0.6b-onnx | FP32 | 2.4 GB | dynamic | Reference |
| cstr/octen-embedding-0.6b-onnx-int8 | INT8 | 1.1 GB | dynamic | Recommended |
| cstr/octen-embedding-0.6b-onnx-int4 | INT4 | 0.9 GB | batch=1 | This repo — minimum RAM |
Octen.apache-2.0. This repository redistributes under the same terms; it grants no rights the upstream licence does not.