Description
The Violence and Abuse classifier employs MedicalBertForSequenceClassification embeddings within a robust classifier architecture. Trained on a diverse dataset, this model provides accurate label assignments and confidence scores for its predictions. The primary goal of this model is to categorize text into four key labels: Domestic_Violence_Abuse
, Personal_Violence_Abuse
, No_Violence_Abuse
and Unknown
.
-
Domestic_Violence_Abuse
:This category refers to a pattern of behavior in any relationship that is aimed at gaining or maintaining power and control over an intimate partner or family member. -
Personal_Violence_Abuse
: This category encompasses any form of violence or abuse that is directed towards an individual, whether admitted by the perpetrator or recognized by the victim. -
No_Violence_Abuse
: This category denotes the complete absence of violence and abuse in any form. -
Unknown
: This category covers when the nature or type of violence or abuse within a given text cannot be clearly identified or defined.
Predicted Entities
Domestic_Violence_Abuse
, Personal_Violence_Abuse
, No_Violence_Abuse
, Unknown
How to use
document_assembler = DocumentAssembler() \
.setInputCol("text") \
.setOutputCol("document")
tokenizer = Tokenizer() \
.setInputCols(["document"]) \
.setOutputCol("token")
sequence_classifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_sdoh_violence_abuse_onnx", "en", "clinical/models")\
.setInputCols(["document", "token"])\
.setOutputCol("class")
pipeline = Pipeline(stages=[
document_assembler,
tokenizer,
sequence_classifier
])
sample_texts = [
["Repeated visits for fractures, with vague explanations suggesting potential family-related trauma."],
["Patient presents with multiple bruises in various stages of healing, suggestive of repeated physical abuse."],
["There are no reported instances or documented episodes indicating the patient poses a risk of violence."] ,
["Patient B is a 40-year-old female who was diagnosed with breast cancer. She has received a treatment plan that includes surgery, chemotherapy, and radiation therapy."]
]
data = spark.createDataFrame(sample_texts).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_sdoh_violence_abuse_onnx", "en", "clinical/models")\
.setInputCols(["document","token"])\
.setOutputCol("classes")
pipeline = nlp.Pipeline(stages=[
document_assembler,
tokenizer,
sequenceClassifier
])
sample_texts = [
["Repeated visits for fractures, with vague explanations suggesting potential family-related trauma."],
["Patient presents with multiple bruises in various stages of healing, suggestive of repeated physical abuse."],
["There are no reported instances or documented episodes indicating the patient poses a risk of violence."] ,
["Patient B is a 40-year-old female who was diagnosed with breast cancer. She has received a treatment plan that includes surgery, chemotherapy, and radiation therapy."]
]
data = spark.createDataFrame(sample_texts).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_sdoh_violence_abuse_onnx", "en", "clinical/models")
.setInputCols(Array("document","token"))
.setOutputCol("class")
val pipeline = new Pipeline().setStages(Array(document_assembler, tokenizer, sequenceClassifier))
val data = Seq(Array("Repeated visits for fractures, with vague explanations suggesting potential family-related trauma.",
"Patient presents with multiple bruises in various stages of healing, suggestive of repeated physical abuse.",
"There are no reported instances or documented episodes indicating the patient poses a risk of violence." ,
"Patient B is a 40-year-old female who was diagnosed with breast cancer. She has received a treatment plan that includes surgery, chemotherapy, and radiation therapy.",
)).toDF("text")
val model = pipeline.fit(data)
val result = model.transform(data)
Results
+----------------------------------------------------------------------------------------------------+-------------------------+
| text| result|
+----------------------------------------------------------------------------------------------------+-------------------------+
| Repeated visits for fractures, with vague explanations suggesting potential family-related trauma.|[Domestic_Violence_Abuse]|
|Patient presents with multiple bruises in various stages of healing, suggestive of repeated physi...|[Personal_Violence_Abuse]|
|There are no reported instances or documented episodes indicating the patient poses a risk of vio...| [No_Violence_Abuse]|
|Patient B is a 40-year-old female who was diagnosed with breast cancer. She has received a treatm...| [Unknown]|
+----------------------------------------------------------------------------------------------------+-------------------------+
Model Information
Model Name: | bert_sequence_classifier_sdoh_violence_abuse_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 |