Portuguese BERT Embeddings (Base Cased)


This is the pre-trained BERT model trained on the Portuguese language. BERT-Base and BERT-Large Cased variants were trained on the BrWaC (Brazilian Web as Corpus), a large Portuguese corpus, for 1,000,000 steps, using whole-word mask.


How to use

embeddings = BertEmbeddings.pretrained("bert_portuguese_base_cased", "pt") \
      .setInputCols("sentence", "token") \
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(pd.DataFrame({"text": ["Eu amo PNL"]})))
val embeddings = BertEmbeddings.pretrained("bert_portuguese_base_cased", "pt")
      .setInputCols("sentence", "token")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, tokenizer, embeddings))
val result = pipeline.fit(Seq.empty["Eu amo PNL"].toDS.toDF("text")).transform(data)
import nlu

text = ["Eu amo PNL"]
embeddings_df = nlu.load('pt.bert.cased').predict(text, output_level='token')


	pt_bert_cased_embeddings	                        token
      [0.476963073015213, -0.31151092052459717, 0.91... 	Eu
 	[0.5710286498069763, 0.039474084973335266, 0.3... 	amo
 	[0.3184247314929962, 0.11230389773845673, 0.36... 	PNL

Model Information

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

Data Source

The model is imported from https://github.com/neuralmind-ai/portuguese-bert