Portuguese DistilBertForQuestionAnswering Cased model (from mrm8488)

Description

Pretrained DistilBERT Question Answering model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. distilbert-multi-finedtuned-squad-pt is a Portuguese model originally trained by mrm8488.

Download Copy S3 URI

How to use

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

spanClassifier = DistilBertForQuestionAnswering.pretrained("distilbert_qa_finetuned_squad","pt") \
    .setInputCols(["document_question", "document_context"]) \
    .setOutputCol("answer")\
    .setCaseSensitive(True)
    
pipeline = Pipeline(stages=[documentAssembler, spanClassifier])

data = spark.createDataFrame([["PUT YOUR 'QUESTION' STRING HERE?", "PUT YOUR 'CONTEXT' STRING HERE"]]).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 = DistilBertForQuestionAnswering.pretrained("distilbert_qa_finetuned_squad","pt") 
    .setInputCols(Array("document", "token"))
    .setOutputCol("answer")
    .setCaseSensitive(true)

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

val data = Seq("PUT YOUR 'QUESTION' STRING HERE?", "PUT YOUR 'CONTEXT' STRING HERE").toDS.toDF("question", "context")

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("pt.answer_question.distil_bert.squad.finetuned").predict("""PUT YOUR 'QUESTION' STRING HERE?|||"PUT YOUR 'CONTEXT' STRING HERE""")

Model Information

Model Name: distilbert_qa_finetuned_squad
Compatibility: Spark NLP 4.0.0+
License: Open Source
Edition: Official
Input Labels: [document_question, document_context]
Output Labels: [answer]
Language: pt
Size: 505.7 MB
Case sensitive: true
Max sentence length: 512

References

https://huggingface.co/mrm8488/distilbert-multi-finedtuned-squad-pt