Hausa Named Entity Recognition (from mbeukman)

Description

Pretrained Named Entity Recognition model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. xlm-roberta-base-finetuned-ner-hausa is a Hausa model orginally trained by mbeukman.

Predicted Entities

PER, ORG, LOC, DATE

Download Copy S3 URI

How to use

documentAssembler = DocumentAssembler() \
        .setInputCol("text") \
        .setOutputCol("document")

sentenceDetector = SentenceDetectorDLModel.pretrained("sentence_detector_dl", "xx")\
       .setInputCols(["document"])\
       .setOutputCol("sentence")

tokenizer = Tokenizer() \
    .setInputCols("sentence") \
    .setOutputCol("token")

tokenClassifier = XlmRoBertaForTokenClassification.pretrained("xlmroberta_ner_xlm_roberta_base_finetuned_ner_hausa","ha") \
    .setInputCols(["sentence", "token"]) \
    .setOutputCol("pos")

pipeline = Pipeline(stages=[documentAssembler, sentenceDetector, tokenizer, tokenClassifier])

data = spark.createDataFrame([["Ina son Spark NLP"]]).toDF("text")

result = pipeline.fit(data).transform(data)
val documentAssembler = new DocumentAssembler() 
          .setInputCol("text") 
          .setOutputCol("document")

val sentenceDetector = SentenceDetectorDLModel.pretrained("sentence_detector_dl", "xx")
       .setInputCols(Array("document"))
       .setOutputCol("sentence")

val tokenizer = new Tokenizer() 
    .setInputCols(Array("sentence"))
    .setOutputCol("token")

val tokenClassifier = XlmRoBertaForTokenClassification.pretrained("xlmroberta_ner_xlm_roberta_base_finetuned_ner_hausa","ha") 
    .setInputCols(Array("sentence", "token")) 
    .setOutputCol("pos")

val pipeline = new Pipeline().setStages(Array(documentAssembler,sentenceDetector, tokenizer, tokenClassifier))

val data = Seq("Ina son Spark NLP").toDF("text")

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("ha.ner.xlmr_roberta.base_finetuned_hausa.by_mbeukman").predict("""Ina son Spark NLP""")

Model Information

Model Name: xlmroberta_ner_xlm_roberta_base_finetuned_ner_hausa
Compatibility: Spark NLP 5.4.0+
License: Open Source
Edition: Official
Input Labels: [document, token]
Output Labels: [ner]
Language: ha
Size: 774.7 MB

References

References

  • https://huggingface.co/mbeukman/xlm-roberta-base-finetuned-ner-hausa
  • https://arxiv.org/abs/2103.11811
  • https://github.com/Michael-Beukman/NERTransfer
  • https://www.apache.org/licenses/LICENSE-2.0
  • https://github.com/Michael-Beukman/NERTransfer
  • htt