Update README.md
Browse files
README.md
CHANGED
@@ -11,12 +11,15 @@ tags:
|
|
11 |
license: other
|
12 |
language:
|
13 |
- en
|
|
|
|
|
|
|
14 |
---
|
15 |
-
#
|
16 |
|
17 |
This is a merge of pre-trained language models created using [mergekit](https://github.com/cg123/mergekit).
|
18 |
|
19 |
-
This model is effective in **structuring** the unstructured clinical texts.
|
20 |
|
21 |
### Model Composition and Features:
|
22 |
1. **Base Model**: The foundation of this model is based on "refuelai/Llama-3-Refueled," which itself is a refined version of the Llama3-8B model, renowned for its instruction-following capabilities and adaptability across various domains.
|
@@ -57,11 +60,79 @@ parameters:
|
|
57 |
dtype: bfloat16
|
58 |
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
```
|
61 |
|
62 |
```text
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
A 52-year-old woman comes to the physician because of a 6-month history of generalized fatigue, low-grade fever, and a 10-kg (22-lb) weight loss. Physical examination shows generalized pallor and splenomegaly. Her hemoglobin concentration is 7.5 g/dL and leukocyte count is 41,800/mm3. Leukocyte alkaline phosphatase activity is low. Peripheral blood smear shows basophilia with myelocytes and metamyelocytes. Bone marrow biopsy shows cellular hyperplasia with proliferation of immature granulocytic cells. Which of the following mechanisms is most likely responsible for this patient's condition?
|
66 |
Output JSON in this format.
|
67 |
{
|
@@ -75,21 +146,25 @@ A 52-year-old woman comes to the physician because of a 6-month history of gener
|
|
75 |
"possible diseases"
|
76 |
}
|
77 |
|
78 |
-
PLEASE WRITE ONLY JSON
|
|
|
|
|
|
|
|
|
79 |
|
|
|
80 |
{
|
81 |
"age": 52,
|
82 |
"gender": "female",
|
83 |
-
"past medical history":
|
84 |
-
"present symptoms":
|
85 |
-
"interventions":
|
86 |
-
"lab tests":
|
87 |
-
"medications":
|
88 |
-
"possible diseases":
|
89 |
-
}
|
90 |
```
|
91 |
|
92 |
-
|
93 |
### Limitations and Ethical Considerations:
|
94 |
- **Reliance on Training Data**: The model's effectiveness is contingent on the diversity and quality of the data it was trained on. There could be limitations in scenarios where it encounters rare or atypical medical cases not well-represented in the training data.
|
95 |
- **Potential Bias**: As with any AI model, there is a risk of bias inherent in the training datasets, which could influence the responses in unforeseen ways.
|
|
|
11 |
license: other
|
12 |
language:
|
13 |
- en
|
14 |
+
datasets:
|
15 |
+
- ruslanmv/ai-medical-chatbot
|
16 |
+
- Locutusque/hercules-v5.0
|
17 |
---
|
18 |
+
# Medichat-V2-Llama3-8B
|
19 |
|
20 |
This is a merge of pre-trained language models created using [mergekit](https://github.com/cg123/mergekit).
|
21 |
|
22 |
+
This model is particularly effective in **structuring** the unstructured clinical texts.
|
23 |
|
24 |
### Model Composition and Features:
|
25 |
1. **Base Model**: The foundation of this model is based on "refuelai/Llama-3-Refueled," which itself is a refined version of the Llama3-8B model, renowned for its instruction-following capabilities and adaptability across various domains.
|
|
|
60 |
dtype: bfloat16
|
61 |
|
62 |
|
63 |
+
```
|
64 |
+
## Usage
|
65 |
+
```python
|
66 |
+
import torch
|
67 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
68 |
+
|
69 |
+
class MedicalAssistant:
|
70 |
+
def __init__(self, model_name="sethuiyer/Medichat-V2-Llama3-8B", device="cuda"):
|
71 |
+
self.device = device
|
72 |
+
self.tokenizer = AutoTokenizer.from_pretrained(model_name)
|
73 |
+
self.model = AutoModelForCausalLM.from_pretrained(model_name).to(self.device)
|
74 |
+
self.sys_message = '''
|
75 |
+
You are an AI Medical Assistant trained on a vast dataset of health information. Please be thorough and
|
76 |
+
provide an informative answer. If you don't know the answer to a specific medical inquiry, advise seeking professional help.
|
77 |
+
'''
|
78 |
+
|
79 |
+
def format_prompt(self, question):
|
80 |
+
messages = [
|
81 |
+
{"role": "system", "content": self.sys_message},
|
82 |
+
{"role": "user", "content": question}
|
83 |
+
]
|
84 |
+
prompt = self.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
85 |
+
return prompt
|
86 |
+
|
87 |
+
def generate_response(self, question, max_new_tokens=512):
|
88 |
+
prompt = self.format_prompt(question)
|
89 |
+
inputs = self.tokenizer(prompt, return_tensors="pt").to(self.device)
|
90 |
+
with torch.no_grad():
|
91 |
+
outputs = self.model.generate(**inputs, max_new_tokens=max_new_tokens, use_cache=True)
|
92 |
+
answer = self.tokenizer.batch_decode(outputs, skip_special_tokens=True)[0].strip()
|
93 |
+
return answer
|
94 |
+
```
|
95 |
+
|
96 |
+
```python
|
97 |
+
assistant = MedicalAssistant()
|
98 |
+
question = '''
|
99 |
+
Symptoms:
|
100 |
+
Dizziness, headache, and nausea.
|
101 |
+
|
102 |
+
What is the differential diagnosis?
|
103 |
+
'''
|
104 |
+
response = assistant.generate_response(question)
|
105 |
+
print(response)
|
106 |
```
|
107 |
|
108 |
```text
|
109 |
+
Based on the symptoms of dizziness, headache, and nausea, the differential diagnosis could include several conditions. Here are some possible causes:
|
110 |
+
|
111 |
+
1. Vestibular disorders: These can cause dizziness, vertigo, and nausea. Examples include benign paroxysmal positional vertigo (BPPV), labyrinthitis, and vestibular neuritis.
|
112 |
+
|
113 |
+
2. Migraine: Migraines can cause severe headaches, nausea, and dizziness. They can be triggered by various factors, such as stress, changes in sleep patterns, or certain foods.
|
114 |
+
|
115 |
+
3. Inner ear infections: Infections in the inner ear, such as labyrinthitis or otitis media, can cause dizziness, nausea, and headache.
|
116 |
+
|
117 |
+
4. Meniere's disease: This is a disorder of the inner ear that can cause episodes of vertigo, nausea, and hearing loss.
|
118 |
+
|
119 |
+
5. Motion sickness: This can occur when the body receives conflicting signals from the eyes, inner ear, and other sensory systems. It can cause dizziness, nausea, and headache.
|
120 |
+
|
121 |
+
6. Anxiety or panic attacks: Anxiety or panic attacks can cause dizziness, nausea, and headache.
|
122 |
|
123 |
+
7. Low blood sugar (hypoglycemia): Low blood sugar can cause dizziness, headache, and nausea.
|
124 |
+
|
125 |
+
8. Medication side effects: Certain medications, such as antibiotics, antihistamines, and antidepressants, can cause dizziness, headache, and nausea as side effects.
|
126 |
+
|
127 |
+
9. Stroke or transient ischemic attack (TIA): These can cause sudden onset of dizziness, headache, and nausea.
|
128 |
+
|
129 |
+
10. Brain tumor or other central nervous system disorders: Rarely, a brain tumor or other central nervous system disorder can cause dizziness, headache, and nausea.
|
130 |
+
|
131 |
+
It is essential to consult a healthcare professional for a proper evaluation and diagnosis. They will likely perform a physical examination, take a detailed medical history, and order appropriate tests to determine the underlying cause of the symptoms. Treatment will depend on the specific diagnosis and may include medications, lifestyle changes, or other interventions.
|
132 |
+
|
133 |
+
```
|
134 |
+
```python
|
135 |
+
prompt = '''
|
136 |
A 52-year-old woman comes to the physician because of a 6-month history of generalized fatigue, low-grade fever, and a 10-kg (22-lb) weight loss. Physical examination shows generalized pallor and splenomegaly. Her hemoglobin concentration is 7.5 g/dL and leukocyte count is 41,800/mm3. Leukocyte alkaline phosphatase activity is low. Peripheral blood smear shows basophilia with myelocytes and metamyelocytes. Bone marrow biopsy shows cellular hyperplasia with proliferation of immature granulocytic cells. Which of the following mechanisms is most likely responsible for this patient's condition?
|
137 |
Output JSON in this format.
|
138 |
{
|
|
|
146 |
"possible diseases"
|
147 |
}
|
148 |
|
149 |
+
PLEASE WRITE ONLY JSON
|
150 |
+
'''
|
151 |
+
response = assistant.generate_response(prompt)
|
152 |
+
print(response)
|
153 |
+
```
|
154 |
|
155 |
+
```text
|
156 |
{
|
157 |
"age": 52,
|
158 |
"gender": "female",
|
159 |
+
"past medical history": "unknown",
|
160 |
+
"present symptoms": "generalized fatigue, low-grade fever, 10-kg (22-lb) weight loss",
|
161 |
+
"interventions": "bone marrow biopsy",
|
162 |
+
"lab tests": "hemoglobin concentration: 7.5 g/dL, leukocyte count: 41,800/mm3, leukocyte alkaline phosphatase activity: low, peripheral blood smear: basophilia with myelocytes and metamyelocytes",
|
163 |
+
"medications": "none",
|
164 |
+
"possible diseases": "chronic myeloid leukemia"
|
165 |
+
}
|
166 |
```
|
167 |
|
|
|
168 |
### Limitations and Ethical Considerations:
|
169 |
- **Reliance on Training Data**: The model's effectiveness is contingent on the diversity and quality of the data it was trained on. There could be limitations in scenarios where it encounters rare or atypical medical cases not well-represented in the training data.
|
170 |
- **Potential Bias**: As with any AI model, there is a risk of bias inherent in the training datasets, which could influence the responses in unforeseen ways.
|