Skip to content

How to load the model uploaded to HF using transformers? #9

Description

@AMR-KELEG

Hi,

Thanks for your efforts developing the model.
I am trying to load the NER model, but I am getting strange results as an output. Do you have any thoughts for why that's the case?

  • Code:
from transformers import pipeline
from transformers import AutoTokenizer, AutoModelForTokenClassification

NER_model_name = "SinaLab/ArabicWojood-FlatNER"
tokenizer = AutoTokenizer.from_pretrained(NER_model_name)
model = AutoModelForTokenClassification.from_pretrained(NER_model_name)

ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer)

def get_ne(text):
    output = ner_pipeline(text)
    return {"text": text, "entities": output}

get_ne("أنا اسمي محمد")
  • Output:
{'text': 'أنا اسمي محمد',
 'entities': [{'entity': 'B-FAC',
   'score': 0.111766666,
   'index': 1,
   'word': 'انا',
   'start': 0,
   'end': 3},
  {'entity': 'B-FAC',
   'score': 0.08029653,
   'index': 2,
   'word': 'اسمي',
   'start': 4,
   'end': 8},
  {'entity': 'B-FAC',
   'score': 0.072174296,
   'index': 3,
   'word': 'محمد',
   'start': 9,
   'end': 13}]}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions