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