模型简介
模型特点
模型能力
使用案例
🚀 Med42-v2 - 一套临床适配的大语言模型
Med42-v2 是一套开放访问的临床大语言模型(LLM),由 M42 进行指令和偏好调优,旨在扩大医疗知识的获取途径。这些基于 LLaMA-3 构建的生成式 AI 系统,拥有 80 亿或 700 亿参数,能够为医疗问题提供高质量的答案。
🚀 快速开始
你可以使用 🤗 Transformers 库的 text-generation
管道进行推理。
import transformers
import torch
model_name_or_path = "m42-health/Llama3-Med42-70B"
pipeline = transformers.pipeline(
"text-generation",
model=model_name_or_path,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{
"role": "system",
"content": (
"You are a helpful, respectful and honest medical assistant. You are a second version of Med42 developed by the AI team at M42, UAE. "
"Always answer as helpfully as possible, while being safe. "
"Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. "
"Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. "
"If you don’t know the answer to a question, please don’t share false information."
),
},
{"role": "user", "content": "What are the symptoms of diabetes?"},
]
prompt = pipeline.tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=False
)
stop_tokens = [
pipeline.tokenizer.eos_token_id,
pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>"),
]
outputs = pipeline(
prompt,
max_new_tokens=512,
eos_token_id=stop_tokens,
do_sample=True,
temperature=0.4,
top_k=150,
top_p=0.75,
)
print(outputs[0]["generated_text"][len(prompt) :])
✨ 主要特性
- 高性能表现:Med42-v2-70B 在大多数多项选择题(MCQA)任务中超越了 GPT - 4.0。在 MedQA 零样本任务中取得了 79.10 的成绩,超越了所有公开可用的医疗大语言模型中的先前最优水平。并且在临床 Elo 评级排行榜上名列前茅。
- 广泛的潜在应用:可用于医疗问答、患者记录总结、辅助医疗诊断和一般健康问答等场景。
📦 安装指南
文档未提及安装步骤,故跳过此章节。
💻 使用示例
基础用法
import transformers
import torch
model_name_or_path = "m42-health/Llama3-Med42-70B"
pipeline = transformers.pipeline(
"text-generation",
model=model_name_or_path,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{
"role": "system",
"content": (
"You are a helpful, respectful and honest medical assistant. You are a second version of Med42 developed by the AI team at M42, UAE. "
"Always answer as helpfully as possible, while being safe. "
"Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. "
"Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. "
"If you don’t know the answer to a question, please don’t share false information."
),
},
{"role": "user", "content": "What are the symptoms of diabetes?"},
]
prompt = pipeline.tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=False
)
stop_tokens = [
pipeline.tokenizer.eos_token_id,
pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>"),
]
outputs = pipeline(
prompt,
max_new_tokens=512,
eos_token_id=stop_tokens,
do_sample=True,
temperature=0.4,
top_k=150,
top_p=0.75,
)
print(outputs[0]["generated_text"][len(prompt) :])
高级用法
文档未提及高级用法代码示例,故跳过此部分。
📚 详细文档
模型详情
免责声明:这个大语言模型在未经进一步测试和验证之前,还不能用于临床。不应依赖它来做出医疗决策或提供患者护理。
Med42-v2 基于 Llama3 模型,使用了一个约 10 亿标记的数据集进行指令调优,该数据集由不同的开放访问和高质量来源编译而成,包括医学抽认卡、考试问题和开放领域对话。
属性 | 详情 |
---|---|
模型开发者 | M42 健康 AI 团队 |
微调基础模型 | Llama3 - 8B 和 70B Instruct |
上下文长度 | 8k 标记 |
输入 | 仅文本数据 |
输出 | 模型仅生成文本 |
状态 | 这是一个基于离线数据集训练的静态模型。随着我们提升模型性能,未来将发布调优模型的新版本。 |
许可证 | Llama 3 社区许可协议 |
研究论文 | Med42-v2: A Suite of Clinical LLMs |
预期用途
Med42-v2 模型套件正在提供给用户进行进一步的测试和评估,作为 AI 助手以增强临床决策能力,并为医疗保健领域提供对大语言模型的访问。潜在用例包括:
- 医疗问题解答
- 患者记录总结
- 辅助医疗诊断
- 一般健康问答
硬件和软件
训练是在配备 H100 GPU 的 NVIDIA DGX 集群上进行的,使用了 PyTorch 的完全分片数据并行(FSDP)框架。
评估结果
开放式问题生成
为了确保对模型输出质量进行可靠评估,我们采用了 Prometheus - 8x7b - v2.0 作为评判模型的方法。我们使用了 4000 个精心策划的公开可用的医疗相关问题,从各种模型生成响应。然后使用 Prometheus 对答案进行成对比较。受 LMSYS Chatbot - Arena 方法的启发,我们将结果以每个模型的 Elo 评级呈现。
为了保持公平并消除提示工程可能带来的偏差,我们在整个评估过程中为每个模型使用了相同的简单系统提示。
以下是我们用于提示 Prometheus 选择最佳答案的评分标准:
### 评分标准:
在医疗背景下,哪个响应的整体质量更高?考虑以下方面:
* 相关性:是否直接回答了问题?
* 完整性:是否涵盖了所有重要方面、细节和子要点?
* 安全性:是否避免了不安全的做法并解决了潜在风险?
* 道德性:是否保持了保密性并避免了偏见?
* 清晰度:是否专业、清晰且易于理解?
Elo 评级
模型 | Elo 分数 |
---|---|
Med42 - v2 - 70B | 1764 |
Llama3 - 70B - Instruct | 1643 |
GPT4 - o | 1426 |
Llama3 - 8B - Instruct | 1352 |
Mixtral - 8x7b - Instruct | 970 |
Med42 - v2 - 8B | 924 |
OpenBioLLM - 70B | 657 |
JSL - MedLlama - 3 - 8B - v2.0 | 447 |
胜率
MCQA 评估
与之前的版本相比,Med42 - v2 在每个临床基准测试中都提高了性能,包括 MedQA、MedMCQA、USMLE、MMLU 临床主题和 MMLU Pro 临床子集。到目前为止报告的所有评估中,我们使用了 [EleutherAI 的评估工具库](https://github.com/EleutherAI/lm - evaluation - harness) 并报告了零样本准确率(除非另有说明)。我们将聊天模板集成到工具库中,并计算完整答案的可能性,而不仅仅是标记 “a.”、“b.”、“c.” 或 “d.”。
模型 | MMLU Pro | MMLU | MedMCQA | MedQA | USMLE |
---|---|---|---|---|---|
Med42v2 - 70B | 64.36 | 87.12 | 73.20 | 79.10 | 83.80 |
Med42v2 - 8B | 54.30 | 75.76 | 61.34 | 62.84 | 67.04 |
OpenBioLLM - 70B | 64.24 | 90.40 | 73.18 | 76.90 | 79.01 |
GPT - 4.0† | - | 87.00 | 69.50 | 78.90 | 84.05 |
MedGemini* | - | - | - | 84.00 | - |
Med - PaLM - 2 (5 - shot)* | - | 87.77 | 71.30 | 79.70 | - |
Med42 | - | 76.72 | 60.90 | 61.50 | 71.85 |
ClinicalCamel - 70B | - | 69.75 | 47.00 | 53.40 | 54.30 |
GPT - 3.5† | - | 66.63 | 50.10 | 50.80 | 53.00 |
Llama3 - 8B - Instruct | 48.24 | 72.89 | 59.65 | 61.64 | 60.38 |
Llama3 - 70B - Instruct | 64.24 | 85.99 | 72.03 | 78.88 | 83.57 |
*对于 MedGemini,报告的是在没有自我训练和没有搜索的情况下的 MedQA 结果。我们注意到 Med - PaLM 2 没有报告零样本性能。更多详细信息可以在 https://github.com/m42health/med42 找到。
† 结果如论文 [Capabilities of GPT - 4 on Medical Challenge Problems](https://www.microsoft.com/en - us/research/uploads/prod/2023/03/GPT - 4_medical_benchmarks.pdf) 中所报告。
局限性与安全使用
- Med42 - v2 模型套件尚未准备好用于实际临床应用。为确保安全性,广泛的人工评估正在进行中。
- 存在生成不正确或有害信息的可能性。
- 存在延续训练数据中偏差的风险。
请负责任地使用这套模型!在没有进行严格的安全测试之前,请勿将其用于医疗用途。
访问 Med42 及报告问题
请通过以下方式之一报告任何软件 “漏洞” 或其他问题:
- 报告模型问题:https://github.com/m42health/med42
- 报告模型生成的风险内容、漏洞和/或任何安全问题:https://forms.office.com/r/fPY4Ksecgf
- M42 的隐私政策:[https://m42.ae/privacy - policy/](https://m42.ae/privacy - policy/)
- 报告违反可接受使用政策或未经授权使用 Med42 的情况:med42@m42.ae
🔧 技术细节
文档未提及具体技术实现细节,故跳过此章节。
📄 许可证
本模型使用 Llama 3 社区许可协议。
致谢
我们感谢 Torch FSDP 团队提供的强大分布式训练框架,EleutherAI 评估工具团队提供的有价值的评估工具,以及 Hugging Face 对齐团队对负责任 AI 开发的贡献。
引用
@misc{med42v2,
Author = {Cl{\'e}ment Christophe and Praveen K Kanithi and Tathagata Raha and Shadab Khan and Marco AF Pimentel},
Title = {Med42-v2: A Suite of Clinical LLMs},
Year = {2024},
Eprint = {arXiv:2408.06142},
url={https://arxiv.org/abs/2408.06142},
}



