Description
This model contains a deep bidirectional transformer trained on Wikipedia and the BookCorpus. The details are described in the paper “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding”.
How to use
...
embeddings = BertEmbeddings.pretrained("bert_multi_cased", "xx") \
.setInputCols("sentence", "token") \
.setOutputCol("embeddings")
nlp_pipeline = Pipeline(stages=[document_assembler, sentence_detector, tokenizer, embeddings])
pipeline_model = nlp_pipeline.fit(spark.createDataFrame([[""]]).toDF("text"))
result = pipeline_model.transform(spark.createDataFrame([['I love Spark NLP']], ["text"]))
...
val embeddings = BertEmbeddings.pretrained("bert_multi_cased", "xx")
.setInputCols("sentence", "token")
.setOutputCol("embeddings")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, tokenizer, embeddings))
val data = Seq("I love Spark NLP").toDF("text")
val result = pipeline.fit(data).transform(data)
import nlu
text = ["I love Spark NLP"]
embeddings_df = nlu.load('xx.embed.bert_multi_cased').predict(text, output_level='token')
embeddings_df
Results
xx_embed_bert_multi_cased_embeddings token
[0.31631314754486084, -0.5579454898834229, 0.1... I
[-0.1488783359527588, -0.27264419198036194, -0... love
[0.0496230386197567, -0.43625175952911377, -0.... Spark
[-0.2838578224182129, -0.7103433012962341, 0.4... NLP
Model Information
Model Name: | bert_multi_cased |
Type: | embeddings |
Compatibility: | Spark NLP 2.6.0+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [sentence, token] |
Output Labels: | [word_embeddings] |
Language: | [xx] |
Dimension: | 768 |
Case sensitive: | true |
Data Source
The model is imported from https://tfhub.dev/tensorflow/bert_multi_cased_L-12_H-768_A-12/3