BERT Sentence Embeddings (Large Cased)

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”.

Download Copy S3 URI

How to use

...
embeddings = BertSentenceEmbeddings.pretrained("sent_bert_large_cased", "en") \
.setInputCols("sentence") \
.setOutputCol("sentence_embeddings")
nlp_pipeline = Pipeline(stages=[document_assembler, sentence_detector, embeddings])
pipeline_model = nlp_pipeline.fit(spark.createDataFrame([[""]]).toDF("text"))
result = pipeline_model.transform(spark.createDataFrame([['I hate cancer', "Antibiotics aren't painkiller"]], ["text"]))
...
val embeddings = BertSentenceEmbeddings.pretrained("sent_bert_large_cased", "en")
.setInputCols("sentence")
.setOutputCol("sentence_embeddings")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, embeddings))
val data = Seq("I hate cancer", "Antibiotics aren't painkiller").toDF("text")
val result = pipeline.fit(data).transform(data)
import nlu

text = ["I hate cancer", "Antibiotics aren't painkiller"]
embeddings_df = nlu.load('en.embed_sentence.bert_large_cased').predict(text, output_level='sentence')
embeddings_df

Results

	token	en_embed_sentence_bert_large_cased_embeddings
	
	I 	[[-0.6228358149528503, -0.3453695774078369, 0....
love 	[[-0.6228358149528503, -0.3453695774078369, 0....
NLP 	[[-0.6228358149528503, -0.3453695774078369, 0....

Model Information

Model Name: sent_bert_large_cased
Type: embeddings
Compatibility: Spark NLP 2.6.0+
License: Open Source
Edition: Official
Input Labels: [sentence]
Output Labels: [sentence_embeddings]
Language: [en]
Dimension: 1024
Case sensitive: true

Data Source

The model is imported from https://tfhub.dev/google/bert_cased_L-24_H-1024_A-16/1