CoolFace
Modelpublic

CordwainerSmith/GolemPII-v1

sourceHugging Facemitupdated 2y agoView on Hugging Face
1likes339downloads
Model Card

GolemPII-v1 - Hebrew PII Detection Model

This model is trained to detect personally identifiable information (PII) in Hebrew text. While based on the multilingual XLM-RoBERTa model, it has been specifically fine-tuned on Hebrew data to achieve high accuracy in identifying and classifying various types of PII.

Model Details

  • —Based on xlm-roberta-base
  • —Fine-tuned on the GolemGuard: Hebrew Privacy Information Detection Corpus
  • —Optimized for token classification tasks in Hebrew text

Intended Uses & Limitations

This model is intended for:

  • —Privacy Protection: Detecting and masking PII in Hebrew text to protect individual privacy.
  • —Data Anonymization: Automating the process of de-identifying Hebrew documents in legal, medical, and other sensitive contexts.
  • —Research: Supporting research in Hebrew natural language processing and PII detection.

Training Parameters

  • —Batch Size: 32
  • —Learning Rate: 2e-5 with linear warmup and decay.
  • —Optimizer: AdamW
  • —Hardware: Trained on a single NVIDIA A100GPU.

Dataset Details

Performance Metrics

Final Evaluation Results

eval_loss: 0.000729
eval_precision: 0.9982
eval_recall: 0.9982
eval_f1: 0.9982
eval_accuracy: 0.999795

Detailed Performance by Label

LabelPrecisionRecallF1-ScoreSupport
BANKACCOUNTNUM1.00001.00001.00004847
CC_NUM1.00001.00001.0000234
CC_PROVIDER1.00001.00001.0000242
CITY0.99970.99950.999612237
DATE0.99970.99980.999711943
EMAIL0.99981.00000.999913235
FIRST_NAME0.99370.99380.993717888
ID_NUM0.99991.00001.000010577
LAST_NAME0.99280.99210.992515655
PHONE_NUM1.00000.99980.999920838
POSTAL_CODE0.99980.99990.999913321
STREET0.99990.99990.999914032
micro avg0.99820.99820.9982135049
macro avg0.99880.99870.9988135049
weighted avg0.99820.99820.9982135049

Training Progress

EpochTraining LossValidation LossPrecisionRecallF1Accuracy
10.0058000.0024870.9931090.9936780.9933930.999328
20.0017000.0013850.9954690.9959470.9957080.999575
30.0012000.0009460.9971590.9974870.9973230.999739
40.0009000.0008960.9976260.9978680.9977470.999750
50.0006000.0007290.9979810.9981910.9980860.999795

Model Architecture

The model is based on the FacebookAI/xlm-roberta-base architecture, a transformer-based language model pre-trained on a massive multilingual dataset. No architectural modifications were made to the base model during fine-tuning.

Usage

python
import torch
from transformers import AutoTokenizer, AutoModelForTokenClassification

tokenizer = AutoTokenizer.from_pretrained("{repo_id}")
model = AutoModelForTokenClassification.from_pretrained("{repo_id}")

# Example text (Hebrew)
text = "שלום, שמי דוד כהן ואני גר ברחוב הרצל 42 בתל אביב. הטלפון שלי הוא 050-1234567"

# Tokenize and get predictions
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
with torch.no_grad():
    outputs = model(**inputs)
    predictions = torch.argmax(outputs.logits, dim=2)

# Convert predictions to labels
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
labels = [model.config.id2label[t.item()] for t in predictions[0]]

# Print results (excluding special tokens and non-entity labels)
for token, label in zip(tokens, labels):
    if label != "O" and not token.startswith("##"):
        print(f"Token: {token}, Label: {label}")

License

The GolemPII-v1 model is released under MIT License with the following additional terms:

MIT License

Copyright (c) 2024 Liran Baba

Permission is hereby granted, free of charge, to any person obtaining a copy
of this dataset and associated documentation files (the "Dataset"), to deal
in the Dataset without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Dataset, and to permit persons to whom the Dataset is
furnished to do so, subject to the following conditions:

1. The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Dataset.

2. Any academic or professional work that uses this Dataset must include an 
appropriate citation as specified below.

THE DATASET IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE DATASET OR THE USE OR OTHER DEALINGS IN THE
DATASET.

How to Cite

If you use this model in your research, project, or application, please include the following citation:

For informal usage (e.g., blog posts, documentation):

GolemPII-v1 model by Liran Baba (https://huggingface.co/CordwainerSmith/GolemPII-v1)