German Public Health Mention Sequence Classifier (GBERT-large)

Description

This model is a GBERT-large 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_gbert_large", "de", "clinical/models")\
    .setInputCols(["document","token"])\
    .setOutputCol("class")

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

data = spark.createDataFrame([
      ["Durch jahrelanges Rauchen habe ich meine Lunge einfach zu sehr geschädigt - Punkt."],
      ["die Schatzsuche war das Highlight beim Kindergeburtstag, die kids haben noch lange davon gesprochen"]
    ]).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_gbert_large", "de", "clinical/models")
    .setInputCols(Array("document","token"))
    .setOutputCol("class")

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

val data = Seq(Array("Durch jahrelanges Rauchen habe ich meine Lunge einfach zu sehr geschädigt - Punkt.",
                     "Das Gefühl kenne ich auch denke, dass es vorallem mit der Sorge um das Durchfallen zusammenhängt.")).toDS().toDF("text")

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("de.classify.bert_sequence.health_mentions_gbert_large").predict("""die Schatzsuche war das Highlight beim Kindergeburtstag, die kids haben noch lange davon gesprochen""")

Results

+---------------------------------------------------------------------------------------------------+----------------+
|text                                                                                               |result          |
+---------------------------------------------------------------------------------------------------+----------------+
|Durch jahrelanges Rauchen habe ich meine Lunge einfach zu sehr geschädigt - Punkt.                 |[health-related]|
|die Schatzsuche war das Highlight beim Kindergeburtstag, die kids haben noch lange davon gesprochen|[non-health]    |
+---------------------------------------------------------------------------------------------------+----------------+

Model Information

Model Name: bert_sequence_classifier_health_mentions_gbert_large
Compatibility: Healthcare NLP 4.0.2+
License: Licensed
Edition: Official
Input Labels: [document, token]
Output Labels: [class]
Language: de
Size: 1.3 GB
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.99      0.99        82 
health-related       0.99      0.99      0.99        69 
      accuracy         -         -       0.99       151 
     macro-avg       0.99      0.99      0.99       151 
  weighted-avg       0.99      0.99      0.99       151