Swedish BertForQuestionAnswering Base Cased model (from KBLab)

Description

Pretrained Question Answering model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. bert-base-swedish-cased-squad-experimental is a Swedish model originally trained by KBLab.

Predicted Entities

Download Copy S3 URI

How to use

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

spanClassifier = BertForQuestionAnswering.pretrained("bert_qa_base_swedish_cased_squad_experimental","sv") \
    .setInputCols(["document_question", "document_context"]) \
    .setOutputCol("answer")\
    .setCaseSensitive(True)

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

data = spark.createDataFrame([["Vad är mitt namn?", "Jag heter Clara och jag bor i Berkeley."]]).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 = BertForQuestionAnswering.pretrained("bert_qa_base_swedish_cased_squad_experimental","sv")
    .setInputCols(Array("document", "token"))
    .setOutputCol("answer")
    .setCaseSensitive(true)

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

val data = Seq("Vad är mitt namn?", "Jag heter Clara och jag bor i Berkeley.").toDF("question", "context")

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("sv.answer_question.bert.squad.cased_base.by_KBLab").predict("""Vad är mitt namn?|||"Jag heter Clara och jag bor i Berkeley.""")

Model Information

Model Name: bert_qa_base_swedish_cased_squad_experimental
Compatibility: Spark NLP 5.2.0+
License: Open Source
Edition: Official
Input Labels: [document_question, document_context]
Output Labels: [answer]
Language: sv
Size: 465.2 MB
Case sensitive: true
Max sentence length: 512

References

References

  • https://huggingface.co/KBLab/bert-base-swedish-cased-squad-experimental