Instructions to use semprerudi/maschera-ch-v63b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use semprerudi/maschera-ch-v63b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="semprerudi/maschera-ch-v63b")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("semprerudi/maschera-ch-v63b") model = AutoModelForTokenClassification.from_pretrained("semprerudi/maschera-ch-v63b", device_map="auto") - Notebooks
- Google Colab
- Kaggle
maschera-ch-v63b
Use it: MASCHERA is the free desktop app (Windows, macOS, Linux, Docker) that runs this model to mask and anonymise personal data in Swiss documents before they go to an AI service. Source: github.com/semprerudi/maschera.
Token classification for personal data in Swiss documents in the three national languages German, French and Italian, as well as in English. Rumantsch is not supported.
It labels spans that carry personal data so they can be replaced by placeholders before a text is handed to an AI service.
Sehr geehrte Frau Brülhart -> Sehr geehrte Frau [FULLNAME_1]
AHV 756.1234.5678.97 -> AHV [AHVN13_1]
Lindenstrasse 12, 3011 Bern -> [STREET_1] [BUILDINGNUM_1], [ZIPCODE_1] [CITY_1]
Where it is used
This model is the recognition stage of MASCHERA, a local masking tool for Swiss documents. MASCHERA fetches or bundles exactly this model; it runs on your own device and sends nothing anywhere.
- Website: www.maschera.ch
- Source code and downloads: github.com/semprerudi/maschera
What it is
| Base model | jhu-clsp/mmBERT-base (ModernBERT), 22 layers, 308M parameters |
| Task | token classification, BIO |
| Labels | 91 BIO labels over 45 tags, frozen contract b7a96dc9 |
| Context | 512 tokens; longer documents are windowed by the tool |
| Weights | model.safetensors, 1.2 GB |
| Training data | synthetic only — it has never seen a real document |
The tag set covers Swiss identifiers with checksums (AHV, UID, IBAN, QR reference, GLN), addresses, names, dates, and administrative references. The full taxonomy lives in the repository.
How good it is
Two measurements. Both are here, not only the friendlier one.
| synthetic | gold documents | |
|---|---|---|
| Size | 2000 documents, 29,210 gold spans | 9 documents, 280 gold spans |
| Leak rate | 0.02 % (13 leaks) | 1.27 % (6 leaks) |
| Micro-F1 | 0.997 | 0.736 |
| Over-masking | 84 | 95 |
| Reproducible | yes | no |
The synthetic figure is the reproducible one. Measured with MASCHERA
1.0.1 (python3 tools/mess_synthetisch.py --model runs/ch-v63b --n 2000);
the documents depend on the templates and the generator, so the numbers
change if those change. The documents are
generated from the templates and nomenclatures in the repository; the
values come from a holdout zone, so no value in the measurement was
seen during training. That separates "recognises names" from "memorised a
list" — but it does not replace real documents.
⚠️ The gold documents cannot be recomputed by anyone. They contain real personal data and are not published. There are nine, hand-marked. It is the most honest figure available and the least comfortable one.
⚠️ This test set resolves very little. Earlier evaluations on an older version of the test set (four training runs, each evaluated after epoch 2 and after epoch 3, eight evaluations in total) ranged from 0.769 to 0.833 micro-F1. Two models less than about 0.06 micro-F1 apart (roughly ±0.03) cannot be told apart by it. The 0.736 above was measured on the current test set and is not directly comparable to that range.
⚠️ Over-masking is not a leak. One word too many costs readability; one word too few costs personal data. The model is tuned towards the second.
What this means in practice
The leak rate on real documents is around one percent, not zero. Review the masked text before you pass it on. This is pseudonymisation, not anonymisation: as long as the dictionary exists the step is reversible, and under Swiss data protection law the data remain personal data.
Intended use
Masking personal data in Swiss administrative and business correspondence before it is given to a third-party AI service, with a human reviewing the result. It is a preparation step, not a compliance guarantee.
Not intended for unattended redaction, automated decisions, or as the sole safeguard before publishing a document.
How it was trained
Trained on synthetic data generated from the templates and nomenclatures of the repository. Values are drawn from open Swiss administrative sources (see Data sources below); no real document was used.
| Epochs | 3 |
| Learning rate | 3e-5, linear, warmup 0.1 |
| Batch | 8 × 2 (gradient accumulation) |
| Weight decay | 0.01 |
| Precision | bf16 |
| max_length | 512 |
| Training seed | 4711 |
Read from the run's training_args.bin, not copied from defaults.
⚠️ The seed of the training set is not recorded anywhere. The generator writes it into the header of the dataset it produces, but that file is not published. The path is reproducible; the exact run is not quite.
The generator, the templates and the nomenclatures are in the repository, so a comparable model can be built from scratch.
Data sources
The nomenclatures come from open Swiss government data. All of them require attribution:
- Surnames, given names — Federal Statistical Office (BFS)
- Localities with postal codes, streets — Federal Office of Topography (swisstopo)
- Places of origin — Federal Office of Justice, eCH-0135
- Company names — Zefix / EHRA via LINDAS, terms: Provide-the-Source
Limitations
- Trained on synthetic documents. Real correspondence is messier.
- The 512-token window is handled by the tool, not by the model. Used directly, long documents must be windowed by the caller.
- Recognition is statistical and incomplete; it misses things and masks too much when in doubt.
- Swiss-specific. The tag set and the anchors assume Swiss formats and the three official languages plus English. Rumantsch is not supported — neither the patterns nor the training data cover it.
Licence
Model weights: MIT.
Built on the idea of rizzo-pii by Simone Rizzo (MIT). No affiliation with that project.
- Downloads last month
- 81
Model tree for semprerudi/maschera-ch-v63b
Base model
jhu-clsp/mmBERT-base