BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
Paper
•
1810.04805
•
Published
•
26
This is a chat fine-tuned version of google-bert/bert-base-uncased, designed to perform Named Entity Recognition on a text sentence imput.
google-bert/bert-base-uncasedModel can be used to recognize Named Entities in text.
from transformers import AutoTokenizer, AutoModelForTokenClassification
from transformers import pipeline
tokenizer = AutoTokenizer.from_pretrained("sartajbhuvaji/bert-named-entity-recognition")
model = AutoModelForTokenClassification.from_pretrained("sartajbhuvaji/bert-named-entity-recognition")
nlp = pipeline("ner", model=model, tokenizer=tokenizer)
example = "My name is Wolfgang and I live in Berlin"
ner_results = nlp(example)
print(ner_results)
[
{
"end": 19,
"entity": "B-PER",
"index": 4,
"score": 0.99633455,
"start": 11,
"word": "wolfgang"
},
{
"end": 40,
"entity": "B-LOC",
"index": 9,
"score": 0.9987465,
"start": 34,
"word": "berlin"
}
]
| Abbreviation | Description |
|---|---|
| O | Outside of a named entity |
| B-MISC | Beginning of a miscellaneous entity right after another miscellaneous entity |
| I-MISC | Miscellaneous entity |
| B-PER | Beginning of a person's name right after another person's name |
| I-PER | Person's name |
| B-ORG | Beginning of an organization right after another organization |
| I-ORG | Organization |
| B-LOC | Beginning of a location right after another location |
| I-LOC | Location |
| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| LOC | 0.91 | 0.93 | 0.92 | 1668 |
| MISC | 0.76 | 0.81 | 0.78 | 702 |
| ORG | 0.87 | 0.88 | 0.88 | 1661 |
| PER | 0.98 | 0.97 | 0.97 | 1617 |
| Micro Avg | 0.90 | 0.91 | 0.91 | 5648 |
| Macro Avg | 0.88 | 0.90 | 0.89 | 5648 |
| Weighted Avg | 0.90 | 0.91 | 0.91 | 5648 |
Base model
google-bert/bert-base-uncased