A large model fine-tuning method and device for medical school education scenarios
By combining data sets and supervising fine-tuning of the general large language model, an efficient large language model suitable for medical education is generated, which solves the problem of insufficient adaptability of the existing models in medical education scenarios, realizes intelligent question-setting and question-answer functions, and improves learning efficiency and quality.
Patent Information
- Application Number
- CN202510536211.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2045-04-27
AI Technical Summary
The existing general big models cannot be effectively adapted in medical education scenarios, and it is difficult to meet the efficient and precise learning needs of medical school education, and lack intelligent question generation and intelligent question-answer functions.
By collecting data sets from medical school educational resources, combining data and supervising fine-tuning, an efficient large language model suitable for medical education can be generated to achieve intelligent question-setting and question-and-answer.
It improves the model's understanding of medical knowledge and question-setting ability, improves the adaptability and practicality of the model, and meets the intelligent needs of medical education.
Smart Images

Figure CN120067276B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of artificial intelligence and medical education, and particularly to a method and device for fine-tuning a large model for a medical school education scenario. Background Art
[0002] With the continuous expansion of the knowledge system and the accelerating update speed, medical students are facing the dual challenges of information overload and scattered learning resources. Traditional learning methods are no longer sufficient to meet their urgent needs for efficient and accurate learning. At the same time, medical schools also need to use modern means to monitor and improve teaching quality in real time to ensure that teaching results are in line with industry standards.
[0003] In the field of medical education, with the rapid development of information technology and artificial intelligence technology, large model technology is increasingly becoming a key force in promoting educational innovation and improving teaching quality. Current general large models, including the GPT series, Llama series, ChatGLM series, and Qwen series, although performing well in many fields, still need to be improved in vertical fields. The scope of medical question generation is wide and the types are diverse, making it unable to effectively adapt to the teaching scenarios of medical schools. Therefore, the present invention provides a method for fine-tuning a large model for a medical school education scenario, using the fine-tuned large model to implement functions such as intelligent question generation, intelligent question answering, and personalized assisted learning, providing comprehensive support and solutions for medical education. Summary of the Invention
[0004] The purpose of the present invention is to provide a method and device for fine-tuning a large model for a medical school education scenario in view of the deficiencies of the prior art.
[0005] The purpose of the present invention is achieved through the following technical solutions: A method for fine-tuning a large model for a medical school education scenario includes the following steps:
[0006] (1) Select a suitable general large language model;
[0007] (2) Obtain an exam question fine-tuning dataset and a Q&A fine-tuning dataset from commonly used textbooks, tutoring books, exercise sets, and high-quality medical record PDF files in medical school education, and collect an open-source Chinese dialogue dataset in the general field to obtain a general field dialogue dataset; Combine the exam question fine-tuning dataset, the Q&A fine-tuning dataset, and the general field dialogue dataset according to 4 data combination strategies to obtain a first fine-tuning dataset, a second fine-tuning dataset, a third fine-tuning dataset, and a fourth fine-tuning dataset;
[0008] (3)Supervisedly fine-tune the selected general language large model using the first fine-tuning dataset, the second fine-tuning dataset, the third fine-tuning dataset, and the fourth fine-tuning dataset respectively to obtain the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model;
[0009] (4)Evaluate and iterate on the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model respectively to obtain the fine-tuned large language model with the highest score as the optimal medical model, and use the data combination strategy corresponding to the fine-tuned large language model with the highest score as the optimal data combination strategy;
[0010] (5)Implement the intelligent question generation and intelligent question answering functions in the medical education assistance platform through the optimal medical model to provide comprehensive support and solutions for medical education.
[0011] Furthermore, the general large language model includes large language models of the Qwen series, ChatGLM series, Llama series, or Baichuan series.
[0012] Furthermore, step (2) specifically includes the following sub-steps:
[0013] (2.1)Collect commonly used textbooks, tutoring books, exercise sets, and high-quality medical record PDF files for medical school education;
[0014] (2.2)Convert the collected commonly used textbooks, tutoring books, exercise sets, and high-quality medical record PDF files for medical school education into standard format markdown text through the first data processing module;
[0015] (2.3)Manually review the converted markdown text to ensure correct title trees and text content;
[0016] (2.4)Subsequently, extract question-answer pairs based on the reviewed markdown text to obtain the question generation fine-tuning dataset;
[0017] The sub-step (2.4) specifically includes the following sub-steps:
[0018] (2.4.1)Slice the reviewed markdown text into multiple data blocks according to the chunking strategy module to obtain a data block set;
[0019] (2.4.2)Call the open-source or closed-source general large model multiple times, and generate a fixed number of questions of definition explanation type, medical knowledge understanding type, knowledge application type, and practice evaluation type according to the text corresponding to each data block in the data block set according to the Bloom cognitive hierarchy;
[0020] The open-source or closed-source general large models include ChatGPT, GPT-4, GPT-4o, Qwen2-72B-instruct, or Claude 3 Opus model;
[0021] (2.4.3) Send the text corresponding to each data block together with the corresponding question to the open-source or closed-source general large model to generate the relevant answers corresponding to each question, obtaining the first Q&A pair dataset, where each piece of data in the first Q&A pair dataset contains the question corresponding to the text corresponding to the data block and the relevant answer;
[0022] (2.4.4) Input the text corresponding to each data block in the data block set into the open-source or closed-source general large model, and generate relevant single-choice and multiple-choice questions according to the teaching material content as the question-setting fine-tuning dataset;
[0023] (2.5) Process the first Q&A pair dataset according to the second data processing module to obtain the Q&A fine-tuning dataset;
[0024] (2.6) Collect the open-source Chinese dialogue dataset in the general domain, where the data contains rich instructions and multi-domain multi-task questions, obtaining the general domain dialogue dataset;
[0025] (2.7) Combine the question-setting fine-tuning dataset, the Q&A fine-tuning dataset, and the general domain dialogue dataset according to 4 data combination strategy methods to obtain the first fine-tuning dataset, the second fine-tuning dataset, the third fine-tuning dataset, and the fourth fine-tuning dataset. Specifically:
[0026] The first data combination strategy method: Sequentially combine the Q&A fine-tuning dataset and the question-setting fine-tuning dataset to obtain the first fine-tuning dataset;
[0027] The second data combination strategy method: Sequentially combine the Q&A fine-tuning dataset, the question-setting fine-tuning dataset, and the general domain dialogue dataset to obtain the second fine-tuning dataset;
[0028] The third data combination strategy method: Combine the Q&A fine-tuning dataset and the question-setting fine-tuning dataset and shuffle them randomly to obtain the third fine-tuning dataset;
[0029] The fourth data combination strategy method: Combine the Q&A fine-tuning dataset, the question-setting fine-tuning dataset, and the general dialogue dataset and shuffle them randomly to obtain the fourth fine-tuning dataset.
[0030] Further, the first data processing module is used to build an open-source high-quality PDF-to-markdown framework and open a closed-source high-quality PDF-to-markdown platform interface. The closed-source high-quality PDF-to-markdown platform interface includes Miner-U, Textin, and NoteGPT. It converts PDF or image files into markdown format in a standard format and selects the optimal converted markdown text.
[0031] Further, the sub-step (2.4.1) specifically includes the following sub-steps:
[0032] (2.4.1.1) According to the third-level headings of the reviewed markdown text by the chunking strategy module, convert the reviewed markdown text into a complete list of data chunks;
[0033] (2.4.1.2) Given a fixed maximum character length threshold for chunking as MaxLen;
[0034] (2.4.1.3) Traverse each data chunk in the complete list of data chunks in turn. First, judge whether the character length of any data chunk is greater than MaxLen: If the character length of the data chunk is greater than MaxLen, divide the data chunk according to the segmentation symbol and the full stop until the character lengths of all divided data chunks are less than MaxLen; If the character length of the data chunk is less than MaxLen, combine the data chunk with adjacent data chunks until the character length of the combined data chunk is closest to MaxLen;
[0035] (2.4.1.4) After the traversal is completed, sort all the data chunks processed in sub-step (2.4.1.3) according to the original reading order of the reviewed markdown text to obtain a set of data chunks.
[0036] Further, the sub-step (2.5) specifically includes the following sub-steps:
[0037] (2.5.1) Judge according to the character length of the relevant answer for each piece of data in the first Q&A pair dataset by the second data processing module: If the character length of the relevant answer is less than 50, delete this piece of data from the first Q&A pair dataset; If the character length of the relevant answer is greater than 200 or the relevant answer includes ordered or unordered list symbols, use an open-source or closed-source general large model to convert the format of the relevant answer into markdown format without changing the original content to obtain the converted relevant answer, and then replace the original relevant answer in the corresponding data with the converted relevant answer; Otherwise, do not process;
[0038] After judging the character lengths of the relevant answers for all the data, a second Q&A pair dataset is obtained;
[0039] (2.5.2)Subsequently, the second Q&A pair dataset is converted into a Q&A fine-tuning dataset in the instruction-input-output format.
[0040] Furthermore, in step (3), supervised fine-tuning is performed through an efficient fine-tuning hyperparameter fine-tuning method, and the efficient fine-tuning hyperparameter fine-tuning method includes LoRA, QLoRA, full-parameter fine-tuning, P-tuing, and P-tuning V2 fine-tuning methods.
[0041] Furthermore, the specific steps of step (4) include the following sub-steps:
[0042] (4.1)Design 4 quantitative evaluation indicators for the question-setting tasks, namely the result parsing rate, the question quantity accuracy rate, the question completeness rate, and the question repetition rate. Among them, the result parsing rate = the number of questions that can be correctly parsed into the specified format by the fine-tuned model / the total number of data in the question-setting evaluation set; the question quantity accuracy rate = the total number of correct questions in the generated results / the total number of data in the question-setting evaluation set; the question completeness rate = the number of questions with complete elements in the generated results / the total number of data in the question-setting evaluation set; the question repetition rate = the total number of repeated questions in the generated results / the total number of data in the question-setting evaluation set;
[0043] (4.2)Construct a medical Q&A evaluation dataset, collect five-year and eight-year medical textbooks and school final exam questions as the medical Q&A evaluation dataset, and evaluate the medical Q&A capabilities of the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model;
[0044] (4.3)Select appropriate general-domain evaluation datasets to evaluate the general-domain capabilities of the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model. The general-domain evaluation datasets include C-Eval, CMMLU, MMLU, and MT-Bench datasets;
[0045] (4.4)Use open-source or closed-source general large models to evaluate the question-setting connotations of the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model;
[0046] (4.5) Load and evaluate the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model respectively, and select the fine-tuned large language model with the highest score as the optimal medical model, and use the data combination strategy corresponding to the fine-tuned large language model with the highest score as the optimal data combination strategy.
[0047] The present invention also includes a large model fine-tuning device for a medical school education scenario, including a memory and one or more processors. Executable code is stored in the memory. When the one or more processors execute the executable code, it is used for the above-mentioned large model fine-tuning method for a medical school education scenario.
[0048] The present invention also includes a computer-readable storage medium, on which a program is stored. When the program is executed by a processor, it implements the above-mentioned large model fine-tuning method for a medical school education scenario.
[0049] The beneficial effects of the present invention are as follows: The method proposed by the present invention can help quickly generate high-quality fine-tuning data in the field, improve the understanding of medical knowledge by the general large model, improve the question-setting ability and efficiency, and improve the adaptability and practicality of the model. Description of the Drawings
[0050] Figure 1 It is a flowchart of a large model fine-tuning method for a medical school education scenario;
[0051] Figure 2 It is a flowchart of sub-step (2.4.1) in the embodiment;
[0052] Figure 3 It is a structural diagram of a large model fine-tuning device for a medical school education scenario. Detailed Embodiments
[0053] In order to make the purpose, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
[0054] Embodiment 1: As Figure 1 shown, the present invention provides a large model fine-tuning method for a medical school education scenario, including the following steps:
[0055] (1)Select a suitable general large language model. The general large language model includes the Qwen series, ChatGLM series, Llama series, or Baichuan series of large language models.
[0056] (2)Obtain an exam question fine-tuning dataset and a Q&A fine-tuning dataset from commonly used textbooks, tutoring books, exercise sets, and high-quality medical record PDF files in medical school education, and collect open-source Chinese dialogue datasets in the general domain to obtain a general domain dialogue dataset; combine the exam question fine-tuning dataset, Q&A fine-tuning dataset, and general domain dialogue dataset according to 4 data combination strategies to obtain a first fine-tuning dataset, a second fine-tuning dataset, a third fine-tuning dataset, and a fourth fine-tuning dataset.
[0057] Step (2) specifically includes the following sub-steps:
[0058] (2.1)Data collection and conversion: Collect commonly used textbooks, tutoring books, exercise sets, and high-quality medical record PDF files in medical school education.
[0059] (2.2)Data preprocessing: Convert the collected commonly used textbooks, tutoring books, exercise sets, and high-quality medical record PDF files in medical school education into standard format markdown text through a first data processing module.
[0060] The first data processing module is used to build an open-source high-quality PDF to markdown framework, open the interface of a closed-source high-quality PDF to markdown platform, and the closed-source high-quality PDF to markdown platform interface includes Miner-U, Textin, and NoteGPT, convert PDF or picture files into standard format markdown format, and select the optimal converted markdown text.
[0061] (2.3)Data review: Manually review the converted markdown text to ensure the correct title tree and text content.
[0062] (2.4)Subsequently, extract Q&A pairs based on the reviewed markdown text to obtain an exam question fine-tuning dataset.
[0063] Sub-step (2.4) specifically includes the following sub-steps:
[0064] (2.4.1)Slice the reviewed markdown text into multiple data blocks according to the chunking strategy module to obtain a data block set.
[0065] Sub-step (2.4.1) specifically includes the following sub-steps:
[0066] (2.4.1.1)Convert the reviewed markdown text into a complete list of data blocks according to the third-level headings of the reviewed markdown text based on the chunking strategy module.
[0067] (2.4.1.2)Given a fixed maximum character length threshold for chunking as MaxLen.
[0068] (2.4.1.3)Traverse each data block in the complete list of data blocks in turn. First, judge whether the character length of any data block is greater than MaxLen: If the character length of the data block is greater than MaxLen, divide the data block according to the segmentation symbol and the full stop until the character lengths of all the divided data blocks are less than MaxLen; If the character length of the data block is less than MaxLen, combine the data block with adjacent data blocks until the character length of the combined data block is closest to MaxLen.
[0069] (2.4.1.4)After the traversal, sort all the data blocks processed in sub-step (2.4.1.3) according to the original reading order of the reviewed markdown text to obtain a data block set.
[0070] (2.4.2)Call the open-source or closed-source general large model multiple times. According to the Bloom cognitive hierarchy, generate a fixed number of questions of definition explanation type, medical knowledge understanding type, knowledge application type, and practice evaluation type respectively according to the text corresponding to each data block in the data block set.
[0071] The open-source or closed-source general large model is a model with high language understanding and generation capabilities, containing rich world knowledge, and performing well in many application scenarios, including the widely recognized GPT series models ChatGPT, GPT-4, GPT-4o, Qwen2-72B-instruct or Claude 3 Opus model.
[0072] (2.4.3)Send the text corresponding to each data block together with the corresponding questions to the open-source or closed-source general large model to generate relevant answers for each question, obtaining a first question-answer pair data set. Each piece of data in the first question-answer pair data set contains the question and the relevant answer corresponding to the text corresponding to the data block.
[0073] (2.4.4)Input the text corresponding to each data block in the data block set into the open-source or closed-source general large model, and generate relevant single-choice and multiple-choice questions according to the textbook content as an item fine-tuning data set.
[0074] (2.5) Post-processing of question-answer pairs: Processing the first question-answer pair dataset according to the second data processing module to obtain a question-answer fine-tuning dataset.
[0075] The sub-step (2.5) specifically includes the following sub-steps:
[0076] (2.5.1) Data screening and format conversion: Judging the character length of the relevant answer for each piece of data in the first question-answer pair dataset according to the second data processing module: If the character length of the relevant answer is less than 50, delete this piece of data from the first question-answer pair dataset; If the character length of the relevant answer is greater than 200 or the relevant answer includes ordered or unordered list symbols, use an open-source or closed-source general large model to convert the format of the relevant answer to markdown format without changing the original content to obtain the converted relevant answer, and then replace the original relevant answer in the corresponding data with the converted relevant answer; Otherwise, do not process.
[0077] After completing the judgment of the character length of the relevant answers for all data, a second question-answer pair dataset is obtained.
[0078] (2.5.2) Subsequently, convert the second question-answer pair dataset into a question-answer fine-tuning dataset in the instruction-input-output format.
[0079] (2.6) Collecting a general-domain dialogue dataset: Collecting an open-source Chinese dialogue dataset in the general domain, the data contains rich instructions, multi-domain and multi-task questions, which is used to alleviate catastrophic forgetting after model fine-tuning, and obtaining a general-domain dialogue dataset.
[0080] (2.7) Constructing a multi-task dataset with multiple strategies: Combining the question-generation fine-tuning dataset, the question-answer fine-tuning dataset, and the general-domain dialogue dataset according to 4 data combination strategy methods to obtain the first fine-tuning dataset, the second fine-tuning dataset, the third fine-tuning dataset, and the fourth fine-tuning dataset. Specifically:
[0081] The first data combination strategy method: Sequentially combine the question-answer fine-tuning dataset and the question-generation fine-tuning dataset to obtain the first fine-tuning dataset;
[0082] The second data combination strategy method: Sequentially combine the question-answer fine-tuning dataset, the question-generation fine-tuning dataset, and the general-domain dialogue dataset to obtain the second fine-tuning dataset;
[0083] The third data combination strategy method: Combine the question-answer fine-tuning dataset and the question-generation fine-tuning dataset and shuffle them randomly to obtain the third fine-tuning dataset;
[0084] The fourth data combination strategy: Combine the question-answering fine-tuning dataset, the question-generation fine-tuning dataset, and the general dialogue dataset, and randomly shuffle them to obtain the fourth fine-tuning dataset.
[0085] (3)Use the first fine-tuning dataset, the second fine-tuning dataset, the third fine-tuning dataset, and the fourth fine-tuning dataset to perform supervised fine-tuning on the selected general language large model, respectively, to obtain the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model.
[0086] In step (3), the first fine-tuned large language model is obtained by performing supervised fine-tuning on the selected general language large model using the first fine-tuning dataset; the second fine-tuned large language model is obtained by performing supervised fine-tuning on the selected general language large model using the second fine-tuning dataset; the third fine-tuned large language model is obtained by performing supervised fine-tuning on the selected general language large model using the third fine-tuning dataset; the fourth fine-tuned large language model is obtained by performing supervised fine-tuning on the selected general language large model using the fourth fine-tuning dataset.
[0087] In step (3), supervised fine-tuning is performed through the efficient fine-tuning hyperparameter fine-tuning method, and the efficient fine-tuning hyperparameter fine-tuning method includes LoRA, QLoRA, full-parameter fine-tuning, P-tuing, and P-tuning V2 fine-tuning methods.
[0088] (4)Evaluate and iterate on the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model, respectively, to obtain the fine-tuned large language model with the highest score as the optimal medical model, and use the data combination strategy corresponding to the fine-tuned large language model with the highest score as the optimal data combination strategy;
[0089] The specific steps of step (4) include the following sub-steps:
[0090] (4.1)Design 4 quantitative evaluation indicators for the question-generation task, namely the result parsing rate, the question quantity accuracy rate, the question completeness rate, and the question repetition rate. Among them, the result parsing rate = the number of questions that can be correctly parsed into the specified format by the fine-tuning model / the total number of data in the question-generation evaluation set; the question quantity accuracy rate = the total number of correct questions in the generated result / the total number of data in the question-generation evaluation set; the question completeness rate = the number of questions with complete elements in the generated result / the total number of data in the question-generation evaluation set; the question repetition rate = the total number of repeated questions in the generated result / the total number of data in the question-generation evaluation set.
[0091] (4.2)Construct a medical Q&A evaluation dataset, collect five-year and eight-year medical textbooks and school final exam questions as the medical Q&A evaluation dataset, and evaluate the medical Q&A capabilities of the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model.
[0092] (4.3)Select appropriate general domain evaluation datasets to evaluate the general domain capabilities of the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model. The general domain evaluation datasets include the C-Eval, CMMLU, MMLU, and MT-Bench datasets.
[0093] An example of the general domain evaluation dataset is shown in Table 1.
[0094] Table 1: Example of General Domain Evaluation Dataset
[0095]
[0096] (4.4)Use open-source or closed-source general large models to evaluate the question-setting connotations of the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model.
[0097] (4.5)Load and evaluate the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model respectively, and select the fine-tuned large language model with the highest score as the optimal medical model, and use the data combination strategy corresponding to the fine-tuned large language model with the highest score as the optimal data combination strategy.
[0098] When evaluating the fine-tuned large language model, the output of 3 questions related to gastric cancer is shown in Table 2. The output of 2 multiple-choice questions about tracheitis is shown in Table 3.
[0099] Table 2: Output of 3 Questions Related to Gastric Cancer
[0100]
[0101] Table 3: Output of 2 Multiple-Choice Questions about Tracheitis
[0102]
[0103] (5)Implement the intelligent question-setting and intelligent Q&A functions in the medical education assistance platform through the optimal medical model, providing comprehensive support and solutions for medical education.
[0104] Example 2: The step (2) specifically includes the following sub-steps:
[0105] (2.1) Collect PDF files of commonly used textbooks, tutoring books, exercise sets, and high-quality medical records in medical school education.
[0106] (2.2) Convert the collected PDF files of commonly used textbooks, tutoring books, exercise sets, and high-quality medical records in medical school education into standard format markdown text through the first data processing module.
[0107] (2.3) Manually review the converted markdown text to ensure correct title trees and text content.
[0108] (2.4) Subsequently, extract question-answer pairs based on the reviewed markdown text to obtain the question-set fine-tuning dataset.
[0109] The sub-step (2.4) specifically includes the following sub-steps:
[0110] (2.4.1) Split the reviewed markdown text into multiple data blocks according to the chunking strategy module to obtain a data block set.
[0111] As Figure 2 shown, the sub-step (2.4.1) specifically includes the following sub-steps:
[0112] (2.4.1.1) Based on the third-level headings of the reviewed markdown text, convert the reviewed markdown text into a complete list of data blocks according to the chunking strategy module.
[0113] (2.4.1.2) Given a fixed maximum character length threshold for chunking as MaxLen.
[0114] (2.4.1.3) Traverse each data block in the complete list of data blocks in turn. First, judge whether the character length of any data block is greater than MaxLen: if the character length of the data block is greater than MaxLen, divide the data block according to the paragraph break symbol and the full stop until the character lengths of all divided data blocks are less than MaxLen; if the character length of the data block is less than MaxLen, combine the data block with adjacent data blocks until the character length of the combined data block is closest to MaxLen.
[0115] (2.4.1.4) After the traversal is completed, sort all the data blocks processed in sub-step (2.4.1.3) according to the original reading order of the reviewed markdown text to obtain a data block set.
[0116] (2.4.2) Call the GPT-4o model multiple times. According to the Bloom's cognitive hierarchy, generate a fixed number of questions of definition explanation type, medical knowledge understanding type, knowledge application type, and practical evaluation type respectively for each piece of text corresponding to each data block in the data block set.
[0117] (2.4.3)Send the text corresponding to each data block and the corresponding questions to the GPT-4o model to generate relevant answers for each question, obtaining the first question-answer pair data set. Each piece of data in the first question-answer pair data set contains the questions corresponding to the text corresponding to the data block and the relevant answers.
[0118] The format of any piece of generated data is: {"question": "The i th question generated by the model", "answer": "The i th relevant answer generated by the model"}, where "question" represents the questions corresponding to the text corresponding to each data block, and "answer" represents the relevant answers corresponding to the questions.
[0119] (2.4.4)Input the text corresponding to each data block in the data block set into the GPT-4o model, and generate relevant single-choice and multiple-choice questions according to the textbook content as the question-setting fine-tuning data set.
[0120] (2.5)Process the first question-answer pair data set according to the second data processing module to obtain the question-answer fine-tuning data set.
[0121] The sub-step (2.5) specifically includes the following sub-steps:
[0122] (2.5.1)Judge according to the character length of the relevant answers of each piece of data in the first question-answer pair data set by the second data processing module: If the character length of the relevant answer is less than 50, delete this piece of data from the first question-answer pair data set; If the character length of the relevant answer is greater than 200 or the relevant answer includes ordered or unordered list symbols, use an open-source or closed-source general large model to convert the format of this relevant answer into markdown format without changing the original content, obtaining the converted relevant answer, and then replace the original relevant answer in the corresponding data with the converted relevant answer; Otherwise, do not process;
[0123] After judging the character lengths of all relevant answers of the data, obtain the second question-answer pair data set.
[0124] (2.5.2)Subsequently, convert the second question-answer pair data set into a question-answer fine-tuning data set in the instruction-input-output format.
[0125] (2.6) Collect the open-source Chinese dialogue dataset alpaca_data_zh_51k.json in the general domain. The data contains rich instructions and multi-domain and multi-task questions to obtain the general-domain dialogue dataset;
[0126] (2.7) Combine the question-setting fine-tuning dataset, the question-and-answer fine-tuning dataset, and the general-domain dialogue dataset according to four data combination strategies to obtain the first fine-tuning dataset, the second fine-tuning dataset, the third fine-tuning dataset, and the fourth fine-tuning dataset.
[0127] Embodiment 3: This embodiment relates to a large model fine-tuning device for a medical school education scenario, including a memory and one or more processors. Executable code is stored in the memory. When the one or more processors execute the executable code, it is used for the large model fine-tuning method for a medical school education scenario in Embodiment 1 above; The device embodiment can be applied to any device with data processing capabilities, and the any device with data processing capabilities can be a device or apparatus such as a computer.
[0128] Such as Figure 3 , at the hardware level, the device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include other hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the above Figure 1 shown method. Of course, in addition to the software implementation method, the present invention does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, and can also be hardware or a logic device.
[0129] For an improvement in a technology, it can be clearly distinguished whether it is an improvement in hardware (for example, improvements in circuit structures such as diodes, transistors, switches, etc.) or an improvement in software (improvements in method flows). However, with the development of technology, many improvements in method flows today can be regarded as direct improvements in hardware circuit structures. Almost all designers obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented with a hardware entity module. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logical function is determined by the user programming the device. The designer can program by himself to "integrate" a digital system on a piece of PLD without asking the chip manufacturer to design and fabricate a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing. The original code before compilation also has to be written in a specific programming language, which is called a Hardware Description Language (HDL), and there is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also be aware that as long as the method flow is slightly logically programmed with the above-mentioned several hardware description languages and programmed into the integrated circuit, it is easy to obtain the hardware circuit that implements the logical method flow.
[0130] The controller can be implemented in any suitable manner. For example, the controller can take the form of, for example, a microprocessor or a processor, and a computer-readable medium that stores computer-readable program code (such as software or firmware) executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of the controller include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program code, it is entirely possible to logically program the method steps to enable the controller to be implemented in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, and embedded microcontrollers to achieve the same function. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be regarded as the structures within the hardware component. Or even, the devices for implementing various functions can be regarded as either software modules for implementing the method or the structures within the hardware component.
[0131] The systems, devices, modules, or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.
[0132] It should also be noted that the term "comprising", "including", or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, commodity, or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or elements inherent to such process, method, commodity, or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of another identical element in the process, method, commodity, or device comprising the said element.
[0133] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0134] The present invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in a distributed computing environment where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0135] Embodiment 4: The embodiment of the present invention also provides a computer-readable storage medium, on which a program is stored. When the program is executed by a processor, it implements the method for fine-tuning a large model for a medical school education scenario in Embodiment 1 above.
[0136] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the scope of protection of the present invention.
Claims
1. A large model fine-tuning method for medical school education scenarios, characterized in that, Including the following steps: (1) Select a suitable general large language model; (2) Obtain an exam question fine-tuning dataset and a Q&A fine-tuning dataset from commonly used textbooks, tutoring books, exercise sets, and high-quality medical record PDF files in medical school education, and collect open-source Chinese dialogue datasets in the general field to obtain a general field dialogue dataset; Combine the exam question fine-tuning dataset, the Q&A fine-tuning dataset, and the general field dialogue dataset according to 4 data combination strategy methods to obtain a first fine-tuning dataset, a second fine-tuning dataset, a third fine-tuning dataset, and a fourth fine-tuning dataset; The specific steps of step (2) include the following sub-steps: (2.1) Collect commonly used textbooks, tutoring books, exercise sets, and high-quality medical record PDF files in medical school education; (2.2) Convert the collected commonly used textbooks, tutoring books, exercise sets, and high-quality medical record PDF files in medical school education into standard format markdown text through a first data processing module; (2.3) Manually review the converted markdown text to ensure correct title trees and text content; (2.4) Subsequently, extract Q&A pairs based on the reviewed markdown text to obtain an exam question fine-tuning dataset; The specific sub-steps of sub-step (2.4) include the following sub-steps: (2.4.1) Cut the reviewed markdown text into multiple data blocks according to a chunking strategy module to obtain a data block set; (2.4.2) Call open-source or closed-source general large models multiple times, and generate a fixed number of questions of definition explanation type, medical knowledge understanding type, knowledge application type, and practice evaluation type according to the Bloom cognitive hierarchy for each data block corresponding text in the data block set; (2.4.3) Send the text corresponding to each data block and the corresponding questions to an open-source or closed-source general large model to generate relevant answers for each question, obtaining a first Q&A pair dataset, where each piece of data in the first Q&A pair dataset contains the questions and relevant answers corresponding to the text corresponding to the data block; (2.4.4) Input the text corresponding to each data block in the data block set into an open-source or closed-source general large model, and generate relevant single-choice and multiple-choice questions according to the textbook content as the exam question fine-tuning dataset; (3) Use the first fine-tuning dataset, the second fine-tuning dataset, the third fine-tuning dataset, and the fourth fine-tuning dataset to perform supervised fine-tuning processing on the selected general language large model respectively, obtaining a first fine-tuned large language model, a second fine-tuned large language model, a third fine-tuned large language model, and a fourth fine-tuned large language model; (4) Evaluate and iterate on the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model respectively, obtaining the fine-tuned large language model with the highest score as the optimal medical model, and taking the data combination strategy method corresponding to the fine-tuned large language model with the highest score as the optimal data combination strategy; (5) Implement intelligent question generation and intelligent Q&A functions in the medical education assistance platform through the optimal medical model, providing comprehensive support and solutions for medical education.
2. The fine-tuning method of the large model for the medical school education scenario according to claim 1, characterized in that, The general large language model includes large language models of the Qwen series, ChatGLM series, Llama series, or Baichuan series.
3. A fine-tuning method for large models for medical school education scenarios according to claim 1, characterized in that The step (2) further includes the following sub-steps: (2.5) Process the first question-and-answer pair dataset according to the second data processing module to obtain a question-and-answer fine-tuning dataset; (2.6) Collect an open-source Chinese dialogue dataset in the general domain, where the data contains rich instructions and multi-domain and multi-task questions, to obtain a general-domain dialogue dataset; (2.7) Combine the question-setting fine-tuning dataset, the question-and-answer fine-tuning dataset, and the general-domain dialogue dataset according to 4 data combination strategy methods to obtain a first fine-tuning dataset, a second fine-tuning dataset, a third fine-tuning dataset, and a fourth fine-tuning dataset. Specifically: The first data combination strategy method: Sequentially combine the question-and-answer fine-tuning dataset and the question-setting fine-tuning dataset to obtain a first fine-tuning dataset; The second data combination strategy method: Sequentially combine the question-and-answer fine-tuning dataset, the question-setting fine-tuning dataset, and the general-domain dialogue dataset to obtain a second fine-tuning dataset; The third data combination strategy method: Combine the question-and-answer fine-tuning dataset and the question-setting fine-tuning dataset and shuffle them randomly to obtain a third fine-tuning dataset; The fourth data combination strategy method: Combine the question-and-answer fine-tuning dataset, the question-setting fine-tuning dataset, and the general dialogue dataset and shuffle them randomly to obtain a fourth fine-tuning dataset; The open-source or closed-source general large model includes ChatGPT, GPT-4, GPT-4o, Qwen2-72B-instruct, or Claude 3 Opus model.
4. The fine-tuning method of a large model for a medical school education scenario according to claim 3, wherein, The first data processing module is used to build an open-source high-quality PDF to markdown framework, open the interface of a closed-source high-quality PDF to markdown platform, and the interface of the closed-source high-quality PDF to markdown platform includes Miner-U, Textin, and NoteGPT, convert PDF or picture files into standard markdown format, and select the optimal converted markdown text.
5. The fine-tuning method of a large model for a medical school education scenario according to claim 3, characterized in that, The sub-step (2.4.1) specifically includes the following sub-steps: (2.4.1.1) According to the chunking strategy module, based on the third-level headings of the reviewed markdown text, convert the reviewed markdown text into a complete list of data chunks; (2.4.1.2) Given a fixed maximum character length threshold for chunking as MaxLen; (2.4.1.3) Traverse each data chunk in the complete list of data chunks in turn. First, judge whether the character length of any data chunk is greater than MaxLen: If the character length of the data chunk is greater than MaxLen, then divide the data chunk according to the paragraph symbol and the full stop until the character lengths of all divided data chunks are less than MaxLen; If the character length of the data chunk is less than MaxLen, then combine the data chunk with adjacent data chunks until the character length of the combined data chunk is closest to MaxLen; After the traversal in (2.4.1.4), sort all the data blocks processed in sub-step (2.4.1.3) according to the original reading order of the reviewed markdown text to obtain a data block set.
6. The fine-tuning method of a large model for a medical school education scenario according to claim 4, wherein The specific sub-steps of the sub-step (2.5) are as follows: (2.5.1) Judge according to the character length of the relevant answer for each piece of data in the first Q&A pair dataset by the second data processing module: if the character length of the relevant answer is less than 50, delete this piece of data from the first Q&A pair dataset; if the character length of the relevant answer is greater than 200 or the relevant answer includes ordered or unordered list symbols, use an open-source or closed-source general large model to convert the format of the relevant answer into markdown format without changing the original content to obtain the converted relevant answer, and then replace the original relevant answer in the corresponding data with the converted relevant answer; otherwise, do not process. After judging the character lengths of the relevant answers of all the data, obtain a second Q&A pair dataset. (2.5.2) Then convert the second Q&A pair dataset into a Q&A fine-tuning dataset in the instruction-input-output format.
7. A fine-tuning method for large models for medical school education scenarios according to claim 1, characterized in that In step (3), perform supervised fine-tuning through an efficient fine-tuning hyperparameter fine-tuning method, and the efficient fine-tuning hyperparameter fine-tuning method includes LoRA, QLoRA, full-parameter fine-tuning, P-tuing, and P-tuning V2 fine-tuning methods.
8. A method for fine-tuning a large model for a medical school education scenario according to claim 1, characterized in that, The specific sub-steps of the step (4) are as follows: (4.1) Design 4 quantitative evaluation indicators for the question-setting task, namely the result parsing rate, the question quantity accuracy rate, the question completeness rate, and the question repetition rate. Among them, the result parsing rate = the number of questions that can be correctly parsed into the specified format by the fine-tuned model / the total number of data in the question-setting evaluation set; the question quantity accuracy rate = the total number of correct questions in the generated result / the total number of data in the question-setting evaluation set; the question completeness rate = the number of questions with complete elements in the generated result / the total number of data in the question-setting evaluation set; the question repetition rate = the total number of repeated questions in the generated result / the total number of data in the question-setting evaluation set. (4.2) Construct a medical Q&A evaluation dataset, collect medical textbooks for five-year and eight-year programs and school final exam questions as the medical Q&A evaluation dataset, and evaluate the medical Q&A capabilities of the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model. (4.3) Select appropriate general domain evaluation datasets to evaluate the general domain capabilities of the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model. The general domain evaluation datasets include C-Eval, CMMLU, MMLU, and MT-Bench datasets. (4.4) Use an open-source or closed-source general large model to evaluate the question-setting connotations of the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model. (4.5) Evaluate the first fine-tuned large language model, the second fine-tuned large language model, the third fine-tuned large language model, and the fourth fine-tuned large language model respectively. Select the fine-tuned large language model with the highest score as the optimal medical model, and use the data combination strategy corresponding to the fine-tuned large language model with the highest score as the optimal data combination strategy.
9. A large model fine-tuning device for medical school education scenarios, characterized in that, It includes a memory and one or more processors. Executable code is stored in the memory. When the one or more processors execute the executable code, it is used to implement the large model fine-tuning method for the medical school education scenario according to any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, A program is stored thereon. When the program is executed by a processor, it implements the large model fine-tuning method for the medical school education scenario according to any one of claims 1-8.
Citation Information
Patent Citations
Proportion determination method and device, electronic equipment and storage medium
CN119740656A