Views
No views yet
1from transformers import AutoTokenizer, AutoModelForTokenClassification
2from transformers import pipeline
3
4tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
5model = AutoModelForTokenClassification.from_pretrained("PassbyGrocer/bert-ner-conll2003")
6
7nlp = pipeline("ner", model=model, tokenizer=tokenizer)
8example = "My name is Wolfgang and I live in Berlin."
9
10ner_results = nlp(example)
11print(ner_results)
12| Training Loss | Epoch | Step | Validation Loss | Precision | Recall | F1 | Accuracy |
|---|---|---|---|---|---|---|---|
| 0.0844 | 1.0 | 878 | 0.0693 | 0.9029 | 0.9201 | 0.9114 | 0.9806 |
| 0.0216 | 2.0 | 1756 | 0.0559 | 0.9340 | 0.9444 | 0.9391 | 0.9854 |
| 0.0206 | 3.0 | 2634 | 0.0569 | 0.9436 | 0.9447 | 0.9442 | 0.9863 |
| 0.0141 | 4.0 | 3512 | 0.0634 | 0.9369 | 0.9488 | 0.9428 | 0.9860 |
| 0.0176 | 5.0 | 4390 | 0.0631 | 0.9414 | 0.9493 | 0.9454 | 0.9866 |