🚀 Medical-Llama3-8B-16bit:为医疗问答微调的Llama3模型
本仓库提供了强大的Llama3 8B模型的微调版本,专门用于以信息丰富的方式回答医疗问题。它利用了AI医疗聊天机器人数据集(ruslanmv/ai-medical-chatbot)中丰富的知识。
🚀 快速开始
本模型可通过Hugging Face Transformers库访问。以下是使用pip安装所需库的命令:
pip install transformers bitsandbytes accelerate
✨ 主要特性
- 专注医疗领域:针对解决健康相关问题进行了优化。
- 知识丰富:在全面的医疗聊天机器人数据集上进行训练。
- 文本生成能力:能够生成信息丰富且可能有帮助的回复。
📦 安装指南
此模型可通过Hugging Face Transformers库访问,使用以下pip命令进行安装:
pip install transformers bitsandbytes accelerate
💻 使用示例
基础用法
以下是一个Python代码片段,展示了如何与Medical-Llama3-8B-16bit
模型进行交互,并生成医疗问题的答案:
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import torch
model_name = "ruslanmv/Medical-Llama3-8B"
device_map = 'auto'
bnb_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4",bnb_4bit_compute_dtype=torch.float16,)
model = AutoModelForCausalLM.from_pretrained( model_name,quantization_config=bnb_config, trust_remote_code=True,use_cache=False,device_map=device_map)
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
tokenizer.pad_token = tokenizer.eos_token
def askme(question):
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.
'''
messages = [{"role": "system", "content": sys_message}, {"role": "user", "content": question}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=100, use_cache=True)
response_text = tokenizer.batch_decode(outputs)[0].strip()
answer = response_text.split('<|im_start|>assistant')[-1].strip()
return answer
question = '''I'm a 35-year-old male and for the past few months, I've been experiencing fatigue,
increased sensitivity to cold, and dry, itchy skin.
Could these symptoms be related to hypothyroidism?
If so, what steps should I take to get a proper diagnosis and discuss treatment options?'''
print(askme(question))
回答类型示例如下:
Based on your description, it sounds like you may be experiencing symptoms of hypothyroidism.
Hypothyroidism is a condition where the thyroid gland doesn't produce enough hormones, leading to a variety of symptoms.
Some common symptoms include fatigue, weight gain, constipation, and dry skin.
If you're experiencing any of these symptoms, it's important to see a doctor for a proper diagnosis and treatment plan.
Your doctor may order blood tests to check your thyroid hormone levels
📚 详细文档
模型与开发信息
- 开发者:ruslanmv
- 许可证:Apache-2.0
- 微调基础模型:meta-llama/Meta-Llama-3-8B
重要提示
⚠️ 重要提示
本模型仅用于提供信息,不能替代专业医疗建议。如有任何医疗问题,请始终咨询合格的医疗服务提供者。
💡 使用建议
虽然我们努力提供有价值的回复,但不能保证模型输出的准确性。如需明确的医疗建议,务必咨询医生或其他医疗专业人员。
📄 许可证
本模型根据Apache License 2.0进行分发(详情请参阅LICENSE文件)。
贡献说明
我们欢迎对本仓库进行贡献!如果您有改进建议或想法,请随时创建拉取请求。
免责声明
尽管我们致力于提供有信息价值的回复,但无法保证模型输出的准确性。对于确定的医疗建议,咨询医生或其他医疗专业人员至关重要。