Token Classification
Safetensors
GLiNER2
GLiNER
openmed
extractor
medical
clinical
pii
de-identification
anonymization
privacy
multilingual
Eval Results (legacy)

OpenMed

OpenMed GLiNER2.5 PII Multilingual v1

OpenMed on Hugging Face OpenMed SDK on GitHub pip install openmed License Apache-2.0

OpenMed's open model for masking personal information in clinical text, in several languages. It finds the identifiers in Spanish clinical notes (names, record and license numbers, dates, ages, addresses, phone numbers, e-mails) and returns each one as an exact character span with a score, ready to mask. It also covers English, French, German, Italian, Dutch and Swedish, tested on synthetic finance documents. Trained and evaluated by OpenMed. Apache-2.0, 287.4M parameters, runs on CPU.

Developed by OpenMed
Task PII masking, one generic label: personally identifying information (the prompt it was trained with)
Output text, start, end, label, score; text[start:end] is the exact span
Parameters 287.4M
Default threshold 0.15
Languages Spanish (clinical text); English, French, German, Italian, Dutch, Swedish (tested on synthetic finance text)
License Apache-2.0

About OpenMed

OpenMed builds open models and open-source tools for clinical and biomedical text that run on your own hardware.

Quick start

pip install -U "openmed[gliner2]"  # OpenMed 3.2 or later
from openmed import OpenMedConfig, analyze_text

text = (
    "Paciente: Lucía Martín Herrera, 58 años, NHC 2847193. "
    "Ingresa el 14/03/2025 en el Hospital Universitario Río "
    "Tajo por disnea de esfuerzo."
)
result = analyze_text(
    text,
    model_id="OpenMed/GLiNER2.5-PII-Multilingual-v1",
    labels=["personally identifying information"],
    threshold=0.1,
    confidence_threshold=0.15,
    max_length=120,
    config=OpenMedConfig(use_medical_tokenizer=False),
)
for e in result.entities:
    print(e.start, e.end, e.text, f"{e.confidence:.2f}")

masked = text
for e in sorted(result.entities, key=lambda e: e.start, reverse=True):
    masked = masked[: e.start] + "[PII]" + masked[e.end :]
print(masked)
10 30 Lucía Martín Herrera 1.00
32 39 58 años 0.99
45 52 2847193 0.99
65 75 14/03/2025 0.98
82 113 Hospital Universitario Río Tajo 0.99
Paciente: [PII], [PII], NHC [PII]. Ingresa el [PII] en el [PII] por disnea de esfuerzo.

The settings

  • labels=["personally identifying information"] is the prompt the model was trained with. Keep it as written. Every span comes back with this label: the model marks what to mask, not which kind of identifier it is.
  • threshold=0.1 lets the model propose spans down to 0.1, and confidence_threshold=0.15 keeps those scoring 0.15 or more. This is the decoding behind the evaluation below; the threshold was chosen on the tuning data to favor recall. Raise confidence_threshold for fewer, surer spans, at the cost of leaving more identifiers unmasked.
  • max_length=120 makes analyze_text group sentences into pieces of at most 480 characters, close to the windows used in training and evaluation (at most 438 UTF-8 bytes). It only matters for long texts.
  • use_medical_tokenizer=False keeps the model's own span boundaries. With the SDK default, spans are remapped onto its own word tokens: in example 3 it returns 46002 and Valencia as one span, 46002 Valencia; in example 4 it widens Carmen to hija Carmen.

Long notes, many notes, GPU

  • Pass a whole note: analyze_text splits it into sentences, groups them into pieces and returns offsets into the original text.
  • The model loads once and stays cached, so call analyze_text in a loop for many notes.
  • On a GPU, pass config=OpenMedConfig(device="cuda", use_medical_tokenizer=False).

Evaluation

Spanish clinical case reports (main result): 91 case reports from the MEDDOCAN corpus, from 90 article groups held out of training and tuning, with 2,065 annotated identifiers. 946 of them are critical: names, ID numbers, e-mails, phone and fax numbers, relatives and street addresses. The case text is authentic; the identifiers in it were substituted or added by the corpus authors. All cases come from the MEDDOCAN authors' training file (the official test set was not used), so these numbers are not comparable to published MEDDOCAN results. Scores are counted per character in the original text: F2 weighs recall twice as much as precision, because a missed identifier costs more than an extra mask. An identifier is fully masked when every one of its characters is.

Three more views, on the same frozen model: 588 synthetic finance documents in seven languages (English, French, German, Italian, Spanish, Dutch and Swedish, 84 each) from 12 document types held out of training and tuning, where dates, times and company names are outside the mask scope (macro F2 is the mean of the seven languages); 107 person names in German court decisions, counted as fully masked or not (the gold marks names only, so there is no precision); and 24 short clinical notes with no personal data (12 Spanish, 6 German, 6 French), written as controls, counted as masked if anything in them is masked.

Model Spanish character F2 Spanish exact-span F1 Spanish critical identifiers fully masked Finance macro F2 (7 languages) German names fully masked Clean notes masked (of 24)
OpenMed GLiNER2.5 PII Multilingual v1 (this model), threshold 0.15 98.57 97.60 98.94 76.95 61.68 0
Earlier OpenMed PII model (EmbeddingGemma2 PII Multilingual 270M v2, frozen reference) 84.64 43.12 81.71 65.27 63.55 1
Before OpenMed fine-tuning: fastino/gliner2.5-multi-v1, same prompt, threshold 0.5 35.77 37.77 51.27 38.52 53.27 0

OpenMed's fine-tuning raised Spanish character F2 from 35.77 to 98.57. Against the earlier trained reference it gained +13.92 points (95% CI +12.80 to +15.10, paired bootstrap over the 90 article groups, 2,000 resamples), and the share of critical identifiers fully masked rose by +17.23 points (95% CI +14.74 to +19.69). The reference was chosen on the tuning data from three earlier OpenMed PII models, the threshold (0.15) was chosen on the tuning data too, and these cases were scored once, with the model, threshold and scoring code frozen first. The model was trained on 303 other MEDDOCAN case reports and 2,730 synthetic finance documents.

What it still misses: 19 of the 91 Spanish case reports kept at least one identifier character unmasked, and 9 kept part of a critical identifier (the reference: 91 and 82). It masked 0.08% of the characters that are not identifiers (the reference: 0.27%).

By identifier type (Spanish case reports)

Identifier (MEDDOCAN type) Critical Annotated Fully masked Share fully masked
place (city, province, postcode) (TERRITORIO) 332 328 98.80
date (FECHAS) 229 229 100.00
patient age (EDAD_SUJETO_ASISTENCIA) 189 187 98.94
patient name (NOMBRE_SUJETO_ASISTENCIA) yes 185 185 100.00
clinician name (NOMBRE_PERSONAL_SANITARIO) yes 182 182 100.00
patient sex (SEXO_SUJETO_ASISTENCIA) 172 172 100.00
street address (CALLE) yes 156 155 99.36
country (PAIS) 131 131 100.00
patient ID or record number (ID_SUJETO_ASISTENCIA) yes 105 101 96.19
e-mail (CORREO_ELECTRONICO) yes 85 84 98.82
clinician license number (ID_TITULACION_PERSONAL_SANITARIO) yes 84 84 100.00
insurance number (ID_ASEGURAMIENTO) yes 71 71 100.00
relatives (FAMILIARES_SUJETO_ASISTENCIA) yes 44 40 90.91
hospital (HOSPITAL) 42 41 97.62
encounter ID (ID_CONTACTO_ASISTENCIAL) yes 18 18 100.00
institution (INSTITUCION) 17 13 76.47
phone number (NUMERO_TELEFONO) yes 11 11 100.00
profession (PROFESION) 6 1 16.67
fax number (NUMERO_FAX) yes 5 5 100.00
other patient detail (OTROS_SUJETO_ASISTENCIA) 1 0 0.00

The weakest types (at least five annotations, under 95% fully masked): profession, 1 of 6; institution, 13 of 17; relatives, 40 of 44.

Synthetic finance documents by language

Character F2 English French German Italian Spanish Dutch Swedish
OpenMed GLiNER2.5 PII Multilingual v1 91.46 78.94 80.90 82.11 75.16 60.66 69.40
Earlier trained reference 77.28 72.02 65.25 70.42 65.16 47.34 59.41
Before fine-tuning 42.39 34.80 40.77 43.40 42.78 29.34 36.20

Dutch is its weakest finance language (60.66). Across the seven languages names are the most common finance identifier, and 764 of the 1,404 names (54.42%) were fully masked. These documents are synthetic, so the numbers show transfer across languages, not performance on real records.

German names are the one view where it does not beat the reference: 61.68% of the 107 names fully masked against 63.55% for the earlier reference (77.47% and 81.85% of name characters).

The OpenMed multilingual PII models

Same training data, same frozen comparison, same views. GLiNER2.5 is ahead on every scored view, and neither masks any of the 24 clean notes; mmBERT runs with plain transformers and no extra library.

Model Parameters Default threshold Quick start Spanish character F2 Spanish critical identifiers fully masked Finance macro F2 (7 languages) German names fully masked Clean notes masked (of 24)
OpenMed GLiNER2.5 PII Multilingual v1 (this model) 287.4M 0.15 OpenMed SDK 98.57 98.94 76.95 61.68 0
OpenMed mmBERT PII Multilingual Base v1 307.5M 0.35 transformers 98.12 97.89 74.04 36.45 0
Earlier OpenMed PII model (EmbeddingGemma2 270M v2, reference, not released) 84.64 81.71 65.27 63.55 1

Examples

Real outputs of this model through the OpenMed SDK, with the default threshold 0.15, on CPU. The texts are synthetic, written for this card: every name, number, address, e-mail and hospital is invented. Spans to mask are in bold with their score.

  1. Admission note (Spanish): Paciente: Lucía Martín Herrera1.00, 58 años0.99, NHC 28471930.99. Ingresa el 14/03/20250.98 en el Hospital Universitario Río Tajo0.99 por disnea de esfuerzo.
  2. Signing physician (Spanish): Informe firmado por la Dra. Elena Sanz Prieto1.00, número de colegiado 2845127061.00, Servicio de Neumología. Correo: esanz.neumo@hospitalriotajo.es1.00.
  3. Address and phone (Spanish): Vive con su marido en la calle Pintor Sorolla 23, 4º B0.85, 460020.16 Valencia0.16. Teléfono de contacto: 961 234 5671.00.
  4. Relative and profession (Spanish): Varón1.00 de 71 años0.99, NASS 28 41235678 090.99, que acude acompañado de su hija Carmen0.98, enfermera de profesión.
  5. English discharge (English): Discharge summary for John Patrick Miller1.00, DOB 04/17/19621.00, MRN 004829130.96. Follow-up with Dr. Sarah Chen0.93, phone (617) 555-01420.96.
  6. French referral (French): Mme Claire Dubois1.00, née le 3 mars 19581.00, domiciliée 12 rue des Lilas, 69003 Lyon0.99, est adressée par le Dr Antoine Mercier0.89.
  7. German bank details (German): Herr Klaus Becker0.98, geboren am 14.08.19710.99, wohnhaft in der Hauptstraße 27, 10115 Berlin0.83, IBAN DE89 3704 0044 0532 0130 000.94.
  8. Italian tax code (Italian): Il signor Marco Bianchi1.00, codice fiscale BNCMRC80A01F205X, residente in Via Garibaldi 8, 20121 Milano0.99, telefono 02 4567 89100.99.
  9. Dutch account holder (Dutch): Rekeninghouder Jan de Vries0.99, Keizersgracht 1120.98, 1015 CW Amsterdam0.57, e-mail j.devries@voorbeeld.nl1.00.
  10. No personal data (Spanish): Se pauta amoxicilina 875 mg cada 8 horas durante 7 días y control de la tensión arterial en atención primaria. (nothing masked)

A longer Spanish note (803 characters, 16 spans) in one analyze_text call:

Mujer de 46 años, natural de Toledo, que acude a urgencias del Hospital General Sierra Alta el 2 de febrero de 2025 por fiebre y dolor lumbar. Antecedentes: hipertensión arterial en tratamiento con enalapril. Vive en la avenida de la Constitución 51, 2º A, 45004 Toledo, con su pareja, Andrés Molina. NHC 5530918, NASS 45 10293847 22.
Exploración: temperatura 38,7 °C, puñopercusión renal derecha positiva. Analítica con leucocitosis y proteína C reactiva elevada. Se diagnostica pielonefritis aguda y se inicia ceftriaxona intravenosa.
Evolución favorable, con alta a las 72 horas y control por su médica de familia, la Dra. Beatriz Lozano Gil, en el centro de salud Los Almendros. Remitida por: Dr. Tomás Ibáñez Ruiz, nº de colegiado 454503218. Contacto: tibanez@hgsierraalta.es, teléfono 925 280 114.

Good to know

  • Across the six languages of examples 1 to 9, one call masks names, record and license numbers, dates, addresses, phone numbers, IBANs and e-mails. It also masks the patient's sex and age (Varón, 71 años in example 4, Mujer in the longer note), which MEDDOCAN counts as identifiers.
  • Titles stay inside the span: Dr. Sarah Chen, Dr Antoine Mercier, Herr Klaus Becker (examples 5 to 7).
  • It leaves professions and relationship words: example 4 masks the daughter's name Carmen but not hija or enfermera, and example 3 leaves marido. Professions are its weakest type in the evaluation too (1 of 6 fully masked).
  • Some spans pass the 0.15 threshold narrowly: the postcode 46002 (0.16) and the city Valencia (0.16) in example 3. A higher threshold would leave them visible.
  • Example 10, a prescription with no personal data, comes back with nothing masked.
  • It misses the Italian tax code BNCMRC80A01F205X (example 8) and the written-out date 2 de febrero de 2025 in the longer note.

Limitations

  • The main result is in-distribution: the 91 Spanish case reports are MEDDOCAN article groups held out of the same author training file the model learned from, and their identifiers were substituted or added by the corpus authors. It was not tested on the official MEDDOCAN test set or on real hospital notes.
  • Clinical training data is Spanish only. The other languages were measured on synthetic finance documents, not on clinical notes, and Portuguese and other languages were not trained or tested.
  • German names: 61.68% fully masked, below the earlier reference's 63.55%; in the synthetic finance documents 764 of the 1,404 names were fully masked.
  • One generic label. It does not say which kind of identifier a span is, so type-aware replacement (fake names for names, shifted dates for dates) needs another step.
  • Scores rank spans; they are not calibrated probabilities.
  • Long texts are cut into pieces, and an identifier cut across two pieces can be partly missed.
  • It does not guarantee de-identification. Even on the in-distribution Spanish test, 19 of 91 case reports kept part of an identifier. Have a person review the output before any text leaves your control, and follow the rules that apply to your data.
  • The base model's pretraining data is not public.
  • It finds text spans. It does not give medical advice and is not a medical device.

Built on

OpenMed fine-tuned this model from fastino/gliner2.5-multi-v1 by Fastino (Apache-2.0), built with the open-source GLiNER2 library. Training and tuning data: Spanish clinical case reports from the MEDDOCAN corpus by Marimon et al. (2019, CC BY 4.0; Zenodo record 4279323), whose identifiers were substituted or added by the corpus authors, and the Gretel synthetic PII finance multilingual dataset (Apache-2.0). Evaluation only: person names from the German LER corpus of German court decisions by Leitner et al. (CC BY 4.0). OpenMed's changes: every identifier type was mapped to one generic mask, and MEDDOCAN cases linked to earlier OpenMed Spanish data (27) were left out. Thank you to Fastino, to the MEDDOCAN authors, to Gretel and to the German LER authors for releasing their work openly.

This model is released under Apache-2.0. No corpus text is included in this repository.

Citation

@misc{panahi2025openmedner,
  title={OpenMed NER: Open-Source, Domain-Adapted State-of-the-Art Transformers for Biomedical NER Across 12 Public Datasets},
  author={Maziyar Panahi},
  year={2025},
  eprint={2508.01630},
  archivePrefix={arXiv}
}

@inproceedings{marimon2019meddocan,
  title={Automatic De-identification of Medical Texts in Spanish: the {MEDDOCAN} Track, Corpus, Guidelines, Methods and Evaluation of Results},
  author={Marimon, Montserrat and Gonzalez-Agirre, Aitor and Intxaurrondo, Ander and Rodriguez, Heidy and Lopez Martin, Jose Antonio and Villegas, Marta and Krallinger, Martin},
  booktitle={Proceedings of the Iberian Languages Evaluation Forum (IberLEF 2019)},
  series={CEUR Workshop Proceedings},
  volume={2421},
  year={2019}
}

@inproceedings{leitner2020german,
  title={A Dataset of German Legal Documents for Named Entity Recognition},
  author={Leitner, Elena and Rehm, Georg and Moreno-Schneider, Julian},
  booktitle={Proceedings of the 12th Language Resources and Evaluation Conference (LREC 2020)},
  year={2020}
}

@misc{zaratiana2025gliner2,
  title={GLiNER2: An Efficient Multi-Task Information Extraction System with Schema-Driven Interface},
  author={Urchade Zaratiana and Gil Pasternak and Oliver Boyd and George Hurn-Maloney and Ash Lewis},
  year={2025},
  eprint={2507.18546},
  archivePrefix={arXiv}
}

OpenMed · Hugging Face · GitHub · PyPI · X

Downloads last month
21
Safetensors
Model size
0.3B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for OpenMed/GLiNER2.5-PII-Multilingual-v1

Finetuned
(21)
this model

Datasets used to train OpenMed/GLiNER2.5-PII-Multilingual-v1

Papers for OpenMed/GLiNER2.5-PII-Multilingual-v1

Evaluation results

  • Character F2 (threshold 0.15) on MEDDOCAN (91 held-out Spanish clinical case reports)
    self-reported
    98.570
  • Exact-span F1 (threshold 0.15) on MEDDOCAN (91 held-out Spanish clinical case reports)
    self-reported
    97.600
  • Critical identifiers fully masked (threshold 0.15) on MEDDOCAN (91 held-out Spanish clinical case reports)
    self-reported
    98.940
  • Character F2, macro over 7 languages (threshold 0.15) on Gretel synthetic PII finance multilingual (588 held-out documents, 7 languages)
    self-reported
    76.950
  • Names fully masked (threshold 0.15) on German LER (107 person names)
    self-reported
    61.680