nym-pii-multilingual-small
Compact multilingual PII token-classification model for the
nym anonymization CLI β a 16-layer
depth-pruned, vocabulary-pruned student of
Wismut/nym-pii-multilingual
(mmBERT architecture). 69 MB int8 / 274 MB fp32, 17Γ smaller than the
teacher β and it outperforms the teacher on real-world text.
40 entity types / 81 BIO labels across ~23 languages and 6 scripts (Latin, Cyrillic, CJK, Korean, Arabic, Devanagari), trained with ~20% OCR-style corruption for robustness to scanned/mangled text.
Files
| File | Use |
|---|---|
model.onnx |
fp32 ONNX, 274 MB β nym's default (accuracy-first) |
int8/ |
dynamic-int8 variant (70 MB, per_channel+reduce_range β plain dynamic int8 collapses this architecture). Measured cost vs fp32: in-dist β0.3 F1, non-Latin β1.6, ai4privacy β4.2. Use via token_model = "Wismut/nym-pii-multilingual-small/int8" |
tokenizer.json |
vocabulary-pruned tokenizer (106,372 of 256,000 tokens; byte-fallback keeps any input representable) |
Benchmarks
Span-level, label-agnostic F1 via the nym eval harness:
| Benchmark | this model (69 MB) | teacher (1.2 GB) | Rampart (15 MB) |
|---|---|---|---|
| Synthetic held-out (in-distribution) | 97.9 | 96.3 | 48.5 |
| ai4privacy pii-masking-300k (OOD) | 47.4 | 51.3 | 57.9* |
| WikiANN real text, 8 non-Latin languages (char-F1) | 59.2 | 50.9 | 6.5 |
| WikiANN Latin reference (de/es) | 70.6 | 61.5 | 58.6 |
* ai4privacy is Rampart's training distribution and Latin-only. On real multilingual text β the reason this model exists β Rampart's English WordPiece tokenizer cannot represent non-Latin scripts at all (0.0 char-F1 on Arabic), while this model beats its own 1.2 GB teacher (Arabic 56.3 vs 41.4, Hindi 54.9 vs 41.5, Japanese 55.2 vs 43.0).
How it was trained
- Init:
jhu-clsp/mmBERT-smalldepth-pruned 22β16 layers (evenly spaced, per-layer attention types preserved). - Data: 724k exactly-labeled synthetic examples
(
Wismut/nym-pii-multilingual-datav2) + 161k real Wikipedia passages (22 languages) auto-labeled by the teacher and filtered to high precision. - Weak-label handling (the step that matters): for teacher-labeled real
text,
Otokens are masked from the loss β only verified entity spans supervise β because entities the teacher missed would otherwise train as false negatives. 25% of PII-free real passages are kept with fullOsupervision to preserve precision. This recipe is why the student beats its teacher on real text. - Vocabulary pruning: embedding rows restricted to the 106k tokens the corpora use (+ BPE merge-closure + byte tokens); verified lossless.
- int8 quantization: plain dynamic int8 collapses this architecture
(~15% token agreement);
per_channel=True, reduce_range=Truerecovers it to 99.6% agreement with the benchmark deltas quoted above. Always re-benchmark quantized variants β token-level spot checks can mislead.
Training pipeline: scripts/
in the nym repo (datagen/, prune/, train_ner.py).
Use with nym
[ner]
enabled = true
backend = "tokens"
token_model = "Wismut/nym-pii-multilingual-small" # fp32, accuracy-first
# token_model = "Wismut/nym-pii-multilingual-small/int8" # 70 MB, small accuracy cost
threshold = 0.5
Limitations
- The pruned tokenizer + ONNX layout targets nym / onnxruntime; for transformers fine-tuning use the teacher repo.
- Trained partly on teacher-labeled Wikipedia text (CC-BY-SA source text; not redistributed here). Labels for real text are machine-generated: precision- filtered, recall-imperfect.
- Higher recall / lower precision than the teacher on messy Latin-script forms data (see ai4privacy row) β it flags more aggressively, which for anonymization is usually the safer direction.
- No claim of HIPAA/GDPR compliance by itself; it is a detection component.
License
MIT (inherited from mmBERT-small). The synthetic training data contains no real personal information; the real-text training corpus is not distributed with this model.
- Downloads last month
- 47
Model tree for Wismut/nym-pii-multilingual-small
Base model
jhu-clsp/mmBERT-small