BERT Embeddings (Large 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_large_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_large_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.large_cased').predict(text, output_level='token')


	token	en_embed_bert_large_cased_embeddings
	I	[-0.5893247723579407, -1.1389378309249878, -0....
	love	[-0.8002289533615112, -0.15043185651302338, 0....
	NLP	[-0.8995863199234009, 0.08327484875917435, 0.9...

Model Information

Model Name: bert_large_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: 1024
Case sensitive: true

Data Source

The model is imported from