Chinese Bert Embeddings (Base, MacBERT)

Description

Pretrained Bert Embeddings model, uploaded to Hugging Face, adapted and imported into Spark NLP. chinese-macbert-base is a Chinese model orginally trained by hfl.

Download Copy S3 URICopied!

How to use

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

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

embeddings = BertEmbeddings.pretrained("bert_embeddings_chinese_macbert_base","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_chinese_macbert_base
Compatibility: Spark NLP 3.4.2+
License: Open Source
Edition: Official
Input Labels: [sentence, token]
Output Labels: [bert]
Language: zh
Size: 384.0 MB
Case sensitive: true

References

  • https://huggingface.co/hfl/chinese-macbert-base
  • https://github.com/ymcui/MacBERT/blob/master/LICENSE
  • https://2020.emnlp.org
  • https://arxiv.org/abs/2004.13922
  • https://arxiv.org/abs/2004.13922
  • https://github.com/ymcui/Chinese-BERT-wwm
  • https://github.com/ymcui/Chinese-ELECTRA
  • https://github.com/ymcui/Chinese-XLNet
  • https://github.com/airaria/TextBrewer
  • https://github.com/ymcui/HFL-Anthology
  • https://github.com/chatopera/Synonyms
  • https://arxiv.org/abs/2004.13922
  • https://arxiv.org/abs/2004.13922