Downloads · 30 days
13
8% of all-time downloads
kierandesmond/spanish-gdpr-pii-ner-v9
spanish-gdpr-pii-ner-v9 is a token classification model from kierandesmond. Use it when you need labels on individual words, such as names. It is set up for transformers. The card lists the license as cc-by-4.0.
Token-classification (NER) model that detects GDPR / LOPDGDD-regulated personal data in Spanish text, including standard identifiers and GDPR Art. 9 special-category data (health, genetic, biometric, ethnic, political…
Downloads · 30 days
13
8% of all-time downloads
All-time downloads
159
Public
Parameters
277M
6.7 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.1 GB · 98%
From the Hugging Face model README
Token-classification (NER) model that detects GDPR / LOPDGDD-regulated personal data in Spanish text, including standard identifiers and GDPR Art. 9 special-category data (health, genetic, biometric, ethnic, political, religious, union membership, sexual orientation, criminal records).
kierandesmond/spanish-gdpr-pii-ner-v8 (continued fine-tuning, NOT trained from scratch)XLMRobertaForTokenClassification (xlm-roberta-base, ~277M params)v9 was driven by a large, statistically-meaningful held-out evaluation set (7,304 examples, 200–336 per entity, with hard negatives) — replacing the tiny n=1–6 battery used for v6/v8 that masked real weaknesses. Re-scoring v8 on this honest eval exposed gaps (e.g. SIP_CARD 0.5%, ETHNIC_ORIGIN 40%, GENETIC_DATA 70%) that the old battery rated as 80–100%.
v9 adds targeted real + synthetic training data for the weak entities and hard negatives for the false-positive traps, while preserving locked entities.
| Metric | v8 | v9 |
|---|---|---|
| Macro positive pass-rate (avg over 28 entities) | 87.3% | 99.55% |
| Macro negative pass-rate (hard negatives + false-positive guards) | 76.6% | 100% |
| Lowest single entity | 0.5% (SIP_CARD) | 94.6% (GENETIC_DATA) |
Every one of the 28 entity types scores ≥ 90%. Biggest gains vs v8: SIP_CARD 0.5%→100%, ETHNIC_ORIGIN 40%→100%, GENETIC_DATA 70%→94.6%, CREDIT_CARD 71%→100%, BANK_ACCOUNT 80%→100%, POLITICAL_OPINION 81%→97.6%, UNION_MEMBERSHIP 82%→100%, BIOMETRIC_DATA 82%→100%, USERNAME 85%→100%, SEXUAL_ORIENTATION 88%→100%, PERSON_NAME 90%→100%. (One minor trade-off: HEALTH_DATA 99.4%→97.0%, still well above bar.)
Confusion guards are clean: SEXUAL_ORIENTATION↔RELIGIOUS_BELIEF = 0 confusion; POLITICAL_OPINION↔UNION_MEMBERSHIP = 0 confusion.
Full per-entity numbers, comparison CSV, and confusion matrix:
kierandesmond/spanish-gdpr-pii-ner-v9-validation.
Real corpora (parquet-native, no script execution):
BSC-NLP4BIA/bsc-bio-distemist-ner (ENFERMEDAD, train split)PlanTL-GOB-ES/pharmaconer (PROTEINAS, train split)bigbio/meddocan (char-offset → BIO, train split) for catastrophic-forgetting protectionSynthetic (special categories have no labeled Spanish corpus) — register-varied templates (legal / informal / clinical), contrastive minimal pairs for confusion guards, hard negatives, and regex-generated structured identifiers (DNI/NIE/NIF/CIF/IBAN/SIP/credit-card/etc.). Anti-leakage: synthetic eval uses template families disjoint from training; real-corpus eval uses validation/test splits never seen in training.
PERSON_NAME, EMAIL, PHONE_ES, ADDRESS_ES, DATE_OF_BIRTH, IP_ADDRESS, URL, USERNAME, DNI, NIE, NIF, CIF, NUSS, IBAN_ES, SIP_CARD, PASSPORT_ES, VEHICLE_PLATE_ES, CREDIT_CARD, BANK_ACCOUNT, HEALTH_DATA, GENETIC_DATA, BIOMETRIC_DATA, ETHNIC_ORIGIN, POLITICAL_OPINION, RELIGIOUS_BELIEF, UNION_MEMBERSHIP, SEXUAL_ORIENTATION, CRIMINAL_RECORD.
from transformers import pipeline
ner = pipeline("token-classification", model="kierandesmond/spanish-gdpr-pii-ner-v9",
aggregation_strategy="simple")
ner("El trabajador está afiliado a CCOO y fue diagnosticado de diabetes mellitus tipo 2 .")