Description
Pretrained named entity recognition deep learning model for clinical terminology. The SparkNLP deep learning model (MedicalNerModel) is inspired by a former state-of-the-art model for NER: Chiu & Nicols, Named Entity Recognition with Bidirectional LSTM-CNN. This model is the official version of jsl_ner_wip_clinical model.
Definitions of Predicted Entities:
Injury_or_Poisoning
: Physical harm or injury caused to the body, including those caused by accidents, falls, or poisoning of a patient or someone else.Direction
: All the information relating to the laterality of the internal and external organs.Test
: Mentions of laboratory, pathology, and radiological tests.Admission_Discharge
: Terms that indicate the admission and/or the discharge of a patient.Death_Entity
: Mentions that indicate the death of a patient.Relationship_Status
: State of patients romantic or social relationships (e.g. single, married, divorced).Duration
: The duration of a medical treatment or medication use.Respiration
: Number of breaths per minute.Hyperlipidemia
: Terms that indicate hyperlipidemia with relevant subtypes and synonims.Birth_Entity
: Mentions that indicate giving birth.Age
: All mention of ages, past or present, related to the patient or with anybody else.Labour_Delivery
: Extractions include stages of labor and delivery.Family_History_Header
: identifies section headers that correspond to Family History of the patient.BMI
: Numeric values and other text information related to Body Mass Index.Temperature
: All mentions that refer to body temperature.Alcohol
: Terms that indicate alcohol use, abuse or drinking issues of a patient or someone else.Kidney_Disease
: Terms that refer to any kidney diseases (includes mentions of modifiers such as “Acute” or “Chronic”).Oncological
: All the cancer, tumor or metastasis related extractions mentioned in the document, of the patient or someone else.Medical_History_Header
: Identifies section headers that correspond to Past Medical History of a patient.Cerebrovascular_Disease
: All terms that refer to cerebrovascular diseases and events.Oxygen_Therapy
: Breathing support triggered by patient or entirely or partially by machine (e.g. ventilator, BPAP, CPAP).O2_Saturation
: Systemic arterial, venous or peripheral oxygen saturation measurements.Psychological_Condition
: All the Mental health diagnosis, disorders, conditions or syndromes of a patient or someone else.Heart_Disease
: All mentions of acquired, congenital or degenerative heart diseases.Employment
: All mentions of patient or provider occupational titles and employment status .Obesity
: Terms related to a patient being obese (overweight and BMI are extracted as different labels).Disease_Syndrome_Disorder
: All the diseases mentioned in the document, of the patient or someone else (excluding diseases that are extracted with their specific labels, such as “Heart_Disease” etc.).Pregnancy
: All terms related to Pregnancy (excluding terms that are extracted with their specific labels, such as “Labour_Delivery” etc.).ImagingFindings
: All mentions of radiographic and imagistic findings.Procedure
: All mentions of invasive medical or surgical procedures or treatments.Medical_Device
: All mentions related to medical devices and supplies.Race_Ethnicity
: All terms that refer to racial and national origin of sociocultural groups.Section_Header
: All the section headers present in the text (Medical History, Family History, Social History, Physical Examination and Vital signs Headers are extracted separately with their specific labels).Symptom
: All the symptoms mentioned in the document, of a patient or someone else.Treatment
: Includes therapeutic and minimally invasive treatment and procedures (invasive treatments or procedures are extracted as “Procedure”).Substance
: All mentions of substance use related to the patient or someone else (recreational drugs, illicit drugs).Route
: Drug and medication administration routes available described by FDA.Drug_Ingredient
: Active ingredient/s found in drug products.Blood_Pressure
: Systemic blood pressure, mean arterial pressure, systolic and/or diastolic are extracted.Diet
: All mentions and information regarding patients dietary habits.External_body_part_or_region
: All mentions related to external body parts or organs that can be examined by naked eye.LDL
: All mentions related to the lab test and results for LDL (Low Density Lipoprotein).VS_Finding
: Qualitative data (e.g. Fever, Cyanosis, Tachycardia) and any other symptoms that refers to vital signs.Allergen
: Allergen related extractions mentioned in the document.EKG_Findings
: All mentions of EKG readings.Imaging_Technique
: All mentions of special radiographic views or special imaging techniques used in radiology.Triglycerides
: All mentions terms related to specific lab test for Triglycerides.RelativeTime
: Time references that are relative to different times or events (e.g. words such as “approximately”, “in the morning”).Gender
: Gender-specific nouns and pronouns.Pulse
: Peripheral heart rate, without advanced information like measurement location.Social_History_Header
: Identifies section headers that correspond to Social History of a patient.Substance_Quantity
: All mentions of substance quantity (quantitative information related to illicit/recreational drugs).Diabetes
: All terms related to diabetes mellitus.Modifier
: Terms that modify the symptoms, diseases or risk factors. If a modifier is included in ICD-10 name of a specific disease, the respective modifier is not extracted separately.Internal_organ_or_component
: All mentions related to internal body parts or organs that can not be examined by naked eye.Clinical_Dept
: Terms that indicate the medical and/or surgical departments.Form
: Drug and medication forms available described by FDA.Drug_BrandName
: Commercial labeling name chosen by the labeler or the drug manufacturer for a drug containing a single or multiple drug active ingredients.Strength
: Potency of one unit of drug (or a combination of drugs) the measurement units available are described by FDA.Fetus_NewBorn
: All terms related to fetus, infant, new born (excluding terms that are extracted with their specific labels, such as “Labour_Delivery”, “Pregnancy” etc.).RelativeDate
: Temporal references that are relative to the date of the text or to any other specific date (e.g. “approximately two years ago”, “about two days ago”).Height
: All mentions related to a patients height.Test_Result
: Terms related to all the test results present in the document (clinical tests results are included).Sexually_Active_or_Sexual_Orientation
: All terms that are related to sexuality, sexual orientations and sexual activity.Frequency
: Frequency of administration for a dose prescribed.Time
: Specific time references (hour and/or minutes).Weight
: All mentions related to a patients weight.Vaccine
: Generic and brand name of vaccines or vaccination procedure.Vital_Signs_Header
: Identifies section headers that correspond to Vital Signs of a patient.Communicable_Disease
: Includes all mentions of communicable diseases.Dosage
: Quantity prescribed by the physician for an active ingredient; measurement units are available described by FDA.Overweight
: Terms related to the patient being overweight (BMI and Obesity is extracted separately).Hypertension
: All terms related to Hypertension (quantitative data such as 150/100 is extracted as Blood_Pressure).HDL
: Terms related to the lab test for HDL (High Density Lipoprotein).Total_Cholesterol
: Terms related to the lab test and results for cholesterol.Smoking
: All mentions of smoking status of a patient.Date
: Mentions of an exact date, in any format, including day number, month and/or year.
Predicted Entities
Injury_or_Poisoning
, Direction
, Test
, Admission_Discharge
, Death_Entity
, Relationship_Status
, Duration
, Respiration
, Hyperlipidemia
, Birth_Entity
, Age
, Labour_Delivery
, Family_History_Header
, BMI
, Temperature
, Alcohol
, Kidney_Disease
, Oncological
, Medical_History_Header
, Cerebrovascular_Disease
, Oxygen_Therapy
, O2_Saturation
, Psychological_Condition
, Heart_Disease
, Employment
, Obesity
, Disease_Syndrome_Disorder
, Pregnancy
, ImagingFindings
, Procedure
, Medical_Device
, Race_Ethnicity
, Section_Header
, Symptom
, Treatment
, Substance
, Route
, Drug_Ingredient
, Blood_Pressure
, Diet
, External_body_part_or_region
, LDL
, VS_Finding
, Allergen
, EKG_Findings
, Imaging_Technique
, Triglycerides
, RelativeTime
, Gender
, Pulse
, Social_History_Header
, Substance_Quantity
, Diabetes
, Modifier
, Internal_organ_or_component
, Clinical_Dept
, Form
, Drug_BrandName
, Strength
, Fetus_NewBorn
, RelativeDate
, Height
, Test_Result
, Sexually_Active_or_Sexual_Orientation
, Frequency
, Time
, Weight
, Vaccine
, Vaccine_Name
, Vital_Signs_Header
, Communicable_Disease
, Dosage
, Overweight
, Hypertension
, HDL
, Total_Cholesterol
, Smoking
, Date
Live Demo Open in Colab Copy S3 URI
How to use
documentAssembler = DocumentAssembler()\
.setInputCol("text")\
.setOutputCol("document")
sentenceDetector = SentenceDetectorDLModel.pretrained("sentence_detector_dl_healthcare","en","clinical/models") \
.setInputCols(["document"]) \
.setOutputCol("sentence")
tokenizer = Tokenizer()\
.setInputCols(["sentence"])\
.setOutputCol("token")
word_embeddings = WordEmbeddingsModel.pretrained("embeddings_clinical", "en", "clinical/models")\
.setInputCols(["sentence", "token"])\
.setOutputCol("embeddings")
ner = MedicalNerModel.pretrained("ner_jsl","en","clinical/models")\
.setInputCols(["sentence","token","embeddings"])\
.setOutputCol("ner")\
.setLabelCasing("upper")
ner_converter = NerConverter() \
.setInputCols(["sentence", "token", "ner"]) \
.setOutputCol("ner_chunk")
ner_pipeline = Pipeline(stages=[
documentAssembler,
sentenceDetector,
tokenizer,
word_embeddings,
ner,
ner_converter])
empty_data = spark.createDataFrame([[""]]).toDF("text")
ner_model = ner_pipeline.fit(empty_data)
data = spark.createDataFrame([["""The patient is a 21-day-old Caucasian male here for 2 days of congestion - mom has been suctioning yellow discharge from the patient's nares, plus she has noticed some mild problems with his breathing while feeding (but negative for any perioral cyanosis or retractions). Additionally, there is no side effect observed after Influenza vaccine. One day ago, mom also noticed a tactile temperature and gave the patient Tylenol. Baby also has had some decreased p.o. intake. His normal breast-feeding is down from 20 minutes q.2h. to 5 to 10 minutes secondary to his respiratory congestion. He sleeps well, but has been more tired and has been fussy over the past 2 days. The parents noticed no improvement with albuterol treatments given in the ER. His urine output has also decreased; normally he has 8 to 10 wet and 5 dirty diapers per 24 hours, now he has down to 4 wet diapers per 24 hours. Mom denies any diarrhea. His bowel movements are yellow colored and soft in nature.
"""]]).toDF("text")
result = ner_model.transform(data)
val documentAssembler = new DocumentAssembler()
.setInputCol("text")
.setOutputCol("document")
val sentenceDetector = SentenceDetectorDLModel.pretrained("sentence_detector_dl_healthcare","en","clinical/models")
.setInputCols("document")
.setOutputCol("sentence")
val tokenizer = new Tokenizer()
.setInputCols("sentence")
.setOutputCol("token")
val embeddings = WordEmbeddingsModel.pretrained("embeddings_clinical", "en", "clinical/models")
.setInputCols(Array("sentence", "token"))
.setOutputCol("embeddings")
val jsl_ner = MedicalNerModel.pretrained("ner_jsl", "en", "clinical/models")
.setInputCols(Array("sentence", "token", "embeddings"))
.setOutputCol("jsl_ner")
val jsl_ner_converter = new NerConverter()
.setInputCols(Array("sentence", "token", "jsl_ner"))
.setOutputCol("ner_chunk")
val jsl_ner_pipeline = new Pipeline().setStages(Array(
documentAssembler,
sentenceDetector,
tokenizer,
embeddings,
jsl_ner,
jsl_ner_converter))
val data = Seq("""The patient is a 21-day-old Caucasian male here for 2 days of congestion - mom has been suctioning yellow discharge from the patient's nares, plus she has noticed some mild problems with his breathing while feeding (but negative for any perioral cyanosis or retractions). Additionally, there is no side effect observed after Influenza vaccine. One day ago, mom also noticed a tactile temperature and gave the patient Tylenol. Baby also has had some decreased p.o. intake. His normal breast-feeding is down from 20 minutes q.2h. to 5 to 10 minutes secondary to his respiratory congestion. He sleeps well, but has been more tired and has been fussy over the past 2 days. The parents noticed no improvement with albuterol treatments given in the ER. His urine output has also decreased; normally he has 8 to 10 wet and 5 dirty diapers per 24 hours, now he has down to 4 wet diapers per 24 hours. Mom denies any diarrhea. His bowel movements are yellow colored and soft in nature.""").toDS.toDF("text")
val result = jsl_ner_pipeline.fit(data).transform(data)
import nlu
nlu.load("en.med_ner.jsl").predict("""The patient is a 21-day-old Caucasian male here for 2 days of congestion - mom has been suctioning yellow discharge from the patient's nares, plus she has noticed some mild problems with his breathing while feeding (but negative for any perioral cyanosis or retractions). Additionally, there is no side effect observed after Influenza vaccine. One day ago, mom also noticed a tactile temperature and gave the patient Tylenol. Baby also has had some decreased p.o. intake. His normal breast-feeding is down from 20 minutes q.2h. to 5 to 10 minutes secondary to his respiratory congestion. He sleeps well, but has been more tired and has been fussy over the past 2 days. The parents noticed no improvement with albuterol treatments given in the ER. His urine output has also decreased; normally he has 8 to 10 wet and 5 dirty diapers per 24 hours, now he has down to 4 wet diapers per 24 hours. Mom denies any diarrhea. His bowel movements are yellow colored and soft in nature.
""")
Results
| | chunks | begin | end | sentence_id | entities |
|---:|:------------------------------------------|--------:|------:|--------------:|:-----------------------------|
| 0 | 21-day-old | 18 | 27 | 0 | Age |
| 1 | Caucasian | 29 | 37 | 0 | Race_Ethnicity |
| 2 | male | 39 | 42 | 0 | Gender |
| 3 | 2 days | 53 | 58 | 0 | Duration |
| 4 | congestion | 63 | 72 | 0 | Symptom |
| 5 | mom | 76 | 78 | 0 | Gender |
| 6 | suctioning yellow discharge | 89 | 115 | 0 | Symptom |
| 7 | nares | 136 | 140 | 0 | External_body_part_or_region |
| 8 | she | 148 | 150 | 0 | Gender |
| 9 | mild | 169 | 172 | 0 | Modifier |
| 10 | problems with his breathing while feeding | 174 | 214 | 0 | Symptom |
| 11 | perioral cyanosis | 238 | 254 | 0 | Symptom |
| 12 | retractions | 259 | 269 | 0 | Symptom |
| 13 | Influenza vaccine | 326 | 342 | 1 | Vaccine_Name |
| 14 | One day ago | 345 | 355 | 2 | RelativeDate |
| 15 | mom | 358 | 360 | 2 | Gender |
| 16 | tactile temperature | 377 | 395 | 2 | Symptom |
| 17 | Tylenol | 418 | 424 | 2 | Drug_BrandName |
| 18 | Baby | 427 | 430 | 3 | Age |
| 19 | decreased p.o | 450 | 462 | 3 | Symptom |
Model Information
Model Name: | ner_jsl |
Compatibility: | Spark NLP for Healthcare 4.2.0+ |
License: | Licensed |
Edition: | Official |
Input Labels: | [sentence, token, embeddings] |
Output Labels: | [ner] |
Language: | en |
Size: | 15.2 MB |
References
Trained on data gathered and manually annotated by John Snow Labs. https://www.johnsnowlabs.com/data/
Benchmarking
label tp fp fn total precision recall f1
VS_Finding 207.0 37.0 26.0 233.0 0.8484 0.8884 0.8679
Direction 3642.0 418.0 264.0 3906.0 0.897 0.9324 0.9144
Respiration 58.0 5.0 4.0 62.0 0.9206 0.9355 0.928
Cerebrovascular_D... 93.0 20.0 12.0 105.0 0.823 0.8857 0.8532
Family_History_He... 77.0 1.0 1.0 78.0 0.9872 0.9872 0.9872
Heart_Disease 453.0 47.0 50.0 503.0 0.906 0.9006 0.9033
ImagingFindings 85.0 35.0 101.0 186.0 0.7083 0.457 0.5556
RelativeTime 156.0 36.0 50.0 206.0 0.8125 0.7573 0.7839
Strength 648.0 24.0 27.0 675.0 0.9643 0.96 0.9621
Smoking 115.0 8.0 3.0 118.0 0.935 0.9746 0.9544
Medical_Device 3167.0 368.0 283.0 3450.0 0.8959 0.918 0.9068
Allergen 1.0 0.0 8.0 9.0 1.0 0.1111 0.2
EKG_Findings 36.0 13.0 33.0 69.0 0.7347 0.5217 0.6102
Pulse 119.0 14.0 6.0 125.0 0.8947 0.952 0.9225
Psychological_Con... 117.0 14.0 15.0 132.0 0.8931 0.8864 0.8897
Triglycerides 4.0 1.0 0.0 4.0 0.8 1.0 0.8889
Overweight 3.0 0.0 0.0 3.0 1.0 1.0 1.0
Obesity 40.0 1.0 1.0 41.0 0.9756 0.9756 0.9756
Admission_Discharge 307.0 26.0 5.0 312.0 0.9219 0.984 0.9519
HDL 3.0 0.0 1.0 4.0 1.0 0.75 0.8571
Diabetes 117.0 3.0 3.0 120.0 0.975 0.975 0.975
Section_Header 3327.0 103.0 109.0 3436.0 0.97 0.9683 0.9691
Age 556.0 22.0 31.0 587.0 0.9619 0.9472 0.9545
O2_Saturation 28.0 3.0 6.0 34.0 0.9032 0.8235 0.8615
Kidney_Disease 97.0 10.0 19.0 116.0 0.9065 0.8362 0.87
Test 2603.0 391.0 357.0 2960.0 0.8694 0.8794 0.8744
Communicable_Disease 22.0 6.0 6.0 28.0 0.7857 0.7857 0.7857
Hypertension 144.0 5.0 5.0 149.0 0.9664 0.9664 0.9664
External_body_par... 2401.0 228.0 378.0 2779.0 0.9133 0.864 0.8879
Oxygen_Therapy 69.0 14.0 10.0 79.0 0.8313 0.8734 0.8519
Modifier 2229.0 304.0 354.0 2583.0 0.88 0.863 0.8714
Test_Result 1169.0 165.0 187.0 1356.0 0.8763 0.8621 0.8691
BMI 5.0 3.0 1.0 6.0 0.625 0.8333 0.7143
Labour_Delivery 66.0 15.0 17.0 83.0 0.8148 0.7952 0.8049
Employment 220.0 16.0 37.0 257.0 0.9322 0.856 0.8925
Fetus_NewBorn 53.0 16.0 23.0 76.0 0.7681 0.6974 0.731
Clinical_Dept 843.0 69.0 53.0 896.0 0.9243 0.9408 0.9325
Time 28.0 8.0 11.0 39.0 0.7778 0.7179 0.7467
Procedure 2893.0 326.0 307.0 3200.0 0.8987 0.9041 0.9014
Diet 29.0 3.0 18.0 47.0 0.9063 0.617 0.7342
Oncological 419.0 41.0 36.0 455.0 0.9109 0.9209 0.9158
LDL 3.0 0.0 1.0 4.0 1.0 0.75 0.8571
Symptom 6559.0 876.0 908.0 7467.0 0.8822 0.8784 0.8803
Temperature 86.0 7.0 3.0 89.0 0.9247 0.9663 0.9451
Vital_Signs_Header 191.0 25.0 19.0 210.0 0.8843 0.9095 0.8967
Total_Cholesterol 13.0 3.0 7.0 20.0 0.8125 0.65 0.7222
Relationship_Status 52.0 5.0 2.0 54.0 0.9123 0.963 0.9369
Blood_Pressure 132.0 15.0 11.0 143.0 0.898 0.9231 0.9103
Injury_or_Poisoning 500.0 64.0 86.0 586.0 0.8865 0.8532 0.8696
Drug_Ingredient 1505.0 128.0 91.0 1596.0 0.9216 0.943 0.9322
Treatment 134.0 21.0 25.0 159.0 0.8645 0.8428 0.8535
Pregnancy 89.0 23.0 20.0 109.0 0.7946 0.8165 0.8054
Vaccine 7.0 2.0 2.0 9.0 0.7778 0.7778 0.7778
Disease_Syndrome_... 2684.0 383.0 344.0 3028.0 0.8751 0.8864 0.8807
Height 22.0 3.0 1.0 23.0 0.88 0.9565 0.9167
Frequency 604.0 74.0 67.0 671.0 0.8909 0.9001 0.8955
Route 783.0 89.0 64.0 847.0 0.8979 0.9244 0.911
Duration 352.0 83.0 41.0 393.0 0.8092 0.8957 0.8502
Death_Entity 41.0 3.0 3.0 44.0 0.9318 0.9318 0.9318
Internal_organ_or... 5915.0 811.0 713.0 6628.0 0.8794 0.8924 0.8859
Vaccine_Name 5.0 0.0 3.0 8.0 1.0 0.625 0.7692
Alcohol 72.0 4.0 6.0 78.0 0.9474 0.9231 0.9351
Substance_Quantity 3.0 4.0 0.0 3.0 0.4286 1.0 0.6
Date 544.0 26.0 17.0 561.0 0.9544 0.9697 0.962
Hyperlipidemia 44.0 4.0 0.0 44.0 0.9167 1.0 0.9565
Social_History_He... 93.0 3.0 4.0 97.0 0.9688 0.9588 0.9637
Imaging_Technique 59.0 4.0 31.0 90.0 0.9365 0.6556 0.7712
Race_Ethnicity 113.0 0.0 0.0 113.0 1.0 1.0 1.0
Drug_BrandName 819.0 53.0 41.0 860.0 0.9392 0.9523 0.9457
RelativeDate 530.0 86.0 89.0 619.0 0.8604 0.8562 0.8583
Gender 5414.0 55.0 47.0 5461.0 0.9899 0.9914 0.9907
Form 204.0 24.0 35.0 239.0 0.8947 0.8536 0.8737
Dosage 211.0 21.0 48.0 259.0 0.9095 0.8147 0.8595
Medical_History_H... 105.0 7.0 2.0 107.0 0.9375 0.9813 0.9589
Birth_Entity 4.0 0.0 2.0 6.0 1.0 0.6667 0.8
Substance 72.0 14.0 12.0 84.0 0.8372 0.8571 0.8471
Sexually_Active_o... 7.0 0.0 0.0 7.0 1.0 1.0 1.0
Weight 77.0 8.0 11.0 88.0 0.9059 0.875 0.8902
macro - - - - - - 0.8674
micro - - - - - - 0.9054