Views
No views yet
| Metric | Score |
|---|---|
| Micro F1 | 0.9391 |
| Precision | 0.9348 |
| Recall | 0.9434 |
| Macro F1 | 0.9424 |
| Weighted F1 | 0.9382 |
| Accuracy | 0.9949 |
| Rank | Model | F1 | Precision | Recall |
|---|---|---|---|---|
| 1 | OpenMed-PII-Spanish-SnowflakeMed-Large-568M-v1 | 0.9495 | 0.9501 | 0.9490 |
| 2 | OpenMed-PII-Spanish-SuperClinical-Large-434M-v1 | 0.9491 | 0.9515 | 0.9468 |
| 3 | OpenMed-PII-Spanish-BigMed-Large-560M-v1 | 0.9436 | 0.9447 | 0.9426 |
| 4 | OpenMed-PII-Spanish-EuroMed-210M-v1 | 0.9419 | 0.9443 | 0.9395 |
| 5 | OpenMed-PII-Spanish-mClinicalE5-Large-560M-v1 | 0.9405 | 0.9362 | 0.9448 |
| 6 | OpenMed-PII-Spanish-ClinicalBGE-568M-v1 | 0.9391 | 0.9348 | 0.9434 |
| 7 | OpenMed-PII-Spanish-NomicMed-Large-395M-v1 | 0.9379 | 0.9418 | 0.9339 |
| 8 | OpenMed-PII-Spanish-mSuperClinical-Base-279M-v1 | 0.9352 | 0.9312 | 0.9392 |
| 9 | OpenMed-PII-Spanish-SuperMedical-Large-355M-v1 | 0.9346 | 0.9370 | 0.9323 |
| 10 | OpenMed-PII-Spanish-SuperClinical-Base-184M-v1 | 0.9256 | 0.9208 | 0.9303 |
| Entity | Description |
|---|---|
ACCOUNTNAME | Accountname |
BANKACCOUNT | Bankaccount |
BIC | Bic |
BITCOINADDRESS | Bitcoinaddress |
CREDITCARD | Creditcard |
CREDITCARDISSUER | Creditcardissuer |
CVV | Cvv |
ETHEREUMADDRESS | Ethereumaddress |
IBAN | Iban |
IMEI | Imei |
| ... | and 12 more |
| Entity | Description |
|---|---|
AGE | Age |
DATEOFBIRTH | Dateofbirth |
EYECOLOR | Eyecolor |
FIRSTNAME | Firstname |
GENDER | Gender |
HEIGHT | Height |
LASTNAME | Lastname |
MIDDLENAME | Middlename |
OCCUPATION | Occupation |
PREFIX | Prefix |
| ... | and 1 more |
| Entity | Description |
|---|---|
EMAIL | |
PHONE | Phone |
| Entity | Description |
|---|---|
BUILDINGNUMBER | Buildingnumber |
CITY | City |
COUNTY | County |
GPSCOORDINATES | Gpscoordinates |
ORDINALDIRECTION | Ordinaldirection |
SECONDARYADDRESS | Secondaryaddress |
STATE | State |
STREET | Street |
ZIPCODE | Zipcode |
| Entity | Description |
|---|---|
JOBDEPARTMENT | Jobdepartment |
JOBTITLE | Jobtitle |
ORGANIZATION | Organization |
| Entity | Description |
|---|---|
AMOUNT | Amount |
CURRENCY | Currency |
CURRENCYCODE | Currencycode |
CURRENCYNAME | Currencyname |
CURRENCYSYMBOL | Currencysymbol |
| Entity | Description |
|---|---|
DATE | Date |
TIME | Time |
1from transformers import pipeline
2
3# Load the PII detection pipeline
4ner = pipeline("ner", model="OpenMed/OpenMed-PII-Spanish-ClinicalBGE-568M-v1", aggregation_strategy="simple")
5
6text = """
7Paciente María López (nacida el 15/03/1985, DNI: 87654321B) fue atendida hoy.
8Contacto: maria.lopez@email.es, Teléfono: +34 612 345 678.
9Dirección: Calle Serrano 42, 28001 Madrid.
10"""
11
12entities = ner(text)
13for entity in entities:
14 print(f"{entity['entity_group']}: {entity['word']} (score: {entity['score']:.3f})")Important — Accent Handling: This model was trained on text without diacritical marks (accents). For best results, strip accents from your input before inference. Character offsets are preserved, so you can map entities back to the original text.python1import unicodedata 2 3def strip_accents(text: str) -> str: 4 nfc = unicodedata.normalize("NFC", text) 5 nfd = unicodedata.normalize("NFD", nfc) 6 stripped = "".join(ch for ch in nfd if unicodedata.category(ch) != "Mn") 7 return unicodedata.normalize("NFC", stripped) 8 9text = strip_accents(text) # call before passing to the pipeline 10entities = ner(text)
1def redact_pii(text, entities, placeholder='[REDACTED]'):
2 """Replace detected PII with placeholders."""
3 # Sort entities by start position (descending) to preserve offsets
4 sorted_entities = sorted(entities, key=lambda x: x['start'], reverse=True)
5 redacted = text
6 for ent in sorted_entities:
7 redacted = redacted[:ent['start']] + f"[{ent['entity_group']}]" + redacted[ent['end']:]
8 return redacted
9
10# Apply de-identification
11redacted_text = redact_pii(text, entities)
12print(redacted_text)1from transformers import AutoModelForTokenClassification, AutoTokenizer
2import torch
3
4model_name = "OpenMed/OpenMed-PII-Spanish-ClinicalBGE-568M-v1"
5model = AutoModelForTokenClassification.from_pretrained(model_name)
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7
8texts = [
9 "Paciente María López (nacida el 15/03/1985, DNI: 87654321B) fue atendida hoy.",
10 "Contacto: maria.lopez@email.es, Teléfono: +34 612 345 678.",
11]
12
13inputs = tokenizer(texts, return_tensors='pt', padding=True, truncation=True)
14with torch.no_grad():
15 outputs = model(**inputs)
16 predictions = torch.argmax(outputs.logits, dim=-1)1@misc{openmed-pii-2026,
2 title = {OpenMed-PII-Spanish-ClinicalBGE-568M-v1: Spanish PII Detection Model},
3 author = {OpenMed Science},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/OpenMed/OpenMed-PII-Spanish-ClinicalBGE-568M-v1}
7}