Danish BertForTokenClassification Cased model (from Maltehb)

Description

Pretrained BertForTokenClassification model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. danish-bert-botxo-ner-dane is a Danish model originally trained by Maltehb.

Predicted Entities

[CLS], PER, [SEP], ORG, LOC

Download Copy S3 URI

How to use

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

sentenceDetector = SentenceDetectorDLModel.pretrained("sentence_detector_dl", "xx")\
       .setInputCols(["document"])\
       .setOutputCol("sentence")

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

tokenClassifier = BertForTokenClassification.pretrained("bert_ner_danish_bert_botxo_ner_dane","da") \
    .setInputCols(["sentence", "token"]) \
    .setOutputCol("ner")

pipeline = Pipeline(stages=[documentAssembler, sentenceDetector, tokenizer, tokenClassifier])

data = spark.createDataFrame([["Jeg elsker Spark NLP"]]).toDF("text")

result = pipeline.fit(data).transform(data)
val documentAssembler = new DocumentAssembler() 
          .setInputCol("text") 
          .setOutputCol("document")

val sentenceDetector = SentenceDetectorDLModel.pretrained("sentence_detector_dl", "xx")
       .setInputCols(Array("document"))
       .setOutputCol("sentence")

val tokenizer = new Tokenizer() 
    .setInputCols(Array("sentence"))
    .setOutputCol("token")

val tokenClassifier = BertForTokenClassification.pretrained("bert_ner_danish_bert_botxo_ner_dane","da") 
    .setInputCols(Array("sentence", "token")) 
    .setOutputCol("ner")

val pipeline = new Pipeline().setStages(Array(documentAssembler,sentenceDetector, tokenizer, tokenClassifier))

val data = Seq("Jeg elsker Spark NLP").toDF("text")

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("da.ner.bert.by_maltehb").predict("""Jeg elsker Spark NLP""")

Model Information

Model Name: bert_ner_danish_bert_botxo_ner_dane
Compatibility: Spark NLP 4.1.0+
License: Open Source
Edition: Official
Input Labels: [document, token]
Output Labels: [ner]
Language: da
Size: 412.9 MB
Case sensitive: true
Max sentence length: 128

References

  • https://huggingface.co/Maltehb/danish-bert-botxo-ner-dane
  • #danish-bert-version-2-uncased-by-certainlyhttpscertainlyio-previously-known-as-botxo-finetuned-for-named-entity-recognition-on-the-dane-datasethttpsdanlpalexandradk304bd159d5dedatasetsddtzip-hvingelby-et-al-2020-by-malte-højmark-bertelsen
  • https://www.aclweb.org/anthology/2020.lrec-1.565
  • https://www.certainly.io/blog/danish-bert-model/
  • https://www.linkedin.com/in/malte-h%C3%B8jmark-bertelsen-9a618017b/
  • https://danlp.alexandra.dk/304bd159d5de/datasets/ddt.zip
  • https://github.com/certainlyio/nordic_bert
  • https://twitter.com/malteH_B
  • https://www.instagram.com/maltemusen/
  • https://certainly.io/
  • https://github.com/botxo/nordic_bert
  • https://www.dropbox.com/s/19cjaoqvv2jicq9/danish_bert_uncased_v2.zip?dl=1