CoolFace
Modelpublic

onnx-community/bert-small-pii-detection-ONNX

sourceHugging Faceapache-2.0updated 6mo agoView on Hugging Face
0likes2.9kdownloads
Model Card

bert-small-pii-detection (ONNX)

This is an ONNX version of gravitee-io/bert-small-pii-detection. It was automatically converted and uploaded using this Hugging Face Space.

Usage with Transformers.js

See the pipeline documentation for token-classification: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.TokenClassificationPipeline


gravitee-io/bert-small-pii-detection ๐Ÿš€

A more accurate PII detector fine-tuned from `prajjwal1/bert-small` on the datasets described in metatada.

About the dataset:

We combined various datasets in order to cover wide range of document formats like:

  1. 1.JSON,
  2. 2.HTML,
  3. 3.XML,
  4. 4.SQL
  5. 5.Documents

Label Set

AGE, COORDINATE, CREDIT_CARD, DATE_TIME, EMAIL_ADDRESS, FINANCIAL, IBAN_CODE, IMEI,
IP_ADDRESS, LOCATION, MAC_ADDRESS, NRP, ORGANIZATION, PASSWORD, PERSON, PHONE_NUMBER,
TITLE, URL, US_BANK_NUMBER, US_DRIVER_LICENSE, US_ITIN, US_LICENSE_PLATE, US_PASSPORT, US_SSN

How to Use

Quick start (pipeline)

python
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline

repo = "gravitee-io/bert-small-pii-detection"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForTokenClassification.from_pretrained(repo)

pipe = pipeline("token-classification", model=model, tokenizer=tok, aggregation_strategy="simple")
text = ""
pipe(text)

Evaluation

Metric: precision / recall / F1 per entity, micro/macro averages

EntityPrecisionRecallF1-scoreSupport
AGE0.98980.88580.9349219
COORDINATE0.96270.87380.9161325
CREDIT_CARD0.92730.88700.9067115
DATE_TIME0.85980.73640.79333255
EMAIL_ADDRESS0.94280.89410.9178387
FINANCIAL0.98620.95650.9711299
IBAN_CODE0.95770.92520.9412147
IMEI0.98850.96630.977389
IP_ADDRESS0.93380.88120.9068160
LOCATION0.88490.82220.85244264
MAC_ADDRESS0.98891.00000.994489
NRP1.00000.98180.9908494
ORGANIZATION0.74540.66880.70513551
PASSWORD0.83840.81370.8259102
PERSON0.91230.88260.89724454
PHONE_NUMBER0.94620.81990.8785322
TITLE0.98870.97340.9810451
URL1.00000.97870.9892188
USBANKNUMBER1.00000.95790.978595
USDRIVERLICENSE0.91670.91670.9167120
US_ITIN0.96590.87630.918997
USLICENSEPLATE1.00000.90000.947490
US_PASSPORT0.92000.92000.9200100
US_SSN0.97440.95800.9661119
micro avg0.88040.81410.846019532
macro avg0.94290.89480.917819532
weighted avg0.87850.81410.844619532

Intended Uses & Limitations

Use this model for:

  • โ€”Low resource environmens
  • โ€”Redacting PII in customer support logs, dev/test environments, API traces and articles
  • โ€”Real-time hints in form fields or data entry systems

Limitations:

  • โ€”English-focused; other languages will degrade
  • โ€”Domain drift is real: audit on your own data

Citation

If you use the model, please consider citing the papers:

@misc{bhargava2021generalization,
      title={Generalization in NLI: Ways (Not) To Go Beyond Simple Heuristics},
      author={Prajjwal Bhargava and Aleksandr Drozd and Anna Rogers},
      year={2021},
      eprint={2110.01518},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

@article{DBLP:journals/corr/abs-1908-08962,
  author    = {Iulia Turc and
               Ming{-}Wei Chang and
               Kenton Lee and
               Kristina Toutanova},
  title     = {Well-Read Students Learn Better: The Impact of Student Initialization
               on Knowledge Distillation},
  journal   = {CoRR},
  volume    = {abs/1908.08962},
  year      = {2019},
  url       = {http://arxiv.org/abs/1908.08962},
  eprinttype = {arXiv},
  eprint    = {1908.08962},
  timestamp = {Thu, 29 Aug 2019 16:32:34 +0200},
  biburl    = {https://dblp.org/rec/journals/corr/abs-1908-08962.bib},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}

@online{WinNT,
  author = {Benjamin Kilimnik},
  title = {{Privy} Synthetic PII Protocol Trace Dataset},
  year = 2022,
  url = {https://huggingface.co/datasets/beki/privy},
}

@online{gretel2023,
  author = {Gretel.ai},
  title = {{Synthetic PII Finance Multilingual Dataset}},
  year = 2023,
  url = {https://huggingface.co/datasets/gretelai/synthetic_pii_finance_multilingual},
}

@inproceedings{tjong-kim-sang-de-meulder-2003-introduction,
    title = "Introduction to the CoNLL-2003 Shared Task: Language-Independent Named Entity Recognition",
    author = "Tjong Kim Sang, Erik F. and De Meulder, Fien",
    booktitle = "Proceedings of the Seventh Conference on Natural Language Learning at HLT-NAACL 2003",
    year = "2003",
    url = "https://aclanthology.org/W03-0419",
}
}