Token Classification
ONNX
Safetensors
modernbert
pii
privacy
data-masking
anonymization
multilingual

PiiLy large

Finds personal data (PII) in text, so that you can mask it: names, e-mails, phone numbers, addresses, IDs, bank data, passwords, health facts and more.

  • 70 classes, 6 languages: English, French, Spanish, German, Italian, Portuguese.
  • The largest and most accurate PiiLy model: mmBERT-base, 22 layers. Runs on a CPU. The smallest file is 308.8 MB.
  • Apache-2.0.

Need a smaller and faster model? See PiiLy (about 2 times faster) and PiiLy small (about 3 to 4 times faster). Both are a bit less accurate.

Quick start

pip install onnxruntime==1.32.0 tokenizers==0.23.3 numpy==2.5.5 huggingface_hub
hf download Jwuthrich/piily-large --local-dir piily-large
cd piily-large
from piily_onnx import PiiLy, mask

piily = PiiLy(".")
text = "Dear Ms Keller, we will call +41 44 555 01 23 or write to anna.keller@example.com."
spans = piily.detect(text)   # [(start, end, class), ...]
print(spans)
print(mask(text, spans))
[(8, 14, 'PERSON_NAME'), (29, 45, 'PHONE'), (58, 81, 'EMAIL')]
Dear Ms [PERSON_NAME], we will call [PHONE] or write to [EMAIL].

Choose what to mask

The model knows 70 classes. If you change nothing, it masks 38 of them: the classes that point to one person or give access to something (names, contact data, ID numbers, bank data, passwords). This is what masked by default means. The other 32 classes (for example ORGANIZATION, DATE, AMOUNT, HEALTH_CONDITION) are found too, but they are masked only when you ask for them:

PiiLy(".", add=["ORGANIZATION", "DATE"])    # the default classes + these two
PiiLy(".", remove=["POSTAL_CODE"])          # the default classes without this one
PiiLy(".", classes="all")                   # all 70 classes
PiiLy(".", classes=["EMAIL", "PHONE"])      # only these classes
PiiLy(".", threshold=0.3)                   # default 0.5. Lower = misses less, masks more ordinary text
PiiLy(".", onnx_file="onnx/model.onnx")     # another file of the table below

The two tables under "Scores per class" list all 70 classes.

Files

file size for P R F1 time per document
onnx/model.onnx 1231.3 MB CPU, best accuracy 95.6 97.0 96.3 215 ms
onnx/model_fp16.onnx 616.2 MB GPU 95.6 97.0 96.3 -
onnx/model_int8.onnx 308.8 MB CPU, smallest file 95.7 95.8 95.8 198 ms
bardsai (INT8), for comparison 308.6 MB CPU 95.4 92.5 94.0 75 ms
  • P (precision): of the text that the model masked, the share that was personal data. R (recall): of the personal data, the share that the model masked. F1: both in one number. All in %, higher is better.
  • Scores: 5 test sets that the model never saw in training (4 public, 1 of ours), default threshold 0.5.
  • Time: median of 200 real documents (about 270 tokens each), 4 CPU threads, Intel Xeon Platinum 8570.
  • bardsai = bardsai/eu-pii-anonimization-multilang-v3, run by us on the same tests.
  • model.safetensors holds the same weights for PyTorch / transformers.

Scores per class

Test: 3,048 documents in the 6 languages with all 70 classes, threshold 0.5, file onnx/model.onnx. With the default classes the model masks 98.8% of the personal data of this test. The documents were written by an AI model for this project. They are not real documents, so real text can score lower.

P, R and F1 are for the class itself, in %. bardsai = the share of the values of the class that bardsai masks. bardsai has other classes than ours, so a value counts when bardsai masks it with any of its labels, and there is no P for it.

Masked by default (38 classes)

class what it is P R F1 bardsai
API_KEY_TOKEN API key or access token 63.6 98.9 77.4 80.2
BANK_ACCOUNT IBAN or bank account number 97.4 99.0 98.2 94.3
BANK_ROUTING_CODE BIC, routing number or sort code 96.0 98.7 97.4 48.2
BIOMETRIC_ID id of a fingerprint, face or iris record 95.9 84.2 89.7 65.2
CARD_EXPIRY card expiry date 99.5 96.8 98.2 33.6
CARD_SECURITY_CODE card security code (CVV) 99.3 86.5 92.4 24.4
COMPANY_ID company register or VAT number 98.2 95.0 96.6 85.7
CRYPTO_WALLET crypto wallet address 97.7 97.8 97.7 55.2
CUSTOMER_ID customer, member or policy number 83.9 75.5 79.5 62.6
DATE_OF_BIRTH date of birth 99.9 99.7 99.8 94.1
DEVICE_ID MAC address, IMEI or serial number 89.1 81.8 85.3 76.8
DRIVING_LICENCE_NUMBER driving licence number 91.5 99.3 95.2 99.6
EMAIL e-mail address 99.9 100.0 99.9 95.3
EMPLOYEE_STUDENT_ID employee or student number 95.9 85.8 90.6 70.6
GEO_COORDINATES latitude and longitude 96.8 100.0 98.4 62.4
HEALTH_ID health insurance or patient number 84.4 73.7 78.7 76.2
IP_ADDRESS IP address 98.0 99.4 98.7 92.0
NATIONAL_ID national identity number 87.7 92.1 89.9 97.4
ONLINE_ID cookie, advertising or app id 97.9 50.8 66.9 46.3
PASSPORT_NUMBER passport number 85.6 99.7 92.1 100.0
PASSWORD password or passphrase 97.0 96.3 96.6 82.5
PAYMENT_CARD payment card number 95.4 99.8 97.5 100.0
PERSON_NAME name of a person 99.8 99.2 99.5 97.6
PHONE phone or fax number 99.1 99.6 99.4 99.0
PIN_OR_CODE PIN, one-time code or door code 92.4 86.5 89.4 63.3
PLACE_OF_BIRTH place of birth 99.0 98.0 98.5 94.3
POSTAL_CODE postal code written alone 84.9 95.7 90.0 87.5
PRIVATE_KEY private key or seed phrase 97.9 99.0 98.4 21.2
PROFESSIONAL_LICENCE licence number of a doctor, lawyer, ... 96.4 87.2 91.5 76.2
PROFILE_URL link to the profile of one person 98.7 98.8 98.7 19.5
PROPERTY_ID meter, land parcel or supply point number 99.9 74.4 85.3 94.5
RESIDENCE_PERMIT visa or residence permit number 97.4 74.4 84.3 90.1
SOCIAL_SECURITY_NUMBER social security number 87.0 93.5 90.1 99.1
STREET_ADDRESS street address 99.5 99.0 99.3 97.9
TAX_ID personal tax number 86.7 95.8 91.0 98.3
TRAVEL_BOOKING_REFERENCE flight, rail or hotel booking reference 98.9 71.9 83.3 83.7
USERNAME login or handle 96.2 99.0 97.6 84.1
VEHICLE_ID number plate or VIN 92.7 95.3 94.0 88.3

Masked only when you ask (32 classes)

class what it is P R F1 bardsai
AGE age of a person 95.6 98.4 97.0 33.0
AMOUNT amount of money 98.3 95.4 96.8 31.7
CASE_NUMBER court case, police report or claim number 87.9 76.9 82.0 20.8
CRIMINAL_RECORD offence, charge, conviction or sentence 86.6 59.5 70.6 0.2
DATE date that is not a date of birth 98.9 99.4 99.2 82.8
EDUCATION degree, school level or grade 94.8 75.4 84.0 24.3
ETHNICITY ethnic origin 93.5 82.7 87.8 21.5
GENDER sex or gender 98.4 93.5 95.9 63.2
GENETIC_DATA gene, variant or genetic test 94.3 55.4 69.8 4.4
HEALTH_CONDITION diagnosis, symptom, allergy or disability 86.4 83.0 84.7 0.3
HOSTNAME internal computer or network name 93.5 80.7 86.6 32.0
INCOME salary, pension or account balance 91.6 74.5 82.2 47.1
LOCATION town, district or named place 93.9 94.1 94.0 79.2
MARITAL_STATUS marital status 93.1 84.9 88.8 19.2
MEDICAL_CODE diagnosis or drug code (ICD-10, ATC) 93.2 80.9 86.6 12.6
MEDICAL_PROCEDURE surgery, examination or therapy 86.2 46.5 60.4 0.3
MEDICAL_TEST_RESULT lab value, blood pressure, blood type 93.6 62.1 74.7 0.9
MEDICATION drug that a person takes, with its dose 88.0 86.5 87.3 1.4
MENTAL_HEALTH psychiatric condition or therapy 91.6 77.3 83.9 0.7
NATIONALITY nationality or citizenship 86.7 84.3 85.5 21.2
OCCUPATION job or job title 94.2 80.8 87.0 26.4
ORGANIZATION name of a company or institution 89.1 94.6 91.8 55.7
PARTIAL_IDENTIFIER partly hidden value (**** 4417) 92.2 97.6 94.8 35.2
PHYSICAL_DESCRIPTION height, weight, hair, scar, tattoo 97.2 62.0 75.7 0.6
POLITICAL_OR_UNION political opinion, party or union membership 81.2 95.4 87.8 38.6
REFERENCE_NUMBER order, invoice or ticket number 81.0 77.0 79.0 53.5
REGION_OR_COUNTRY country, state or region 94.8 90.1 92.4 50.3
RELIGION religion or belief 90.9 61.9 73.7 45.9
SEXUAL_ORIENTATION sexual orientation 93.6 33.7 49.5 23.7
SUBSTANCE_USE use of tobacco, alcohol or drugs 89.7 67.9 77.3 1.0
TIMESTAMP date with clock time (log line) 99.9 98.4 99.1 75.1
URL web address 97.5 99.0 98.2 28.8

Good to know

  • Six languages only. Other languages were not tested.
  • The training data is public: piily-dataset, 72,461 documents.
  • The model was trained on synthetic text only (no real personal data): documents written by Claude models for this project, and rows of OpenPII 1M and Nemotron-PII.
  • The INT8 file can give slightly different spans on another CPU type. The FP32 and FP16 files do not.
  • The INT8 file finds less than the FP32 file: R 95.8 against 97.0 in the table of the files. For the best accuracy use onnx/model.onnx, or onnx/model_fp16.onnx on a GPU.
  • A detector is not a guarantee. Add a human check where a miss causes harm.

Licence

Apache-2.0 (LICENSE). Credits for the base model mmBERT-base (MIT) and the training data (OpenPII 1M by Ai4Privacy, Nemotron-PII by NVIDIA, both CC BY 4.0) are in NOTICE.

Downloads last month
17
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 Jwuthrich/piily-large

Quantized
(317)
this model

Datasets used to train Jwuthrich/piily-large