pii-redactor
Full finetune of a fresh token-classification head on
microsoft/Multilingual-MiniLM-L12-H384
(revision 6e8c1ec6b4ec4e3fc6eb7d2cd834fcd582b61daf).
The head was not copied from another PII model.
Window 256, stride 64, bf16.
The published ONNX file is opset 17 weight-only INT8.
MatMul weights are stored as signed INT8 with one scale per group of 8 input features.
The PyTorch checkpoint uses those same dequantized weights, so the two forwards match.
Inputs are input_ids and attention_mask. The output is logits.
Chosen sweep: lr5e5_ep5_trainable_base.
Selection rule: highest held-out exact-span micro F1. If two runs are within 0.001 absolute,
the higher HTTP micro F1 wins.
Sweep results
| run | lr | epochs | frozen embeddings | extra slices | held-out micro F1 | HTTP micro F1 |
|---|---|---|---|---|---|---|
| baseline_1epoch | 5e-05 | 1 | False | False | 0.8463 | 0.9151 |
| lr3e5_ep3_trainable_extra | 3e-05 | 3 | False | True | 0.8631 | 1.0000 |
| lr3e5_ep5_frozen_extra | 3e-05 | 5 | True | True | 0.8710 | 1.0000 |
| lr5e5_ep3_trainable_extra | 5e-05 | 3 | False | True | 0.8730 | 1.0000 |
| lr5e5_ep5_trainable_base | 5e-05 | 5 | False | False | 0.8829 | 0.8683 |
Winner held-out micro F1: 0.8829. Winner HTTP micro F1: 0.8683. Train steps: 17455. Train seconds: 4466.6066. Batch size used: 96. Seed: 20261119.
Capability
Exact character-span micro F1. A span counts only when start, end, and type all match. Compared with (a) the same base model and a randomly initialized token-classification head, and (b) that head trained for one epoch on the same training mix and the winner's other hyperparameters. Official test splits were not used for training or for choosing the sweep.
Winner on eval_gretel_en.jsonl
| type | support | precision | recall | f1 |
|---|---|---|---|---|
| PERSON | 3209 | 0.8377 | 0.8654 | 0.8513 |
| CONTACT | 1953 | 0.9534 | 0.9739 | 0.9635 |
| ADDRESS | 1536 | 0.9184 | 0.9303 | 0.9243 |
| GOV_ID | 1730 | 0.9412 | 0.9445 | 0.9429 |
| FINANCIAL | 1092 | 0.9024 | 0.9148 | 0.9086 |
| SECRET | 121 | 0.8345 | 0.9587 | 0.8923 |
| NETWORK_ID | 962 | 0.9273 | 0.9418 | 0.9345 |
| RECORD_ID | 6314 | 0.9501 | 0.9585 | 0.9543 |
| DATE_OF_BIRTH | 2331 | 0.8723 | 0.9000 | 0.8860 |
| DATE | 1474 | 0.7854 | 0.8616 | 0.8217 |
| LOCATION | 311 | 0.7403 | 0.7974 | 0.7678 |
| ORGANIZATION | 185 | 0.7748 | 0.9297 | 0.8452 |
| AGE | 0 | 0.0000 | n/a | n/a |
| DEMOGRAPHIC | 137 | 0.8993 | 0.9781 | 0.9371 |
| OTHER | 0 | n/a | n/a | n/a |
| micro | 21355 | 0.9002 | 0.9242 | 0.9121 |
- one_epoch micro F1 0.8592 precision 0.8236 recall 0.8981
- untrained micro F1 0.0000 precision 0.0000 recall 0.0002
- INT8 micro F1 0.9121 precision 0.9002 recall 0.9242
Winner on eval_gretel_finance.jsonl
| type | support | precision | recall | f1 |
|---|---|---|---|---|
| PERSON | 9715 | 0.6417 | 0.8187 | 0.7195 |
| CONTACT | 2038 | 0.8742 | 0.9750 | 0.9218 |
| ADDRESS | 3965 | 0.7249 | 0.8805 | 0.7951 |
| GOV_ID | 408 | 0.7333 | 0.8358 | 0.7812 |
| FINANCIAL | 988 | 0.6180 | 0.8431 | 0.7132 |
| SECRET | 326 | 0.5293 | 0.8037 | 0.6382 |
| NETWORK_ID | 288 | 0.7633 | 0.7951 | 0.7789 |
| RECORD_ID | 430 | 0.7670 | 0.9186 | 0.8360 |
| DATE_OF_BIRTH | 233 | 0.6785 | 0.9056 | 0.7757 |
| DATE | 9954 | 0.6428 | 0.8308 | 0.7248 |
| LOCATION | 92 | 0.3873 | 0.8587 | 0.5338 |
| ORGANIZATION | 5881 | 0.6411 | 0.8595 | 0.7344 |
| AGE | 0 | 0.0000 | n/a | n/a |
| DEMOGRAPHIC | 0 | 0.0000 | n/a | n/a |
| OTHER | 0 | n/a | n/a | n/a |
| micro | 34318 | 0.6632 | 0.8482 | 0.7443 |
- one_epoch micro F1 0.6864 precision 0.5993 recall 0.8031
- untrained micro F1 0.0003 precision 0.0001 recall 0.0057
- INT8 micro F1 0.7443 precision 0.6632 recall 0.8482
Winner on eval_nemotron.jsonl
| type | support | precision | recall | f1 |
|---|---|---|---|---|
| PERSON | 143289 | 0.9817 | 0.9884 | 0.9850 |
| CONTACT | 84098 | 0.9722 | 0.9835 | 0.9778 |
| ADDRESS | 23156 | 0.9194 | 0.9358 | 0.9276 |
| GOV_ID | 10211 | 0.8993 | 0.9558 | 0.9267 |
| FINANCIAL | 48311 | 0.9583 | 0.9706 | 0.9644 |
| SECRET | 22992 | 0.8899 | 0.9429 | 0.9156 |
| NETWORK_ID | 13467 | 0.7666 | 0.9667 | 0.8551 |
| RECORD_ID | 82502 | 0.9514 | 0.9709 | 0.9610 |
| DATE_OF_BIRTH | 18078 | 0.9334 | 0.9479 | 0.9406 |
| DATE | 111561 | 0.7644 | 0.8884 | 0.8217 |
| LOCATION | 75891 | 0.9216 | 0.9692 | 0.9448 |
| ORGANIZATION | 54705 | 0.9204 | 0.9763 | 0.9476 |
| AGE | 7167 | 0.7284 | 0.9057 | 0.8074 |
| DEMOGRAPHIC | 41607 | 0.7650 | 0.9727 | 0.8564 |
| OTHER | 0 | n/a | n/a | n/a |
| micro | 737035 | 0.9004 | 0.9601 | 0.9293 |
- one_epoch micro F1 0.9131 precision 0.8778 recall 0.9515
- untrained micro F1 0.0004 precision 0.0002 recall 0.0049
Winner on eval_openpii.jsonl
| type | support | precision | recall | f1 |
|---|---|---|---|---|
| PERSON | 6239 | 0.7985 | 0.8548 | 0.8257 |
| CONTACT | 3822 | 0.9336 | 0.9377 | 0.9356 |
| ADDRESS | 3818 | 0.9177 | 0.9259 | 0.9218 |
| GOV_ID | 3819 | 0.8703 | 0.8714 | 0.8709 |
| FINANCIAL | 931 | 0.8514 | 0.8614 | 0.8564 |
| SECRET | 0 | n/a | n/a | n/a |
| NETWORK_ID | 0 | 0.0000 | n/a | n/a |
| RECORD_ID | 0 | 0.0000 | n/a | n/a |
| DATE_OF_BIRTH | 0 | n/a | n/a | n/a |
| DATE | 3427 | 0.9365 | 0.9431 | 0.9398 |
| LOCATION | 1967 | 0.9421 | 0.9680 | 0.9549 |
| ORGANIZATION | 0 | 0.0000 | n/a | n/a |
| AGE | 1437 | 0.7586 | 0.8420 | 0.7982 |
| DEMOGRAPHIC | 1536 | 0.9408 | 0.9928 | 0.9661 |
| OTHER | 0 | n/a | n/a | n/a |
| micro | 26996 | 0.8787 | 0.9058 | 0.8920 |
- one_epoch micro F1 0.8393 precision 0.8154 recall 0.8645
- untrained micro F1 0.0024 precision 0.0013 recall 0.0149
- INT8 micro F1 0.8920 precision 0.8787 recall 0.9058
Winner on http_eval.jsonl
| type | support | precision | recall | f1 |
|---|---|---|---|---|
| PERSON | 267 | 0.5278 | 0.4270 | 0.4720 |
| CONTACT | 533 | 0.9851 | 0.9906 | 0.9878 |
| ADDRESS | 133 | 1.0000 | 1.0000 | 1.0000 |
| GOV_ID | 134 | 1.0000 | 1.0000 | 1.0000 |
| FINANCIAL | 0 | n/a | n/a | n/a |
| SECRET | 132 | 1.0000 | 1.0000 | 1.0000 |
| NETWORK_ID | 133 | 1.0000 | 1.0000 | 1.0000 |
| RECORD_ID | 0 | 0.0000 | n/a | n/a |
| DATE_OF_BIRTH | 67 | 1.0000 | 1.0000 | 1.0000 |
| DATE | 0 | n/a | n/a | n/a |
| LOCATION | 67 | 1.0000 | 1.0000 | 1.0000 |
| ORGANIZATION | 67 | 1.0000 | 0.8060 | 0.8926 |
| AGE | 67 | 1.0000 | 1.0000 | 1.0000 |
| DEMOGRAPHIC | 0 | n/a | n/a | n/a |
| OTHER | 0 | n/a | n/a | n/a |
| micro | 1600 | 0.8466 | 0.8931 | 0.8692 |
- one_epoch micro F1 0.9183 precision 0.8870 recall 0.9519
- untrained micro F1 0.0000 precision 0.0000 recall 0.0000
- INT8 micro F1 0.8692 precision 0.8466 recall 0.8931
Winner on secrets_eval.jsonl
| type | support | precision | recall | f1 |
|---|---|---|---|---|
| PERSON | 0 | n/a | n/a | n/a |
| CONTACT | 0 | n/a | n/a | n/a |
| ADDRESS | 0 | n/a | n/a | n/a |
| GOV_ID | 0 | n/a | n/a | n/a |
| FINANCIAL | 0 | n/a | n/a | n/a |
| SECRET | 900 | 0.7430 | 0.8289 | 0.7836 |
| NETWORK_ID | 0 | n/a | n/a | n/a |
| RECORD_ID | 0 | 0.0000 | n/a | n/a |
| DATE_OF_BIRTH | 0 | n/a | n/a | n/a |
| DATE | 0 | n/a | n/a | n/a |
| LOCATION | 0 | n/a | n/a | n/a |
| ORGANIZATION | 0 | n/a | n/a | n/a |
| AGE | 0 | n/a | n/a | n/a |
| DEMOGRAPHIC | 0 | n/a | n/a | n/a |
| OTHER | 0 | n/a | n/a | n/a |
| micro | 900 | 0.7401 | 0.8289 | 0.7820 |
- one_epoch micro F1 0.6730 precision 0.6415 recall 0.7078
- untrained micro F1 0.0000 precision 0.0000 recall 0.0000
- INT8 micro F1 0.7820 precision 0.7401 recall 0.8289
INT8 exact-span counts matched the published PyTorch counts on: eval_gretel_en.jsonl, eval_gretel_finance.jsonl, eval_openpii.jsonl, http_eval.jsonl, secrets_eval.jsonl.
INT8 was not scored as a full suite on: eval_nemotron.jsonl.
INT8 latency
onnxruntime CPU, intra-op threads 4, inter-op threads 1, in process.
Times are the summed session.run cost of every window in the document.
| text | chars | windows | p50 ms | p99 ms | mean ms |
|---|---|---|---|---|---|
| chars_1800 | 1800 | 5 | 258.1035 | 271.7706 | 259.1359 |
| long | 290 | 1 | 36.6247 | 38.6442 | 36.7418 |
| median | 193 | 1 | 20.2055 | 21.9453 | 20.2676 |
| short | 129 | 1 | 14.1948 | 15.1140 | 14.2328 |
Published INT8 vs PyTorch span mismatches on the HTTP checks: 0 of 400.
ORT dynamic quantization (quantize_dynamic, per-channel QInt8 MatMul/Gemm, opset 17) changed spans on 94 of 400 HTTP documents, so that file is not the published model. The published file is the weight-only group INT8 graph above.
Group size 8. Quantized MatMuls: 73. Max absolute reconstruction error versus the snapped PyTorch weights: 0.0.
Data
- INCLUDED
nvidia/Nemotron-PII@b70ffaf5ff39e079776134c5bf4381f00a9fd1edlicensecc-by-4.0. Train rows used: 90000. Held-out rows: 10000. Eval rows: 100000. Template rows dropped: 0. CC-BY-4.0 allows a public model with attribution to NVIDIA. Unmapped source labels, ignored in the loss: url (82650), occupation (66474), education_level (18817), employment_status (17652), language (15181), political_view (9149). - INCLUDED
gretelai/gretel-pii-masking-en-v1@e06eb1499ca8d54470f085021cd8e54f9efac7fdlicenseapache-2.0. Train rows used: 50000. Held-out rows: 5000. Eval rows: 5000. Template rows dropped: 0. Apache-2.0 allows a public model. Unmapped source labels, ignored in the loss: url (350). - INCLUDED
gretelai/synthetic_pii_finance_multilingual@7b844d16738527a04264f50214cb426a4cea0897licenseapache-2.0. Train rows used: 43126. Held-out rows: 4792. Eval rows: 5295. Template rows dropped: 2727. Apache-2.0 allows a public model. Unfilled template spans are dropped. - INCLUDED
ai4privacy/pii-masking-openpii-1m@ecfdc547f4a0955600cfe6ab98ba2a162207fcc0licensecc-by-4.0. Train rows used: 60000. Held-out rows: 4000. Eval rows: 4000. Template rows dropped: 0. README states CC-BY-4.0 and permits commercial use and redistribution with attribution. Unmapped source labels, ignored in the loss: TITLE (27994). - EXCLUDED
ai4privacy/pii-masking-400k@414d0a3b5798a152588a0828f1c08a5787de10f4licenseother. Custom license.md allows academic/non-commercial use only and requires a written license before derivative works or redistribution. A public model is not allowed. - Code secrets were generated (6000 train, 400 eval). Hub search for a permissively licensed, synthetic, span-labeled code-secret corpus did not find one. Datasets that looked like real API-key dumps were not used. This slice is generated from documented key formats only.
- HTTP/JSON slice was generated (6000 train, 400 eval). Seeded HTTP requests and responses with PII in fields, headers, and query strings. The eval seed is disjoint from the train seed.
- Seed: 20261119.
- Training windows: base 335130 from 243126 docs; extra 12000 from 12000 docs.
Label map
BIO tags are O plus B-TYPE and I-TYPE for these 15 types.
Unmapped source labels are counted and their tokens use ignore index -100.
They are not assigned OTHER.
- PERSON: contact_name, contactname, customer_name, customername, employee_name, employeename, family_name, familyname, first_name, firstname, full_name, fullname, given_name, givenname, last_name, lastname, middle_name, middlename, name, patient_name, patientname, person, surname
- CONTACT: e_mail, email, email_address, emailaddress, fax, fax_number, faxnumber, mobile, mobile_number, mobilenumber, phone, phone_number, phonenumber, telephone, telephone_number, telephonenum, telephonenumber
- ADDRESS: address, building_number, buildingnum, buildingnumber, house_number, housenumber, po_box, pobox, postal_code, postalcode, postcode, street, street_address, street_name, streetaddress, streetname, zip_code, zipcode
- GOV_ID: driver_license, driver_license_number, driverlicense, driverlicensenum, driverlicensenumber, drivers_license, driverslicense, id_card, id_card_number, idcard, idcardnum, idcardnumber, itin, national_id, nationalid, nin, passport, passport_number, passportnum, passportnumber, social_security, social_security_number, socialnum, socialsecurity, socialsecuritynumber, ssn, tax_id, tax_number, taxid, taxnum, taxnumber, visa_number, visanumber
- FINANCIAL: account_number, accountnumber, bank_account, bank_account_number, bank_routing_number, bankaccount, bankaccountnumber, bankroutingnumber, bban, bic, credit_card, credit_card_cvv, credit_card_number, credit_card_security_code, credit_debit_card, creditcard, creditcardcvv, creditcardnumber, creditcardsecuritycode, creditdebitcard, cvc, cvv, iban, routing_number, routingnumber, swift, swift_bic, swift_bic_code, swiftbic, swiftbiccode
- SECRET: access_token, accesstoken, account_pin, accountpin, api_key, apikey, client_secret, clientsecret, http_cookie, httpcookie, password, pin, private_key, privatekey, refresh_token, refreshtoken, secret
- NETWORK_ID: ip, ip_address, ipaddress, ipv4, ipv6, mac, mac_address, macaddress
- RECORD_ID: account_id, accountid, beneficiary_id, beneficiaryid, certificate_license_number, certificatelicensenumber, customer_id, customerid, device_id, device_identifier, deviceid, deviceidentifier, employee_id, employeeid, health_plan_beneficiary_number, health_plan_id, healthplanbeneficiarynumber, healthplanid, license_plate, licenseplate, medical_record, medical_record_number, medicalrecord, medicalrecordnumber, member_id, memberid, mrn, patient_id, patientid, record_id, recordid, unique_id, unique_identifier, uniqueid, uniqueidentifier, user_id, user_name, userid, username, vehicle_identifier, vehicle_vin, vehicleidentifier, vehiclevin, vin
- DATE_OF_BIRTH: birth_date, birthdate, birthday, date_of_birth, dateofbirth, dob
- DATE: date, date_time, datetime, time
- LOCATION: city, coordinate, coordinates, country, county, geo, latitude, local_latlng, locallatlng, location, longitude, province, state
- ORGANIZATION: company, company_name, companyname, employer, org, organisation, organization
- AGE: age
- DEMOGRAPHIC: biometric, biometric_identifier, biometricidentifier, blood_type, bloodtype, ethnicity, gender, marital_status, maritalstatus, nationality, race, race_ethnicity, raceethnicity, religion, religious_belief, religiousbelief, sex, sexual_orientation, sexuality, sexualorientation
- OTHER: misc, miscellaneous, other
Commands
unset HF_TOKEN HUGGING_FACE_HUB_TOKEN
uv sync
uv run prepare
uv run train --config configs/lr3e5_ep3_trainable_extra.toml
uv run train --config configs/lr5e5_ep3_trainable_extra.toml
uv run train --config configs/lr3e5_ep5_frozen_extra.toml
uv run train --config configs/lr5e5_ep5_trainable_base.toml
uv run export-onnx --model runs/lr5e5_ep5_trainable_base/model --output exports/pii-redactor
uv run benchmark --winner runs/lr5e5_ep5_trainable_base/model --one-epoch runs/baseline_1epoch/model --int8 exports/pii-redactor/onnx/model_int8.onnx
Training details
AdamW, linear warmup 6% then decay, weight decay 0.01, gradient clip 1.0.
Cross-entropy uses weight 0.2 on O and 1.0 on the other labels.
Embeddings are frozen only in the frozen sweep. The classification head is always new and trainable.
Gretel English entities do not ship character offsets. Prepare locates each entity string with non-alphanumeric boundaries.
OpenPII 1M's license allows this public model. Training uses a seeded reservoir of 60,000 train rows and 8,000 validation rows.
The validation sample is split in half: one half is the sweep held-out set, the other half is the reported eval set.
Nemotron's card prose says 50,000/50,000. This revision's parquet files contain 100,000 train and 100,000 test rows.
Limitations
Scores are exact span matches on synthetic data, not a guarantee on live traffic.
Ignored labels (including source url, occupation, title, and several demographic-adjacent tags) are neither positive nor negative examples.
Sliding windows of 256 tokens can miss entities past 16 windows.
ORT dynamic activation quantization changes low-margin boundaries. The published file is weight-only group INT8, and the HTTP mismatch count above is the measured result for that file.
Snapping the linear weights onto the INT8 grid changes a few character boundaries versus the pre-snap checkpoint. Sweep selection used the pre-snap held-out scores. Capability tables below are the published snapped weights.
The one-epoch baseline uses the winner's learning rate, embedding setting, and data mix.
Generated secrets follow documented key shapes. They are not real credentials.