创新医疗AI模型在中文医疗场景超越GPT-4
HuatuoGPT-II是一款面向医疗领域的大型语言模型,采用一阶段适应方法提升医学知识和对话能力。在多项医疗基准测试中表现优异,专家评估和最新医学执照考试中超越GPT-4。项目开源了多个版本模型、训练代码和部分数据,为医疗AI研究提供支持。
欢迎来到HuatuoGPT2的代码仓库。
HuatuoGPT2采用创新的领域适应方法,显著提升了其医学知识和对话能力。它在多项医学基准测试中展现出最先进的性能,特别是在专家评估和最新医师执照考试中超越了GPT-4。
HuatuoGPT-2的开源发布包括:
请注意,我们仍在积极整理代码和数据。请持续关注即将到来的更新!
<div align=center> <img src="https://yellow-cdn.veclightyear.com/ab5030c0/57a34f4c-580c-46cb-a1fa-f7826577049d.png" width = "90%" alt="HuatuoGPT2" align=center/> </div>与代表性的开源模型和闭源模型(包括GPT-4)相比,HuatuoGPT2在医学基准测试中表现出色。以下是两项结果展示。
HuatuoGPT-II胜率 | 胜 | 平 | 负 |
---|---|---|---|
单轮医疗回答 | |||
HuatuoGPT-II(7B) vs GPT-4 | 38 | 38 | 24 |
HuatuoGPT-II(7B) vs ChatGPT | 52 | 33 | 15 |
HuatuoGPT-II(7B) vs Baichuan2-13B-Chat | 63 | 19 | 18 |
HuatuoGPT-II(7B) vs HuatuoGPT | 81 | 11 | 8 |
多轮医疗对话 | |||
HuatuoGPT-II(7B) vs GPT-4 | 53 | 17 | 30 |
HuatuoGPT-II(7B) vs ChatGPT | 56 | 11 | 33 |
HuatuoGPT-II(7B) vs Baichuan2-13B-Chat | 63 | 19 | 18 |
HuatuoGPT-II(7B) vs HuatuoGPT | 68 | 6 | 26 |
我们的模型现已在Huggingface上提供。你可以在https://www.huatuogpt.cn/试用我们的模型。
模型 | 基础模型 | 检查点 |
---|---|---|
HuatuoGPT2-7B | Baichuan2-7B-Base | HF链接 |
HuatuoGPT2-13B | Baichuan2-13B-Base | HF链接 |
HuatuoGPT2-34B | Yi-34B | HF链接 |
我们还提供了HuatuoGPT2的量化版本,使内存或计算资源有限的用户也能使用我们的HuatuoGPT2。
量化 | 基础模型 | 检查点 |
---|---|---|
HuatuoGPT2-7B-4bits | Baichuan2-7B-Base | HF链接 |
HuatuoGPT2-7B-8bits | Baichuan2-7B-Base | HF链接 |
HuatuoGPT2-34B-4bits | Yi-34B | HF链接 |
HuatuoGPT2-34B-8bits | Yi-34B | HF链接 |
import torch from transformers import AutoModelForCausalLM, AutoTokenizer tokenizer = AutoTokenizer.from_pretrained("FreedomIntelligence/HuatuoGPT2-7B", use_fast=True, trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("FreedomIntelligence/HuatuoGPT2-7B", device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True) messages = [] messages.append({"role": "user", "content": "肚子疼怎么办?"}) response = model.HuatuoChat(tokenizer, messages) print(response)
python cli_demo.py --model_name FreedomIntelligence/HuatuoGPT2-7B
我们开源了部分训练数据。
数据类型 | 训练数据量 | 链接 |
---|---|---|
医疗微调指令 (GPT-4) | 142,248 | HF链接 |
医疗预训练指令 | 5,286,308 | HF链接 |
python adaption/data_unification/rewrite.py
python adaption/one_stage_training/data_process.py
bash adaption/one_stage_training/train.sh
通过采用一阶段适应方法,您将观察到以下损失曲线:
<div align=center> <img src="https://yellow-cdn.veclightyear.com/ab5030c0/d013c9c5-b5ad-4105-b645-991e8167d5f6.png" width = "50%" alt="HuatuoGPT2" align=center/> </div>-- 问答基准测试的评估代码。
accelerate launch evaluation/eval_qa.py --model_path=FreedomIntelligence/HuatuoGPT2-7B --data_path=./evaluation/data/eval_qa.json
python evaluation/eval_huatuo_inst.py
python evaluation/eval_huatuo_conv.py
通过提供的链接访问我们最新的医学考试数据集。该数据集包含完整的考试题目,并注明考试日期以提醒潜在的泄露。我们计划在未来发布更多更新的考试。
考试 | 题目数量 | 考试时间 | 链接 |
---|---|---|---|
2023年中国执业药师资格考试(药学类) | 480 | 2023.10.22 | huggingface |
2023年中国执业药师资格考试(中药学类) | 480 | 2023.10.22 | huggingface |
其他最新医学考试即将推出 |
华佗GPT系列目前已推出两代:
未来,我们将继续发布华佗GPT的新版本。我们的目标是提升大语言模型在中文医疗领域的能力,并坚持开源原则(与FreedomIntelligence的理念一致)。我们希望与大家一起推动医疗大语言模型的发展!
我们来自香港中文大学(深圳)数据科学学院和深圳市大数据研究院。
@misc{chen2023huatuogptii,
title={HuatuoGPT-II, One-stage Training for Medical Adaption of LLMs},
author={Junying Chen and Xidong Wang and Anningzhe Gao and Feng Jiang and Shunian Chen and Hongbo Zhang and Dingjie Song and Wenya Xie and Chuyi Kong and Jianquan Li and Xiang Wan and Haizhou Li and Benyou Wang},
year={2023},
eprint={2311.09774},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
@article{huatuogpt-2023,
title={HuatuoGPT, Towards Taming Language Models To Be a Doctor},
author={Hongbo Zhang and Junying Chen and Feng Jiang and Fei Yu and Zhihong Chen and Jianquan Li and Guiming Chen and Xiangbo Wu and Zhiyi Zhang and Qingying Xiao and Xiang Wan and Benyou Wang and Haizhou Li},
journal={arXiv preprint arXiv:2305.15075},
year={2023}
}