marefa-ner / READMR.md
bakrianoo's picture
upload the first version
7c71c1b
|
raw
history blame
1.93 kB
metadata
language: ar
datasets:
  - Marefa-NER

Marefa NER نموذج المعرفة لتصنيف أجزاء النص

Model description

Marefa-NER is a Large Arabic NER model which built on completely new dataset and targets to extract up to 9 different types of entities

Person, Location, Organization, Nationality, Job, Product, Event, Time, Art-Work

نموذج المعرفة لتصنيف أجزاء النص. نموذج جديد كليا من حيث البيانات المستخدمة في تدريب النموذج. كذلك يستهدف النموذج تصنيف حتى 9 أنواع مختلفة من أجزاء النص

شخص - مكان - منظمة - جنسية - وظيفة - منتج - حدث - توقيت - عمل إبداعي

How to use كيف تستخدم النموذج

Install transformers

$ pip3 install transformers==4.3.0

If you are using Google Colab, please restart your runtime after installing the packages.


from transformers import AutoTokenizer, AutoModelForTokenClassification
from transformers import pipeline

# ===== import the model
m_name = "marefa-nlp/marefa-ner"
tokenizer = AutoTokenizer.from_pretrained(m_name)
model = AutoModelForTokenClassification.from_pretrained(m_name)

# ===== build the NER pipeline
nlp = pipeline("ner", model=model, tokenizer=tokenizer, grouped_entities=True)

# ===== extract the entities from a sample text
example = 'قاد عمر المختار القوات في ليبيا ضد الجيش الإيطالي'
ner_results = nlp(example)

# ===== print the ner_results
for ent in ner_results:
  print(ent["word"], '->' ,ent['entity_group'], " # score:", "%.2f" % ent['score'])
  
#####
# عمر المختار -> person  # score: 1.00
# ليبيا -> location  # score: 0.99
# الجيش الإيطالي -> organization  # score: 0.99
####