Enhanced self-training-based medical scene dialogue generation method and system
By using enhanced self-training and direct preference optimization algorithms in medical scenarios, combined with SFT fine-tuning training and data expansion, the problem of low inference accuracy of large language models is solved, and the model's dialogue generation capabilities in medical scenarios are significantly improved.
Patent Information
- Application Number
- CN202410307642.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-18
- Publication Date
- 2024-08-30
AI Technical Summary
In medical scenarios, the inference accuracy of large language models is not high, mainly due to the difficulty of collecting real data and the difficulty of training reward models, especially when using the PPO algorithm.
Using a method based on reinforced self-training, the answer text obtained by inference of the large language model is inconsistent with the standard answer text given by medical experts to form an answer comparison group. The direct preference optimization algorithm is used to iteratively train the large language model, combined with SFT Fine-tune training and data augmentation to improve the model’s inference accuracy.
Through the training of the direct preference optimization algorithm, the reasoning accuracy of the large language model in medical scene dialogue generation is significantly improved, the problems of data collection and reward model training are solved, and the performance of the model in practical applications is improved.
Smart Images

Figure CN118569381A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of large language models, and in particular to a method and system for generating medical scenario dialogues based on enhanced self-training. Background Art
[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.
[0003] With the continuous advancement of technology and the in-depth development of its application, large language model technology has been used in more and more scenarios in the medical field, such as generating outpatient electronic medical records through pre-consultation and generating diagnostic results from examination and testing items. These application scenarios are collectively referred to as dialogue generation, that is, based on the input user question text question, the large language model generates the answer text response. How to generate accurate dialogues poses challenges to the construction and fine-tuning of large language models in the medical field.
[0004] At present, the fine-tuning training of large language models in medical scenarios is mainly carried out in stages using technologies such as SFT (Supervised Finetuning) and RLHF (Reinforcement Learning from Human Feedback). In the field of RLHF, PPO (Proximal Policy Optimization) is the most widely used algorithm, but this algorithm has problems such as difficulty in collecting real data and difficulty in training reward models, resulting in low inference accuracy of large language models. Summary of the invention
[0005] In order to overcome the shortcomings of the above-mentioned prior art, the present invention provides a medical scenario dialogue generation method and system based on enhanced self-training, applies the Direct Preference Optimization (DPO) algorithm to the training process of the large language model, and improves the reasoning accuracy of the large language model in medical scenario dialogue generation.
[0006] To achieve the above objectives, one or more embodiments of the present invention provide the following technical solutions:
[0007] The first aspect of the present invention provides a method for generating medical scenario dialogues based on enhanced self-training.
[0008] Medical scenario dialogue generation method based on enhanced self-training, including:
[0009] Obtain the text of questions raised by users in medical scenarios as model input;
[0010] Input the user's question text into the large language model after reinforcement self-training, and generate the answer text through reasoning;
[0011] Among them, the enhanced self-training is to form an answer comparison group with the answer texts obtained by reasoning with the large language model and the texts that are inconsistent with the standard answer texts given by medical experts, construct a preference data set, and use a direct preference optimization algorithm to iteratively train the large language model.
[0012] Furthermore, the user question texts are divided into two types: question texts with strong subjective reasoning and question texts with strong objective reasoning, and the answer text formats generated by different types are different.
[0013] Furthermore, the large language model adopts a Transformer-based Qwen model, which takes the user's question text as input and the generated answer text as output.
[0014] Furthermore, the answer text obtained by reasoning and the text that is inconsistent with the standard answer text given by the medical expert form an answer comparison group, specifically:
[0015] Collect the actual user question text question and the corresponding standard answer text y given by medical experts w ;
[0016] Using the fine-tuned large language model, the collected question text question is used as input to infer the answer text y l ;
[0017] y w With y l The inconsistent answer texts form the answer comparison group (question, w ,y l ).
[0018] Furthermore, the fine-tuning training is to perform fine-tuning training based on SFT before performing enhanced self-training, specifically:
[0019] The actual question text question is used as input, and the standard answer text y given by the corresponding medical expert is used as input. w For output, fine-tune the large language model.
[0020] Furthermore, the direct preference optimization algorithm is used to iteratively train the large language model, based on the answer comparison group (question, y w ,y l ) as the preference data of the direct preference optimization algorithm, adding preference samples y w The generation probability of reducing non-preferred samples y l The generation probability of the response is then trained to obtain the optimal large language model.
[0021] Furthermore, after the preference data set is constructed, data expansion is performed on the preference data set. The principle of expansion is that the scene data with the largest amount of data shall not exceed 5 times the scene data with the least amount of data.
[0022] A second aspect of the present invention provides a medical scenario dialogue generation system based on enhanced self-training.
[0023] A medical scenario dialogue generation system based on enhanced self-training, including a question text acquisition module and an answer text generation module:
[0024] The question text acquisition module is configured to: acquire information of user question text in the medical scenario;
[0025] The answer text generation module is configured to: input the user question text into the large language model after reinforcement self-training, and generate the answer text through reasoning;
[0026] Among them, the enhanced self-training is to form an answer comparison group with the answer texts obtained by reasoning with the large language model and the texts that are inconsistent with the standard answer texts given by medical experts, construct a preference data set, and use a direct preference optimization algorithm to train the large language model.
[0027] The third aspect of the present invention provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps in the method for generating medical scenario dialogues based on enhanced self-training as described in the first aspect of the present invention.
[0028] The fourth aspect of the present invention provides an electronic device, including a memory, a processor, and a program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the method for generating medical scenario dialogues based on enhanced self-training as described in the first aspect of the present invention are implemented.
[0029] One or more of the above technical solutions have the following beneficial effects:
[0030] The present invention combines SFT with enhanced self-training, and forms an answer comparison group with the answer texts obtained by large language model reasoning that are inconsistent with the standard answer texts given by medical experts, constructs a preference data set for the direct preference optimization algorithm, and trains the large language model fine-tuned by SFT through the direct preference optimization algorithm (Direct Preference Optimization DPO) to improve the reasoning accuracy of the large language model in generating medical scenario dialogues.
[0031] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will become obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0033] Figure 1 This is a flow chart of the method of the first embodiment.
[0034] Figure 2 This is a structural diagram of a large language model of the first embodiment. DETAILED DESCRIPTION
[0035] It should be noted that the following detailed descriptions are illustrative and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used in the present invention have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.
[0036] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0037] Embodiment 1
[0038] In one embodiment of the present disclosure, a method for generating medical scenario dialogue based on enhanced self-training is provided, such as Figure 1 As shown, the following steps are included:
[0039] Step S1: Obtain the user's question text question in the medical scenario;
[0040] Step S2: Input the user question text question into the large language model after reinforcement self-training, and generate the answer text response through reasoning;
[0041] Among them, the enhanced self-training is to form an answer comparison group with the answer texts obtained by reasoning with the large language model and the texts that are inconsistent with the standard answer texts given by medical experts, construct a preference data set, and use a direct preference optimization algorithm to iteratively train the large language model.
[0042] Furthermore, the user question texts are divided into two types: question texts with strong subjective reasoning and question texts with strong objective reasoning, and the answer text formats generated by different types are different.
[0043] Furthermore, the large language model adopts the Transformer-based Qwen model, which takes the user's question text as input and the generated answer text as output, and is suitable for single-round dialogue generation.
[0044] Furthermore, the answer texts obtained by the large language model inference and the texts that are inconsistent with the standard answer texts given by the medical experts form an answer comparison group, specifically:
[0045] Collect the actual question text question and the corresponding standard answer text y given by medical experts w ;
[0046] Using the fine-tuned large language model, the collected user question text question is used as input to infer the answer text y l ;
[0047] y w With y l The inconsistent texts form the answer comparison group (question, w ,y l ).
[0048] Furthermore, the fine-tuning training is to perform fine-tuning training based on SFT before performing enhanced self-training, specifically:
[0049] The actual user question text question is used as input, and the standard answer text y given by the corresponding medical expert is used as input. w For output, fine-tune the large language model.
[0050] Furthermore, the direct preference optimization algorithm is used to train the large language model, which is based on the answer comparison group (question, y w ,y l ) as the preference data of the direct preference optimization algorithm, adding preference samples y w The generation probability of reducing non-preferred samples y l The generation probability of the response is then trained to obtain the optimal large language model.
[0051] Furthermore, after the preference data set is constructed, data expansion is performed on the preference data set. The principle of expansion is that the scene data with the largest amount of data shall not exceed 5 times the scene data with the least amount of data.
[0052] The following is a detailed description of the implementation process of the medical scenario dialogue generation method based on enhanced self-training in this embodiment.
[0053] In view of the difficulty in collecting real data in medical scenarios and the difficulty in training reward models in reinforcement learning, this embodiment proposes a solution to use the DPO strategy for fine-tuning training, which converts the inference answer text y of the large language model into l The standard answer text given by medical experts w The inconsistent responses constitute the answer comparison group (question, y w ,y l ), which is passed as input to the large language model for DPO strategy training, and is continuously iterated through enhanced self-training to improve the inference accuracy of the large language model.
[0054] Among them, the large language model adopts the Transformer-based Qwen model, and the model structure belongs to the causal decoder (current mainstream) system. The principle is as follows Figure 2 As shown: The causal decoder architecture uses a unidirectional attention mask to ensure that each input token can only pay attention to past tokens and itself, and the input x and output y tokens are processed in the same way by the decoder. Here, the user's question text question is used as input, and a large language model is inferred to generate the answer text response.
[0055] The training process of the large language model is described below. This embodiment uses a few-shot method to collect data, then iterates the training, and combines sampling technology to expand the data. Finally, medical experts formulate evaluation criteria to verify the effect. Experiments using the DPO strategy show that the accuracy of the large language model in online application scenarios can indeed be improved. Specifically:
[0056] 1. Collecting answer data of large language model using few-shot method
[0057] The scenarios selected in this embodiment include 12 medical scenarios, including medical guidance, generating diagnosis results and diagnosis suggestions for examination items, generating diagnosis results and diagnosis suggestions for test items, and incision level judgment. The user question texts used in medical scenarios are divided into two categories: questions with strong subjective reasoning and questions with strong objective reasoning.
[0058] 1. In question scenarios with strong subjective reasoning, medical experts provide specific precautions as a criterion for judging the quality of responses. For example, in generating the conclusion of the general physical examination, the following points should be noted:
[0059] (1) Due to the formality of the answer, some format information of the answer needs to be fixed, such as:
[0060] It starts with "Dear examinee, \nThank you for choosing our physical examination service. Based on your physical examination results, I make the following summary for you:";
[0061] The ending message provides blessing information, such as "Please note that the above suggestions are for reference only. Specific health intervention measures should be carried out according to your personal situation and doctor's advice. If you have any questions, please feel free to consult your doctor. \nWish you good health!".
[0062] (2) Check whether there are any missing items in the analysis content, such as the blood pressure measurement value obtained during the physical examination is not up to standard, but it is not mentioned in the response text.
[0063] (3) Whether the correlation between different items is taken into account, for example, the blood pressure measurement value is up to standard in middle-aged people, but not in the elderly.
[0064] (4) Are detailed suggestions given for specific types of exercise and diet? Examples of detailed suggestions are as follows:
[0065] Dietary guidance:
[0066] 1) Control dietary calories and avoid excessive intake of fat and sugar;
[0067] 2) Increase the intake of vegetables, fruits and whole grains to ensure adequate fiber and vitamins;
[0068] 3) Avoid drinking and smoking.
[0069] Exercise guidance:
[0070] 1) Perform at least 150 minutes of moderate-intensity aerobic exercise per week, such as brisk walking, jogging, etc.;
[0071] 2) Perform strength training more than twice a week, such as weightlifting and push-ups;
[0072] 3) Maintain a good posture and avoid standing or sitting for long periods of time.
[0073] For these highly subjective questions, in order to generate answer text responses that meet the evaluation criteria, the instruction-based model alone cannot fully understand the user's true intentions. In order to make the large language model fully aware of the precautions and format information provided by the expert, so as to generate annotated responses that are more in line with the expert's wishes and reduce the expert's subsequent response modifications, first, a few-shot prompt composed of multiple (question, response) with a standard generation format is used to generate a response through large language model inference; then, the medical expert selects the best one according to the evaluation criteria and modifies it in the format described above; finally, the relatively optimal response is obtained as the standard response, that is, y w , the rest of the responses and the responses generated by the large language model trained by SFT fine-tuning are taken as y l , so there is a comparison group of answers (question, y w ,y l ).
[0074] Specifically, in information scenarios with strong subjective reasoning, in order to obtain standard answers that meet the requirements of medical experts and reduce the workload of medical experts in modifying and optimizing the large language model to generate standard answers, the instruction + few-shot method is first used here to use the large language model to generate answer text. After being modified and optimized by medical experts, the answer text becomes the standard answer text specified by the medical experts.
[0075] 2. In question scenarios with strong objectivity, there is a distinction between single-choice and multiple-choice dialogues; for multiple-choice questions, when constructing answer comparison groups, attention should be paid to excluding the influence of the position of option elements.
[0076] For these more objective questions, the answers are relatively fixed and can be given directly by medical experts, namely, w , and then the response generated by the large language model after SFT fine-tuning training is used as y l .
[0077] 2. Training Process
[0078] The training process of the large language model used for medical scenario dialogue generation can be summarized as follows:
[0079] First use the data collected in the previous step (question, y w ) performs SFT fine-tuning training, and then uses the SFT fine-tuning trained model for inference, and the response is y l ; Next, use the answer comparison group (question,yw ,y l ) is used for enhanced self-training, where the enhanced self-training adopts DPO (Direct Preference Optimization) method for training.
[0080] The DPO method is used here because it is not possible to obtain enough and comprehensive data for reward model training and fine-tuning in the short term. Therefore, the direct preference optimization algorithm DPO + medical expert evaluation is used to strengthen self-training. Specifically:
[0081] To answer the comparison group (question, y w ,y l ) as the preference data of the direct preference optimization algorithm, forming a preference data set and increasing the preference sample y w The generation probability of reducing non-preferred samples y l The generation probability of the response is then trained to obtain the optimal large language model.
[0082] From the above DPO process, we can see that enhanced self-training requires labeled data for training and testing, and requires iterative training. After the training, a large language model is used to infer the user's question text question to obtain the answer text response.
[0083] In general, the iterative training of the model can simulate the interactive performance of the model in the actual medical environment, but sometimes it may appear idealistic. Therefore, it is often necessary to expand the training data, that is, the preference data set, to increase the diversity and comprehensiveness of the data. To this end, it is necessary to enhance and expand the preference data set, specifically:
[0084] (1) Change the inference generation strategy of the large language model to a sampling approach.
[0085] (2) By adjusting the parameters Temperature and top_p, different outputs of the model, namely responses, are obtained. This embodiment uses a 14B large language model qwen as the basic model. According to experience, the number of responses is 14-16. After screening and combination by experts, valid data (question, y) for each question can be obtained. w ,y l ) is 2-6 groups.
[0086] (3) The expanded data (question, y w ,y l ) is given as input to the large language model for fine-tuning training of DPO.
[0087] (4) The large language model obtained after training is then continuously iteratively trained according to the steps in (1)-(3).
[0088] In addition, considering the diversity of training data and the balance of data quantity, the data of the scenario with the largest data volume shall not exceed 5 times that of the scenario with the smallest data volume; note that duplicate data shall be removed during the data processing.
[0089] III. Evaluation Mechanism
[0090] During the training process of the model, an evaluation system is used to score and evaluate the model until the preset threshold score is met, at which point the training stops and a trained large language model is obtained.
[0091] The evaluation system in this embodiment adopts different measurement methods for subjective questions and objective questions, and the score range is [0,1], where 0 points represent the worst and 1 point represents the best.
[0092] 1. Subjective Questions
[0093] It is divided into 2 steps:
[0094] (1) Use other more powerful large language models to score and evaluate according to the evaluation criteria, such as GPT4, and then medical experts correct the evaluation results.
[0095] (2) Adopt the ROUGE score calculation method to obtain the specific score by measuring the difference between the reasoning response and the standard response.
[0096] Finally, the scores obtained from the above 2 steps are fused to obtain the final score.
[0097] 2) Objective Questions
[0098] Since there are multiple-choice and single-choice types in objective questions, the following points are concerned in the evaluation:
[0099] (1) If the output response does not meet the format requirements, it is processed as a score of 0; for example, the output should meet the json format, such as {"functionName":"sign input"}, but the result inferred by the large language model is not a json structure.
[0100] (2) Calculate the intersection-over-union (IOU) score between the output response and the standard response in units of options. The formula is:
[0101]
[0102] Among them, A and B respectively represent the sets of elements in the standard response and the reasoning response. For example, in the following scenario:
[0103] Question: You are a tertiary doctor who can recommend hospital examination items. The patient's diagnosis is now: bladder tumor. The patient's basic information: Gender: female, age: 63 years old, current medical history information: no special medical history record. Please recommend the examination items suitable for this patient from the following `Examination Item List`, at least 3 and no more than 5.
[0104] The final result is strictly returned in JSON format, that is, {"items":["value"]}, where "value" is the check item. For example, the check item list is:
[0105] Cystoscopy and urethroscopy (flexible endoscope), color Doppler ultrasound of urinary system (bilateral kidney, ureter and bladder), color Doppler ultrasound of urinary system (bilateral kidney, ureter, prostate and bladder), color Doppler ultrasound of urinary system, color Doppler ultrasound of urinary system, color Doppler ultrasound of bladder, prostate and seminal vesicle, cystoscopy and urethroscopy (rigid endoscope)
[0106] Response of fine-tuning model: {"items":["Urinary system (bilateral kidney, ureter, bladder) color ultrasound","bilateral kidney, ureter, prostate, bladder color ultrasound","cystoscopy and urethroscopy (flexible endoscope)"]}
[0107] Standard answer response: {"items":["Urinary system (bilateral kidney, ureter and bladder) color ultrasound","Cystoscopic urethroscopic examination (flexible endoscope)","Urinary system color ultrasound","bilateral kidney, ureter and bladder color ultrasound","Cystoscopic urethroscopic examination (rigid endoscope)"]}
[0108] The calculation method of intersection over union (IOU) is:
[0109] The number of options in the intersection of the two responses is 2, and the number of options in the union is: 3+5-2=6, and the final score is 0.33.
[0110] Embodiment 2
[0111] In one embodiment of the present disclosure, a medical scenario dialogue generation system based on enhanced self-training is provided, including a question text acquisition module and an answer text generation module:
[0112] The question text acquisition module is configured to: acquire the user question text in the medical scenario;
[0113] The answer text generation module is configured to: input the question text into the large language model after reinforcement self-training, and generate the answer text through reasoning;
[0114] Among them, the enhanced self-training is to form an answer comparison group with the answer texts obtained by reasoning with the large language model and the texts that are inconsistent with the standard answer texts given by medical experts, construct a preference data set, and use a direct preference optimization algorithm to train the large language model.
[0115] Embodiment 3
[0116] The purpose of this embodiment is to provide a computer-readable storage medium.
[0117] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the method for generating medical scenario dialogues based on enhanced self-training as described in the first embodiment of the present disclosure.
[0118] Embodiment 4
[0119] The purpose of this embodiment is to provide an electronic device.
[0120] An electronic device includes a memory, a processor, and a program stored in the memory and executable on the processor. When the processor executes the program, the steps in the method for generating medical scenario dialogues based on enhanced self-training as described in Embodiment 1 of the present disclosure are implemented.
[0121] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A medical scenario dialogue generation method based on enhanced self-training, characterized in that: include: Obtain the user's question text in the medical scenario; Input the user's question text into the large language model after reinforcement self-training, and generate the answer text through reasoning; Among them, the enhanced self-training is to form an answer comparison group with the answer texts obtained by reasoning with the large language model and the texts that are inconsistent with the standard answer texts given by medical experts, construct a preference data set, and use a direct preference optimization algorithm to iteratively train the large language model.
2. The method for generating medical scenario dialogue based on enhanced self-training according to claim 1, characterized in that: The question texts are divided into two types: question texts with strong subjective reasoning and question texts with strong objective reasoning, and the answer text formats generated by different types are different.
3. The method for generating medical scenario dialogue based on enhanced self-training according to claim 1, characterized in that: The large language model adopts the Transformer-based Qwen model, which takes the user's question text as input and the generated answer text as output, and is suitable for single-round dialogue generation.
4. The method for generating medical scenario dialogue based on enhanced self-training according to claim 1, characterized in that: The answer texts obtained by the large language model inference and the texts that are inconsistent with the standard answer texts given by the medical experts form an answer comparison group, specifically: Collect the actual user question text question and the corresponding standard answer text y given by medical experts w ; Using the fine-tuned large language model, the collected user question text question is used as input to infer the answer text y k ; y w With y l The inconsistent texts form the answer comparison group (question, w ,y l ).
5. The method for generating medical scenario dialogue based on enhanced self-training according to claim 4, characterized in that: The fine-tuning training is to perform fine-tuning training based on SFT before performing enhanced self-training, specifically: The actual user text question is used as input, and the standard answer text y given by the corresponding medical expert is used. w For output, fine-tune the large language model.
6. The method for generating medical scenario dialogue based on enhanced self-training according to claim 1, characterized in that: The direct preference optimization algorithm is used to train the large language model, which is to answer the comparison group (question, y w ,y l ) as the preference data of the direct preference optimization algorithm, adding preference samples y w The generation probability of reducing non-preferred samples y l The generation probability of the response is then trained to obtain the optimal large language model.
7. The method for generating medical scenario dialogue based on enhanced self-training according to claim 1, characterized in that: It also includes, after the preference data set is constructed, data expansion of the preference data set is performed, and the principle of expansion is: the scene data with the largest amount of data shall not exceed 5 times the scene data with the least amount of data.
8. A medical scenario dialogue generation system based on enhanced self-training, characterized by: Including question text acquisition module and answer text generation module: The question text acquisition module is configured to: acquire the question text of the user in the medical scenario; The answer text generation module is configured to: input the question text into the large language model after reinforcement self-training, and generate the answer text through reasoning; Among them, the enhanced self-training is to form an answer comparison group with the answer texts obtained by reasoning with the large language model and the texts that are inconsistent with the standard answer texts given by medical experts, construct a preference data set, and use a direct preference optimization algorithm to train the large language model.
9. An electronic device, comprising: a memory for non-transitory storage of computer readable instructions; a processor for executing the computer-readable instructions; When the computer-readable instructions are executed by the processor, the method described in any one of claims 1 to 7 is executed.
10. A storage medium, characterized in that: The computer-readable instructions are non-transitorily stored, wherein when the computer-readable instructions are executed by a computer, the method of any one of claims 1 to 7 is performed.
Citation Information
Cited By
Question and answer information processing method and device, model training method and device, electronic equipment and medium
CN119168093A
Medical field large model pre-training and fine tuning method and device based on knowledge graph
CN119514674A
Data synthesis method and device based on large follow-up visit model
CN120260961A
Hospital guidance model training method and device, storage medium and program product
CN120561598A
Guidance model training method and device, storage medium and program product
CN120561598B
