MedicalGPT

MedicalGPT: Training Your Own Medical GPT Model with ChatGPT Training Pipeline. 训练医疗大模型,实现了包括增量预训练、有监督微调、RLHF(奖励建模、强化学习训练)和DPO(直接偏好优化)。

APACHE-2.0 License

Stars
2.4K
Committers
11

Bot releases are hidden (Show)

MedicalGPT - v2.2.0 Latest Release

Published by shibing624 3 months ago

v2.2.0

  • 支持了角色扮演模型训练
  • 新增了医患对话SFT数据生成脚本role_play_data

造角色扮演对话

本数据集使用OpenAI API接口生成,流程:

  • 种子特征集和基础设定
    • 手工编写的种子集包含基本角色特征。
    • LLM从这个种子集生成角色的基础设定。
  • 角色设定的进化
    • 第二个种子集包含指导角色设定进化的指令Prompt。
    • 这些进化角色的指令Prompt被放到一个指令池中。基于这些进化Prompt,LLM对基础设定实施进化。
  • 反馈循环
    • 由人类评估者和GPT-4组成的混合评价系统。此系统对进化后的设定给出反馈。
    • 反馈用于迭代更新种子集。如此迭代,我们最终得到一个细致的角色设定数据集。
  • 角色扮演和对话生成
    • 使用self-instruction框架基于角色设定生成角色的对话数据。
  1. 生成角色设定,分别生成护士角色和患者角色
cd role_play_data

python role_generate.py
  1. 生成医患之间的多轮对话
    LLM选择:分别用gpt-4o的api和豆包的doubao-character-pro-32k的api生成对话
python roleplay_data_generate_gpt4.py

python roleplay_data_generate_doubao.py

What's Changed

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/2.1.0...2.2.0

MedicalGPT - 2.1.0

Published by shibing624 4 months ago

v2.1版本:

  • 支持了 Qwen2 系列模型微调训练

What's Changed

New Contributors

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/2.0.0...2.1.0

MedicalGPT - 2.0.0

Published by shibing624 6 months ago

v2.0版本:

What's Changed

New Contributors

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/1.9.0...2.0.0

MedicalGPT - 1.9.0

Published by shibing624 6 months ago

v1.9版本

  1. 支持了 ORPO,详细用法请参照 run_orpo.sh。 不需要参考模型的优化方法,通过ORPO,LLM可以同时学习指令遵循和满足人类偏好,可以直接用base模型训练ORPO,训练相较SFT+DRO更简单,相对需要更多偏好数据集数据。
  2. 新增了支持微调qwen1.5, cohere 模型,和对应的template。

What's Changed

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/1.8.0...1.9.0

MedicalGPT - v1.8.0

Published by shibing624 9 months ago

v1.8版本

  1. 支持微调Mixtral混合专家MoE模型 Mixtral 8x7B,SFT中如果用lora微调模型,可以开启4bit量化和QLoRA--load_in_4bit True --qlora True以节省显存,建议设置--target_modules q_proj,k_proj,v_proj,o_proj,这样可以避免对MoE专家网络的MLP层量化,因为它们很稀疏且量化后会导致性能效果下降。
  2. 新增了支持微调deepseek, deepseekcoder, orion 模型,和对应的template。

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/1.7.0...1.8.0

MedicalGPT - v1.7.0

Published by shibing624 9 months ago

v1.7版本:

  1. 新增检索增强生成(RAG)的基于文件问答ChatPDF功能,代码chatpdf.py,可以基于微调后的LLM结合知识库文件问答提升行业问答准确率。运行python chatpdf.py调用rag问答。

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/1.6.0...1.7.0

MedicalGPT - v1.6.0

Published by shibing624 12 months ago

v1.6版本:

  1. 新增了RoPE插值来扩展GPT模型的上下文长度,通过位置插值方法,在增量数据上进行训练,使模型获得长文本处理能力,使用 --rope_scaling linear 参数训练模型;
  2. 针对LLaMA模型支持了FlashAttention-2,如果您使用的是 RTX4090、A100 或 H100 GPU,请使用 --flash_attn 参数以启用 FlashAttention-2;
  3. 新增了LongLoRA 提出的 $S^2$-Attn,使模型获得长文本处理能力,SFT中使用 --shift_attn 参数以启用该功能;
  4. 支持了NEFTune给embedding加噪SFT训练方法,NEFTune paper, 使用 --neft_alpha 参数启用 NEFTune,例如 --neft_alpha 5
  5. PT增量预训练支持qlora方法,如果使用的是 RTX4090、A100 或 H100 GPU,支持nf4,使用--qlora True --load_in_kbits 4参数启用qlora训练。

What's Changed

New Contributors

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/1.5.0...1.6.0

MedicalGPT - v1.5.0

Published by shibing624 about 1 year ago

v1.5版本

新增DPO(直接偏好优化)方法,DPO通过直接优化语言模型来实现对其行为的精确控制,而无需使用复杂的强化学习,也可以有效学习到人类偏好,DPO相较于RLHF更容易实现且易于训练,效果更好。

提供完整PT+SFT+DPO全阶段串起来训练的pipeline:run_training_dpo_pipeline.ipynb ,其对应的colab: Open In Colab,运行完大概需要15分钟,我运行成功后的副本colab:Open In Colab

What's Changed

New Contributors

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/1.4.0...1.5.0

MedicalGPT - v1.4.0

Published by shibing624 about 1 year ago

v1.4版本

发布基于ShareGPT4数据集微调的中英文Vicuna-13B模型shibing624/vicuna-baichuan-13b-chat,和对应的LoRA模型shibing624/vicuna-baichuan-13b-chat-lora,效果提升,并支持多轮问答。

演示shibing624/vicuna-baichuan-13b-chat模型效果:

What's Changed

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/1.3.0...1.4.0

MedicalGPT - v0.1.3

Published by shibing624 about 1 year ago

v1.3版本

  1. 新增LLaMA, LLaMA2, Bloom, ChatGLM, ChatGLM2, Baichuan模型的多轮对话微调训练
  2. 新增领域词表扩充功能 https://github.com/shibing624/MedicalGPT/blob/main/build_domain_tokenizer.py
  3. 新增中文预训练数据集和中文ShareGPT微调训练集 https://github.com/shibing624/MedicalGPT/wiki/%E6%95%B0%E6%8D%AE%E9%9B%86

What's Changed

New Contributors

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/1.2.0...1.3.0

MedicalGPT - v1.1

Published by shibing624 over 1 year ago

1.1版本:

发布中文医疗模型shibing624/ziya-llama-13b-medical-merged,基于Ziya-LLaMA-13B-v1模型,SFT微调了一版医疗模型,医疗问答效果有提升,发布微调后的完整模型权重

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/1.0.0...1.1

MedicalGPT - v1.0.0

Published by shibing624 over 1 year ago

v1.0.0版本:

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/0.2.0...1.0.0

MedicalGPT - v0.2

Published by shibing624 over 1 year ago

以医疗为例,训练医疗大模型,实现了四阶段训练:包括二次预训练、有监督微调、奖励建模、强化学习训练。

1)各阶段代码已经全部跑通,支持bloom, llama, chatglm等多模型训练;
2)RM奖励建模支持bert, Robert, llama, bloom等模型;
3)支持colab在线训练和测试;
4)支持单Python脚本执行任务;
5)发布了医疗大模型训练数据集shibing624/medical

Full Changelog: https://github.com/shibing624/MedicalGPT/compare/0.1.0...0.2.0

Badges
Extracted from project README's
HF Models Github Stars Contributions welcome License Apache 2.0 python_version GitHub issues Wechat Group Open In Colab Open In Colab GitHub issues
Related Projects