CoolFace
Modelpublic

kierandesmond/spanish-gdpr-pii-ner-v8

sourceHugging Facecc-by-4.0updated 4mo agoView on Hugging Face
0likes16downloads
Model Card

spanish-gdpr-pii-ner-v8

Spanish GDPR / LOPDGDD PII Named Entity Recognition model (XLM-RoBERTa-base, 28 entity types / 57 BIO labels). Continued fine-tune of `kierandesmond/spanish-gdpr-pii-ner-v6` using a real-data-first mixture, targeting the special-category (Art. 9 RGPD) entities that v6 detected poorly, while protecting the entities v6 already handled well.

Why v8 (what changed vs v6)

v6 was strong on clinical/identifier PII but weak on several GDPR special-category entities and produced false positives on negatives. v8 fixes these using real Spanish institutional/clinical corpora (health/genetic data) plus synthetic top-ups for zero-coverage special categories, and hard negatives to cut false positives. Training started from v6 weights with a conservative learning rate (8e-6) to avoid catastrophic forgetting; the 57-label schema is preserved verbatim.

Results — v6 → v8 (identical evaluation methodology)

Independent probe battery (per-entity detection rate)

Entityv6**v8**
SEXUAL_ORIENTATION16.7%100%
HEALTH_DATA50.0%100%
CRIMINAL_RECORD83.3%83.3%
GENETIC_DATA80.0%80.0%
UNION_MEMBERSHIP100%100%
BIOMETRIC_DATA80.0%80.0%
POLITICAL_OPINION100%75.0%
RELIGIOUS_BELIEF100%100%
ETHNIC_ORIGIN100%100%
PERSONNAME / EMAIL / PHONEES / ADDRESS_ES100%100%
DNI / NIE / URL100%100%
NEGATIVE (no false positive)70.0%90.0%
Battery overall76.7%91.7%

MEDDOCAN test (clinical-PII regression guard)

Measured by mapping MEDDOCAN's native entity types onto this model's GDPR schema (this model emits 28 GDPR entities, not MEDDOCAN's 21 tags, so absolute numbers differ from MEDDOCAN-native scoring). On identical methodology, v8 does not regress — it improves:

MEDDOCAN F1 (mapped)v6**v8**
All mappable entities0.73770.7690
Clean 1:1 subset (PERSONNAME, EMAIL, PHONEES, DATEOFBIRTH, ADDRESS_ES)0.75390.7719

Confusion (sensitive pairs)

The v6 SEXUALORIENTATION→RELIGIOUSBELIEF confusion (5/6 misclassified in v6) is eliminated in v8 (0/6). POLITICALOPINION→UNIONMEMBERSHIP leakage is also removed. GENETICDATA shows mild overlap with HEALTHDATA (both tags emitted on some genetic mentions), which is acceptable under Art. 9 (genetic data is a subset of health data).

Full per-entity reports, CSVs and the confusion-matrix image are in `kierandesmond/spanish-gdpr-pii-ner-v8-validation`.

Training data sources

Real-data-first mixture (~7,600 sentences, shuffled/interleaved; 0 BIO errors):

SourceRoleMapped entity
BSC-NLP4BIA/bsc-bio-distemist-ner (DisTEMIST)real clinical disease NERHEALTH_DATA
Rodrigo1771/symptemist-ner (SympTEMIST)real clinical symptom NER (informal phrasing)HEALTH_DATA
PlanTL-GOB-ES/pharmaconer (PROTEINAS)real clinical genes/proteinsGENETIC_DATA
PlanTL-GOB-ES/CoNLL-NERC-es (filtered)real Spanish news, party + affiliation contextPOLITICAL_OPINION
bigbio/meddocan (train)anchor — preserves clinical PII (locked entities)PERSONNAME / EMAIL / PHONEES / ADDRESSES / DATEOF_BIRTH / NUSS
Synthetic templateszero-coverage special categoriesSEXUALORIENTATION, CRIMINALRECORD, UNIONMEMBERSHIP, BIOMETRICDATA, ETHNICORIGIN, RELIGIOUSBELIEF
Contrastive pairs + hard negativesconfusion-boundary fixes + false-positive reduction—

Training procedure

  • —Base: kierandesmond/spanish-gdpr-pii-ner-v6 (XLM-RoBERTa-base, 57 BIO labels preserved verbatim)
  • —learningrate: 8e-6, numtrainepochs: 3, warmupratio: 0.1, weight_decay: 0.01
  • —perdevicetrainbatchsize: 16, gradientaccumulationsteps: 2 (effective batch 32)
  • —max_length: 256, bf16, label-first-subtoken alignment
  • —Final held-out (mixed corpus) seqeval F1: 0.498 — note this held-out set is dominated by long clinical HEALTH_DATA spans where exact-span seqeval is strict; real-world per-entity detection is reflected by the battery above.

Usage

python
from transformers import AutoTokenizer, AutoModelForTokenClassification
import torch

model_id = "kierandesmond/spanish-gdpr-pii-ner-v8"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForTokenClassification.from_pretrained(model_id).eval()

text = "El reclamante declaró ser homosexual y está afiliado a CCOO."
words = text.split()
enc = tok(words, is_split_into_words=True, return_tensors="pt", truncation=True, max_length=256)
with torch.no_grad():
    pred = model(**enc).logits.argmax(-1)[0].tolist()
wids = enc.word_ids(0); prev = None
for i, w in enumerate(wids):
    if w is None or w == prev: prev = w; continue
    lab = model.config.id2label[pred[i]]
    if lab != "O": print(words[w], "->", lab)
    prev = w

Limitations

  • —Special-category entities (SEXUALORIENTATION, CRIMINALRECORD, BIOMETRICDATA, UNIONMEMBERSHIP) are reinforced partly with synthetic templates; coverage of phrasings outside those templates may be lower. Recall is prioritized over precision on sensitive entities by design (a missed PII is a compliance risk).
  • —MEDDOCAN-native F1 is not directly reported because the model emits a 28-entity GDPR schema rather than MEDDOCAN's 21 tags; the regression guard above is computed on a consistent mapping.

<!-- ml-intern-provenance -->

Generated by ML Intern

This model repository was generated by ML Intern, an agent for machine learning research and development on the Hugging Face Hub.