🚀 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文件)。
貢獻說明
我們歡迎對本倉庫進行貢獻!如果您有改進建議或想法,請隨時創建拉取請求。
免責聲明
儘管我們致力於提供有信息價值的回覆,但無法保證模型輸出的準確性。對於確定的醫療建議,諮詢醫生或其他醫療專業人員至關重要。