Home

Awesome

MMedLM

<div align="center"> <img src="./assets/logo.png" width="200"/> <div align="center"></div> </div>

[Nature Communications] The official codes for "Towards Building Multilingual Language Model for Medicine".

Paper (Arxiv version)

Paper (Nature Communications)

Leaderboard

Models: MMedLM-7B, MMedLM 2-7B, MMedLM 2-1.8B, MMed-Llama 3-8B, MMed-Llama3-8B-EnIns

Datasets: MMedC,MMedBench

Introduction

In this paper, we aim to develop an open-source, multilingual language model for medicine. In general, we present the contribution from the following aspects:

  1. Corpus dataset. For multilingual medical-specific adaptation, we construct a new multilingual medical corpus, that contains approximately 25.5B tokens encompassing 6 main languages, termed as MMedC, that enables auto-regressive training for existing general LLMs.
  2. Benchmark. To monitor the development of multilingual LLMs in medicine, we propose a new multilingual medical multi-choice question-answering benchmark with rationale, termed as MMedBench.
  3. Model Evaluation. We have assessed a number of popular LLMs on our benchmark, along with those further auto-regressive trained on MMedC, as a result, our final model, termed as MMedLM 2, with only 7B parameters, achieves superior performance compared to all other open-source models, even rivaling GPT-4 on MMedBench.

News

[2024.9.27] Our paper has been accepted by Nature Communications!

[2024.5.24] We release MMed-Llama 3-8B and MMed-Llama3-8B-EnIns. MMed-Llama 3 is based on Llama 3 and futher pretrained on MMedC, and MMed-Llama 3 EnIns is a fine-tuned version with additional English instructions (from PMC-LLaMA).

[2024.3.1] We release MMedLM 2-1.8B, a 1.8B light-weight model based on InternLM 2-1.8B. With an auto-regressive continues training on MMedC, MMedLM 2-1.8B can exceed the performance of most 7B models, including InternLM and LLaMA 2.

[2024.2.21] Our leaderboard web can be found here. We look forward to more superior efforts in multilingual medical LLMs!.

[2024.2.21] Our pre-print paper is released ArXiv. Dive into our findings here.

[2024.2.20] We release MMedLM and MMedLM 2. With an auto-regressive continues training on MMedC, these models achieves superior performance compared to all other open-source models, even rivaling GPT-4 on MMedBench.

[2023.2.20] We release MMedC, a multilingual medical corpus containing 25.5B tokens.

[2023.2.20] We release MMedBench, a new multilingual medical multi-choice question-answering benchmark with rationale.

Usage

Environment

In our experiments, we used A100 80 GB GPUs and the Slurm scheduling system. We provide a Slurm script to launch training. You can also remove the Slurm commands to run the code on a single machine.

For dependencies, we used Pytorch 1.13 and Transformers 4.37. For LoRA fine-tune, it is also necessary to install the corresponding PEFT library.

Auto-regressive Training on MMedC

We provide all the code used for further training on MMedC. The codes are in the pretrain folder. You can check the documentation in the folder for how to use the codes.

Fine-tuning on MMedBench Trainset

We provide all the code used for fine-tuning. We support 2 fine-tuning methods: Full-Model Fine-tuning and PEFT Fine-Tuning. Both codes are in the finetune folder. You can check the documentation in the folder for how to use the codes.

Inference on MMedBench Testset

We provide the code used for inference on MMedBench Testset. The codes are in the pretrain folder. You can check the documentation in the folder for how to use the codes.

Data Collection Pipeline

We also release our Data Collection Pipeline, including codes of data filtering and Textbooks OCR. For OCR, you may need to install some extra dependencies. Please check out the data_collection folder for more details.

Results on Commonly-used English Benchmarks

Here, we incorporate the additional English instructions (from PMC-LLaMA) into MMed-Llama\ 3 finetuning, and present a comparison between our model and other existing LLMs on various English benchmarks.

MethodSizeYearMedQAMedMCQAPubMedQAMMLU_CKMMLU_MGMMLU_ANMMLU_PMMMLU_CBMMLU_CMAvg.
MedAlpaca7B2023.341.737.572.857.469.057.067.365.354.358.03
PMC-LLaMA13B2023.956.456.077.9-------
MEDITRON7B2023.1157.259.274.464.659.949.355.453.844.857.62
Mistral7B2023.1250.848.275.468.771.055.668.468.159.562.97
Gemma7B2024.247.249.076.269.870.059.366.279.960.164.19
BioMistral7B2024.250.648.177.559.964.056.560.459.054.758.97
Llama 38B2024.460.950.773.072.176.063.077.279.964.268.56
MMed-Llama 3~(Ours)8B-65.463.580.171.385.069.677.674.366.572.59

Results on MMedBench

Here we show the main results of models' performance on MMedBench. For more details, please check out our paper.

Accuracy(%)

MethodSizeYearMMedCMMedBenchEnglishChineseJapaneseFrenchRussianSpanishAvg.
GPT-3.5-2022.1256.8852.2934.6332.4866.3666.0651.47
GPT-4-2023.378.0075.0772.9156.5983.6285.6774.27
Gemini-1.0 pro-2024.153.7360.1944.2229.9073.4469.6955.20
BLOOMZ7B2023.5trainset43.2858.0632.6626.3762.8947.3445.10
InternLM7B2023.7trainset44.0764.6237.1924.9258.2044.9745.67
Llama 27B2023.7trainset43.3650.2925.1320.9066.8047.1042.26
MedAlpaca7B2023.3trainset46.7444.8029.6421.0659.3845.0041.11
ChatDoctor7B2023.4trainset43.5243.2625.6318.8162.5043.4439.53
PMC-LLaMA7B2023.4trainset47.5342.4424.1220.7462.1143.2940.04
Mistral7B2023.10trainset61.7471.1044.7248.7174.2263.8660.73
MEDITRON7B2023.11trainset55.4661.8840.2035.0567.5853.2852.24
InternLM 21.8B2024.2trainset38.4964.132.1618.0153.9136.8340.58
InternLM 27B2024.2trainset57.2777.5547.7441.0068.3659.5958.59
BioMistral7B2024.2trainset57.8271.5437.1947.2769.9260.9857.45
Llama 38B2024.4trainset63.8678.2348.2450.8071.4864.1562.79
MMedLM (Ours)7B-trainset49.8870.4946.2336.6672.2754.5255.01
MMedLM 2(Ours)7B-trainset61.7480.0161.8152.0980.4767.6567.30
MMedLM 2(Ours)1.8B-trainset45.4066.7842.2125.5669.1443.4048.75
MMed-Llama 3(Ours)8B-trainset66.0679.2561.8155.6375.3968.3867.75

Rationale similarity (BLEU-1/ROUGE-1)

MethodEnglishChineseJapaneseFrenchRussianSpanishAvg.
BLOOMZ45.94/ 40.5148.37/ 48.2644.71/ 48.6144.47/ 41.0529.95/ 21.5045.91/ 40.7743.22/ 40.12
InternLM46.53/ 41.8648.24/ 48.6444.89/ 49.8341.80/ 37.9527.87/ 21.2043.42/ 38.5942.12/ 39.68
Llama 246.87/ 41.3946.62/ 46.5748.53/ 51.2144.43/ 40.3833.05/ 23.2445.96/ 40.3744.24/ 40.53
MedAlpaca47.33/ 42.3145.72/ 46.4945.35/ 49.1243.78/ 40.4132.80/ 23.1545.99/ 40.5743.49/ 40.34
ChatDoctor47.22/ 41.9744.66/ 45.8138.87/ 47.9544.64/ 40.2532.19/ 23.3745.68/ 40.7142.21/ 40.01
PMC-LLaMA47.33/ 42.8745.87/ 46.1844.52/ 48.4443.80/ 40.2331.14/ 22.2846.30/ 40.6843.16/ 40.12
Mistral47.16/ 41.8248.34/ 47.9148.80/ 50.6045.83/ 40.8834.52/ 24.6847.55/ 41.4145.37/ 41.22
InternLM249.48/ 44.1251.38/ 51.5850.64/ 53.4646.73/ 42.0032.93/ 24.0547.94/ 41.9646.52/ 42.86
MMedLM47.37/ 41.9848.68/ 49.2848.95/ 52.3445.39/ 41.4133.24/ 24.6746.68/ 41.3545.05/ 41.84
MMedLM 250.02/ 44.7751.39/ 51.7854.79/ 57.1049.04/ 45.3037.49/ 28.1850.14/ 44.5948.81/ 45.29

Case Study

Acknowledgement

PMC-LLaMA -- https://github.com/chaoyi-wu/PMC-LLaMA

InternLM -- https://github.com/InternLM/InternLM

Llama 3 -- https://llama.meta.com/llama3/

Contact

If you have any question, please feel free to contact qiupengcheng@pjlab.org.cn.

Citation

@misc{qiu2024building,
      title={Towards Building Multilingual Language Model for Medicine}, 
      author={Pengcheng Qiu and Chaoyi Wu and Xiaoman Zhang and Weixiong Lin and Haicheng Wang and Ya Zhang and Yanfeng Wang and Weidi Xie},
      year={2024},
      eprint={2402.13963},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}