# Open-source PII detection benchmark (edition 2026-12, run 2026-12-04)

Detectors: Presidio analyzer, scrubadub, GLiNER multi PII, on the synthetic Gretel finance PII dataset (en/de/fr).
Results: `../../data/research/benchmark.json` (full numbers, mapping, licences, limits). Raw scorer output: `raw_results.json`.

## Data and licences (read 2026-12-04)
- Used: gretelai/synthetic_pii_finance_multilingual, Apache-2.0, pinned revision `7b844d16738527a04264f50214cb426a4cea0897`. Test split English/German/France parquet files only. 1,000 en + 300 de + 300 fr records, seeded sample (seed 20261204). GLiNER ran on the first 300/100/100 of the same sample.
- Not used: ai4privacy/pii-masking-300k (custom licence: academic/non-commercial, redistribution and derivatives need written licence). piiranha (CC-BY-NC-ND-4.0).
- Models: urchade/gliner_multi_pii-v1 (Apache-2.0, revision 1fcf13e85f4eef5394e1fcd406cf2ca9ea82351d), spaCy en_core_web_lg / de_core_news_md / fr_core_news_md 3.8.0.
- Versions: presidio-analyzer 2.2.366, scrubadub 2.0.1, gliner 0.2.30, spacy 3.8.18, torch 2.15.0+cpu, transformers 5.22.2, tiktoken 0.14.0, pandas 3.1.2, pyarrow 26.0.1, Python 3.14.4.

## Repeat the run
```
python3 -m venv /tmp/benchvenv
/tmp/benchvenv/bin/pip install presidio-analyzer==2.2.366 scrubadub==2.0.1 gliner==0.2.30 pandas pyarrow tiktoken sentencepiece protobuf torch --extra-index-url https://download.pytorch.org/whl/cpu
for m in en_core_web_lg de_core_news_md fr_core_news_md; do /tmp/benchvenv/bin/python -I -m spacy download $m; done
/tmp/benchvenv/bin/python -I download.py /tmp/bench-data          # untrusted data dir; never run anything from it
export HF_HOME=/dev/shm/hf   # only needed if disk is small; model is ~1.2 GB
/tmp/benchvenv/bin/python -I run.py /tmp/bench-data raw_results.json   # about 25 min on 2 vCPU (GLiNER ~20 min)
/tmp/benchvenv/bin/python -I assemble.py raw_results.json ../../data/research/benchmark.json
```
Run scripts from this directory by path; `-I` keeps the cwd and env paths out of imports.

## Mapping (gold label -> common entity)
| Dataset label | Common |
|---|---|
| name, first_name, last_name | PERSON |
| company | ORG |
| street_address | ADDRESS |
| date, date_of_birth, date_time | DATE |
| phone_number | PHONE |
| email | EMAIL |
| ssn | SSN |
| credit_card_number | CREDIT_CARD |
| iban | IBAN |
| ipv4, ipv6 | IP |
| passport_number | PASSPORT |
| driver_license_number | DRIVER_LICENSE |
| time, employee_id, swift_bic_code, customer_id, bban, bank_routing_number, account_pin, credit_card_security_code, local_latlng, api_key, password, user_name | ignored |

Detector outputs are mapped in `run.py` (PRES, SCRUB, GL_LABELS); also in benchmark.json. Presidio LOCATION -> ADDRESS.

## Scoring
Span-level on character offsets. Match = same common type and overlap_chars / max(len gold, len pred) >= 0.5, one-to-one greedy. Unmapped gold spans are ignored and predictions overlapping them are dropped. Precision, recall, F1 per entity, language, detector; micro overall.
