BERT Embeddings (Base Cased)


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_base_cased", "en") \
      .setInputCols("sentence", "token") \
nlp_pipeline = Pipeline(stages=[document_assembler, sentence_detector, tokenizer, embeddings])
pipeline_model =[[""]]).toDF("text"))
result = pipeline_model.transform(spark.createDataFrame(pd.DataFrame({"text": ["I love NLP"]})))
val embeddings = BertEmbeddings.pretrained("bert_base_cased", "en")
      .setInputCols("sentence", "token")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, tokenizer, embeddings))
val result =["I love NLP"].toDS.toDF("text")).transform(data)
import nlu

text = ["I love NLP"]
embeddings_df = nlu.load('en.embed.bert.base_cased').predict(text, output_level='token')


	token	en_embed_bert_base_cased_embeddings
	I	[0.43879568576812744, -0.40160006284713745, 0....
	love	[0.21737590432167053, -0.3865768313407898, -0....
	NLP	[-0.16226479411125183, -0.053727392107248306, ...

Model Information

Model Name: bert_base_cased
Type: embeddings
Compatibility: Spark NLP 2.6.0+
License: Open Source
Edition: Official
Input Labels: [sentence, token]
Output Labels: [word_embeddings]
Language: [en]
Dimension: 768
Case sensitive: true

Data Source

The model is imported from