Huggingface RoBERTa model implementation for NER on conll2003 dataset.
1. Importing data using Huggingface Dataset
2. Tokenisation of sentences
3. Importing pre-trained model from huggingface hub
4. Training the model using Trainer Fuction
5. Inference using Huggingface Pipeline
from transformers import pipeline
nlp = pipeline("ner", model=model_, tokenizer=tokenizer)
example = "My name is Wolfgang and I live in Berlin"
ner_results = nlp(example)
print(ner_results)
Ouput
[{'entity': 'B-PER', 'score': 0.84195936, 'index': 4, 'word': 'wolfgang', 'start': 11, 'end': 19}, {'entity': 'B-LOC', 'score': 0.9583987, 'index': 9, 'word': 'berlin', 'start': 34, 'end': 40}]
https://arshad-kazi.com/ner-using-hugging-face-transformers/