Built upon the powerful LLaMa-3 architecture and fine-tuned on an extensive dataset of health information, this model leverages its vast medical knowledge to offer clear, comprehensive answers.
This model is generally better for accurate and informative responses, particularly for users seeking in-depth medical advice.
The following YAML configuration was used to produce this model:
The current model demonstrates a substantial improvement over the previous Dr. Samantha model in terms of subject-specific knowledge and accuracy.
Usage:
importtorchfromtransformersimportAutoTokenizer,AutoModelForCausalLMclassMedicalAssistant:def__init__(self,model_name="sethuiyer/Medichat-Llama3-8B",device="cuda"):self.device=deviceself.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.
'''defformat_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)returnpromptdefgenerate_response(self,question,max_new_tokens=512):prompt=self.format_prompt(question)inputs=self.tokenizer(prompt,return_tensors="pt").to(self.device)withtorch.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()returnanswerif__name__=="__main__":assistant=MedicalAssistant()question='''
Symptoms:
Dizziness, headache, and nausea.
What is the differential diagnosis?
'''response=assistant.generate_response(question)print(response)
This model is now also available on Ollama. You can use it by running the command ollama run monotykamary/medichat-llama3 in your
terminal. If you have limited computing resources, check out this video to learn how to run it on
a Google Colab backend.