Description
Pretrained DistilBertForMaskedLM model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. malaysian-distilbert-small is a Malay model originally trained by w11wo.
How to use
documentAssembler = DocumentAssembler() \
.setInputCol("text") \
.setOutputCol("document")
tokenizer = Tokenizer() \
.setInputCols("document") \
.setOutputCol("token")
distilbert_loaded = DistilBertEmbeddings.pretrained("distilbert_embeddings_malaysian_small","ms") \
.setInputCols(["document", "token"]) \
.setOutputCol("embeddings") \
.setCaseSensitive(False)
pipeline = Pipeline(stages=[documentAssembler, tokenizer, distilbert_loaded])
data = spark.createDataFrame([["I love Spark NLP"]]).toDF("text")
result = pipeline.fit(data).transform(data)
val documentAssembler = new DocumentAssembler()
.setInputCol("text")
.setOutputCol("document")
val tokenizer = new Tokenizer()
.setInputCols("document")
.setOutputCol("token")
val distilbert_loaded = DistilBertEmbeddings.pretrained("distilbert_embeddings_malaysian_small","ms")
.setInputCols(Array("document", "token"))
.setOutputCol("embeddings")
.setCaseSensitive(false)
val pipeline = new Pipeline().setStages(Array(documentAssembler, tokenizer, distilbert_loaded))
val data = Seq("I love Spark NLP").toDS.toDF("text")
val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("ms.embed.distil_bert.small").predict("""I love Spark NLP""")
Model Information
| Model Name: | distilbert_embeddings_malaysian_small |
| Compatibility: | Spark NLP 4.2.4+ |
| License: | Open Source |
| Edition: | Official |
| Input Labels: | [sentence, token] |
| Output Labels: | [embeddings] |
| Language: | ms |
| Size: | 248.4 MB |
| Case sensitive: | false |
References
- https://huggingface.co/w11wo/malaysian-distilbert-small
- https://arxiv.org/abs/1910.01108
- https://github.com/sgugger
- https://github.com/piegu/fastai-projects/blob/master/finetuning-English-GPT2-any-language-Portuguese-HuggingFace-fastaiv2.ipynb
- https://w11wo.github.io/