Fine-tuned DistilBERT model for Personal Identifiable Information (PII) detection and classification.
1from transformers import AutoTokenizer, AutoModelForTokenClassification
2from transformers import pipeline
3
4# Load model and tokenizer
5model_name = "SoelMgd/bert-pii-detection"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForTokenClassification.from_pretrained(model_name)
8
9# Create NER pipeline
10ner_pipeline = pipeline(
11 "ner",
12 model=model,
13 tokenizer=tokenizer,
14 aggregation_strategy="simple"
15)
16
17# Example usage
18text = "Hi, my name is John Smith and my email is john.smith@company.com"
19entities = ner_pipeline(text)
20print(entities)
The model achieves high performance on PII detection tasks with good precision and recall across different entity types.