pii · Guide
Model & benchmarks
Every number on this page is copied from the package's own MODEL_CARD.md and benchmarks/BENCHMARK.md / benchmarks/metrics.json. The two genuinely external benchmarks (never trained on) are called out separately from the package's own evaluation suites, and every caveat that applies to a number is stated next to it rather than left for the reader to discover.
Read the contamination notes before quoting a number
Several of the suites below share data with the model's own training set in ways that are documented but easy to miss — most importantly the homonym suite (below) and the identifier-probe suite. The two external, never-trained-on checks are the third-party CC0 Turkish PII benchmark and the Text Anonymization Benchmark (TAB) / ECHR court judgments.
Architecture
The shipped model (v9, 2026-09-14) is a purpose-built token tagger trained from scratch — not a shrunk BERT — specifically because quantising a BERT-based predecessor addressed size, not shape: it would still have been roughly 100 MB and tens of milliseconds per call, an order of magnitude away from the pattern tier it sits beside.
per token char embedding (24d) -> Conv1d widths 2/3/4, 32 filters -> max-pool (96d)
FNV-1a hashed word embedding, 16384 buckets (32d)
16 shape features (casing, digits, punctuation, position, length,
4 identifier-shape features) (16d)
concat -> 144d
sentence Linear -> 128d, mask applied BEFORE the first conv block too
4x [Conv1d k=3, dilation 1/2/4/8] + GELU + residual + LayerNorm
per token Linear -> 15 BIO logits (O, B/I- x {PER, ORG, LOC, PHONE, EMAIL, ID, FIN})753,703 parameters, 2.91 MB as fp32, 1.45 MB after int8 dynamic quantisation — applied only to the embedding (Gather) tables, which are most of the size. Quantising the convolution layers too was tried and measured slower on CPU at this size, so only the embeddings are quantised.
Key design choices, each tied to a measured failure it fixes:
- A character CNN, because Turkish is agglutinative (
Yılmaz,Yılmaz'ın,Yılmaz'dan,Yılmazlarare one stem with different endings) and no fixed word vocabulary handles that gracefully. - A hashed word embedding (FNV-1a into 16,384 buckets — the Bloom-embedding trick spaCy uses), because the char CNN alone cannot easily memorise that
Yılmazis usually a surname. - 16 explicit shape features, four of them identifier-shape features (
7 ≤ length ≤ 11, all-digit starting with0, all-digit length in{10, 11}, has both a digit and a letter) added specifically so the model can tell a phone number from a national-ID-shaped run of similar length. - Dilated convolutions (1/2/4/8), not a BiLSTM — a wide receptive field without an RNN, chosen because it exports cleanly to ONNX and is several times faster than an LSTM on CPU at this size.
- No CRF — the model outputs plain per-token logits; a BIO-constrained Viterbi decoder (not a learned transition matrix) removes structurally invalid spans at inference time, so both language ports decode identically without reimplementing a CRF in JavaScript.
- Overlapping inference windows. A single call covers at most 160 tokens; longer text is split into windows that overlap by 32 tokens and stitched into one decode, so an entity that would otherwise straddle a hard window boundary is no longer split or dropped, at a cost of roughly 24% more tokens processed on long inputs. Text under 160 tokens (the common case) is byte-identical to the pre-stitching output.
Both language ports run the same ONNX graph, and the package's parity tests assert they return identical spans — FNV-1a hashing (not either language's native hash()), an explicit character vocabulary shipped alongside the model (not ord()/Unicode category tables), and apostrophe-based tokenisation are all chosen specifically because they produce identical results in both languages. One divergence is deliberate: JavaScript strings are UTF-16 and Python strings are code points, so an emoji or other non-BMP character shifts integer offsets by one between languages — redact() output text is still byte-identical in both.
Training data
Trained on datasets whose licences allow commercial training, plus synthetic text generated for this project. Full attribution, including evaluation-only datasets, is in NOTICE; in summary:
| Source | Licence | Contributes |
|---|---|---|
Wismut/nym-pii-multilingual-data | MIT | Form- and record-shaped PII text in Turkish and English. |
BTX24/turkish-privacy-pii-ner | CC BY 4.0 | Turkish PII sentences with character-level person and address spans. |
nvidia/Nemotron-PII (train split only) | CC BY 4.0 | English PII-annotated text. |
| Synthetic text | Generated in-project, no third-party licence needed | Vocabulary lists (names, companies, streets), slot-filled templates (prose and CRM-style record dumps, so entity offsets are correct by construction), combinatorial identifier formats generated as minimal pairs (a real checksummed identifier next to a look-alike non-PII number in an otherwise near-identical sentence), homonym minimal pairs, and natural sentences covering harder surface forms (sentence-initial names, ALL-CAPS/lowercase names, organisations containing a person or place name, and a court/news register for English and Turkish). |
None of the above datasets are vendored in the package repository, and none are redistributed.
Licence-clean by design. Every source above permits commercial training outright, with no share-alike or non-commercial condition to reason about. An earlier line of checkpoints additionally trained on a CC BY-SA 4.0 Turkish corpus and on teacher-labelled silver data (ordinary Turkish text labelled by a separate BERT model); both were dropped for this retrain so the shipped model's training-data provenance is unambiguous, at the cost of the corpus diversity those sources added. The benchmark numbers below are for this cleaned retrain, not the earlier lineage.
Contamination discipline
Read each of these before treating the corresponding number as a clean generalisation result:
- The homonym suite is not an unseen-word test. Its words (
Deniz,Umut,Can, …) also appear as PERSON names in the model's own generated training data. What the suite measures is telling a known name from the same everyday word, not handling a word never seen as a name. BERT's pretraining has seen these names too, so the head-to-head comparison is fair, but neither system's number is a clean out-of-vocabulary result. - The identifier-probe suite is never trained on, but it is not third-party or human-annotated data either — it is a hand-written probe suite built inside this project specifically to avoid sharing the synthetic-data generator's own blind spots. Treat it as an independent check on the project's own generator, not as evidence of external validation.
- The external CC0 Turkish PII benchmark and TAB/ECHR are the real external checks — built by someone else, for a different purpose, never touched by any generator or training step in this project.
- Nemotron-PII is no longer a clean external check for this package specifically. This package trains on its TRAIN split, so its own score on the TEST split measures in-distribution fit, not generalisation. It remains a clean comparison point for BERT, Presidio, and spaCy, whose training was unaffected.
- Held-out Turkish (below) is measured on the same synthetic distribution used for training — an in-distribution sanity check, not a generalisation result on its own.
Results
All numbers below are for the shipped model (v9, 2026-09-14) unless a row says otherwise. This is a numbers-only summary — evaluation harness internals and per-category breakdowns are not published; what follows is what was measured, not how.
Detection quality
| Suite | pattern alone | pattern+ner-verified |
|---|---|---|
| Identifier probes, F1 | 0.795 | 0.942 |
| Held-out Turkish (same synthetic distribution as training), strict span F1 | -- | 0.936 |
| Turkish homonym minimal-pair challenge, strict F1 | -- | 0.818 |
| External CC0 Turkish PII benchmark, all-types recall | -- | 0.888 |
| External CC0 Turkish PII benchmark, PER/ORG/LOC recall | -- | 0.860 |
"External CC0 Turkish PII benchmark" is a third-party, CC0-licensed Turkish PII dataset never used in training, scored per the categories it defines. "Identifier probes" is a hand-written, independent probe suite (phone, email, national ID, IBAN/card) covering both true and look-alike non-PII numbers, also never used in training.
Against other published systems
Two comparisons with independently published or independently reproduced numbers, so this package's score is not graded on its own curve:
| Benchmark | This package (pattern+ner-verified) | Reference systems |
|---|---|---|
| Turkish homonym minimal-pair challenge, strict F1 | 0.818 | akdeniz27 Turkish BERT NER: 0.773 |
| External CC0 Turkish PII benchmark, PER/ORG/LOC recall | 0.860 | akdeniz27 Turkish BERT NER: 0.871 |
| External CC0 Turkish PII benchmark, spans, strict F1 | 0.391 | akdeniz27 Turkish BERT NER: 0.253 |
| English Text Anonymization Benchmark, strict span F1 | 0.362 | BERT 0.262 / Presidio 0.209 / spaCy 0.210 |
| English Text Anonymization Benchmark, official token recall | 0.649 | fine-tuned RoBERTa (published TAB baseline): 0.906 |
| English Text Anonymization Benchmark, official token precision | 0.591 | -- |
akdeniz27/bert-base-turkish-cased-ner is a 441 MB fine-tuned Turkish BERT NER model — roughly 300x this package's 1.45 MB model file. Presidio and spaCy are Microsoft Presidio and bare spaCy NER on the same English set. The Text Anonymization Benchmark (TAB) is scored with the benchmark's own evaluator against its published baselines — this package scores considerably lower there than on its own suites because TAB's definition of "identifying" is much wider than this package's category list (case numbers, nationalities, and generic quantities are all in scope for TAB and out of scope here). A tool that leaves case numbers and most dates in place is not a general anonymiser, whatever it scores on names.
Latency
Single-call latency, CPU, one thread, p50 milliseconds:
| Mode | p50 (ms) |
|---|---|
pattern | well under 0.1 |
pattern+dictionary+ner | 0.69 |
pattern+ner-verified | 0.74 |
Only this package's own latency is published above — a head-to-head against BERT/Presidio/spaCy's latency and resident memory is not currently part of the shipped benchmark artifacts; see Detection modes for the per-mode latency discussion in context.
Model
| Parameters | 753,703 |
| BIO labels | 15 |
| On-disk size (int8, Gather-only) | 1.45 MB |
What changed for v9
The shipped model is a full retrain on the licence-clean corpus described above, so it does not share a training lineage with earlier checkpoints referenced in older release notes — head-to-head regression tracking across versions does not apply here. MultiCoNER is no longer reported as a benchmark: the corpus was removed along with the other non-essential training/eval data during the licence cleanup.
Known gaps
username/passwordare keyword-anchored and off by default — a value with no introducing keyword is never found, and a bare keyword in ordinary prose was a common false trigger in manual review.- CNN-only identifier spans are deliberately down-weighted (
nerOnlyNumberWeight0.35 inpattern+ner-verified) — the regex front stays in charge of whether a number-shaped entity exists at all. birthDate, when enabled, matches every calendar-valid date, not only birth dates — it has no way to distinguish them without a keyword.- English is secondary. TAB strict span F1 (0.362) leads the systems compared here, but TAB's own token-recall bar (0.906, a model trained specifically for anonymising court text) is far off, and English training data is a fraction of the Turkish volume.
- Turkish names on real third-party text are still slightly behind BERT: CC0 PER/ORG/LOC recall 0.860 against BERT's 0.871, at roughly 1/300th the model size.
- Resident memory and cold-load latency for the current 15-label / 1.45 MB model have not been re-measured since an earlier, smaller version of the tagger. Treat the parameter count and on-disk size above as current, and other resource figures as pending remeasurement.
Where to go next
- Detection modes — the judge's fusion math that produces the
pattern+ner-verifiednumbers above. - Turkish specifics — the morphology and homonym handling these benchmarks measure.
- pii overview — headline numbers with the same caveats, condensed.

