Views
No views yet
MatMulNBits export of a Persian PII token-classification model trained on the cleaned OpenMed Persian PII corpus.| Format | Status | Note |
|---|---|---|
| ONNX INT4 | verified | model.onnx loads in ONNX Runtime CPU and was evaluated on held-out rows. |
| CoreML 4-bit | blocked | CoreMLTools produced a package, but FP32 CoreML prediction did not match PyTorch closely enough, so it was not published. |
| AWQ | blocked | Standard AWQ tooling targets causal LLMs, not BERT token-classification encoders. |
| MLX DWQ | blocked | Current mlx-lm DWQ path is LLM-oriented and did not expose a verified BERT token-classifier conversion path. |
| LiteRT 4-bit | blocked | LiteRT/TFLite has no verified 4-bit BERT token-classification path in this workflow. |
test, first 2,000 rows, max_length=256):1{
2 "model": "artifacts/tookabert-pii-4bit/onnx/model.int4.matmulnbits.onnx",
3 "dataset": "data/final_splits_audited/combined_clean",
4 "split": "test",
5 "rows": 2000,
6 "max_length": 256,
7 "batch_size": 16,
8 "precision": 0.9828071072478589,
9 "recall": 0.9842539845100173,
10 "f1": 0.9835300137516391,
11 "accuracy": 0.9961062829019095
12}reports/.max_length=256 or 512, stride=96 or similar, and merge chunk outputs by original character offsets.کد ملی, گواهینامه, گذرنامه, کدپستی, شماره تماس, and ایمیل to correct ambiguous numeric labels.name [dot] x [at] y, spaced phone digits, and verbal Persian phone numbers before or after model inference.1import onnxruntime as ort
2from transformers import AutoTokenizer
3
4tokenizer = AutoTokenizer.from_pretrained(".")
5session = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
6
7def run_window(text, max_length=256):
8 enc = tokenizer(
9 text,
10 return_offsets_mapping=True,
11 return_tensors="np",
12 truncation=True,
13 padding="max_length",
14 max_length=max_length,
15 )
16 offsets = enc.pop("offset_mapping")[0]
17 if "token_type_ids" not in enc:
18 import numpy as np
19 enc["token_type_ids"] = np.zeros_like(enc["input_ids"])
20 logits = session.run(None, {k: v.astype("int64") for k, v in enc.items()})[0][0]
21 # Convert argmax labels to spans, trim whitespace, merge overlaps, then apply regex/rule postprocessing.
22 return logits, offsetsCREDITCARDNUMBER.CITY and STREET; use address cue-word postprocessing.model.onnx: 4-bit ONNX Runtime MatMulNBits model.verification.json: fixture-level ONNX verification.reports/: ad hoc edgecase reports.