multilingual-pii-detector

Find personal data in text and mask it: names, e-mail addresses, phone numbers, street addresses, SSNs, card numbers, passwords, usernames, dates of birth, driver's licence numbers, IP addresses, bank account numbers, ID numbers and API keys / PINs. An XLM-RoBERTa-base token classifier for English, German, French, Spanish, Italian, Dutch and Swedish, Apache-2.0 (piiranha, a widely used open PII model, is CC-BY-NC-ND-4.0). It scores higher than piiranha and gliner_multi_pii on three public PII benchmarks, and runs on CPU or in your browser with no server.

Try it in your browser: a static page that runs the model locally (transformers.js, ONNX int8, about 281 MB, downloaded once). The text you paste never leaves your device.

Results

Micro F1 over characters, on the 10 groups all three models can predict (name, e-mail, phone, address, SSN, card, password, username, date of birth, driver's licence). All models scored with identical code on identical documents; documents are taken in a fixed hash order from each test split.

Benchmark multilingual-pii-detector iiiorg/piiranha-v1-detect-personal-information (247k downloads, CC-BY-NC-ND-4.0) urchade/gliner_multi_pii-v1 (89k downloads)
nvidia/Nemotron-PII test (1,000 docs) 0.940 0.780 0.871
gretelai/gretel-pii-masking-en-v1 test (1,000 docs) 0.920 0.706 0.846
gretelai/synthetic_pii_finance_multilingual test (1,500 docs, 7 languages) 0.871 0.658 0.633

F1 per group on nvidia/Nemotron-PII:

Group this model piiranha gliner_multi_pii
NAME 0.943 0.788 0.572
EMAIL 0.993 0.739 0.985
PHONE 0.941 0.764 0.945
ADDRESS 0.807 0.840 0.833
SSN 0.979 0.800 0.989
CARD 0.911 0.931 0.945
PASSWORD 0.613 0.455 0.779
USERNAME 0.743 0.660 0.807
DOB 0.992 0.939 0.989

Usage

from transformers import pipeline
ner = pipeline("token-classification", model="Project-Bastion/multilingual-pii-detector", aggregation_strategy="simple", stride=64)

def redact(text):
    out, pos = "", 0
    for e in sorted(ner(text), key=lambda e: e["start"]):
        out += text[pos:e["start"]] + f"[{e['entity_group']}]"; pos = e["end"]
    return out + text[pos:]

print(redact("Hi, I'm Maria Garcia. Reach me at maria.garcia@example.com or +34 612 345 678."))
# Hi, I'm [NAME]. Reach me at [EMAIL] or [PHONE].

Labels: NAME, EMAIL, PHONE, ADDRESS, SSN, CARD, PASSWORD, USERNAME, DOB, DRIVER, IP, ACCOUNT, ID_NUM, SECRET. Texts longer than 256 tokens are processed in overlapping windows (stride=64).

Files

onnx/model_quantized.onnx (weight-only int8, 281 MB, the demo default) and onnx/model.onnx (fp32, 1.1 GB) for transformers.js / onnxruntime. In the browser, fp32 returns the same spans as PyTorch on all 126 checked documents; int8 returns identical spans on 118 of them.

Limits

  • Check recall on your own text before relying on it for compliance: it is strongest on documents like the benchmarks above, and weakest on passwords, usernames and driver's licence numbers.
  • The browser demo is best for texts up to a few thousand characters.

License and credits

Apache-2.0. Base model: FacebookAI/xlm-roberta-base (MIT). Training data: gretelai/synthetic_pii_finance_multilingual (Apache-2.0). Benchmarks: nvidia/Nemotron-PII (CC-BY-4.0), gretelai/gretel-pii-masking-en-v1 (Apache-2.0).

Downloads last month
-
Safetensors
Model size
0.3B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Project-Bastion/multilingual-pii-detector

Quantized
(58)
this model

Evaluation results

  • micro F1 on nvidia/Nemotron-PII test (1000 documents)
    self-reported
    0.940
  • micro F1 on gretelai/gretel-pii-masking-en-v1 test (1000 documents)
    self-reported
    0.920
  • micro F1 on gretelai/synthetic_pii_finance_multilingual test (1500 documents
    self-reported
    0.871