Medical Llama3 V2
針對醫療問答微調的Llama3 8B模型,專注於健康相關問題,提供豐富信息的回答。
下載量 2,446
發布時間 : 6/30/2024
模型概述
基於Llama3 8B模型微調的醫療問答模型,使用AI醫療聊天機器人數據集訓練,能夠生成有信息價值的醫療回覆。
模型特點
專注醫療領域
針對健康相關問題進行了優化,能夠提供專業的醫療信息回答。
知識豐富
在全面的醫療聊天機器人數據集上進行訓練,具備豐富的醫療知識。
文本生成能力
能夠生成有信息價值且可能有幫助的醫療回覆。
模型能力
醫療問答
症狀分析
診斷建議
治療信息提供
使用案例
醫療諮詢
症狀分析
用戶描述症狀,模型提供可能的醫療原因和建議。
生成詳細的症狀分析,建議進一步檢查或諮詢專業醫生。
診斷建議
根據用戶描述的症狀,模型提供可能的診斷方向。
列出可能的診斷選項,並建議相關檢查。
🚀 醫療版Llama3-v2:針對醫療問答微調的Llama3模型
本項目提供了強大的Llama3 8B模型的微調版本,專門設計用於以豐富的信息回答醫療問題。它藉助了AI醫療聊天機器人數據集(ruslanmv/ai-medical-chatbot)中的豐富知識。
🚀 快速開始
本模型可通過Hugging Face的Transformers庫訪問。
✨ 主要特性
- 專注醫療領域:針對健康相關問題進行了優化。
- 知識豐富:在全面的醫療聊天機器人數據集上進行訓練。
- 文本生成能力:能夠生成有信息價值且可能有幫助的回覆。
📦 安裝指南
使用pip安裝所需庫:
pip install transformers bitsandbytes accelerate
💻 使用示例
基礎用法
以下是一個Python代碼片段,展示瞭如何與Medical-Llama3-8B-16bit
模型進行交互,並生成醫療問題的答案:
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import torch
# Define BitsAndBytesConfig
bnb_config = BitsAndBytesConfig(load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16)
# Model name
model_name = "ruslanmv/Medical-Llama3-v2"
# Load tokenizer and model with BitsAndBytesConfig
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True, bnb_config=bnb_config)
model = AutoModelForCausalLM.from_pretrained(model_name, config=bnb_config)
# Ensure model is on the correct device
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
# Define askme function
def askme(question):
sys_message = '''
You are Medical AI Assistant. Please be thorough and provide an informative answer.
If you don't know the answer to a specific medical inquiry, advise seeking professional help.
'''
# Create messages structured for the chat template
messages = [{"role": "system", "content": sys_message}, {"role": "user", "content": question}]
# Applying chat template
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, padding=True, max_length=1000)
# Move inputs to device
input_ids = inputs['input_ids'].to(device)
attention_mask = inputs['attention_mask'].to(device)
# Generate outputs
with torch.no_grad():
outputs = model.generate(input_ids=input_ids, attention_mask=attention_mask, max_length=1000, use_cache=True)
# Extract and return the generated text, removing the prompt
response_text = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
return response_text
# Example usage
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))
答案示例如下:
Assistant: You should consult a physician for a proper diagnosis and discussion of treatment options. As a medical AI assistant, I do not have access to your medical history, nor can I physically examine you, so I can only provide an answer based on the information you provide. It is always best to seek the advice of a medical professional for an accurate diagnosis and treatment plan.
That being said, the symptoms you have described could be related to hypothyroidism, which is a condition in which the thyroid gland does not produce sufficient hormone. Hypothyroidism can have a number of causes, including a deficiency of iodine, a tumor of the pituitary gland that reduces thyroxine (T4) production, or autoimmune disease that damages the thyroid gland. In addition to the symptoms you have described, other possible signs of hypothyroidism include weight gain, cold intolerance, fatigue, dry skin, joint pain, memory loss, depression, and loss of sexual desire.
To determine whether your symptoms are related to hypothyroidism, your physician will start by taking a history and performing a physical examination. He or she will also order several laboratory tests, including:
1. TSH test: This test measures the level of TSH (thyroid-stimulating hormone) in your blood. TSH stimulates the thyroid gland to produce T4. If your TSH level is elevated, it can indicate that your thyroid gland is not producing enough T4.
2. T4 test: This test measures the level of T4 in your blood. T4 is the main hormone produced by the thyroid gland. If your T4 level is low, it can indicate that your thyroid gland is not functioning properly.
3. T3 test: This test measures the level of T3 in your blood. T3 is another hormone produced by the thyroid gland. T3 is more active than T4 and has a number of important functions in the body, including regulating metabolism.
4. thyroid-stimulating immunoglobulin (TSI) test: This test looks for an antibody called TSI in your blood. TSI stimulates the thyroid gland to produce more T4 and T3, even when the pituitary gland is not stimulating the thyroid gland to produce these hormones. The presence of TSI can indicate autoimmune thyroiditis.
5. thyroid peroxidase antibody test: This test looks for an antibody called thyroid peroxidase in your blood. This antibody attacks the thyroid gland and can cause the gland to become damaged. The presence of this antibody can indicate autoimmune thyroiditis.
If any of these tests suggest that you have hypothyroidism, your physician may want to order additional tests to confirm the diagnosis. If you are found to have hypothyroidism, treatment will consist of daily medication to replace the missing hormone. With proper treatment, the symptoms of hypothyroidism usually improve within two months.
Google Colab使用
你可以通過以下鏈接在Google Colab中使用該模型: Chatbot-Medical-Llama3-v2.ipynb
📚 詳細文檔
重要提示
本模型僅用於提供信息,不能替代專業的醫療建議。如有任何醫療問題,請始終諮詢合格的醫療保健提供者。
許可證
本模型根據Apache License 2.0進行分發(詳情請參閱LICENSE文件)。
貢獻
我們歡迎對本倉庫進行貢獻!如果您有改進建議或想法,請隨時創建拉取請求。
免責聲明
儘管我們努力提供有價值的回覆,但不能保證模型輸出的準確性。如需確切的醫療建議,務必諮詢醫生或其他醫療專業人員。
📄 許可證
本模型採用Apache License 2.0進行分發,詳情請查看LICENSE
文件。
Phi 2 GGUF
其他
Phi-2是微軟開發的一個小型但強大的語言模型,具有27億參數,專注於高效推理和高質量文本生成。
大型語言模型 支持多種語言
P
TheBloke
41.5M
205
Roberta Large
MIT
基於掩碼語言建模目標預訓練的大型英語語言模型,採用改進的BERT訓練方法
大型語言模型 英語
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基礎模型的蒸餾版本,在保持相近性能的同時更輕量高效,適用於序列分類、標記分類等自然語言處理任務。
大型語言模型 英語
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一個多語言大語言模型,針對多語言對話用例進行了優化,在常見的行業基準測試中表現優異。
大型語言模型 英語
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基於100種語言的2.5TB過濾CommonCrawl數據預訓練的多語言模型,採用掩碼語言建模目標進行訓練。
大型語言模型 支持多種語言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基於Transformer架構的英語預訓練模型,通過掩碼語言建模目標在海量文本上訓練,支持文本特徵提取和下游任務微調
大型語言模型 英語
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI發佈的開放預訓練Transformer語言模型套件,參數量從1.25億到1750億,旨在對標GPT-3系列性能,同時促進大規模語言模型的開放研究。
大型語言模型 英語
O
facebook
6.3M
198
1
基於transformers庫的預訓練模型,適用於多種NLP任務
大型語言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多語言大語言模型系列,包含8B、70B和405B參數規模,支持8種語言和代碼生成,優化了多語言對話場景。
大型語言模型
Transformers 支持多種語言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基礎版是由Google開發的文本到文本轉換Transformer模型,參數規模2.2億,支持多語言NLP任務。
大型語言模型 支持多種語言
T
google-t5
5.4M
702
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98