Views
No views yet
| Category | Description |
|---|---|
account_number | Financial account identifiers |
private_address | Physical and mailing addresses |
private_email | Email addresses |
private_person | Personal names |
private_phone | Phone numbers |
private_url | URLs and web addresses |
private_date | Birth dates and personal dates |
secret | API keys, passwords, credentials |
pip install transformers torch1from transformers import pipeline
2
3detector = pipeline("token-classification", model="comethrusws/tegmen", aggregation_strategy="simple")
4
5text = "Contact John Smith at john.smith@email.com"
6results = detector(text)
7
8for item in results:
9 print(f"Found: {item['word']} ({item['entity_group']})")1import torch
2from transformers import AutoModelForTokenClassification, AutoTokenizer
3
4tokenizer = AutoTokenizer.from_pretrained("comethrusws/tegmen")
5model = AutoModelForTokenClassification.from_pretrained("comethrusws/tegmen")
6
7text = "My name is Alice and my email is alice@example.com"
8inputs = tokenizer(text, return_tensors="pt")
9
10with torch.no_grad():
11 outputs = model(**inputs)
12
13predictions = outputs.logits.argmax(dim=-1)
14labels = [model.config.id2label[p.item()] for p in predictions[0]]
15print(labels)