German Clinical De-identification
A token classifier that finds names, dates, addresses, phone numbers, IDs and other personal information (18 types, as in GraSCCo) in German clinical text, so that you can redact it. It is based on gelectra-large (335M parameters) and was trained only on synthetic letters.
For German I recommend the smaller german-clinical-deid-base (109M) first: it leaks about as rarely (table below). This model leaks less than the base model in five of the six other MDeID languages.
Quick start
pip install transformers torch
from transformers import pipeline
ner = pipeline("token-classification", model="LukasKunhardt/german-clinical-deid",
aggregation_strategy="simple", stride=128)
text = "Herr Max Muster (geb. 03.02.1961) wurde am 12.05.2024 im Klinikum Nord aufgenommen."
for e in ner(text):
print(e["entity_group"], text[e["start"]:e["end"]], round(float(e["score"]), 2))
NAME_PATIENT Max Muster 1.0
DATE 03.02.1961 1.0
DATE 12.05.2024 1.0
LOCATION_HOSPITAL Klinikum Nord 0.97
The pipeline gives each token its most likely label. That misses far more than the reading the model was tuned for, which redacts every token whose probability of being personal is at least 0.01 (stored in config.json): on the German MDeID test the pipeline leaks in 21.9 % of notes, the 0.01 reading in 11.7 %. For redaction, use the helper package: pip install german-clinical-deid, then Deidentifier("LukasKunhardt/german-clinical-deid").redact(text) (code on GitHub, also Presidio and spaCy).
Browser and Node
onnx/model.onnx (fp32) and onnx/model_quantized.onnx (embedding table in int8) run in transformers.js; in my Node test (version 3.8.1) both gave the same entities.
import { pipeline } from "@huggingface/transformers";
const ner = await pipeline("token-classification", "LukasKunhardt/german-clinical-deid", { dtype: "q8" });
const out = await ner("Herr Max Muster (geb. 03.02.1961) wurde am 12.05.2024 im Klinikum Nord aufgenommen.");
console.log(out.map(e => `${e.entity} ${e.word}`).join(", "));
NAME_PATIENT Max, NAME_PATIENT Muster, DATE 03, DATE ., DATE 02, DATE ., DATE 1961, DATE 12, DATE ., DATE 05, DATE ., DATE 202, DATE ##4, LOCATION_HOSPITAL Klinikum, LOCATION_HOSPITAL Nord
transformers.js returns one entry per token, so you join neighbouring tokens yourself. The int8 file is only 7 % smaller than fp32 and slower on CPU (1,850 against 1,266 ms per text). For a smaller download use onnx/model_fp16.onnx (669 MB) or the base model.
Results
Test sets: the 41 test letters of GraSCCo (real letters with hand-replaced identifiers) and the MDeID test split (synthetic notes, 402 German and about 410 in each of six other languages). A document has a leak if a name, ID, phone or fax number, e-mail address or street stays readable. Strict typed F1 needs start, end and type to match. Here other models ran at the better of their default and a tuned threshold.
| Model and reading | Size | GraSCCo char F1 | GraSCCo letters with a leak | MDeID German notes with a leak | MDeID German strict typed F1 |
|---|---|---|---|---|---|
this model, threshold 0.01 (model.onnx) | 335M | 0.960 | 2 / 41 | 11.7 % | 0.475 |
| this model, plain pipeline | 335M | 0.980 | 3 / 41 | 21.9 % | not measured |
| german-clinical-deid-base, threshold 0.01 | 109M | 0.948 | 1 / 41 | 11.2 % | 0.439 |
| Ibrahimbaroud/personal-information-detection-german | 109M | 0.973 | 5 / 41 | 78.6 % | 0.300 |
| Horizon-Labs/pii-redactor-base | 308M | 0.832 | 8 / 41 | 23.4 % | 0.363 |

The chart shows each model's best threshold reading against its size (F1 chart). PyTorch, model.onnx and model_fp16.onnx give the same numbers.
On all seven MDeID languages the other models ran at their default label (openai/privacy-filter through its own package):
| Model and reading | Char F1 | Notes with a leak |
|---|---|---|
this model, threshold 0.01 (model.onnx) | 0.927 | 15.2 % |
| this model, plain pipeline | 0.898 | 35.8 % |
| Horizon-Labs/pii-redactor-base | 0.900 | 47.8 % |
| obi/deid_roberta_i2b2 | 0.778 | 68.3 % |
| StanfordAIMI/stanford-deidentifier-base | 0.641 | 75.4 % |
| openai/privacy-filter (opf, Viterbi) | 0.761 | 90.3 % |
Notes with a leak per language:
| Reading | de | en | es | fr | it | nl | pt | all 7 |
|---|---|---|---|---|---|---|---|---|
threshold 0.01 (model.onnx) | 11.7 % | 24.3 % | 15.7 % | 8.8 % | 9.7 % | 24.0 % | 12.2 % | 15.2 % |
I compared training data versions by their test scores, so these numbers are probably a little optimistic; threshold and seed came from development data. RESULTS.md has all models, the int8 file, confidence intervals and every look at the test sets.
Other languages: MultiGraSCCo
MultiGraSCCo (Baroud et al., 2026, CC BY 4.0) translates the 63 GraSCCo letters into nine languages with the same labels. I scored the same 41 test letters in every language and compared with the authors' open models, one per language, which were trained on about 65 % of the sentences of these letters. Character F1:
| Model and reading | de | en | fr | it | pl | tr | ru | uk | ar | fa | mean of 9 translations |
|---|---|---|---|---|---|---|---|---|---|---|---|
| german-clinical-deid, plain pipeline | 0.980 | 0.929 | 0.847 | 0.838 | 0.823 | 0.706 | 0.566 | 0.590 | 0.175 | 0.003 | 0.609 |
| german-clinical-deid, threshold 0.01 | 0.960 | 0.921 | 0.814 | 0.836 | 0.735 | 0.605 | 0.560 | 0.577 | 0.181 | 0.028 | 0.584 |
| authors' model for that language (trained on these letters) | 0.976 | 0.962 | 0.858 | 0.891 | 0.880 | 0.863 | 0.917 | 0.901 | 0.971 | 0.929 | 0.908 |
The authors' models have the higher F1 in every translated language. In German this model is level with theirs (0.980 against 0.976). This model was trained on German only; in Cyrillic, Arabic and Persian script it fails, because the German vocabulary of its base model does not cover them.
Paired bootstrap over the 41 German test letters (2,000 resamples), this model minus the authors' German model, character F1: plain pipeline +0.004 (95 % interval −0.008 to 0.015), threshold 0.01 −0.016 (95 % interval −0.029 to −0.005). So the plain pipeline is level with theirs and the 0.01 reading is slightly behind.
An additional measure of my own, not a standard one: the share of letters in which a name, ID, phone number or street stays readable (less than half redacted).
| Model and reading | de | en | fr | it | pl | tr | ru | uk | ar | fa | mean of 9 translations |
|---|---|---|---|---|---|---|---|---|---|---|---|
| german-clinical-deid, threshold 0.01 | 4.9 % | 7.3 % | 17.1 % | 19.5 % | 34.1 % | 24.4 % | 97.6 % | 97.6 % | 100.0 % | 100.0 % | 55.3 % |
| german-clinical-deid, plain pipeline | 7.3 % | 9.8 % | 22.0 % | 26.8 % | 41.5 % | 61.0 % | 97.6 % | 97.6 % | 100.0 % | 100.0 % | 61.8 % |
| authors' model for that language (trained on these letters) | 14.6 % | 12.2 % | 26.8 % | 26.8 % | 43.9 % | 36.6 % | 26.8 % | 24.4 % | 22.0 % | 31.7 % | 27.9 % |
Development numbers and span F1 are in RESULTS.md.
Limits
- It does not work for Russian, Ukrainian, Arabic or Persian text (MultiGraSCCo, above).
- Check the output before you share text: the model misses some identifiers. I have not tested it on real hospital letters yet.
- If you have annotated clinical text,
partner_eval.pymeasures the model at your site and writes only sums (no text). I would be glad to hear the numbers. - Removing identifiers is not anonymisation under the GDPR. It is a research tool, not a medical device.
Training
- A script invents a case, an open-weight model (DeepSeek V4.1 Flash or GLM-5.3) writes the letter, and the script labels every invented value: 2,550 letters in LukasKunhardt/synthetic-german-clinical-letters. gpt-oss-120b and Gemini 4 Argon screened them for unlabelled personal data; I dropped every flagged letter.
- I fine-tuned deepset/gelectra-large for 3 epochs (learning rate 3e-5, batch size 16, 512-token windows), each letter three times with fresh identifiers, and kept the seed of three with the fewest leaks on development data. One run takes about 45 minutes on one NVIDIA A10G.
License
MIT, like the base model. The letter-writing models allow free use of their outputs. GraSCCo (CC BY 4.0), MDeID (CC BY-NC 4.0) and SPARCLING-DE were used for testing only.
Citation
@misc{kunhardt2026germandeid,
author = {Kunhardt, Lukas},
title = {German Clinical De-identification},
year = {2026},
url = {https://huggingface.co/LukasKunhardt/german-clinical-deid}
}
Lukas Kunhardt, ORCID 0000-0001-5135-6427. Questions and bug reports are welcome in the Community tab or as GitHub issues.
Versions
- v1.0.12: code repository README shows how to use the model as a Presidio recognizer. Model files and numbers unchanged.
- v1.0.11: bootstrap interval for the German MultiGraSCCo comparison;
partner_eval.pyin the code repository to measure the model on your own annotated documents. Model files unchanged. - v1.0.10: MultiGraSCCo section now leads with character F1 (the standard measure); the leak share is shown as an additional measure. Model files unchanged.
- v1.0.9: the helper package is on PyPI (
pip install german-clinical-deid). Model files unchanged. - v1.0.8: MultiGraSCCo results in nine more languages (card and RESULTS.md). Model files unchanged.
- v1.0.7: new
onnx/model.onnxandonnx/model_quantized.onnx, measured on both test sets;onnx/model_int8.onnxreplaced bymodel_quantized.onnxand removed. Weights unchanged.
Kurz auf Deutsch
Das Modell findet persönliche Angaben in deutschen Arztbriefen, damit man sie schwärzen kann. Der pipeline-Weg aus dem Schnellstart lässt auf dem deutschen MDeID-Test in 21,9 % der Notizen etwas lesbar, mit der Schwelle 0,01 aus dem Hilfspaket 11,7 %. Bitte prüfen Sie die Ausgabe vor der Weitergabe; es ist kein Medizinprodukt.