praveenramesh commited on
Commit
5249b97
·
verified ·
1 Parent(s): c347354

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -7
README.md CHANGED
@@ -9,7 +9,7 @@ tags:
9
  licence: license
10
  ---
11
 
12
- # Model Card for clinical_sdtm
13
 
14
  This model is a fine-tuned version of [google/medgemma-4b-it](https://huggingface.co/google/medgemma-4b-it).
15
  It has been trained using [TRL](https://github.com/huggingface/trl).
@@ -23,8 +23,8 @@ The [ClinicalIntelligence/saama_gemma](https://huggingface.co/ClinicalIntelligen
23
  pip install -U transformers
24
  ```
25
 
26
- ## Quick start
27
- **NOTE** - Adjust the **max_new_tokens** parameter as needed; it is set to 3000 by default.
28
 
29
  ```python
30
  import re
@@ -33,7 +33,11 @@ from transformers import pipeline
33
 
34
  prefix = """Extract SDTM domain entities from: """
35
 
36
- unstructured_text = """<ENTER YOUR TEXT HERE>"""
 
 
 
 
37
 
38
  generator = pipeline(
39
  "text-generation", model="ClinicalIntelligence/saama_gemma", device="cuda"
@@ -41,7 +45,7 @@ generator = pipeline(
41
  output = generator(
42
  [{"role": "user", "content": prefix + unstructured_text}],
43
  return_full_text=False,
44
- max_new_tokens=3000
45
  )[0]
46
  llm_output = output["generated_text"]
47
 
@@ -80,7 +84,30 @@ for extracted_entity in extracted_entities_list:
80
  print(extracted_entity)
81
  ```
82
 
83
- ## Training procedure
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  * Training Data Size: 6,500 samples (grouped by uid and formatted into complete user/assistant conversational threads)
85
  * Number of Epochs: 5 (The model processed the entire dataset 5 times, totaling approximately 4,065 optimization steps)
86
  * Effective Batch Size: 8 (Per-device batch size of 1 combined with 8 gradient accumulation steps)
@@ -91,7 +118,7 @@ for extracted_entity in extracted_entities_list:
91
  * Maximum Sequence Length: 12,000 tokens (Sufficient to handle extensive hospital course notes)
92
  * Learning Rate: 2e-4Precision: bfloat16 with Flash Attention 2 and gradient checkpointing enabled for memory efficiency.
93
 
94
- ### Framework versions
95
 
96
  - TRL: 0.28.0
97
  - Transformers: 5.2.0
 
9
  licence: license
10
  ---
11
 
12
+ # MODEL CARD
13
 
14
  This model is a fine-tuned version of [google/medgemma-4b-it](https://huggingface.co/google/medgemma-4b-it).
15
  It has been trained using [TRL](https://github.com/huggingface/trl).
 
23
  pip install -U transformers
24
  ```
25
 
26
+ ## QUICK START
27
+ **NOTE** - Adjust the **max_new_tokens** parameter as needed, it is set to **16000** to generate complete think tokens and extracted entities.
28
 
29
  ```python
30
  import re
 
33
 
34
  prefix = """Extract SDTM domain entities from: """
35
 
36
+ unstructured_text = """
37
+ This previously healthy gentleman presented three days after swallowing a fishbone, reporting subsequent odynophagia, right-sided neck pain, and referred otalgia to the right ear.
38
+ Extensive diagnostic imaging, including a soft-tissue neck X-ray, barium swallow, and CT of the neck, showed no evidence of a radiopaque foreign body or esophageal perforation. Furthermore, an ORL endoscopy and a follow-up EGD confirmed the absence of any foreign objects, though the EGD did identify a soft palate ulcer and an antral nodule.
39
+ Following these procedures, the patient was able to tolerate soft foods without further discomfort. It is highly probable that the fishbone caused localized mucosal micro-trauma before being naturally dislodged and passed through the gastrointestinal tract.
40
+ The patient was discharged with a prescription for viscous lidocaine and ibuprofen 400mg as needed for pain, with a documented maximum daily limit of 1200mg."""
41
 
42
  generator = pipeline(
43
  "text-generation", model="ClinicalIntelligence/saama_gemma", device="cuda"
 
45
  output = generator(
46
  [{"role": "user", "content": prefix + unstructured_text}],
47
  return_full_text=False,
48
+ max_new_tokens=16000,
49
  )[0]
50
  llm_output = output["generated_text"]
51
 
 
84
  print(extracted_entity)
85
  ```
86
 
87
+ ## SAMPLE OUTPUT
88
+ ```python
89
+ {'domain': 'AE', 'extracted_entity': 'swallowing a fishbone', 'justification': "This is an adverse event (AE) because it is an untoward medical occurrence that happened to the patient. The timing 'three days after' indicates it is a current event that precipitated the visit, not a pre-existing condition from the patient's medical history (MH)."}
90
+ {'domain': 'AE', 'extracted_entity': 'odynophagia', 'justification': 'This is an adverse event (AE) because it is a new symptom reported by the patient, occurring after the inciting event (swallowing the fishbone). It is an untoward medical occurrence and is temporally associated with the current visit, not a historical condition (MH).'}
91
+ {'domain': 'AE', 'extracted_entity': 'neck pain', 'justification': 'This is an adverse event (AE) because it is a new symptom reported by the patient, occurring after the inciting event. It is an untoward medical occurrence and is temporally associated with the current visit, not a historical condition (MH).'}
92
+ {'domain': 'AE', 'extracted_entity': 'otalgia', 'justification': 'This is an adverse event (AE) because it is a new symptom reported by the patient, occurring after the inciting event. It is an untoward medical occurrence and is temporally associated with the current visit, not a historical condition (MH).'}
93
+ {'domain': 'PR', 'extracted_entity': 'soft-tissue neck X-ray', 'justification': 'This is a procedure (PR) because it represents a diagnostic intervention performed on the patient to investigate their symptoms. It is an action taken, not an observation of a spontaneous event (AE) or a pre-existing condition (MH).'}
94
+ {'domain': 'PR', 'extracted_entity': 'barium swallow', 'justification': 'This is a procedure (PR) because it is a diagnostic intervention performed on the patient. It is an action taken, not an observation of a spontaneous event (AE) or a pre-existing condition (MH).'}
95
+ {'domain': 'PR', 'extracted_entity': 'CT of the neck', 'justification': 'This is a procedure (PR) because it is a diagnostic intervention performed on the patient. It is an action taken, not an observation of a spontaneous event (AE) or a pre-existing condition (MH).'}
96
+ {'domain': 'PR', 'extracted_entity': 'ORL endoscopy', 'justification': 'This is a procedure (PR) because it is a diagnostic intervention performed on the patient to evaluate the oropharynx. It is an action taken, not an observation of a spontaneous event (AE) or a pre-existing condition (MH).'}
97
+ {'domain': 'PR', 'extracted_entity': 'EGD', 'justification': 'This is a procedure (PR) because it is a diagnostic intervention (Esophagogastroduodenoscopy) performed on the patient. It is an action taken, not an observation of a spontaneous event (AE) or a pre-existing condition (MH).'}
98
+ {'domain': 'AE', 'extracted_entity': 'soft palate ulcer', 'justification': 'This is an adverse event (AE) because it is an untoward medical occurrence identified during the current visit. The timing is current, not historical (MH). It is not a planned observation like a physical exam (PE) or vital sign (VS), but a newly identified pathological condition.'}
99
+ {'domain': 'AE', 'extracted_entity': 'antral nodule', 'justification': 'This is an adverse event (AE) because it is an untoward medical occurrence identified during the current visit. The timing is current, not historical (MH). It is not a planned observation like a physical exam (PE) or vital sign (VS), but a newly identified pathological condition.'}
100
+ {'domain': 'AE', 'extracted_entity': 'localized mucosal micro-trauma', 'justification': "This is an adverse event (AE) because it is the pathological event diagnosed as the cause of the patient's symptoms. It is an untoward medical occurrence that happened to the patient, not a historical condition (MH)."}
101
+ {'domain': 'CM', 'extracted_entity': 'viscous lidocaine', 'justification': 'This is a concomitant medication (CM) because it is a therapeutic agent prescribed to the patient for a current condition (pain). It is not a historical medication (MH) and is not a procedural agent (AG).'}
102
+ {'domain': 'CM', 'extracted_entity': 'ibuprofen', 'justification': 'This is a concomitant medication (CM) because it is a therapeutic agent prescribed to the patient for a current condition (pain). It is not a historical medication (MH) and is not a procedural agent (AG).'}
103
+ {'domain': 'AE', 'extracted_entity': 'pain', 'justification': 'This is an adverse event (AE) because it is a symptom for which the patient is receiving treatment. The timing is current, not historical (MH).'}
104
+ {'domain': 'DS', 'extracted_entity': 'discharged', 'justification': "This entity describes the patient's disposition (DS) at the end of the encounter. It indicates the outcome of the visit and the patient's status relative to the clinical setting."}
105
+ {'domain': 'DM', 'extracted_entity': 'gentleman', 'justification': 'This entity describes the sex of the patient, which is a fundamental demographic characteristic. It is not a medical event, finding, or intervention, thus it belongs in the Demographics (DM) domain.'}
106
+ {'domain': 'DM', 'extracted_entity': 'previously healthy', 'justification': "This entity describes the patient's age, which is a fundamental demographic characteristic. It is not a medical event, finding, or intervention, thus it belongs in the Demographics (DM) domain."}
107
+ {'domain': 'DS', 'extracted_entity': 'discharged', 'justification': "This entity describes the patient's disposition (DS) at the end of the encounter. It indicates the outcome of the visit and the patient's status relative to the clinical setting."}
108
+ ```
109
+
110
+ ## TRAINING PROCEDURE
111
  * Training Data Size: 6,500 samples (grouped by uid and formatted into complete user/assistant conversational threads)
112
  * Number of Epochs: 5 (The model processed the entire dataset 5 times, totaling approximately 4,065 optimization steps)
113
  * Effective Batch Size: 8 (Per-device batch size of 1 combined with 8 gradient accumulation steps)
 
118
  * Maximum Sequence Length: 12,000 tokens (Sufficient to handle extensive hospital course notes)
119
  * Learning Rate: 2e-4Precision: bfloat16 with Flash Attention 2 and gradient checkpointing enabled for memory efficiency.
120
 
121
+ ### FRAMEWORK VERSIONS
122
 
123
  - TRL: 0.28.0
124
  - Transformers: 5.2.0