Get all labels / entity groups available to a model
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 areORGandPER. How to find all the labels / entitiy groups available?Kindly advise.
2023-11-30T13:20:29Z
I found this which was semi-helpful although there’s not really a great explanation for them. This was in the config.json in the root of the model fileshuggingface.coconfig.json · dslim/bert-base-NER-uncased at mainWe’re on a journey to advance and democratize artificial intelligence through open source and open science.