FP32 ONNX export of Horizon-Labs/pii-redactor-small (mmBERT-small, 141M parameters, 29 PII types, BIO tags). Opset 18, one file model.onnx (about 565 MB), no external data.
| inputs | input_ids int64 [batch, sequence], attention_mask int64 [batch, sequence] |
| output | logits float32 [batch, sequence, 59] |
| batch, sequence | dynamic |
Exported with torch.onnx.export(dynamo=True) from the PyTorch weights (attn_implementation="eager"), traced at sequence length 300 so the 128-token sliding-window attention path is exercised. Against PyTorch fp32, argmax labels matched on every non-padded token for batch 1–3 and sequence lengths 3, 64, 200, 512 and 1500, with padded rows; largest absolute logit difference 2.3e-4.
Labels are BIO. id2label / label2id are in config.json.
import json
import numpy as np
import onnxruntime as ort
from transformers import AutoTokenizer
repo = "Kostya165/pii-redactor-small-ONNX"
tokenizer = AutoTokenizer.from_pretrained(repo)
labels = {int(k): v for k, v in json.load(open("config.json"))["id2label"].items()}
session = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
encoded = tokenizer("Hi, I'm Anna Müller. Mail anna.mueller@posteo.de or call +49 30 1234567.", return_tensors="np")
logits = session.run(None, {
"input_ids": encoded["input_ids"],
"attention_mask": encoded["attention_mask"],
})[0]
for token, label_id in zip(tokenizer.convert_ids_to_tokens(encoded["input_ids"][0]), logits.argmax(-1)[0].tolist()):
if labels[label_id] != "O":
print(token, labels[label_id])
Apache-2.0, same as the original model. The original model is trained on CC-BY-4.0 data from ai4privacy (OpenPII) and NVIDIA (Nemotron-PII); keep this notice when redistributing derivatives.