casey-martin/MedInstruct
收藏资源简介:
--- configs: - config_name: default data_files: - split: train path: data/MedInstruct-52k.json - split: test path: data/MedInstruct-test.jsonl task_categories: - text-generation language: - en tags: - medical --- # MedInstruct <hr> This is the repo for *MedInstruct*, which is a dataset of synthetically generated medical instructions. The repo contains: - The 52K medical instruction-response dataset [*MedInstruct-52k*](https://github.com/XZhang97666/AlpaCare/blob/master/data/MedInstruct-52k.json) used for fine-tuning *AlpaCare*, and corresponding [clinican-crafted seed task](https://github.com/XZhang97666/AlpaCare/blob/master/data/med_seed.json) to generate instruction. - A 217 clinical craft free-form instruction evaluation test set,[*MedInstruct-test*](https://github.com/XZhang97666/AlpaCare/blob/master/data/MedInstruct-test.jsonl). - The code for: 1. [medical task generation](https://github.com/XZhang97666/AlpaCare/tree/master/test_generation); 2. [fine-tuning LLaMA series models](https://github.com/XZhang97666/AlpaCare/tree/master/training); 3. [instrcution-tuned model response generation](https://github.com/XZhang97666/AlpaCare/tree/master/test_generation); 4. [response evaluation via LLMs](https://github.com/XZhang97666/AlpaCare/tree/master/evaluation). ## Overview *AlpaCare* models contain 4 models (7B/13B - LLaMA[1]/LLaMA-2[2]) tuned on a 52k medical instruction-following dataset *MedInstruct-52k*, following Alpaca[3] and Self-Instruct[4]. You can find our model weights at: | Version | Link | | --- | --- | | *AlpaCare* -LLaMA_7B |[https://huggingface.co/xz97/AlpaCare-llama1-7b](https://huggingface.co/xz97/AlpaCare-llama1-7b)| | *AlpaCare* -LLaMA2_7B |[https://huggingface.co/xz97/AlpaCare-llama2-7b](https://huggingface.co/xz97/AlpaCare-llama2-7b)| | *AlpaCare* -LLaMA_13B |[https://huggingface.co/xz97/AlpaCare-llama-13b](https://huggingface.co/xz97/AlpaCare-llama-13b)| | *AlpaCare* -LLaMA2_13B |[https://huggingface.co/xz97/AlpaCare-llama2-13b](https://huggingface.co/xz97/AlpaCare-llama2-13b)| [1]: LLaMA: Open and Efficient Foundation Language Models. Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, Guillaume Lample. https://arxiv.org/abs/2302.13971v1 [2] Llama 2: Open foundation and fine-tuned chat models. Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, and Thomas Scialom. https://arxiv.org/abs/2307.09288 [3]: Stanford Alpaca: An Instruction-following LLaMA Model.Rohan Taori and Ishaan Gulrajani and Tianyi Zhang and Yann Dubois and Xuechen Li and Carlos Guestrin and Percy Liang and Tatsunori B. Hashimoto. https://crfm.stanford.edu/2023/03/13/alpaca.html [4]: Self-Instruct: Aligning Language Model with Self Generated Instructions. Yizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A. Smith, Daniel Khashabi, Hannaneh Hajishirzi. https://arxiv.org/abs/2212.10560 ## Data Release [*MedInstruct*](https://huggingface.co/datasets/xz97/MedInstruct) contains: - MedInstruct datasets: 1. *MedInstruct-52K*: 52 medical instruction-following data we used for fine-tuning *AlpaCare* models 2. *MedInstruct-test*: 217 clinican craft free-form instruction evulation tasks with reference responses generated by `gpt-4`, `gpt-tubro-3.5`, `text-davinci-003` and `claude-2`. All files is a list of dictionaries in JSON/JSONL format, each dictionary contains the following fields: - `instruction`: `str`, the medical task the model should perform. Each of instrcutions in *MedInstruct-52K* and *MedInstruct-test* is unique. The instrcutions in *MedInstruct-52K* are generated by OpenAI `gpt-4`, while *MedInstruct-test* are clinian-craft. - `input`: `str`, optional medical context or example for the task to further explain the instruction and increase the task diversity. - `output`: `str`, the answer to the instruction as generated by `text-davinci-003`. - `difficulity`: `str`, medical knolwedge difficulty level scale from 1-5 evulated by clinicans following the [scoring system](plots/scoresystem.pdf). This only appear in *MedInstruct-test*. - Instructions: 1. Clinican-crafted instruction seed set, containing 167 instances. 2. All medical instructions generated by OpenAI `gpt-4` with/without filtering. </details> ## Data Generation Process We following the data generation pipeline from [self-instruct](https://github.com/yizhongw/self-instruct) and [Alpaca](https://crfm.stanford.edu/2023/03/13/alpaca.html), and modified several points: *Instructions*: - Beginning with a [medical task seed set](https://github.com/XZhang97666/AlpaCare/blob/master/data/med_seed.json) that contains 167 clinical-craft clinical tasks. - Utilizing the GPT-4 engine for instruction data generation. - Crafting a [prompt](https://github.com/XZhang97666/AlpaCare/blob/master/prompt/instruction_prompt.txt) to serve as the medical instruction generation guidelines for GPT-4. - To reduce costs in task generation and introduce greater randomness, 12 instructions are generated at once. This is followed by the selection of 3 random seed instructions from the seed set. *Responses*: - The GPT-3.5-turbo engine is used to synthesize responses, processing each instruction individually. Here's an illustration of an instruction-response pair: ``` { instruction: "Rewrite this instruction on how to use an inhaler to be more patient-friendly and less technical." input: "Exhale deeply, engage mouthpiece of inhaler, depress canister while simultaneously inhaling long and deep, hold the breath for ten seconds, then gently exhale" output: "Here's a more patient-friendly version of the instruction on how to use an inhaler: 1. Take a deep breath and completely breathe out. 2. Put the mouthpiece of the inhaler into your mouth and seal your lips around it properly. 3. Press down the canister while breathing in slowly and deeply at the same time. 4. Hold your breath for ten seconds. 5. Finally, breathe out gently." } ```
configs: - config_name: default data_files: - split: train path: data/MedInstruct-52k.json - split: test path: data/MedInstruct-test.jsonl task_categories: - text-generation language: - en tags: - medical # MedInstruct <hr> 本仓库为*MedInstruct*项目仓库,该项目包含人工合成生成的医疗指令数据集。仓库内容如下: - 用于微调*AlpaCare*模型的52K条医疗指令-响应数据集[*MedInstruct-52k*](https://github.com/XZhang97666/AlpaCare/blob/master/data/MedInstruct-52k.json),以及用于生成指令的[临床专家编写的种子任务集](https://github.com/XZhang97666/AlpaCare/blob/master/data/med_seed.json)。 - 包含217条临床专家编写的自由格式指令的评估测试集[*MedInstruct-test*](https://github.com/XZhang97666/AlpaCare/blob/master/data/MedInstruct-test.jsonl)。 - 以下代码工具: 1. [医疗任务生成代码](https://github.com/XZhang97666/AlpaCare/tree/master/test_generation) 2. [LLaMA系列模型微调代码](https://github.com/XZhang97666/AlpaCare/tree/master/training) 3. [指令微调模型响应生成代码](https://github.com/XZhang97666/AlpaCare/tree/master/test_generation) 4. [基于大语言模型(Large Language Model)的响应评估代码](https://github.com/XZhang97666/AlpaCare/tree/master/evaluation) ## 项目概览 *AlpaCare*系列模型包含4款基于LLaMA[1]/LLaMA-2[2]的7B/13B参数版本模型,参照Alpaca[3]与Self-Instruct[4]的范式,在52K条医疗指令跟随数据集*MedInstruct-52k*上完成微调。模型权重可通过以下链接获取: | 版本 | 链接 | | --- | --- | | *AlpaCare*-LLaMA_7B |[https://huggingface.co/xz97/AlpaCare-llama1-7b](https://huggingface.co/xz97/AlpaCare-llama1-7b)| | *AlpaCare*-LLaMA2_7B |[https://huggingface.co/xz97/AlpaCare-llama2-7b](https://huggingface.co/xz97/AlpaCare-llama2-7b)| | *AlpaCare*-LLaMA_13B |[https://huggingface.co/xz97/AlpaCare-llama-13b](https://huggingface.co/xz97/AlpaCare-llama-13b)| | *AlpaCare*-LLaMA2_13B |[https://huggingface.co/xz97/AlpaCare-llama2-13b](https://huggingface.co/xz97/AlpaCare-llama2-13b)| [1]: LLaMA: 开放高效的基础大语言模型(Large Language Model)。Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, Guillaume Lample. https://arxiv.org/abs/2302.13971v1 [2]: LLaMA 2: 开放基础模型与微调聊天模型。Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Singh Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurelien Rodriguez, Robert Stojnic, Sergey Edunov, and Thomas Scialom. https://arxiv.org/abs/2307.09288 [3]: Stanford Alpaca: 一款指令跟随型LLaMA模型。Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, Tatsunori B. Hashimoto. https://crfm.stanford.edu/2023/03/13/alpaca.html [4]: Self-Instruct: 通过自生成指令对齐大语言模型。Yizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A. Smith, Daniel Khashabi, Hannaneh Hajishirzi. https://arxiv.org/abs/2212.10560 ## 数据集发布 [*MedInstruct*](https://huggingface.co/datasets/xz97/MedInstruct)包含以下内容: - MedInstruct数据集子集: 1. *MedInstruct-52K*: 用于微调*AlpaCare*模型的52000条医疗指令跟随数据 2. *MedInstruct-test*: 217条由临床专家编写的自由格式指令评估任务,其参考响应由`gpt-4`、`gpt-turbo-3.5`、`text-davinci-003`和`claude-2`生成。 所有文件均为JSON/JSONL格式的字典列表,每条字典包含以下字段: - `instruction`: 字符串类型,指模型需要执行的医疗任务。*MedInstruct-52K*与*MedInstruct-test*中的指令均唯一,其中*MedInstruct-52K*的指令由OpenAI的`gpt-4`生成,而*MedInstruct-test*的指令由临床专家编写。 - `input`: 字符串类型,可选字段,用于进一步解释指令、提升任务多样性的医疗上下文或示例。 - `output`: 字符串类型,由`text-davinci-003`生成的指令响应答案。 - `difficulity`: 字符串类型,由临床专家依据[评分体系](plots/scoresystem.pdf)评估得出的1-5级医疗知识难度等级,该字段仅在*MedInstruct-test*中出现。 - 指令集: 1. 临床专家编写的指令种子集,包含167条样本。 2. 所有由OpenAI的`gpt-4`生成的医疗指令(含过滤与未过滤版本)。 </details> ## 数据生成流程 我们参照[Self-Instruct](https://github.com/yizhongw/self-instruct)和[Alpaca](https://crfm.stanford.edu/2023/03/13/alpaca.html)的数据生成流程,并对部分细节进行了修改: ### 指令生成流程 - 以包含167条临床任务的[医疗任务种子集](https://github.com/XZhang97666/AlpaCare/blob/master/data/med_seed.json)为起点 - 采用GPT-4引擎生成指令数据 - 编写[提示词](https://github.com/XZhang97666/AlpaCare/blob/master/prompt/instruction_prompt.txt)作为GPT-4生成医疗指令的指导准则 - 为降低生成成本并提升随机性,每次批量生成12条指令,随后从种子集中随机选取3条种子指令。 ### 响应生成流程 - 采用GPT-3.5-turbo引擎生成响应,逐条处理每条指令。 以下为一条指令-响应对示例: { "instruction": "请将这份吸入器使用说明改写为更易懂的患者友好型版本,减少专业术语使用。", "input": "深呼气,将吸嘴放入口中,按下药罐同时缓慢深吸气,屏息十秒,随后缓缓呼气", "output": "以下是更易懂的吸入器使用说明: 1. 深吸气后完全呼出。 2. 将吸入器吸嘴放入口中,用嘴唇紧密包裹。 3. 按下药罐的同时缓慢深吸气。 4. 屏息十秒。 5. 最后缓缓呼气。" }
数据集概述
数据集名称
- MedInstruct
数据集内容
- MedInstruct-52K: 包含52,000条医疗指导数据,用于微调AlpaCare模型。
- MedInstruct-test: 包含217条临床手工自由形式的指导评估任务,包含参考响应。
数据集格式
- 数据以JSON/JSONL格式存储,每个文件包含一系列字典,每个字典包含以下字段:
instruction: 字符串,描述模型应执行的医疗任务。input: 字符串,可选的医疗上下文或任务示例,用于进一步解释指导并增加任务多样性。output: 字符串,text-davinci-003生成的指导答案。difficulty: 字符串,医疗知识难度级别,范围从1-5,仅在MedInstruct-test中出现。
数据生成过程
- 使用GPT-4引擎生成指导数据。
- 使用GPT-3.5-turbo引擎合成响应。
数据集用途
- 用于微调AlpaCare模型,包括LLaMA系列模型。
数据集链接




