I have the following code to get the named entity values from a given text:
from transformers import AutoTokenizer, AutoModelForTokenClassification
from transformers import pipeline
tokenizer = AutoTokenizer.from_pretrained("Davlan/distilbert-base-multilingual-cased-ner-hrl")
model = AutoModelForTokenClassification.from_pretrained("Davlan/distilbert-base-multilingual-cased-ner-hrl")
nlp = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="max")
example = "My name is Johnathan Smith and I work at Apple"
ner_results = nlp(example)
print(ner_results)
The following is the output:
[{'end': 26,
'entity_group': 'PER',
'score': 0.9994689,
'start': 11,
'word': 'Johnathan Smith'},
{'end': 46,
'entity_group': 'ORG',
'score': 0.9983876,
'start': 41,
'word': 'Apple'}]
In the above example the labels / entitiy groups are ORG
and PER
. How to find all the labels / entitiy groups available?
Kindly advise.