Premise About Health Mandates Related to Covid-19 Classifier (BioBERT) ONNX

Description

This model is a BioBERT based classifier that can classify premise about health mandates related to Covid-19 from tweets. This model is intended for direct use as a classification model and the target classes are: Has no premise (no argument), Has premise (argument).

Predicted Entities

Has premise (argument), Has no premise (no argument)

Copy S3 URI

How to use

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

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

sequence_classifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_health_mandates_premise_tweet_onnx", "en", "clinical/models")\
  .setInputCols(["document", "token"])\
  .setOutputCol("class")

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

data = spark.createDataFrame(["""It's too dangerous to hold the RNC, but let's send students and teachers back to school.""",
"""So is the flu and pneumonia what are their s stop the Media Manipulation covid has treatments You're Speaker Pelosi nephew so stop the agenda LIES.""",
"""Just a quick update to my U.S. followers, I'll be making a stop in all 50 states this spring!  No tickets needed, just don't wash your hands, cough on each other.""",
"""Go to a restaurant no mask Do a food shop wear a mask INCONSISTENT No Masks No Masks.""",
"""But if schools close who is gonna occupy those graves Cause politiciansprotected smokers protected drunkardsprotected school kids amp teachers""",
"""New title Maskhole I think I'm going to use this very soon coronavirus."""
], StringType()).toDF("text")

model = pipeline.fit(data)
result = model.transform(data)
document_assembler = nlp.DocumentAssembler() \
    .setInputCol("text") \
    .setOutputCol("document")

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

sequenceClassifier = medical.BertForSequenceClassification.pretrained("bert_sequence_classifier_health_mandates_premise_tweet_onnx", "en", "clinical/models")\
    .setInputCols(["document","token"])\
    .setOutputCol("classes")

pipeline = nlp.Pipeline(stages=[
    document_assembler,
    tokenizer,
    sequenceClassifier
])
data = spark.createDataFrame(["""It's too dangerous to hold the RNC, but let's send students and teachers back to school.""",
"""So is the flu and pneumonia what are their s stop the Media Manipulation covid has treatments You're Speaker Pelosi nephew so stop the agenda LIES.""",
"""Just a quick update to my U.S. followers, I'll be making a stop in all 50 states this spring!  No tickets needed, just don't wash your hands, cough on each other.""",
"""Go to a restaurant no mask Do a food shop wear a mask INCONSISTENT No Masks No Masks.""",
"""But if schools close who is gonna occupy those graves Cause politiciansprotected smokers protected drunkardsprotected school kids amp teachers""",
"""New title Maskhole I think I'm going to use this very soon coronavirus."""
], StringType()).toDF("text")

model = pipeline.fit(data)
result = model.transform(data)

val document_assembler = new DocumentAssembler() 
    .setInputCol("text") 
    .setOutputCol("document")

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

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

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

val data = Seq(
  "It's too dangerous to hold the RNC, but let's send students and teachers back to school.",
  "So is the flu and pneumonia what are their s stop the Media Manipulation covid has treatments You're Speaker Pelosi nephew so stop the agenda LIES.",
  "Just a quick update to my U.S. followers, I'll be making a stop in all 50 states this spring!  No tickets needed, just don't wash your hands, cough on each other.",
  "Go to a restaurant no mask Do a food shop wear a mask INCONSISTENT No Masks No Masks.",
  "But if schools close who is gonna occupy those graves Cause politiciansprotected smokers protected drunkardsprotected school kids amp teachers",
  "New title Maskhole I think I'm going to use this very soon coronavirus."
).toDF("text")

val model = pipeline.fit(data)
val result = model.transform(data)

Results


+------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------+
|text                                                                                                                                                              |result                        |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------+
|It's too dangerous to hold the RNC, but let's send students and teachers back to school.                                                                          |[Has premise (argument)]      |
|So is the flu and pneumonia what are their s stop the Media Manipulation covid has treatments You're Speaker Pelosi nephew so stop the agenda LIES.               |[Has premise (argument)]      |
|Just a quick update to my U.S. followers, I'll be making a stop in all 50 states this spring!  No tickets needed, just don't wash your hands, cough on each other.|[Has no premise (no argument)]|
|Go to a restaurant no mask Do a food shop wear a mask INCONSISTENT No Masks No Masks.                                                                             |[Has no premise (no argument)]|
|But if schools close who is gonna occupy those graves Cause politiciansprotected smokers protected drunkardsprotected school kids amp teachers                    |[Has premise (argument)]      |
|New title Maskhole I think I'm going to use this very soon coronavirus.                                                                                           |[Has no premise (no argument)]|
+------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------+

Model Information

Model Name: bert_sequence_classifier_health_mandates_premise_tweet_onnx
Compatibility: Healthcare NLP 6.1.1+
License: Licensed
Edition: Official
Input Labels: [document, token]
Output Labels: [label]
Language: en
Size: 437.7 MB
Case sensitive: true