INT8-quantized ONNX version of the Kiji PII detection model for efficient CPU inference. Detects Personally Identifiable Information (PII) in text with coreference resolution.
This is a quantized version of
DataikuNLP/kiji-pii-model — a multi-task DistilBERT model fine-tuned for PII detection with coreference resolution.
1import numpy as np
2from onnxruntime import InferenceSession
3from transformers import AutoTokenizer
4
5# Load tokenizer and model
6tokenizer = AutoTokenizer.from_pretrained("DataikuNLP/kiji-pii-model-onnx")
7session = InferenceSession("DataikuNLP/kiji-pii-model-onnx/model_quantized.onnx") # or local path
8
9# Tokenize
10text = "Contact John Smith at john.smith@example.com or call +1-555-123-4567."
11inputs = tokenizer(text, return_tensors="np", truncation=True, max_length=512)
12
13# Run inference
14outputs = session.run(None, dict(inputs))
15pii_logits, coref_logits = outputs # (1, seq_len, 53), (1, seq_len, 7)
16
17# Decode PII predictions
18pii_predictions = np.argmax(pii_logits, axis=-1)[0]
19
20# See label_mappings.json for label ID -> label name mapping
The source model was trained on the
DataikuNLP/kiji-pii-training-data dataset — a synthetic multilingual PII dataset with entity annotations and coreference resolution.