🚀 Medichat-Llama3-8B
Medichat-Llama3-8B 基于强大的 LLaMa - 3 架构构建,并在大量健康信息数据集上进行了微调。该模型凭借其丰富的医学知识,能够提供清晰、全面的答案,尤其适合那些寻求深入医疗建议的用户,能给出准确且有价值的回复。
✨ 主要特性
- 基于强大的 LLaMa - 3 架构,拥有丰富的医学知识储备。
- 在大量健康信息数据集上进行微调,能提供准确、全面的医疗相关回答。
- 相比之前的模型,在特定学科知识和准确性上有显著提升。
📦 安装指南
文档未提供具体安装步骤,暂不展示。
💻 使用示例
基础用法
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
class MedicalAssistant:
def __init__(self, model_name="sethuiyer/Medichat-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
if __name__ == "__main__":
assistant = MedicalAssistant()
question = '''
Symptoms:
Dizziness, headache, and nausea.
What is the differential diagnosis?
'''
response = assistant.generate_response(question)
print(response)
📚 详细文档
模型基础信息
属性 |
详情 |
基础模型 |
Undi95/Llama - 3 - Unholy - 8B、Locutusque/llama - 3 - neural - chat - v1 - 8b、ruslanmv/Medical - Llama3 - 8B - 16bit |
库名称 |
transformers |
标签 |
mergekit、merge、medical |
许可证 |
other |
训练数据集 |
mlabonne/orpo - dpo - mix - 40k、Open - Orca/SlimOrca - Dedup、jondurbin/airoboros - 3.2、microsoft/orca - math - word - problems - 200k、m - a - p/Code - Feedback、MaziyarPanahi/WizardLM_evol_instruct_V2_196k、ruslanmv/ai - medical - chatbot |
模型构建配置
以下是用于生成此模型的 YAML 配置:
models:
- model: Undi95/Llama-3-Unholy-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: Locutusque/llama-3-neural-chat-v1-8b
- model: ruslanmv/Medical-Llama3-8B-16bit
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: Locutusque/llama-3-neural-chat-v1-8b
parameters:
int8_mask: true
dtype: bfloat16
与 Dr.Samantha 7B 模型对比
学科 |
Medichat - Llama3 - 8B 准确率 (%) |
Dr. Samantha 准确率 (%) |
临床知识 |
71.70 |
52.83 |
医学遗传学 |
78.00 |
49.00 |
人类衰老 |
70.40 |
58.29 |
人类性学 |
73.28 |
55.73 |
大学医学 |
62.43 |
38.73 |
解剖学 |
64.44 |
41.48 |
大学生物学 |
72.22 |
52.08 |
高中生物学 |
77.10 |
53.23 |
专业医学 |
63.97 |
38.73 |
营养学 |
73.86 |
50.33 |
专业心理学 |
68.95 |
46.57 |
病毒学 |
54.22 |
41.57 |
高中心理学 |
83.67 |
66.60 |
平均 |
70.33 |
48.85 |
当前模型在特定学科知识和准确性方面相较于之前的 Dr. Samantha 模型有显著提升。
量化版本
感谢 Quant Factory,该模型的量化版本可在 QuantFactory/Medichat - Llama3 - 8B - GGUF 获取。
Ollama 使用
此模型现在也可在 Ollama 上使用。你可以在终端中运行命令 ollama run monotykamary/medichat-llama3
来使用它。如果你计算资源有限,可以查看这个 视频 学习如何在 Google Colab 后端运行该模型。
🔧 技术细节
文档未提供具体技术细节,暂不展示。
📄 许可证
该模型使用的许可证为 other。