Views
No views yet
O: Outside of a named entityB-PER, I-PER: Person namesB-ORG, I-ORG: OrganizationsB-LOC, I-LOC: LocationsB-MISC, I-MISC: Miscellaneous entitiestransformers library:1from transformers import pipeline
2
3# Load the fine-tuned model from Hugging Face Hub
4ner_pipeline = pipeline("ner", model="aren-golazizian/distilbert-ner-finetuned-conll2003")
5
6# Example text for NER
7example_text = "Hugging Face Inc. is based in New York City. Its founder is Thomas Wolf."
8
9# Perform Named Entity Recognition
10results = ner_pipeline(example_text)
11
12# Print results
13for entity in results:
14 print(entity)
15
16
17[
18 {"entity": "B-ORG", "score": 0.99, "index": 1, "word": "Hugging Face Inc.", "start": 0, "end": 18},
19 {"entity": "B-LOC", "score": 0.98, "index": 2, "word": "New York City", "start": 31, "end": 44},
20 {"entity": "B-PER", "score": 0.97, "index": 3, "word": "Thomas Wolf", "start": 60, "end": 71}
21]