Flmc commited on
Commit
d1c81c0
1 Parent(s): f0d73e4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +171 -1
README.md CHANGED
@@ -9,4 +9,174 @@ tags:
9
  ---
10
  This repository contains the DISC-MedLLM, version of Baichuan-13b-base as the base model.
11
 
12
- Check [DISC-MedLLM](https://github.com/FudanDISC/DISC-MedLLM) for more information.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  ---
10
  This repository contains the DISC-MedLLM, version of Baichuan-13b-base as the base model.
11
 
12
+ Check [DISC-MedLLM](https://github.com/FudanDISC/DISC-MedLLM) for more information.
13
+
14
+ # DISC-MedLLM
15
+
16
+ [**Demo**](http://medllm.fudan-disc.com) | [**Tech Report**](https://arxiv.org/abs/2308.14346)
17
+
18
+ This is the repo of DISC-MedLLM, a medical domain-specific LLM designed for conversational healthcare scenarios by [Fudan-DISC](http://fudan-disc.com) lab.
19
+
20
+ The following resources have been released:
21
+ * DISC-Med-SFT Dataset (with out behavioral preference dataset)
22
+ * Model [weights](https://huggingface.co/Flmc/DISC-MedLLM) of DISC-MedLLM
23
+
24
+ You can check this [link](http://medllm.fudan-disc.com) to try our online demo.
25
+
26
+ ## Overview
27
+ The DISC-MedLLM is a large-scale domain-specific model designed for conversational healthcare scenarios. It can address a variety of your needs, including medical consultations and treatment inquiries, offering you high-quality health support services.
28
+
29
+ The DISC-MedLLM effectively bridges the gap between general language models and real-world medical consultations, as evidenced by experimental results.
30
+
31
+ Owing to our goal-oriented strategy and the framework that integrates both LLM and Human in the loop based on real-world doctor-patient dialogues and knowledge graphs, DISC-MedLLM boasts several features:
32
+
33
+ * **Knowledge-intensive and reliable**
34
+ * **Ability of multi-turn inquiry**
35
+ * **Alignment with human preferences**
36
+
37
+ <img src="https://github.com/FudanDISC/DISC-MedLLM/blob/main/images/data_construction.png" alt="data-construction" width="85%"/>
38
+
39
+ ## Demo
40
+ ### Consultation
41
+ <img src="https://github.com/FudanDISC/DISC-MedLLM/blob/main/images/consultation.gif" alt="sample1" width="60%"/>
42
+
43
+ ### Treatment Inquiry
44
+ <img src="https://github.com/FudanDISC/DISC-MedLLM/blob/main/images/advice.gif" alt="sample2" width="60%"/>
45
+
46
+ ## Dataset
47
+ <!-- In order to align the distribution of actual doctor responses with the intended AI doctor response distribution, our dataset is constructed from five main resources: Real-world Conversations (420k), Knowledge Graph-derived Question-Answer pairs (50k), Artificially Annotated Data aligned with human preferences (2k), MedMCQA (8k), and additional general data (34k). -->
48
+
49
+ To train DISC-MedLLM, we construct a high-quality dataset called DISC-Med-SFT consisting of over 470k distinct examples derived from existing medical datasets. We adopt a goal-oriented strategy by selectively reconstructing the dataset using a few deliberately chosen sources. These data sources serve the purpose of assisting LLMs in acquiring medical domain knowledge, aligning behavioral patterns with human preferences, and capturing real-world online medical dialogue distributions.
50
+
51
+ <!-- <style type="text/css">
52
+ .tg {border-collapse:collapse;border-spacing:0;}
53
+ .tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
54
+ overflow:hidden;padding:10px 5px;word-break:normal;}
55
+ .tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
56
+ font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
57
+ .tg .tg-9wq8{border-color:inherit;text-align:center;vertical-align:middle}
58
+ .tg .tg-c3ow{border-color:inherit;text-align:center;vertical-align:top}
59
+ </style> -->
60
+ <table class="tg" style="undefined;table-layout: fixed; width: 442px">
61
+ <colgroup>
62
+ <col style="width: 204.428571px">
63
+ <col style="width: 135.428571px">
64
+ <col style="width: 102.428571px">
65
+ </colgroup>
66
+ <thead>
67
+ <tr>
68
+ <th class="tg-9wq8" rowspan="2"><br>Dateset</th>
69
+ <th class="tg-9wq8" rowspan="2"><br>Original Source</th>
70
+ <th class="tg-9wq8" rowspan="2"><br>Size</th>
71
+ </tr>
72
+ <tr>
73
+ </tr>
74
+ </thead>
75
+ <tbody>
76
+ <tr>
77
+ <td class="tg-9wq8" rowspan="2">Re-constructed AI Doctor-Patient Dialogue</td>
78
+ <td class="tg-9wq8">MedDialog</td>
79
+ <td class="tg-9wq8">400k</td>
80
+ </tr>
81
+ <tr>
82
+ <td class="tg-9wq8">cMedQA2</td>
83
+ <td class="tg-c3ow">20k</td>
84
+ </tr>
85
+ <tr>
86
+ <td class="tg-c3ow">Knowledge Graph <br>QA pairs</td>
87
+ <td class="tg-9wq8">CMeKG</td>
88
+ <td class="tg-9wq8">50k</td>
89
+ </tr>
90
+ <tr>
91
+ <td class="tg-c3ow">Behavior Preference<br>Dataset</td>
92
+ <td class="tg-9wq8">Manual selection</td>
93
+ <td class="tg-9wq8">2k</td>
94
+ </tr>
95
+ <tr>
96
+ <td class="tg-9wq8" rowspan="3">Others</td>
97
+ <td class="tg-c3ow">MedMCQA</td>
98
+ <td class="tg-c3ow">8k</td>
99
+ </tr>
100
+ <tr>
101
+ <td class="tg-c3ow">MOSS-SFT</td>
102
+ <td class="tg-c3ow">33k</td>
103
+ </tr>
104
+ <tr>
105
+ <td class="tg-c3ow">Alpaca-GPT4-zh</td>
106
+ <td class="tg-c3ow">1k</td>
107
+ </tr>
108
+ </tbody>
109
+ </table>
110
+
111
+ <br>
112
+
113
+
114
+ ## Deploy
115
+ The current version of DISC-MedLLM is derived from the [Baichuan-13B-Base](https://github.com/baichuan-inc/Baichuan-13B). You can directly download our model weights from the HuggingFace [repository](https://huggingface.co/Flmc/DISC-MedLLM), or automatically obtain them through the demo code.
116
+
117
+
118
+ ### Using through hugging face transformers
119
+ ```python
120
+ >>> import torch
121
+ >>> from transformers import AutoModelForCausalLM, AutoTokenizer
122
+ >>> from transformers.generation.utils import GenerationConfig
123
+ >>> tokenizer = AutoTokenizer.from_pretrained("Flmc/DISC-MedLLM", use_fast=False, trust_remote_code=True)
124
+ >>> model = AutoModelForCausalLM.from_pretrained("Flmc/DISC-MedLLM", device_map="auto", torch_dtype=torch.float16, trust_remote_code=True)
125
+ >>> model.generation_config = GenerationConfig.from_pretrained("Flmc/DISC-MedLLM")
126
+ >>> messages = []
127
+ >>> messages.append({"role": "user", "content": "我感觉自己颈椎非常不舒服,每天睡醒都会头痛"})
128
+ >>> response = model.chat(tokenizer, messages)
129
+ >>> print(response)
130
+ ```
131
+
132
+
133
+ Additionally, since the current version uses Baichuan as the base model, you can refer to its [repo](https://github.com/baichuan-inc/Baichuan-13B) for deploying with int8, int4 quantized inference. However, using quantized deployment will result in performance degradation.
134
+ <br>
135
+
136
+ ## Training
137
+ You can fine-tuning our model using the data same as our data schema.
138
+ Our train code is derived from [Firefly](https://github.com/yangjianxin1/Firefly) with the different data schema and dialogue format. We jsut provide the code of Full Params Fine-tuning:
139
+ ```shell
140
+ deepspeed --num_gpus={num_gpus} ./train/train.py --train_args_file ./train/train_args/sft.json
141
+ ```
142
+ > Please check the setup of `sft.json` before you attempt to start training.
143
+
144
+ <br>If you want to fine-tuning our model with other training code, please use the following dialogue format.
145
+ ```shell
146
+ <\b><$user_token>content<$assistant_token>content<\s><$user_token>content ...
147
+ ```
148
+ The `user_token` and `assistant_token` we used are `195` and `196`, respectly. Which is same as Baichuan-13b-Chat.
149
+
150
+
151
+ ## Acknowledgement
152
+ This project wouldn't have been possible without the support and contributions of various individuals, teams, and organizations. Special thanks go to these repositories:
153
+
154
+ - [**MedDialog**](https://github.com/UCSD-AI4H/Medical-Dialogue-System)
155
+
156
+ - [**cMeKG**](https://github.com/king-yyf/CMeKG_tools)
157
+
158
+ - [**cMedQA**](https://github.com/zhangsheng93/cMedQA2)
159
+
160
+ - [**Baichuan-13B**](https://github.com/baichuan-inc/Baichuan-13B)
161
+
162
+ - [**FireFly**](https://github.com/yangjianxin1/Firefly)
163
+
164
+ Thank you also for the work that provided important assistance to the project, but limited in length.
165
+
166
+ ## Delcaration
167
+ Due to the inherent limitations of language models, we cannot assure the accuracy or reliability of information generated by this model. This model is designed exclusively for research and testing by individuals and academic groups. We urge users to critically assess any information or medical advice obtained through the model's output. Blindly trusting or following such information is strongly discouraged. We disclaim responsibility for any issues, risks, or adverse consequences resulting from the model's use.
168
+
169
+ ## Licenses
170
+ The use of the source code in this repository complies with the Apache 2.0 License.
171
+
172
+ ## Citation
173
+ ```angular2
174
+ @misc{bao2023discmedllm,
175
+ title={DISC-MedLLM: Bridging General Large Language Models and Real-World Medical Consultation},
176
+ author={Zhijie Bao and Wei Chen and Shengze Xiao and Kuang Ren and Jiaao Wu and Cheng Zhong and Jiajie Peng and Xuanjing Huang and Zhongyu Wei},
177
+ year={2023},
178
+ eprint={2308.14346},
179
+ archivePrefix={arXiv},
180
+ primaryClass={cs.CL}
181
+ }
182
+ ```