newmean-pii-medium
A small multilingual model that finds personal information (PII) in text so it can be masked in the browser, before the text
leaves the device. It is the medium tier (17.7M parameters, 11.3 MB download) of the
models behind the JavaScript SDK @newmean-ai/pii. Other tiers: newmean-pii-large, newmean-pii-small, newmean-pii-nano.
- 54 languages, 11 labels at the character level: PERSON, EMAIL, PHONE, ADDRESS, ID_NUMBER, FINANCIAL, ORG, USERNAME, URL, DATE_OF_BIRTH, SECRET; persons and URLs carry a level (1 = directly identifying, 2 = indirect). IP addresses are covered only by the SDK's optional pattern layer (off by default).
- Built for real input: forms, chats, spreadsheet cells, logs, JSON, OCR text, e-mails, speech transcripts.
- Apache-2.0, free for any use including commercial use; ONNX with 4-bit weights; runs in WebAssembly (onnxruntime-web or the SDK's own built-in engine).
Use
Try it in your browser first: pii.newmean.ai.
npm install @newmean-ai/pii
import { createRedactor } from "@newmean-ai/pii";
const redactor = await createRedactor({ size: "medium" }); // downloads this repository's files once, checks their SHA-256
const { text, spans } = await redactor.redact("Hi, I'm Kim Minji, call me at 010-1234-5678.");
The SDK pins revision v1.0.0 of this repository. The files can also be used directly with onnxruntime: the model takes
input_ids and attention_mask (windows of 256 tokens, stride 64) and returns BIO logits for the tags in config.json.
| file | |
|---|---|
onnx/model_q4e.onnx |
11.3 MB, 4-bit weights and 4-bit embeddings (SDK default) |
onnx/model_q4.onnx |
14.0 MB, 4-bit weights |
tokenizer.web.json |
compact Unigram tokenizer for the browser |
tokenizer.json, tokenizer_config.json |
the same tokenizer for Hugging Face tokenizers |
config.json |
tags, window settings, architecture |
Results
Model only (no pattern layer), default file, scored on a Colab L4 VM. Miss = share of PII characters left unmasked (lower is better; what matters most for masking); over = share of non-PII characters masked.
| set | miss % / over % |
|---|---|
| newmean-pii-dataset (public test) (54 languages, 17,058 rows) | 2.1 / 0.6 (exact F1 0.77) |
| KDPII (Korean) | 9.8 / 2.0 |
| OpenPII 1.5M (30 languages) | 6.1 / 4.1 |
| Nemotron-PII (English) | 7.9 / 0.7 |
| Gretel finance (7 languages) | 22.5 / 4.2 |
Speed on the VM's CPU (Xeon 2.20 GHz, onnxruntime): 88 ms per text with one thread, 23 ms with 12 threads, on the public test's texts. The public test of newmean-pii-dataset is generated with the same design and guideline as the training data, so these models have an in-distribution advantage there; the external sets were never used for training. On the public test the closest of the eight public detectors we compared (gliner-pii-edge, 176 MB) misses 19.6%; the leaderboard scores them weekly on its public and private test. The full comparison, per-label and per-language results are in the technical report.
Model
6 layers, embeddings rank 192; 17.7M parameters. All four tiers start from mMiniLMv2-L6-H384 with the XLM-R vocabulary pruned to the 35,298 pieces that occur in the training data, and are distilled from two larger private teacher models (mDeBERTa-v3-base and XLM-R-large, fine-tuned for this task). Training data: about 1.07 million synthetic texts in 54 languages generated with Claude models from a written labelling guideline; no real personal data and no external dataset was used for training.
Limitations
- No detector finds everything: use the result to reduce what is sent, not as a guarantee of anonymity.
- Trained on synthetic text; rare formats, very long documents and languages outside the 54 may be weaker.
- Context decides some labels (an organisation is masked only when a person belongs to it; dates only when they are birth
dates), so results depend on the surrounding text.
sensitivityin the SDK trades misses for over-masking.
License and attribution
Apache-2.0 (LICENSE), like the SDK. If you use the model in a product, we would appreciate a "Powered by newmean.ai" mention in your docs or an about or licenses screen, and "Based on newmean-pii-medium" in the card of a model you derive from it (requests, not license conditions).
Built on mMiniLMv2 (Microsoft, MIT License) and the XLM-R SentencePiece tokenizer (Facebook AI, MIT License); see NOTICE.
Made by newmean.ai โ questions and commercial inquiries: hoonjae@newmean.ai.
- Downloads last month
- 4