模型概述
模型特點
模型能力
使用案例
🚀 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},
}



