German Public Health Mention Sequence Classifier (BERT-base)

Description

This model is a bert-base-german based sequence classification model that can classify public health mentions in German social media text.

Predicted Entities

non-health, health-related

Copy S3 URI

How to use

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

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

sequenceClassifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_health_mentions_bert", "de", "clinical/models")\
    .setInputCols(["document","token"])\
    .setOutputCol("class")

pipeline = Pipeline(stages=[
    document_assembler, 
    tokenizer,
    sequenceClassifier    
])

data = spark.createDataFrame([
      ["Die Temperaturen klettern am Wochenende."],
      ["Zu den Symptomen gehört u.a. eine verringerte Greifkraft."]
    ]).toDF("text")

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

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

val sequenceClassifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_health_mentions_bert", "de", "clinical/models")
    .setInputCols(Array("document","token"))
    .setOutputCol("class")

val pipeline = new Pipeline().setStages(Array(documenter, tokenizer, sequenceClassifier))

val data = Seq(Array("Die Temperaturen klettern am Wochenende.",
                     "Zu den Symptomen gehört u.a. eine verringerte Greifkraft.")).toDS().toDF("text")

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("de.classify.bert_sequence.health_mentions_bert").predict("""Zu den Symptomen gehört u.a. eine verringerte Greifkraft.""")

Results

+---------------------------------------------------------+----------------+
|text                                                     |result          |
+---------------------------------------------------------+----------------+
|Die Temperaturen klettern am Wochenende.                 |[non-health]    |
|Zu den Symptomen gehört u.a. eine verringerte Greifkraft.|[health-related]|
+---------------------------------------------------------+----------------+

Model Information

Model Name: bert_sequence_classifier_health_mentions_bert
Compatibility: Healthcare NLP 4.0.2+
License: Licensed
Edition: Official
Input Labels: [document, token]
Output Labels: [class]
Language: de
Size: 409.8 MB
Case sensitive: true
Max sentence length: 128

References

Curated from several academic and in-house datasets.

Benchmarking

         label  precision    recall  f1-score   support 
    non-health       0.99      0.90      0.94        82 
health-related       0.89      0.99      0.94        69 
      accuracy         -         -       0.94       151 
     macro-avg       0.94      0.94      0.94       151 
  weighted-avg       0.94      0.94      0.94       151