Description
Pretrained RobertaForQuestionAnswering model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. longformer-base-4096-spanish-finetuned-squad
is a Spanish model originally trained by mrm8488
.
How to use
Document_Assembler = MultiDocumentAssembler()\
.setInputCols(["question", "context"])\
.setOutputCols(["document_question", "document_context"])
Question_Answering = RoBertaForQuestionAnswering.pretrained("roberta_qa_longformer_base_4096_spanish_finetuned_squad","es")\
.setInputCols(["document_question", "document_context"])\
.setOutputCol("answer")\
.setCaseSensitive(True)
pipeline = Pipeline(stages=[Document_Assembler, Question_Answering])
data = spark.createDataFrame([["What's my name?","My name is Clara and I live in Berkeley."]]).toDF("question", "context")
result = pipeline.fit(data).transform(data)
val Document_Assembler = new MultiDocumentAssembler()
.setInputCols(Array("question", "context"))
.setOutputCols(Array("document_question", "document_context"))
val Question_Answering = RoBertaForQuestionAnswering.pretrained("roberta_qa_longformer_base_4096_spanish_finetuned_squad","es")
.setInputCols(Array("document_question", "document_context"))
.setOutputCol("answer")
.setCaseSensitive(True)
val pipeline = new Pipeline().setStages(Array(Document_Assembler, Question_Answering))
val data = Seq("What's my name?","My name is Clara and I live in Berkeley.").toDS.toDF("question", "context")
val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("es.answer_question.squad.roberta.base_4096.by_mrm8488").predict("""What's my name?|||"My name is Clara and I live in Berkeley.""")
Model Information
Model Name: | roberta_qa_longformer_base_4096_spanish_finetuned_squad |
Compatibility: | Spark NLP 4.2.4+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [document, token] |
Output Labels: | [class] |
Language: | es |
Size: | 473.8 MB |
Case sensitive: | true |
Max sentence length: | 256 |
References
- https://huggingface.co/mrm8488/longformer-base-4096-spanish-finetuned-squad
- https://es.wikipedia.org/
- https://creativecommons.org/licenses/by-sa/3.0/legalcode
- https://es.wikinews.org/
- https://creativecommons.org/licenses/by/2.5/
- http://clic.ub.edu/corpus/en
- https://creativecommons.org/licenses/by/4.0/legalcode
- https://twitter.com/mrm8488
- https://www.narrativa.com/