English BertForQuestionAnswering model (from batterydata)

Description

Pretrained Question Answering model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. batterybert-uncased-squad-v1 is a English model orginally trained by batterydata.

Download Copy S3 URICopied!

How to use

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

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

pipeline = Pipeline().setStages([
document_assembler,
spanClassifier
])

example = spark.createDataFrame([["What's my name?", "My name is Clara and I live in Berkeley."]]).toDF("question", "context")

result = pipeline.fit(example).transform(example)

Model Information

Model Name: bert_qa_batterybert_uncased_squad_v1
Compatibility: Spark NLP 4.0.0+
License: Open Source
Edition: Official
Input Labels: [sentence, token]
Output Labels: [embeddings]
Language: en
Size: 407.6 MB
Case sensitive: false
Max sentence length: 512

References

  • https://huggingface.co/batterydata/batterybert-uncased-squad-v1
  • https://github.com/ShuHuang/batterybert