Persian XlmRoBertaForQuestionAnswering model (from m3hrdadfi)

Description

Pretrained Question Answering model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. xlmr-large-qa-fa is a Persian model originally trained by m3hrdadfi.

Download Copy S3 URI

How to use

documentAssembler = MultiDocumentAssembler() \
.setInputCols(["question", "context"]) \
.setOutputCols(["document_question", "document_context"])

spanClassifier = XlmRoBertaForQuestionAnswering.pretrained("xlmroberta_qa_xlmr_large","fa") \
.setInputCols(["document_question", "document_context"]) \
.setOutputCol("answer")\
.setCaseSensitive(True)

pipeline = Pipeline(stages=[documentAssembler, spanClassifier])

data = spark.createDataFrame([["اسم من چیست؟", "نام من کلارا است و من در برکلی زندگی می کنم."]]).toDF("question", "context")

result = pipeline.fit(data).transform(data)
val documentAssembler = new MultiDocumentAssembler() 
.setInputCols(Array("question", "context")) 
.setOutputCols(Array("document_question", "document_context"))

val spanClassifer = XlmRoBertaForQuestionAnswering.pretrained("xlmroberta_qa_xlmr_large","fa") 
.setInputCols(Array("document", "token")) 
.setOutputCol("answer")
.setCaseSensitive(true)

val pipeline = new Pipeline().setStages(Array(documentAssembler, spanClassifier))

val data = Seq("اسم من چیست؟", "نام من کلارا است و من در برکلی زندگی می کنم.").toDF("question", "context")

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("fa.answer_question.xlmr_roberta.large").predict("""اسم من چیست؟|||"نام من کلارا است و من در برکلی زندگی می کنم.""")

Model Information

Model Name: xlmroberta_qa_xlmr_large
Compatibility: Spark NLP 4.0.0+
License: Open Source
Edition: Official
Input Labels: [document_question, document_context]
Output Labels: [answer]
Language: fa
Size: 1.9 GB
Case sensitive: true
Max sentence length: 512

References

  • https://huggingface.co/m3hrdadfi/xlmr-large-qa-fa
  • https://github.com/sajjjadayobi/PersianQA
  • https://github.com/m3hrdadfi