sethuiyer's picture
Update README.md
602c422 verified
|
raw
history blame
7.37 kB
metadata
base_model:
  - ruslanmv/ai-medical-model-32bit
  - Locutusque/Llama-3-Hercules-5.0-8B
  - refuelai/Llama-3-Refueled
library_name: transformers
tags:
  - mergekit
  - merge
  - medical
license: other
language:
  - en
datasets:
  - ruslanmv/ai-medical-chatbot
  - Locutusque/hercules-v5.0

Medichat-V2-Llama3-8B

This is a merge of pre-trained language models created using mergekit.

This model is particularly effective in structuring the unstructured clinical texts.

Model Composition and Features:

  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.

  2. Merged Models:

    • ruslanmv/ai-medical-model-32bit: A model fine-tuned specifically for answering technical medical questions, providing a solid base of medical knowledge.
    • Locutusque/Llama-3-Hercules-5.0-8B: Known for its ability to follow complex instructions and handle conversational interactions effectively, especially in scientific and technical contexts.

This model was merged using the DARE TIES merge method using refuelai/Llama-3-Refueled as a base.

Models Merged

The following models were included in the merge:

Configuration

The following YAML configuration was used to produce this model:



models:
  - model: Locutusque/Llama-3-Hercules-5.0-8B
    parameters:
      weight: [0.25, 0.35, 0.45, 0.35, 0.25]
      density: [0.1, 0.25, 0.5, 0.25, 0.1]
  - model: refuelai/Llama-3-Refueled
  - model: ruslanmv/ai-medical-model-32bit
    parameters:
      weight: [0.55, 0.45, 0.35, 0.45, 0.55]
      density: [0.1, 0.25, 0.5, 0.25, 0.1]
merge_method: dare_ties
base_model: refuelai/Llama-3-Refueled
parameters:
  int8_mask: true
dtype: bfloat16

Usage

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

class MedicalAssistant:
    def __init__(self, model_name="sethuiyer/Medichat-V2-Llama3-8B", device="cuda"):
        self.device = device
        self.tokenizer = AutoTokenizer.from_pretrained(model_name)
        self.model = AutoModelForCausalLM.from_pretrained(model_name).to(self.device)
        self.sys_message = ''' 
        You are an AI Medical Assistant trained on a vast dataset of health information. Please be thorough and
        provide an informative answer. If you don't know the answer to a specific medical inquiry, advise seeking professional help.
        '''

    def format_prompt(self, question):
        messages = [
            {"role": "system", "content": self.sys_message},
            {"role": "user", "content": question}
        ]
        prompt = self.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
        return prompt

    def generate_response(self, question, max_new_tokens=512):
        prompt = self.format_prompt(question)
        inputs = self.tokenizer(prompt, return_tensors="pt").to(self.device)
        with torch.no_grad():
            outputs = self.model.generate(**inputs, max_new_tokens=max_new_tokens, use_cache=True)
        answer = self.tokenizer.batch_decode(outputs, skip_special_tokens=True)[0].strip()
        return answer
assistant = MedicalAssistant()
question = '''
Symptoms:
Dizziness, headache, and nausea.

What is the differential diagnosis?
'''
response = assistant.generate_response(question)
print(response)
Based on the symptoms of dizziness, headache, and nausea, the differential diagnosis could include several conditions. Here are some possible causes:

1. Vestibular disorders: These can cause dizziness, vertigo, and nausea. Examples include benign paroxysmal positional vertigo (BPPV), labyrinthitis, and vestibular neuritis.

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.

3. Inner ear infections: Infections in the inner ear, such as labyrinthitis or otitis media, can cause dizziness, nausea, and headache.

4. Meniere's disease: This is a disorder of the inner ear that can cause episodes of vertigo, nausea, and hearing loss.

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.

6. Anxiety or panic attacks: Anxiety or panic attacks can cause dizziness, nausea, and headache.

7. Low blood sugar (hypoglycemia): Low blood sugar can cause dizziness, headache, and nausea.

8. Medication side effects: Certain medications, such as antibiotics, antihistamines, and antidepressants, can cause dizziness, headache, and nausea as side effects.

9. Stroke or transient ischemic attack (TIA): These can cause sudden onset of dizziness, headache, and nausea.

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.

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.
prompt = '''
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?
    Output JSON in this format.
    {
    "age":
    "gender"
    "past medicial history"
    "present symptoms"
    "interventions"
    "lab tests"
    "medications"
    "possible diseases"
    }
    
    PLEASE WRITE ONLY JSON
'''
response = assistant.generate_response(prompt)
print(response)
{
    "age": 52,
    "gender": "female",
    "past medical history": "unknown",
    "present symptoms": "generalized fatigue, low-grade fever, 10-kg (22-lb) weight loss",
    "interventions": "bone marrow biopsy",
    "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",
    "medications": "none",
    "possible diseases": "chronic myeloid leukemia"
}

Quants

Quants of this model is available at mradermacher/Medichat-V2-Llama3-8B-GGUF