Chinese Bert Embeddings (Base, captions dataset)

Description

Pretrained Bert Embeddings model, uploaded to Hugging Face, adapted and imported into Spark NLP. mengzi-oscar-base-caption is a Chinese model orginally trained by Langboat.

Download Copy S3 URICopied!

How to use

documentAssembler = DocumentAssembler() \
.setInputCol("text") \
.setOutputCol("document")

tokenizer = Tokenizer() \
.setInputCols("document") \
.setOutputCol("token")

embeddings = BertEmbeddings.pretrained("bert_embeddings_mengzi_oscar_base_caption","zh") \
.setInputCols(["document", "token"]) \
.setOutputCol("embeddings")

pipeline = Pipeline(stages=[documentAssembler, tokenizer, embeddings])

data = spark.createDataFrame([["I love Spark NLP"]]).toDF("text")

result = pipeline.fit(data).transform(data)

Model Information

Model Name: bert_embeddings_mengzi_oscar_base_caption
Compatibility: Spark NLP 3.4.2+
License: Open Source
Edition: Official
Input Labels: [sentence, token]
Output Labels: [bert]
Language: zh
Size: 383.6 MB
Case sensitive: true

References

  • https://huggingface.co/Langboat/mengzi-oscar-base-caption
  • https://arxiv.org/abs/2110.06696
  • https://github.com/Langboat/Mengzi/blob/main/Mengzi-Oscar.md
  • https://github.com/microsoft/Oscar/blob/master/INSTALL.md
  • https://github.com/Langboat/Mengzi/blob/main/Mengzi-Oscar.md