CoolFace
Modelpublic

exdsgift/NerGuard-0.3B

sourceHugging Faceopenrailupdated 7mo agoView on Hugging Face
2likes374downloads
Model Card

![Downloads](https://huggingface.co/exdsgift/NerGuard-0.3B) ![GitHub](https://github.com/exdsgift/NerGuard) ![Likes](https://huggingface.co/exdsgift/NerGuard-0.3B) ![License: OpenRAIL](https://huggingface.co/spaces/CompVis/stable-diffusion-license) ![Model Size](https://huggingface.co/exdsgift/NerGuard-0.3B)

NerGuard-0.3B is a multilingual transformer model for Personally Identifiable Information (PII) detection, built on mDeBERTa-v3-base. It performs token-level classification across 20 PII entity types using BIO tagging, covering names, addresses, government IDs, financial data, and contact information across 8 European languages.

Trained on 500K+ samples from AI4Privacy, it achieves F1-macro 99.63% on in-distribution validation. On the out-of-distribution NVIDIA Nemotron-PII benchmark (1,000 samples, 7-system comparison), the base model ranks 4th out of 7 systems on F1-macro and 3rd on Entity-F1 — without any LLM augmentation. For the full hybrid system with entropy-based LLM routing (which ranks 1st on both F1-macro and F1-micro), see the NerGuard GitHub repository.

Note on labels: The model outputs its native AI4Privacy label space (e.g., GIVENNAME, SURNAME, SOCIALNUM). The NerGuard pipeline includes a semantic alignment layer that maps these to benchmark-specific label spaces (e.g., NVIDIA Nemotron-PII uses first_name, ssn).

Supported Entity Types

CategoryEntity Types
PersonGIVENNAME, SURNAME, TITLE
LocationCITY, STREET, BUILDINGNUM, ZIPCODE
Government IDIDCARDNUM, PASSPORTNUM, DRIVERLICENSENUM, SOCIALNUM, TAXNUM
FinancialCREDITCARDNUMBER
ContactEMAIL, TELEPHONENUM
TemporalDATE, TIME
DemographicAGE, SEX, GENDER

Evaluation Results

In-Distribution: AI4Privacy (validation split)

MetricValue
F1 (macro)99.63%
F1 (weighted)99.33%
Accuracy99.26%

Out-of-Distribution: NVIDIA Nemotron-PII (1,000 samples)

Tier 2 evaluation: semantic alignment over 16 comparable entity types. Seven systems compared.

SystemF1-macroF1-microEntity-F1Latency (ms)
NerGuard Hybrid V2 (base + LLM)0.50690.70150.663441
Presidio0.49330.54930.668086
NerGuard Hybrid V10.49430.68620.647531
Piiranha0.47310.65010.619531
NerGuard Base (this model)0.41750.61050.607633
spaCy (encoreweb_trf)0.36070.41750.5527144
dslim/bert-base-NER0.33310.48210.622538

The base model (no LLM) achieves 33 ms median latency. The entropy-gated hybrid adds +8.94 pt F1-macro by routing only uncertain spans (~3% of tokens) to an LLM for disambiguation.

Usage

python
from transformers import pipeline

ner = pipeline(
    "token-classification",
    model="exdsgift/NerGuard-0.3B",
    aggregation_strategy="simple"
)

results = ner("My name is John Smith and my email is john@acme.com")
for entity in results:
    print(f"{entity['word']} -> {entity['entity_group']} ({entity['score']:.2%})")
# John  -> GIVENNAME (99.82%)
# Smith -> SURNAME   (99.71%)
# john@acme.com -> EMAIL (99.54%)

For the full hybrid pipeline with LLM routing and regex validation:

python
from src.inference.tester import PIITester

tester = PIITester(model_path="exdsgift/NerGuard-0.3B")
entities = tester.get_entities("John Smith, SSN: 078-05-1120, email: john@acme.com")

Training Details

ParameterValue
Base modelmicrosoft/mdeberta-v3-base
DatasetAI4Privacy Open PII Masking 500K
Training samples~450K
Max sequence length512 (stride 382)
Learning rate2e-5
Batch size32
Epochs3
Hardware2× NVIDIA A100

Citation

bibtex
@mastersthesis{durante2026nerguard,
  title     = {Engineering a Scalable Multilingual PII Detection System
               with mDeBERTa-v3 and LLM-Based Validation},
  author    = {Durante, Gabriele},
  year      = {2026},
  school    = {University of Verona},
  department = {Department of Computer Science}
}