Views
No views yet
| Metric | Score |
|---|---|
| Accuracy | 92.0% |
| F1 (weighted) | 91.0% |
| Training Time | 43 seconds (MI300X GPU) |
1from peft import PeftModel
2from transformers import AutoModelForTokenClassification, AutoTokenizer
3
4# Load model
5base_model = AutoModelForTokenClassification.from_pretrained(
6 "jhu-clsp/mmBERT-base", num_labels=35 # O + 17 entity types × 2 (B/I)
7)
8model = PeftModel.from_pretrained(base_model, "llm-semantic-router/mmbert-pii-detector-lora")
9tokenizer = AutoTokenizer.from_pretrained("jhu-clsp/mmBERT-base")
10
11# Detect PII
12text = "Contact John Smith at john.smith@email.com or call 555-123-4567"
13inputs = tokenizer(text.split(), is_split_into_words=True, return_tensors="pt")
14outputs = model(**inputs)
15predictions = outputs.logits.argmax(-1)
16
17# Map predictions to labels
18# ... (see full example in repository)| Entity Type | Description |
|---|---|
| PERSON | Full names |
| EMAIL_ADDRESS | Email addresses |
| PHONE_NUMBER | Phone numbers (various formats) |
| STREET_ADDRESS | Physical addresses |
| CREDIT_CARD | Credit card numbers |
| US_SSN | US Social Security Numbers |
| IP_ADDRESS | IP addresses |
| DATE_TIME | Dates and times |
| URL | Web URLs |
| ORGANIZATION | Company/org names |