├── LICENSE
├── README.md
├── assets
├── WiNGPT2-Llama3-8B.png
├── WiNGPT2-PT.png
├── WiNGPT2-SFT.png
├── WiNGPT_GROUP.JPG
├── chestxr_analyzer.png
├── medicine_db.png
├── struct_output.png
├── wechatgroup.jpg
└── 客观题.png
└── demo.py
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## WiNGPT2
2 |
3 | WiNGPT是一个医疗垂直领域大模型,旨在将专业的医学知识、医疗信息、数据融会贯通,为医疗行业提供智能化的医疗问答、诊断支持和医学知识等信息服务,提高诊疗效率和医疗服务质量。
4 |
5 | ## 更新日志
6 |
7 | [2024/08/15] 开源 [🤗](https://huggingface.co/winninghealth/WiNGPT2-Gemma-2-9B-Chat)WiNGPT2-Gemma-2-9B-Chat;医疗领域增量预训练权重[🤗](https://huggingface.co/winninghealth/WiNGPT2-Gemma-2-9B-Base)WiNGPT2-Gemma-2-9B-Base
8 |
9 | [2024/04/24] 开源 [🤗](https://huggingface.co/winninghealth/WiNGPT2-Llama-3-8B-Chat)WiNGPT2-Llama3-8B-Chat;及其量化版模型[🤗](https://huggingface.co/winninghealth/WiNGPT2-Llama-3-8B-Chat-AWQ)WiNGPT2-Llama3-8B-Chat-AWQ、[🤗](https://huggingface.co/winninghealth/WiNGPT2-Llama-3-8B-Chat-GGUF)WiNGPT2-Llama3-8B-Chat-GGUF
10 |
11 | [2024/04/23] 开源 基于Llama3-8b-base模型医疗领域增量预训练权重: [🤗](https://huggingface.co/winninghealth/WiNGPT2-Llama-3-8B-Base)WiNGPT2-Llama3-8B-Base
12 |
13 | [2024/04/01] 更新 WiNEval 测评结果
14 |
15 | [2024/03/05] 开源7B/14B-Chat-4bit模型权重: [🤗](https://huggingface.co/winninghealth/WiNGPT2-7B-Chat-AWQ)WiNGPT2-7B-Chat-4bit和[🤗](https://huggingface.co/winninghealth/WiNGPT2-14B-Chat-AWQ)WiNGPT2-14B-Chat-4bit。
16 |
17 | [2023/12/20] 新增用户微信群二维码,有效期到12月27日,扫码进群。
18 |
19 | [2023/12/18] 发布卫宁健康医疗模型测评方案 WiNEval-MCKQuiz的评测结果。
20 |
21 | [2023/12/12] 开源 WiNGPT2 14B模型权重: [🤗](https://huggingface.co/winninghealth/WiNGPT2-14B-Base)WiNGPT2-14B-Base 和 [🤗](https://huggingface.co/winninghealth/WiNGPT2-14B-Chat)WiNGPT2-14B-Chat。
22 |
23 | [2023/11/02] [34B模型平台测试](https://wingpt.winning.com.cn/) 和 [欢迎加入微信讨论群](https://github.com/winninghealth/WiNGPT2/blob/main/assets/WiNGPT_GROUP.JPG)
24 |
25 | [2023/10/13] 更新一个简单的[Chatbot示例](#部署),可以进行简单的多轮对话。
26 |
27 | [2023/09/26] 开源 WiNGPT2 与7B模型权重: [🤗](https://huggingface.co/winninghealth/WiNGPT2-7B-Base)WiNGPT2-7B-Base 和 [🤗](https://huggingface.co/winninghealth/WiNGPT2-7B-Chat)WiNGPT2-7B-Chat。
28 |
29 | ## 目录
30 |
31 | - [介绍](#介绍)
32 | - [特点](#特点)
33 | - [如何使用](#如何使用)
34 | - [训练数据](#训练数据)
35 | - [模型卡](#模型卡)
36 | - [评测](#评测)
37 | - [应用](#应用)
38 | - [多模态](#多模态 - WiNGPT-3)
39 | - [局限性与免责声明](#局限性与免责声明)
40 | - [许可证](#许可证)
41 | - [参考资料](#参考资料)
42 | - [联系我们](#联系我们)
43 |
44 | ## 介绍
45 |
46 | WiNGPT(卫宁健康医疗语言大模型,以下简称WiNGPT)的研发和训练工作开始于2023年1月。
47 |
48 | 3月,卫宁健康人工智能实验室已完成了WiNGPT1可行性验证并开始内测。WiNGPT1采用通用的GPT架构、62亿参数,实现了从预训练到微调的全过程自研。
49 |
50 | 今年5月,WiNGPT1训练的数据量已达到9720项药品知识、 18个药品类型、7200余项疾病知识、 2800余项检查检验知识、53本书籍知识、1100余份指南文档,总训练Token数达37亿。
51 |
52 | 7月,WiNGPT升级到7B并采用最新的模型架构,新增检索式增强生成能力,同时开始了13B模型的训练和行业邀测。
53 |
54 | 9月,WiNGPT迎来最新版本迭代,推出了全新的WiNGPT2,新版本可以被轻松扩展和个性化并用于下游各种应用场景。
55 |
56 | 12月,WiNGPT3上线,具备图文聊天功能的大语言模型。
57 |
58 | 为了回馈开源社区我们尝试开源了WiNGPT2-7B/14B版本。我们的初衷是希望通过更多的开源项目加速医疗语言大模型技术与行业的共同发展,最终惠及我们人类健康。
59 |
60 |
61 | ## 特点
62 |
63 | - 核心功能
64 |
65 | - **医学知识问答**:可以回答关于医学、健康、疾病等方面的问题,包括但不限于症状、治疗、药物、预防、检查等。
66 | - **自然语言理解**:理解医学术语、病历等医疗文本信息,提供关键信息抽取和归类
67 | - **多轮对话**:可扮演各种医疗专业角色如医生与用户进行对话,根据上下文提供更加准确的答案。
68 | - **多任务支持**:支持32项医疗任务,八大医疗场景18个子场景。
69 |
70 | - 模型架构
71 |
72 | - 基于Transformer的70亿参数规模大语言模型, 采用RoPE相对位置编码、SwiGLU激活函数、RMSNorm,训练采用Qwen-7b1作为基础预训练模型。
73 |
74 | - 主要特点
75 |
76 | - 高准确度:基于大规模医疗语料库训练,具有较高的准确率和较低的误诊可能性。
77 | - 场景导向:针对不同的医疗场景和真实需求进行专门优化和定制,更好的服务应用落地。
78 | - 迭代优化:持续搜集和学习最新的医学研究,不断提高模型性能和系统功能。
79 |
80 | ## 如何使用
81 |
82 | ### 下载
83 |
84 | 🤗下载地址:
85 |
86 | [WiNGPT2-7B-Base](https://huggingface.co/winninghealth/WiNGPT2-7B-Base)
87 |
88 | [WiNGPT2-7B-Chat](https://huggingface.co/winninghealth/WiNGPT2-7B-Chat)
89 |
90 | [WiNGPT2-14B-Base](https://huggingface.co/winninghealth/WiNGPT2-14B-Base)
91 |
92 | [WiNGPT2-14B-Chat](https://huggingface.co/winninghealth/WiNGPT2-14B-Chat)
93 |
94 | [WiNGPT2-7B-Chat-4bit](https://huggingface.co/winninghealth/WiNGPT2-7B-Chat-AWQ)
95 |
96 | [WiNGPT2-14B-Chat-4bit](https://huggingface.co/winninghealth/WiNGPT2-14B-Chat-AWQ)
97 |
98 | [WiNGPT2-Llama3-8B-Base](https://huggingface.co/winninghealth/WiNGPT2-Llama-3-8B-Base)
99 |
100 | [WiNGPT2-Llama3-8B-Chat](https://huggingface.co/winninghealth/WiNGPT2-Llama-3-8B-Chat)
101 |
102 | [WiNGPT2-Llama3-8B-Chat-AWQ](https://huggingface.co/winninghealth/WiNGPT2-Llama-3-8B-Chat-AWQ)
103 |
104 | [WiNGPT2-Llama3-8B-Chat-GGUF](https://huggingface.co/winninghealth/WiNGPT2-Llama-3-8B-Chat-GGUF)
105 |
106 | ### 推理
107 |
108 | ```python
109 | from transformers import AutoModelForCausalLM, AutoTokenizer
110 |
111 | model_path = "WiNGPT2-7B-Chat"
112 | device = "cuda"
113 |
114 | tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
115 | model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True).to(device)
116 | model = model.eval()
117 |
118 |
119 | text = 'User: WiNGPT, 你好<|endoftext|>\n Assistant:'
120 | inputs = tokenizer.encode(text, return_tensors="pt").to(device)
121 | outputs = model.generate(inputs, repetition_penalty=1.1, max_new_tokens=1024)
122 | response = tokenizer.decode(outputs[0])
123 | print(response)
124 |
125 | ## 输出结果:你好!今天我能为你做些什么?<|endoftext|>
126 | ```
127 |
128 | ### 提示
129 |
130 | WiNGPT2-7B-Chat使用了自定义的提示格式:
131 |
132 | 用户角色:User/Assistant
133 |
134 | 提示模板:User:[此处有空格]WiNGPT, 你好<|endoftext|>\n[此处有空格]Assistant:;**多轮对话**按此模板进行拼接,例如:
135 | ```
136 | "User: WiNGPT, 你好<|endoftext|>\n Assistant:你好!今天我能为你做些什么?<|endoftext|>\n User: 你是谁?<|endoftext|>\n Assistant:"
137 | ```
138 |
139 | 解码时推荐使用repetition_penalty=1.1 [greedy search]
140 |
141 | ### 部署
142 |
143 | 简单的chatbot部署示例:
144 |
145 | ```
146 | python demo.py
147 | ```
148 | 注意:需要安装gradio
149 |
150 | ### 企业服务
151 |
152 | [通过WiNGPT测试平台申请密钥或与我们取得联系](https://wingpt.winning.com.cn/)
153 |
154 | ## 训练数据
155 |
156 | - 数据总览
157 |
158 | - 总数据量:预训练数据约20G,指令数据约50万条,数据分布情况如下图所示。

159 |
160 | - 医疗专业数据
161 |
162 | | 来源 | 类型 | 数量 |
163 | | ---------------- | ------ | ------------------- |
164 | | 药品说明书 | 知识库 | 15000 条 |
165 | | 多病种知识库 | 知识库 | 9720 项 |
166 | | 医疗专业书籍 | 教材 | 300 本 |
167 | | 临床路径知识库 | 知识库 | 1400 条 |
168 | | 检查检验知识 | 知识库 | 110 万条 |
169 | | 多学科临床指南 | 书籍 | 18 个科室共 1100 份 |
170 | | 医疗知识图谱 | 知识库 | 256 万三元组 |
171 | | 人工标注数据集 | 指令 | 5 万条 |
172 | | 医学资格考试试题 | 试题 | 30 万条 |
173 | | 医疗病例、报告 | 知识库 | 100 万条 |
174 |
175 | - 其他公开数据
176 |
177 | | 来源 | 类型 | 数量 |
178 | | -------------------- | ------ | -------- |
179 | | 医学科普书籍 | 书籍 | 500 本 |
180 | | 其他多学科书籍 | 书籍 | 1000 本 |
181 | | 代码 | 指令 | 20 万条 |
182 | | 通用类试题 | 试题 | 300 万条 |
183 | | 多种自然语言处理任务 | 指令 | 90 万条 |
184 | | 互联网文本 | 互联网 | 300 万条 |
185 | | 医疗问答、对话 | 指令 | 500 万条 |
186 |
187 | - 继续预训练
188 |
189 | - 扩充模型的医疗知识库:预训练数据+部分指令数据。
190 |
191 | - 指令微调
192 |
193 | - 从书籍、指南、病例、医疗报告、知识图谱等数据中自动化构建医疗指令集。
194 | - 人工标注指令集,数据来源包括:电子病历系统、护理病历系统、PACS系统、临床科研系统、手术管理系统、公共卫生场景、医务管理场景以及工具助手场景。
195 | - 采用 FastChat2、Self-Instruct3、Evol-Instruct4 等方案,对指令集进行扩展以及丰富指令集多样化形式。
196 |
197 | - 数据工程
198 |
199 | - 数据分类:根据训练阶段和任务场景进行分类。
200 | - 数据清洗:去除无关信息,更正数据中的拼写错误,提取关键信息以及去隐私处理。
201 | - 数据去重:采用 embedding 方法剔除重复数据。
202 | - 数据采样:根据数据集的质量与分布需求进行有针对性的采样。
203 |
204 | ## 模型卡
205 |
206 | - 训练配置与参数
207 |
208 | | 名称 | 长度 | 精度 | 学习率 | Weight_decay | Epochs | GPUs |
209 | | --------------- | ---- | ---- | ------ | ------------ | ------ | ------ |
210 | | WiNGPT2-7B-Base | 2048 | bf16 | 5e-5 | 0.05 | 3 | A100*8 |
211 | | WiNGPT2-7B-Chat | 4096 | bf16 | 5e-6 | 0.01 | 3 | A100*8 |
212 |
213 | - 分布式训练策略与参数
214 |
215 | - deepspeed + cpu_offload + zero_stage3
216 | - gradient_checkpointing
217 |
218 | ## 评测
219 |
220 | ### 1. 中文基础模型评估 C-EVAL(Zero-shot/Few-shot)
221 |
222 | | | 平均 | 平均(Hard) | **兽医学** | **基础医学** | **临床医学** | **医师资格** |
223 | | -------------------------------------------------------------------------------------------- | -------- | ---------- | ---------- | ------------ | ------------ | ------------ |
224 | | [bloomz-mt-176B](https://cevalbenchmark.com/static/model.html?method=bloomz-mt-176B*) | 44.3 | 30.8 | 53.3 | 50.3 | 42 | 50.1 |
225 | | [Chinese LLaMA-13B](https://cevalbenchmark.com/static/model.html?method=Chinese%20LLaMA-13B) | 33.3 | 27.3 | 34.8 | 32 | 32.5 | 35 |
226 | | [ChatGLM-6B*](https://cevalbenchmark.com/static/model.html?method=ChatGLM-6B*) | 38.9 | 29.2 | 35.2 | 39.4 | 37 | 39.5 |
227 | | [baichuan-7B](https://cevalbenchmark.com/static/model.html?method=baichuan-7B) | 42.8 | 31.5 | 44.3 | 43.4 | 35 | 47 |
228 | | [Baichuan-13B](https://cevalbenchmark.com/static/model.html?method=Baichuan-13B) | 53.6 | 36.7 | 57.1 | 56 | 52 | 57.3 |
229 | | [Qwen-7B](https://cevalbenchmark.com/static/model.html?method=Qwen-7B) | **59.6** | 41 | 61 | 57.1 | 56 | 63.9 |
230 | | [WiNGPT2-7B-Base](https://huggingface.co/winninghealth/WiNGPT2-7B-Base) | 57.4 | **42.7** | **61.4** | **70.9** | **69.5** | **76.7** |
231 |
232 |
233 | ** _因当前发现MedQA-MCMLE存在数据泄露问题,我们去除了该评测表格。_
234 |
235 | ** _目前公开测评存在一定局限性,结果仅供参考。_
236 |
237 | ### 2. 卫宁健康医疗模型测评方案 WiNEval(Zero-shot)
238 |
239 | MCKQuiz(客观题):17个科目分类13060选择题;输入问题和选项,让模型输出答案。根据标准答案判断对错,统计准确率。

240 |
241 | MSceQA(主观题):由细分领域场景题目构成,包含八大业务场景,17个一级分类和32个二级分类。使用人工/模型对模型的回答进行准确性、相关性、一致性、完整性、权威性评价,并参照标准答案对模型生成的答案进行评分。
242 |
243 | 更新时间:2024-04-03
244 | | | | WiNEval-MCKQuiz | WiNEval-MSceQA | | | | | |
245 | | -------------------- | ------ | --------------- | -------------- | ------ | ------ | ------ | ------ | ------ |
246 | | 模型 | 平均分 | 准确率 | 5个维度平均分 | 准确性 | 相关性 | 一致性 | 完整性 | 专业性 |
247 | | WiNGPT2-34B-0317-DPO | 85.1 | 88.1 | 82 | 78.4 | 84.6 | 86.5 | 80.6 | 79.9 |
248 | | Qwen1.5-72B-Chat | 83.1 | 84.9 | 81.3 | 77.5 | 84 | 85.8 | 78.9 | 80.5 |
249 | | WiNGPT2-34B-Chat | 81.2 | 87.0 | 75.3 | 71.2 | 77.2 | 84.4 | 67.6 | 76.2 |
250 | | qwen-14B-Chat | 71.4 | 66.8 | 76.1 | 73.0 | 79.4 | 84.0 | 70.0 | 74.0 |
251 | | WiNGPT2-14B-Chat | 70.6 | 68.2 | 72.9 | 69.2 | 74.6 | 81.4 | 67.6 | 71.8 |
252 | | WiNGPT2-13B-Chat | 67.7 | 65.1 | 70.3 | 67.2 | 73.4 | 76.8 | 63.4 | 70.8 |
253 | | Baichuan2-13B-Chat | 61.9 | 56.4 | 67.3 | 64.6 | 68.0 | 74.8 | 59.4 | 69.8 |
254 | | qwen-7B-Chat | 60.8 | 55.0 | 66.6 | 63.2 | 68.8 | 73.8 | 60.0 | 67.4 |
255 | | WiNGPT2-7B-Chat | 60.3 | 59.2 | 61.5 | 55.8 | 64.0 | 67.8 | 56.6 | 63.2 |
256 | | Baichuan2-7B-Chat | 58.5 | 48.6 | 68.4 | 66.0 | 70.0 | 76.8 | 60.0 | 69.2 |
257 | | MedicalGPT | 53.4 | 43.1 | 63.7 | 59.8 | 65.2 | 73.4 | 54.2 | 66.0 |
258 |
259 | ** _目前34B模型可以通过 WiNGPT 网站进行测试_
260 |
261 | ## 应用
262 |
263 | ### 1. 药品助手
264 |
265 | 基于药品知识库进行 WiNGPT2 的药品知识问答,进一步解决大模型幻觉问题,产生更精确答案。

266 |
267 | ### 2. 结构化输出
268 |
269 | 根据用户需求进行推理回答并按结构化 json 格式返回结果。
270 |
271 |
272 |
273 | ### 3. 影像报告生成
274 |
275 | 从胸片解析报告所见,再生成相应胸片报告结论,完成从读片到写报告的整个流程。

276 |
277 |
278 | ** _注意上面的列举的应用案例包括了多项技术例如RAG、医学影像模型超出了项目范围,仅作为 WiNGPT2 应用于下游场景的示例。_
279 |
280 | ## 多模态 - WiNGPT-3
281 |
282 | 目前有一些比较成熟的多模态方案, 如 DSVL(DeepSpeedViLModel)和 Llava。Llava 多模态方案使用两阶段训练方式,模型功能强大,但仅支持单图对话模式;DSVL 多模态方案支持多图多轮对话的方式,但对大语言模型内部结构进行了修改,导致语言能力降低。为了充分利用 Llava 和 DSVL方案各自的优点,我们决定将 DSVL 图文拼接方案与 Llava 两阶段方案融合,以此构建我们的模型方案。在训练多模态 WiNGPT 时,采用两阶段方案。第一阶段:冻结图像层和大语言模型 (LLM) 层,仅训练投影层 (projection layer), 投影层由两个Linear layer 和一个 LayerNrom 组合而成;第二阶段:冻结图像层,仅微调投影层和大语言模型层。详细内容可通过卫宁健康企业公众号获取医疗AI年度报告。
283 |
284 | WiNGPT-3 目前已经开放 Alpha 版内测,请通过 [WiNGPT 测试平台](https://wingpt.winning.com.cn/) 获取内测资格。
285 |
286 |
287 | ## 局限性与免责声明
288 |
289 | (a) WiNGPT2 是一个专业医疗领域的大语言模型,可为一般用户提供拟人化AI医生问诊和问答功能,以及一般医学领域的知识问答。对于专业医疗人士,WiNGPT2 提供关于患者病情的诊断、用药和健康建议等方面的回答的建议仅供参考。
290 |
291 | (b) 您应理解 WiNGPT2 仅提供信息和建议,不能替代医疗专业人士的意见、诊断或治疗建议。在使用 WiNGPT2 的信息之前,请寻求医生或其他医疗专业人员的建议,并独立评估所提供的信息。
292 |
293 | (c) WiNGPT2 的信息可能存在错误或不准确。卫宁健康不对 WiNGPT2 的准确性、可靠性、完整性、质量、安全性、及时性、性能或适用性提供任何明示或暗示的保证。使用 WiNGPT2 所产生的结果和决策由您自行承担。第三方原因而给您造成的损害结果承担责任。
294 |
295 | ## 许可证
296 |
297 | 1. 本项目授权协议为 Apache License 2.0,模型权重需要遵守基础模型[Qwen-7B](https://github.com/QwenLM/Qwen-7B)相关协议及[许可证](https://github.com/QwenLM/Qwen-7B/blob/main/LICENSE),详细内容参照其网站。
298 |
299 | 2. 使用本项目包括模型权重时请引用本项目:https://github.com/winninghealth/WiNGPT2
300 |
301 | ## 参考资料
302 |
303 | 1. https://github.com/QwenLM/Qwen-7B
304 | 2. https://github.com/lm-sys/FastChat
305 | 3. https://github.com/yizhongw/self-instruct
306 | 4. https://github.com/nlpxucan/evol-instruct
307 |
308 | ## 联系我们
309 |
310 | 网站:https://www.winning.com.cn
311 |
312 | 邮箱:wair@winning.com.cn
313 |
314 |
315 |
--------------------------------------------------------------------------------
/assets/WiNGPT2-Llama3-8B.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/winninghealth/WiNGPT2/2e46a1d99976b835882b3794f0f5a4c245d9a316/assets/WiNGPT2-Llama3-8B.png
--------------------------------------------------------------------------------
/assets/WiNGPT2-PT.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/winninghealth/WiNGPT2/2e46a1d99976b835882b3794f0f5a4c245d9a316/assets/WiNGPT2-PT.png
--------------------------------------------------------------------------------
/assets/WiNGPT2-SFT.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/winninghealth/WiNGPT2/2e46a1d99976b835882b3794f0f5a4c245d9a316/assets/WiNGPT2-SFT.png
--------------------------------------------------------------------------------
/assets/WiNGPT_GROUP.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/winninghealth/WiNGPT2/2e46a1d99976b835882b3794f0f5a4c245d9a316/assets/WiNGPT_GROUP.JPG
--------------------------------------------------------------------------------
/assets/chestxr_analyzer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/winninghealth/WiNGPT2/2e46a1d99976b835882b3794f0f5a4c245d9a316/assets/chestxr_analyzer.png
--------------------------------------------------------------------------------
/assets/medicine_db.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/winninghealth/WiNGPT2/2e46a1d99976b835882b3794f0f5a4c245d9a316/assets/medicine_db.png
--------------------------------------------------------------------------------
/assets/struct_output.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/winninghealth/WiNGPT2/2e46a1d99976b835882b3794f0f5a4c245d9a316/assets/struct_output.png
--------------------------------------------------------------------------------
/assets/wechatgroup.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/winninghealth/WiNGPT2/2e46a1d99976b835882b3794f0f5a4c245d9a316/assets/wechatgroup.jpg
--------------------------------------------------------------------------------
/assets/客观题.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/winninghealth/WiNGPT2/2e46a1d99976b835882b3794f0f5a4c245d9a316/assets/客观题.png
--------------------------------------------------------------------------------
/demo.py:
--------------------------------------------------------------------------------
1 | import gradio as gr
2 |
3 | from transformers import AutoModelForCausalLM, AutoTokenizer
4 |
5 |
6 | model_path = "winninghealth/WiNGPT2-7B-Chat"
7 | tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
8 | model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True).half().to("cuda")
9 | model = model.eval()
10 | user_role, assistant_role, stop = 'User: ', 'Assistant: ', '<|endoftext|>\n '
11 |
12 |
13 | def generate(text):
14 | inputs = tokenizer.encode(text, return_tensors="pt").to("cuda")
15 | outputs = model.generate(inputs, repetition_penalty=1.1, max_new_tokens=1024)
16 | output = tokenizer.decode(outputs[0])
17 | return output.split(assistant_role)[-1].strip(stop.strip())
18 |
19 |
20 | with gr.Blocks() as demo:
21 | chatbot = gr.Chatbot()
22 | msg = gr.Textbox()
23 | clear = gr.ClearButton([msg, chatbot])
24 |
25 | def bot(message, chat_history):
26 | formatted_chat_history = stop.join([f'{user_role}{i[0]}{stop}{assistant_role}{i[1]}' for i in chat_history])
27 | formatted_message = f'{user_role}{message}{stop}{assistant_role}'
28 | inputs = f'{formatted_chat_history}{stop}{formatted_message}' if formatted_chat_history else formatted_message
29 | response = generate(inputs)
30 | chat_history.append((message, response))
31 | return "", chat_history
32 |
33 | msg.submit(bot, [msg, chatbot], [msg, chatbot])
34 |
35 | if __name__ == "__main__":
36 | demo.launch(server_name="0.0.0.0")
37 |
--------------------------------------------------------------------------------