本仓库提供了功能强大的 Llama3 8B Instruct 模型的微调版本,专门设计用于以信息丰富的方式回答医学问题。
它充分利用了 AI Medical Dataset([ruslanmv/ai-medical-dataset])中包含的丰富知识。
模型与开发
主要特性
安装
该模型可通过 Hugging Face Transformers 库获取。使用 pip 安装:
!python -m pip install --upgrade pip
!pip3 install torch==2.2.1 torchvision torchaudio xformers --index-url https://download.pytorch.org/whl/cu121
!pip install bitsandbytes accelerate使用示例
以下是一个 Python 代码片段,演示如何与 ai-medical-model-32bit 模型交互并生成医学问题的答案:
from openmind import AutoModelForCausalLM, AutoTokenizer
import torch
model_name = "LF_AICC/ai-medical-model-32bit"
device_map = 'npu:0'
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16,
device_map=device_map
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
tokenizer.pad_token = tokenizer.eos_token
def askme(question):
prompt = f"<|start_header_id|>system<|end_header_id|> You are a Medical AI chatbot assistant. <|eot_id|><|start_header_id|>User: <|end_header_id|>This is the question: {question}<|eot_id|>"
# Tokenizing the input and generating the output
#prompt = f"{question}"
# Tokenizing the input and generating the output
inputs = tokenizer([prompt], return_tensors="pt").to("npu")
outputs = model.generate(**inputs, max_new_tokens=256, use_cache=True)
answer = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
# Try Remove the prompt
try:
# Split the answer at the first line break, assuming system intro and question are on separate lines
answer_parts = answer.split("\n", 1)
# If there are multiple parts, consider the second part as the answer
if len(answer_parts) > 1:
answers = answer_parts[1].strip() # Remove leading/trailing whitespaces
else:
answers = "" # If no split possible, set answer to empty string
print(f"Answer: {answers}")
except:
print(answer)
# Example usage
# - Question: Make the question.
question="What was the main cause of the inflammatory CD4+ T cells?"
askme(question)答案类型为:
Answer: I'm happy to help!
The main cause of inflammatory CD4+ T cells is a complex process that involves multiple factors. However, some of the key triggers include:
1. Activation of CD4+ T cells: CD4+ T cells are activated by antigens, cytokines, and other signals, leading to their proliferation and differentiation into effector cells.
2. Cytokine production: Activated CD4+ T cells produce cytokines such as interleukin-2 (IL-2), interferon-gamma (IFN-γ), and tumor necrosis factor-alpha (TNF-α), which promote inflammation and immune responses.
3. Chemokine production: CD4+ T cells also produce chemokines, such as CCL3, CCL4, and CCL5, which attract other immune cells to the site of inflammation.
4. Toll-like receptor (TLR) activation: TLRs are pattern recognition receptors that recognize pathogen-associated molecular patterns (PAMPs) and activate CD4+ T cells.
5. Bacterial or viral infections: Infections caused by bacteria, viruses, or fungi can trigger the activation of CD4+ T cells and the production of cytokines and chemokines重要说明
本模型仅用于信息参考,不应替代专业医疗建议。如有任何健康问题,请务必咨询合格的医疗保健提供者。
许可证
本模型根据 Apache License 2.0 协议分发(详情参见 LICENSE 文件)。
贡献指南
我们欢迎对本仓库的贡献!如果您有改进建议或想法,欢迎创建拉取请求。
免责声明
尽管我们努力提供有价值的响应,但模型输出的准确性无法保证。
| 指标 | 数值 |
|---|---|
| 平均值 | 67.67 |
| AI2 Reasoning Challenge (25-Shot) | 61.43 |
| HellaSwag (10-Shot) | 78.69 |
| MMLU (5-Shot) | 68.10 |
| TruthfulQA (0-shot) | 51.99 |
| Winogrande (5-shot) | 75.77 |
| GSM8k (5-shot) | 70.05 |