Instructions to use amsintelligence/masker-mini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use amsintelligence/masker-mini with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="amsintelligence/masker-mini")# Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("amsintelligence/masker-mini") model = AutoModelForTokenClassification.from_pretrained("amsintelligence/masker-mini") - Notebooks
- Google Colab
- Kaggle
Masker Mini
Masker-mini is the on-device sibling of masker: a 6-layer distilled PII detector for 23 European languages that keeps ~99% of the teacher's strict-span F1 while shrinking to as little as 17 MB (4-bit Core ML).
It runs fully offline, no PII leaves the device.
| artifact | format | size | strict F1 |
|---|---|---|---|
model.safetensors |
PyTorch fp16 | 68 MB | 0.965 |
onnx/model_fp16.onnx |
ONNX fp16 (portable) | 68 MB | 0.965 |
onnx/model_int4.onnx |
ONNX 4-bit (ONNX Runtime) | 22 MB | 0.965 |
coreml/masker_mini_4bit.mlpackage |
Core ML 4-bit (Apple NE) | 17 MB | 0.965 |
Model type & training
Masker Mini is a 6-layer BERT-architecture token classifier (hidden size 384,
12 heads, ~35.6M parameters), a MiniLM-class encoder. It is trained by knowledge
distillation from masker.
After distillation the vocabulary was frequency-pruned, shrinking the embedding table to land the whole network at ~35.6M parameters.
Three deployment artifacts are provided:
- ONNX fp16 (68 MB): portable, runs anywhere via ONNX Runtime (Android / iOS / web / server); numerically identical to the PyTorch model.
- ONNX 4-bit (22 MB): weight-only block quantization (
MatMulNBits+GatherBlockQuantized) of the Linear layers and the embedding table. Needs ONNX Runtime ≥ 1.18 for the 4-bit ops; 99.8% token-faithful to fp16. - Core ML, 4-bit palettized (17 MB): weight-only k-means palettization for the Apple Neural Engine (iOS 18 / macOS 15+). Palettization is effectively lossless here (Δ strict F1 = −0.0002 vs fp16).
It emits the same 12 entity types as
masker (48 BIOES labels + O)
and slots into the same rules-layer pipeline for structured PII.
Usage
For a plain PyTorch / Transformers quick start, the snippet on the
masker card runs unchanged, just
point it at amsintelligence/masker-mini.
What this repo is actually for is the two on-device builds:
ONNX Runtime (portable for Android, iOS, web, server)
import onnxruntime as ort, numpy as np
from transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained("amsintelligence/masker-mini")
sess = ort.InferenceSession("onnx/model_fp16.onnx")
text = "Stuur de factuur naar Sanne de Groot in Utrecht."
feed = {k: v.astype(np.int64) for k, v in tok(text, return_tensors="np").items()}
logits = sess.run(None, feed)[0] # [1, seq_len, 49] BIOES logits -> argmax + decode
For the smallest portable build, swap in onnx/model_int4.onnx (22 MB, 4-bit) —
same inputs/outputs, needs ONNX Runtime ≥ 1.18.
Core ML, add coreml/masker_mini_4bit.mlpackage to an Xcode target.
Inputs input_ids, attention_mask, token_type_ids
(Int32, fixed length 256); output logits. The BIOES→span decode is the same
handful of lines shown on the masker card.
Evaluation
openpii-1m validation, span-level, boundary-exact. In-distribution — see Limitations. Numbers below are the 4-bit Core ML build (fp16/PyTorch are within ±0.001).
Overall: strict F1 0.965 · typed F1 0.991 · leak-safe recall 0.998. Distillation gap vs the masker teacher (0.982): −0.007.
Per-type strict F1
| entity | F1 | entity | F1 |
|---|---|---|---|
| DATE | 0.999 | AGE | 0.969 |
| 0.999 | BUILDING_NUMBER | 0.969 | |
| CREDIT_CARD | 0.999 | CITY | 0.954 |
| PHONE | 0.998 | STREET_NAME | 0.922 |
| GOVERNMENT_ID | 0.998 | GIVEN_NAME | 0.910 |
| ZIP_CODE | 0.994 | SURNAME | 0.900 |
By language
| split | strict F1 |
|---|---|
| English | 0.974 |
| Non-English (22 langs, pooled) | 0.971 |
| Dutch (flagship) | 0.968 |
| Per-language range | 0.960 - 0.983 |
Limitations & biases
- This is a compressed model. It trails the full-size masker by ~0.7 strict-F1
points, and the loss is not uniform: it lands almost entirely on
GIVEN_NAME/SURNAME, plusCITY/STREET_NAMEfrom the reduced 64K vocabulary. Structured types (email, phone, IDs, cards, dates) stay ≥ 0.99. The one language-specific soft spot is Dutch person-name boundaries (tussenvoegsels). If you need the top half-point back, use masker. - Scores are in-distribution (synthetic openpii), treat them as an upper bound, measure on your own text, and design for residual leakage rather than assuming full coverage.
Credits & attribution
Distilled from masker, which is itself a derivative of:
- Backbone / tokenizer lineage:
microsoft/mdeberta-v3-baseby Microsoft; MIT License (masker-mini reuses mDeBERTa's SentencePiece tokenizer). DeBERTaV3: He, Gao & Chen, 2021 (arXiv:2111.09543). - Training data:
ai4privacy/pii-masking-openpii-1mby Ai4Privacy; CC-BY-4.0. Attribution required; please retain this credit in downstream use.
License
Licensed under the Offchain Studio Source License, Version 1.0, a source-available license. Full terms: https://ai.basement.dev/license.
Commercial-license requests: licensing@basement.dev.
See the accompanying NOTICE file; its Required
Notice line MASKER-MINI © 2026 Offchain Studio must be retained in
redistribution.
The underlying components keep their own (attribution-only) terms, retained in Credits above: the mDeBERTa lineage is MIT and the openpii training data is CC-BY-4.0.
Citation
@software{masker_mini,
title = {masker-mini: on-device PII detection for 23 European languages},
year = {2026},
note = {6-layer distillation of masker (mDeBERTa-v3); ONNX + Core ML},
url = {https://huggingface.co/amsintelligence/masker-mini}
}
- Downloads last month
- 3
Model tree for amsintelligence/masker-mini
Dataset used to train amsintelligence/masker-mini
Collection including amsintelligence/masker-mini
Paper for amsintelligence/masker-mini
Evaluation results
- Strict span F1 on pii-masking-openpii-1m (validation)self-reported0.965
- Typed F1 on pii-masking-openpii-1m (validation)self-reported0.991
- Leak-safe recall on pii-masking-openpii-1m (validation)self-reported0.998