Medical knowledge question-answering system construction method and system based on large language model

CN118568221APending Publication Date: 2024-08-30HARBIN INST OF TECH
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410639259.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

There is an illusion problem in the application of large language models in the medical field, which leads to inaccuracy and insufficient reliability of the generated answers, affecting medical decision-making and patient safety.

Method used

Build a medical knowledge question and answer system based on a large language model. Through the training of medical entity extraction, attribute extraction and answer generation model, combined with the medical knowledge base and LoRA technology, we fine-tune the model to reduce hallucination problems and improve the accuracy and reliability of answers.

Benefits of technology

It significantly reduces the time cost of manually writing medical questions, ensures the stability and scalability of generated content, improves the accuracy and reliability of medical answers, and reduces the occurrence of hallucination problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568221A
    Figure CN118568221A
Patent Text Reader

Abstract

The invention discloses a medical knowledge question-answering system construction method and system based on a large language model, and relates to the technical field of computers, in particular to a medical knowledge question-answering system construction method and system. The objective of the invention is to solve the problems of low accuracy and poor reliability of medical answers generated by an existing medical big language model. The method comprises the following steps: constructing a training set of a medical entity extraction model; constructing a medical entity extraction model; obtaining a trained medical entity extraction model; constructing a training set of a medical entity attribute extraction model; constructing a medical entity attribute extraction model; obtaining a trained medical entity attribute extraction model; constructing a training set of a medical answer generation model; constructing a medical answer generation model; obtaining a trained medical answer generation model; and based on the trained medical entity extraction model, the trained medical entity attribute extraction model and the trained medical answer generation model, processing a to-be-tested medical question, and outputting a medical answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and system for constructing a medical knowledge question-answering system. Background Art

[0002] In recent years, large language models have largely transformed the interaction mode between humans and machines. In particular, the ChatGPT language model based on the Transformer architecture has demonstrated excellent language understanding and generation capabilities through in-depth learning of large-scale text datasets. The significant advantage of this type of model is that it can extract knowledge from a large amount of text in a specific field, and effectively integrate the knowledge into the model through pre-training and fine-tuning techniques to further enhance its performance.

[0003] Although large language models have shown significant advantages, they still face a series of challenges in actual application scenarios, among which the hallucination problem is particularly prominent, highlighting the important difficulties faced by current large language model technology. The so-called hallucination problem refers to the situation in which the information generated by the model is inaccurate, irrelevant, or completely fictitious during the text generation process. This problem often stems from the model's insufficient understanding of a topic, bias in the training data set, or limitations of the model's generation mechanism itself. Hallucination problems manifest themselves in various forms, including but not limited to factual errors, logical contradictions, irrelevant content, and fictitious information, which directly affects the authenticity and credibility of the content generated by the model and becomes a key indicator for measuring the performance of large language models.

[0004] The challenge of hallucination is particularly evident in areas where user safety is critical, and the medical field is a notable example. In this field, the accuracy and reliability of model output are not only directly related to the quality of medical advice and medical decisions, but also an important factor in reducing medical errors and ensuring patient safety. Therefore, taking effective measures to address the hallucination problem of large language models and improving the accuracy and reliability of their generated responses is of vital importance to improving the practical application value of the model. Summary of the invention

[0005] The purpose of the present invention is to solve the problem of low accuracy and poor reliability of medical answers generated by existing large language models for medicine, and to propose a method and system for constructing a medical knowledge question and answer system based on a large language model.

[0006] A method for constructing a medical knowledge question-answering system based on a large language model. The specific process is as follows:

[0007] Step 1: Construct a training set for the medical entity extraction model;

[0008] Step 2: Build a medical entity extraction model, which is a large language model;

[0009] Step 3: using the medical question-and-answer text in the training set of the medical entity extraction model as the input of the medical entity extraction model, using the medical entities in the training set of the medical entity extraction model as the output of the medical entity extraction model, training the medical entity extraction model until convergence, and obtaining a trained medical entity extraction model;

[0010] Step 4: Construct a training set for the medical entity attribute extraction model;

[0011] Step 5: Construct a medical entity attribute extraction model, which is a large language model;

[0012] Step 6: taking the medical question-and-answer texts and medical entities in the training set of the medical entity attribute extraction model as the input of the medical entity attribute extraction model, taking the attributes in the training set of the medical entity attribute extraction model as the output of the medical entity attribute extraction model, training the medical entity attribute extraction model until convergence, and obtaining a trained medical entity attribute extraction model;

[0013] Step 7: Construct a training set for the medical answer generation model;

[0014] Step 8: Construct a medical answer generation model, which is a large language model;

[0015] Step nine: using the questions and medical knowledge information in the training set of the medical answer generation model as the input of the medical answer generation model, using the medical answers in the training set of the medical answer generation model as the output of the medical answer generation model, training the medical answer generation model until convergence, and obtaining a trained medical answer generation model;

[0016] Step 10: Based on the trained medical entity extraction model, the trained medical entity attribute extraction model, and the trained medical answer generation model, the medical question to be tested is processed and a medical answer is output.

[0017] The medical knowledge question answering system based on the large language model includes:

[0018] A medical entity extraction module is used to extract medical entities in the question text based on the medical entity extraction model constructed by the large language model according to the medical question text input by the user;

[0019] A medical entity attribute extraction module is used to extract the medical entity attributes in the question text based on the medical question text and the medical entity input by the user and based on the medical entity attribute extraction model constructed by the large language model;

[0020] A medical knowledge retrieval module is used to retrieve information in a medical knowledge base based on the medical question text, medical entities and medical entity attributes input by the user to obtain the same medical knowledge;

[0021] A medical knowledge fusion module is used to fuse the medical knowledge based on the prompt words according to the medical question text and medical knowledge input by the user, and output the fused medical question text containing professional medical knowledge;

[0022] The medical answer generation module is used to generate corresponding answers based on the fused medical question text and the medical answer generation model constructed by the large language model.

[0023] The beneficial effects of the present invention are:

[0024] The present invention utilizes the rich information resources in the medical knowledge base, including the names of medical entities, medical entity attributes and professional medical knowledge in the medical knowledge base, and generates a large number of medical questions containing the above medical information through the API of ChatGPT. This process uses a variety of prompts to construct training instances in different scenarios. The use of ChatGPT not only significantly reduces the time cost of manually writing medical questions and their verification, but also ensures the stability and scalability of the generated content. The present invention also uses LoRA technology to efficiently fine-tune the large language model based on the Transformer architecture. The application of LoRA technology enables a large language model with considerable effects to be adjusted under limited time and computing resource conditions. Through the above method, the medical knowledge question and answer system construction method and system provided by the present invention are intended to reduce the hallucination problem caused by the large medical model in text generation and improve the accuracy and reliability of the response results. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 It is a flow chart of the present invention;

[0026] Figure 2 This is a flowchart of knowledge retrieval. DETAILED DESCRIPTION

[0027] Specific implementation method 1: This implementation method is a method for constructing a medical knowledge question-answering system based on a large language model. The specific process is as follows:

[0028] Step 1: Construct a training set for the medical entity extraction model;

[0029] Step 2: Build a medical entity extraction model, which is a large language model;

[0030] Example of a large language model: a large language model based on the Transformer architecture;

[0031] Examples of large language models with Transformer architecture include the Movable Type Large Model, the Baichuan Large Model, and the Tongyi Qianwen Large Model.

[0032] Step 3: using the medical question-and-answer text in the training set of the medical entity extraction model as the input of the medical entity extraction model, using the medical entities in the training set of the medical entity extraction model as the output of the medical entity extraction model, training the medical entity extraction model until convergence, and obtaining a trained medical entity extraction model;

[0033] Step 4: Construct a training set for the medical entity attribute extraction model;

[0034] Step 5: Construct a medical entity attribute extraction model, which is a large language model;

[0035] Example of a large language model: a large language model based on the Transformer architecture;

[0036] Examples of large language models with Transformer architecture include the Movable Type Large Model, the Baichuan Large Model, and the Tongyi Qianwen Large Model.

[0037] Step 6: taking the medical question-and-answer texts and medical entities in the training set of the medical entity attribute extraction model as the input of the medical entity attribute extraction model, taking the attributes in the training set of the medical entity attribute extraction model as the output of the medical entity attribute extraction model, training the medical entity attribute extraction model until convergence, and obtaining a trained medical entity attribute extraction model;

[0038] Step 7: Construct a training set for the medical answer generation model;

[0039] Step 8: Construct a medical answer generation model, which is a large language model;

[0040] Example of a large language model: a large language model based on the Transformer architecture;

[0041] Examples of large language models with Transformer architecture include the Movable Type Large Model, the Baichuan Large Model, and the Tongyi Qianwen Large Model.

[0042] Step nine: using the questions and medical knowledge information in the training set of the medical answer generation model as the input of the medical answer generation model, using the medical answers in the training set of the medical answer generation model as the output of the medical answer generation model, training the medical answer generation model until convergence, and obtaining a trained medical answer generation model;

[0043] Step 10: Based on the trained medical entity extraction model, the trained medical entity attribute extraction model, and the trained medical answer generation model, the medical question to be tested is processed and a medical answer is output.

[0044] Specific implementation method 2: This implementation method is different from the specific implementation method 1 in that the training set of the medical entity extraction model is constructed in step 1; the specific process is:

[0045] Input the prompt word prompt1 into the ChatGPT API, call the ChatGPT API, and obtain the medical question text and medical entity from the return value of the API interface;

[0046] Format the medical question text according to prompt word prompt2 to obtain a formatted medical question text;

[0047] Construct a training set of medical entity extraction model based on formatted medical question text and medical entities;

[0048] Medical entities include disease and drug names, such as “type 1 diabetes”, “Liuwei Dihuang Pills”, etc.

[0049] API (Application Programming Interface) is the application programming interface;

[0050] Prompt 1: Please construct several medical question texts and indicate the names of the medical entities involved in the medical question texts;

[0051] For example: Instance = "Question: How should patients with hypertension adjust their daily diet, medical entity: hypertension".

[0052] Prompt 2: Please answer the following questions based on medical knowledge; Question: A, what medicine or disease name is mentioned in this sentence, answer:;

[0053] For example: Instance = "Please answer the following questions based on medical knowledge. Question: How should patients with hypertension adjust their daily diet? What medicine or disease name does this sentence mention? Answer: "hypertension""

[0054] The specific process of calling ChatGPT API is as follows:

[0055] Register a ChatGPT account and obtain an API key, which is used to verify your identity; write code, such as using the requests library in the Python environment; send a POST request to the relevant URL; process the response, parse the format of the response text, and extract the required information;

[0056] The other steps and parameters are the same as those in the first embodiment.

[0057] Specific implementation method three: This implementation method is different from specific implementation methods one or two in that a training set of a medical entity attribute extraction model is constructed in step four; the specific process is as follows:

[0058] Use the few-shot method of small sample learning to construct the prompt word prompt3, input the prompt word prompt3 into the ChatGPT API, call the ChatGPT API, and obtain attributes (for example, symptoms) from the return value of the API interface;

[0059] The prompt word prompt3 is: Example question 1: B, Example answer 1: C, Example question 2: D, Example answer 2: E, Example question 3: F, Example answer 3: G, Example question 4: H, Example answer 4: I, Example question 5: J, Example answer 5: K. Please answer the following questions based on medical knowledge. Question: L, which subject word related to the drug or disease M is mentioned in this sentence? Use the subject word with the closest meaning in the word range of "department, treatment, infection, introduction, symptoms, use, precautions, adverse reactions, usage and dosage, classification" to answer the question. Do not use any words outside the range; Answer:;

[0060] For example: "Example question 1: Why can't surgery be performed after the patent ductus arteriosus has a right-to-left shunt? Example answer 1: Treatment. Example question 2: Why do patients with sickle cell anemia have pain? Example answer 2: Symptoms. Example question 3: Which groups of people should use Compound Blister Capsules with caution? Example answer 3: Precautions. Example question 4: How to treat inhalation injuries? Example answer 4: Treatment. Example question 5: What is the usage and dosage of Diao Xinxuekang Capsules? Example answer 5: Usage and dosage. Please answer the following questions based on medical knowledge. Question: "L", which subject word related to the drug or disease "M" is mentioned in this sentence? Use the subject word with the closest meaning in the range of "department, treatment, infection, introduction, symptoms, use, precautions, adverse reactions, usage and dosage, classification" to answer the question. Do not use any words outside the range; answer: ";

[0061] The attributes are combined with the training set of the medical entity extraction model to form the training set of the medical entity attribute extraction model.

[0062] The other steps and parameters are the same as those in the first or second embodiment.

[0063] Specific implementation method 4: This implementation method is different from any one of the specific implementation methods 1 to 3 in that the training set of the medical answer generation model is constructed in step 7; the specific process is:

[0064] Step 71: Retrieve medical knowledge in the medical knowledge base that is identical to the medical entity obtained in the return value of the API interface in step 1 and the attribute obtained in the return value of the API interface in step 4;

[0065] Medical knowledge includes medical entities and attributes;

[0066] Step 72: Length-truncate the medical knowledge;

[0067] Step 73: Input prompt word prompt4 into ChatGPT's API, call ChatGPT's API, and obtain the medical answer from the return value of the API interface;

[0068] The prompt word prompt4 is: Please answer the question based on the following medical knowledge, question: N, knowledge (the medical knowledge obtained after interception in step 72): O; answer:;

[0069] Example: Please answer the question based on the following medical knowledge. Question: How should patients with hypertension adjust their daily diet? Knowledge: Low-salt diet, the daily salt intake should be less than 5g. In addition to using less salt when cooking, you should also pay attention to using less soy sauce, oyster sauce and other high-salt condiments; eat less pickled vegetables, pickled meat and other foods with high salt content; reduce the intake of sweets and fats appropriately; Answer: "

[0070] Step 74: Combine the question in prompt word prompt4, the medical knowledge information (obtained in step 72), and the medical answer obtained from the return value of the API interface in step 73 as the training set for the medical answer generation model.

[0071] The other steps and parameters are the same as those in Specific Embodiments 1 to 3.

[0072] Specific implementation method five: This implementation method is different from specific implementation methods one to four in that in step seven one, medical knowledge having the same attributes as the medical entity obtained in the return value of the API interface of step one and the attribute obtained in the return value of the API interface of step four is retrieved from the medical knowledge base;

[0073] Medical knowledge includes medical entities and attributes;

[0074] The specific process is:

[0075] Step 7: First, use an exact matching method to search the medical knowledge base for medical knowledge with the same attributes as the medical entity obtained in the return value of the API interface in step 1 and the attribute obtained in the return value of the API interface in step 4;

[0076] If both the medical entity and the attribute are retrieved, the match is successful and the medical knowledge is obtained;

[0077] If the medical entity or attribute is not retrieved, the match fails and step 712 is executed;

[0078] Step 7-2: Use a rule-based fuzzy matching method to search the medical knowledge base for medical knowledge that is identical to the medical entity obtained in the return value of the API interface in step 1 and the attribute obtained in the return value of the API interface in step 4.

[0079] The other steps and parameters are the same as those in Specific Embodiments 1 to 4.

[0080] Specific implementation method 6: This implementation method is different from specific implementation methods 1 to 5 in that the rule-based fuzzy matching method is used in step 7-2 to search the medical knowledge base for medical entities obtained in the return value of the API interface in step 1 and medical knowledge with the same attributes obtained in the return value of the API interface in step 4; the specific process is:

[0081] Pass the medical entities obtained from the return value of the API interface in step 1 and the medical entities in the medical knowledge base as parameters to the FuzzyWuzzy library in the python environment;

[0082] Pass the attributes obtained from the return value of the API interface in step 4 and the attributes in the medical knowledge base as parameters to the FuzzyWuzzy library in the Python environment;

[0083] The FuzzyWuzzy library outputs the medical entity matching similarity and attribute matching similarity. If both the medical entity matching similarity and the attribute matching similarity are greater than or equal to 85%, it is considered a successful match and medical knowledge is obtained;

[0084] If the medical entity matching similarity or attribute matching similarity is less than 85%, it is considered a match failure;

[0085] The medical knowledge base is constructed based on the CMeKG traditional Chinese medicine knowledge graph.

[0086] The other steps and parameters are the same as those in Specific Implementation Methods 1 to 5.

[0087] Specific implementation method 7: This implementation method is different from the specific implementation methods 1 to 6 in that the length of the medical knowledge is cut in step 72; the specific process is:

[0088] The maximum truncation length is set to 200 (200 characters), the length of the medical knowledge information is truncated, the last terminator in the truncated medical knowledge information is identified through a regular expression, and the medical knowledge information ending with the last terminator is returned.

[0089] The other steps and parameters are the same as those in Specific Embodiments 1 to 6.

[0090] Specific implementation eight: This implementation is different from any one of specific implementations one to seven in that, in step ten, based on the trained medical entity extraction model, the trained medical entity attribute extraction model, and the trained medical answer generation model, the medical question to be tested is processed and a medical answer is output; the specific process is:

[0091] 1) Format the medical question to be tested according to prompt2 to obtain the formatted medical question to be tested;

[0092] Input the formatted medical question to be tested into the trained medical entity extraction model, and the medical entity extraction model outputs the medical entity;

[0093] 2) Format the medical entity and the medical question to be tested according to prompt 3 to obtain the formatted medical entity and the medical question to be tested;

[0094] Input the formatted medical entity and the medical question to be tested into the trained medical entity attribute extraction model, and the medical entity attribute extraction model outputs attributes;

[0095] 3) Retrieve medical knowledge with the same medical entities as 1) and attributes as 2) in the medical knowledge base;

[0096] If not found, the medical question to be tested is input into the trained medical answer generation model, and the trained medical answer generation model outputs a medical answer;

[0097] If retrieved, obtain medical knowledge;

[0098] Length truncation of medical knowledge;

[0099] Format the medical knowledge and the medical question to be tested according to prompt4 to obtain the formatted medical knowledge and the medical question to be tested;

[0100] 4) Input the formatted medical knowledge and the medical question to be tested into the trained medical answer generation model, and the trained medical answer generation model outputs the medical answer.

[0101] The other steps and parameters are the same as those in Specific Embodiments 1 to 7.

[0102] Specific implementation method 9: This implementation method is based on a large language model to build a medical knowledge question-answering system, which includes:

[0103] A medical entity extraction module is used to extract medical entities in the question text based on the medical entity extraction model constructed by the large language model according to the medical question text input by the user;

[0104] A medical entity attribute extraction module is used to extract the medical entity attributes in the question text based on the medical question text and the medical entity input by the user and based on the medical entity attribute extraction model constructed by the large language model;

[0105] A medical knowledge retrieval module is used to retrieve information in a medical knowledge base based on the medical question text, medical entities and medical entity attributes input by the user to obtain the same medical knowledge;

[0106] A medical knowledge fusion module is used to fuse the medical knowledge based on the prompt words according to the medical question text and medical knowledge input by the user, and output the fused medical question text containing professional medical knowledge;

[0107] The medical answer generation module is used to generate corresponding answers based on the fused medical question text and the medical answer generation model constructed by the large language model.

[0108] The other steps and parameters are the same as those in the first embodiment.

[0109] Example:

[0110] Embodiment 1:

[0111] The present invention provides a method for constructing a medical knowledge question-answering system based on a large language model, comprising the following steps:

[0112] Step 1: Input the prompt word prompt1 into the ChatGPT API, call the ChatGPT API, and obtain the medical question text and medical entity from the return value of the API interface;

[0113] Format the medical question text according to prompt word prompt2 to obtain a formatted medical question text;

[0114] Construct a training set of medical entity extraction model based on formatted medical question text and medical entities;

[0115] Step 2: Construct a medical entity extraction model, which is the Baichuan model;

[0116] Step 3: using the medical question-and-answer text in the training set of the medical entity extraction model as the input of the medical entity extraction model, using the medical entities in the training set of the medical entity extraction model as the output of the medical entity extraction model, training the medical entity extraction model until convergence, and obtaining a trained medical entity extraction model;

[0117] A Transformer-based Baichuan model is used as the base model M1. The LoRA fine-tuning method is used and the LoRA parameters are set, train_epoch=10, batch_size=32, learning_rate=0.5e-3, and the LoRA weight weight1 with the lowest loss value during training is saved;

[0118] The weight of the base model M1 and the saved LoRA weight weight1 are used as the weights of the trained medical entity extraction model;

[0119] Step 4: Construct a training set for the medical entity attribute extraction model; the process is:

[0120] Input the prompt word prompt3 into the ChatGPT API, call the ChatGPT API, and obtain attributes (e.g., symptoms) from the return value of the API interface;

[0121] Combining the attributes with the training set of the medical entity extraction model to form a training set of the medical entity attribute extraction model;

[0122] Step 5: Construct a medical entity attribute extraction model, which is the Baichuan model;

[0123] Step 6: taking the medical question-and-answer texts and medical entities in the training set of the medical entity attribute extraction model as the input of the medical entity attribute extraction model, taking the attributes in the training set of the medical entity attribute extraction model as the output of the medical entity attribute extraction model, training the medical entity attribute extraction model until convergence, and obtaining a trained medical entity attribute extraction model;

[0124] A Transformer-based Baichuan model is used as the base model M2. The LoRA fine-tuning method is used and the LoRA parameters are set, train_epoch=10, batch_size=32, learning_rate=0.5e-3, and the LoRA weight weight2 with the lowest loss value during training is saved;

[0125] The weight of the base model M2 and the saved LoRA weight weight2 are used as the weights of the trained medical entity attribute extraction model;

[0126] Step 7: Construct a training set for the medical answer generation model;

[0127] Step 7.1. See Figure 2In this embodiment, the medical entity x1 in the return value of the API interface in step 1 and the medical entity attribute y1 in the return value of the API interface in step 4 are obtained, and x1 and y1 are replaced with the medical entity x2 and medical entity attribute y2 with the same or similar meanings through synonym replacement and translated word replacement;

[0128] Among them, synonyms such as "ingredient" and "ingredient", and translated words such as "Alzheimer's disease" and "Alzheimer's disease";

[0129] Exactly match x2 and y2 with the entity names and their attributes in the medical knowledge base;

[0130] If both the medical entity and the attribute are retrieved, the match is successful and the medical knowledge is obtained;

[0131] If the medical entity or attribute is not retrieved, the match fails and step 712 is executed;

[0132] Step 7.12: See Figure 2 , a rule-based fuzzy matching method is used to retrieve medical knowledge with the same attributes as the medical entity obtained in the return value of the API interface in step 1 and the attribute obtained in the return value of the API interface in step 4 in the medical knowledge base; the specific process is:

[0133] Pass the medical entities obtained from the return value of the API interface in step 1 and the medical entities in the medical knowledge base as parameters to the FuzzyWuzzy library in the python environment;

[0134] Pass the attributes obtained from the return value of the API interface in step 4 and the attributes in the medical knowledge base as parameters to the FuzzyWuzzy library in the Python environment;

[0135] Measure the similarity between x2, y2 and the entity names and their attributes in the medical knowledge base. If both the entity name similarity and the attribute matching similarity are greater than or equal to the preset similarity threshold, the match is successful, otherwise the match fails;

[0136] After the match is successful, the extracted medical knowledge is set as k1, and the length of k1 is truncated to finally obtain the extracted knowledge k2;

[0137] The maximum truncation length is set to 200, and the redundant information generated by the whole sentence being separated due to truncation of k1 is deleted;

[0138] K1 before truncation, for example: "Low-salt diet, my country's dietary guidelines recommend no more than 6 grams of sodium salt intake per day, the World Health Organization recommends no more than 5 grams per day, and the American Heart Association recommends no more than 3.75 grams per day. Appropriate potassium supplementation, potassium can counteract the adverse effects of sodium, eat more fresh green leafy vegetables, fruits and soy products rich in potassium, etc. After food is processed, some of the potassium will be lost. It is best to eat fresh fruits and vegetables, quit drinking, the more you drink, the higher your blood pressure. Excessive drinking not only raises blood pressure levels, but also increases the risk of stroke. Long-term heavy drinkers should gradually reduce their intake. Sudden alcohol withdrawal has the risk of severe hypertension. Exercise more, every";

[0139] Truncated k2, for example: "Low-salt diet, my country's dietary guidelines recommend no more than 6 grams of sodium salt intake per day, the World Health Organization recommends no more than 5 grams per day, and the American Heart Association recommends no more than 3.75 grams per day. Appropriate potassium supplementation, potassium can counteract the adverse effects of sodium, eat more fresh green leafy vegetables, fruits and soy products rich in potassium, etc. After food is processed, some potassium will be lost. It is best to eat fresh fruits and vegetables, quit drinking, the more you drink, the higher your blood pressure. Excessive drinking not only raises blood pressure levels, but also increases the risk of stroke. Long-term heavy drinkers should gradually reduce their intake. Suddenly quitting drinking has the risk of severe hypertension";

[0140] If k2 exists, return the extracted knowledge k2, otherwise return empty;

[0141] Step 73: Input prompt word prompt4 into ChatGPT's API, call ChatGPT's API, and obtain the medical answer from the return value of the API interface;

[0142] Step 74: merge the question in prompt word prompt4, the medical knowledge information (obtained in step 72), and the medical answer obtained from the return value of the API interface in step 73 as a training set for the medical answer generation model;

[0143] Step 8: Construct a medical answer generation model, which is the Baichuan model;

[0144] Step nine: using the questions and medical knowledge information in the training set of the medical answer generation model as the input of the medical answer generation model, using the medical answers in the training set of the medical answer generation model as the output of the medical answer generation model, training the medical answer generation model until convergence, and obtaining a trained medical answer generation model;

[0145] A Transformer-based Baichuan model is used as the base model M3. The LoRA fine-tuning method is used and the LoRA parameters are set, train_epoch=10, batch_size=32, learning_rate=0.5e-3, and the LoRA weight weight3 with the lowest loss value during training is saved;

[0146] The weight of the base model M3 and the saved LoRA weight weight3 are used as the weights of the trained medical entity attribute extraction model;

[0147] Step 10: Based on the trained medical entity extraction model, the trained medical entity attribute extraction model, and the trained medical answer generation model, the medical question to be tested is processed and a medical answer is output; the specific process is as follows:

[0148] 1) Format the medical question to be tested according to prompt2 to obtain the formatted medical question to be tested;

[0149] Input the formatted medical question to be tested into the trained medical entity extraction model, and the medical entity extraction model outputs the medical entity;

[0150] 2) Format the medical entity and the medical question to be tested according to prompt 3 to obtain the formatted medical entity and the medical question to be tested;

[0151] Input the formatted medical entity and the medical question to be tested into the trained medical entity attribute extraction model, and the medical entity attribute extraction model outputs attributes;

[0152] 3) Retrieve medical knowledge with the same medical entities as 1) and attributes as 2) in the medical knowledge base;

[0153] If not found, the medical question to be tested is input into the trained medical answer generation model, and the trained medical answer generation model outputs a medical answer;

[0154] If retrieved, obtain medical knowledge;

[0155] Length truncation of medical knowledge;

[0156] Format the medical knowledge and the medical question to be tested according to prompt4 to obtain the formatted medical knowledge and the medical question to be tested;

[0157] 4) Input the formatted medical knowledge and the medical question to be tested into the trained medical answer generation model, and the trained medical answer generation model outputs the medical answer.

[0158] Embodiment 2:

[0159] The present invention provides a medical knowledge question-answering system based on a large language model, comprising a medical entity extraction module, a medical entity attribute extraction module, a medical knowledge retrieval module, a medical knowledge fusion module and a medical answer generation module. The system constructs a knowledge question-answering system in the medical field through the method disclosed in Example 1.

[0160] A medical entity extraction module is used to extract medical entities in the question text based on the medical entity extraction model constructed by the large language model technology according to the medical question text input by the user;

[0161] A medical entity attribute extraction module is used to extract the medical entity attributes in the question text based on the medical question text and medical entity input by the user and based on the medical entity attribute extraction model constructed by the large language model technology;

[0162] The medical knowledge retrieval module is used to retrieve information in the medical knowledge base according to the medical question text, medical entities and medical entity attributes input by the user to obtain relevant medical knowledge;

[0163] A medical knowledge fusion module is used to fuse the medical knowledge based on the prompt words according to the medical question text and medical knowledge input by the user, and output the fused medical question text containing professional medical knowledge;

[0164] The medical answer generation module is used to generate corresponding answers based on the fused medical question text and the medical answer generation model constructed using the large language model technology.

[0165] The present invention may also have many other embodiments. Without departing from the spirit and essence of the present invention, those skilled in the art may make various corresponding changes and modifications based on the present invention, but these corresponding changes and modifications should all fall within the scope of protection of the claims attached to the present invention.

Claims

1. A method for constructing a medical knowledge question-answering system based on a large language model, characterized in that: The specific process of the method is: Step 1: Construct a training set for the medical entity extraction model; Step 2: Build a medical entity extraction model, which is a large language model; Step 3: using the medical question-and-answer text in the training set of the medical entity extraction model as the input of the medical entity extraction model, using the medical entities in the training set of the medical entity extraction model as the output of the medical entity extraction model, training the medical entity extraction model until convergence, and obtaining a trained medical entity extraction model; Step 4: Construct a training set for the medical entity attribute extraction model; Step 5: Construct a medical entity attribute extraction model, which is a large language model; Step 6: taking the medical question-and-answer texts and medical entities in the training set of the medical entity attribute extraction model as the input of the medical entity attribute extraction model, taking the attributes in the training set of the medical entity attribute extraction model as the output of the medical entity attribute extraction model, training the medical entity attribute extraction model until convergence, and obtaining a trained medical entity attribute extraction model; Step 7: Construct a training set for the medical answer generation model; Step 8: Construct a medical answer generation model, which is a large language model; Step nine: using the questions and medical knowledge information in the training set of the medical answer generation model as the input of the medical answer generation model, using the medical answers in the training set of the medical answer generation model as the output of the medical answer generation model, training the medical answer generation model until convergence, and obtaining a trained medical answer generation model; Step 10: Based on the trained medical entity extraction model, the trained medical entity attribute extraction model, and the trained medical answer generation model, the medical question to be tested is processed and a medical answer is output.

2. The method for constructing a medical knowledge question-answering system based on a large language model according to claim 1, characterized in that: In the step 1, a training set of a medical entity extraction model is constructed; the specific process is as follows: Input the prompt word prompt1 into the ChatGPT API, call the ChatGPT API, and obtain the medical question text and medical entity from the return value of the API interface; Format the medical question text according to prompt word prompt2 to obtain a formatted medical question text; Construct a training set of medical entity extraction model based on formatted medical question text and medical entities; Medical entities include disease and drug names; Prompt 1: Please construct several medical question texts and indicate the names of the medical entities involved in the medical question texts; Prompt 2: Please answer the following questions based on medical knowledge; Question: A, what medicine or disease name is mentioned in this sentence, answer:.

3. The method for constructing a medical knowledge question-answering system based on a large language model according to claim 2, characterized in that: In step 4, a training set of a medical entity attribute extraction model is constructed; the specific process is as follows: Use the few-shot method of small sample learning to construct the prompt word prompt3, input the prompt word prompt3 into the ChatGPT API, call the ChatGPT API, and obtain the attributes from the return value of the API interface; The prompt word prompt3 is: Example question 1: B, Example answer 1: C, Example question 2: D, Example answer 2: E, Example question 3: F, Example answer 3: G, Example question 4: H, Example answer 4: I, Example question 5: J, Example answer 5: K. Please answer the following questions based on medical knowledge. Question: L, which subject word related to the drug or disease M is mentioned in this sentence? Use the subject word with the closest meaning in the word range of "department, treatment, infection, introduction, symptoms, use, precautions, adverse reactions, usage and dosage, classification" to answer the question. Do not use any words outside the range; Answer:; The attributes are combined with the training set of the medical entity extraction model to form the training set of the medical entity attribute extraction model.

4. The method for constructing a medical knowledge question-answering system based on a large language model according to claim 3, characterized in that: In step 7, a training set of a medical answer generation model is constructed; the specific process is as follows: Step 71: Retrieve medical knowledge in the medical knowledge base that is identical to the medical entity obtained in the return value of the API interface in step 1 and the attribute obtained in the return value of the API interface in step 4; Medical knowledge includes medical entities and attributes; Step 72: Length-truncate the medical knowledge; Step 73: Input prompt word prompt4 into ChatGPT's API, call ChatGPT's API, and obtain the medical answer from the return value of the API interface; The prompt word prompt4 is: Please answer the question based on the following medical knowledge, question: N, knowledge: O; answer:; Step 74: Combine the question in prompt word prompt4, the medical knowledge information and the medical answer obtained from the return value of the API interface in step 73 as the training set for the medical answer generation model.

5. The method for constructing a medical knowledge question-answering system based on a large language model according to claim 4, characterized in that: In the step 71, the medical knowledge base is searched for medical knowledge that is identical to the medical entity obtained in the return value of the API interface in step 1 and the attribute obtained in the return value of the API interface in step 4; Medical knowledge includes medical entities and attributes; The specific process is: Step 7: First, use an exact matching method to search the medical knowledge base for medical knowledge with the same attributes as the medical entity obtained in the return value of the API interface in step 1 and the attribute obtained in the return value of the API interface in step 4; If both the medical entity and the attribute are retrieved, the match is successful and the medical knowledge is obtained; If the medical entity or attribute is not retrieved, the match fails and step 712 is executed; Step 7-2: Use a rule-based fuzzy matching method to search the medical knowledge base for medical knowledge that is identical to the medical entity obtained in the return value of the API interface in step 1 and the attribute obtained in the return value of the API interface in step 4.

6. The method for constructing a medical knowledge question-answering system based on a large language model according to claim 5, characterized in that: In the step 7-2, a rule-based fuzzy matching method is used to search the medical knowledge base for medical knowledge that is identical to the medical entity obtained in the return value of the API interface in step 1 and the attribute obtained in the return value of the API interface in step 4; The specific process is: Pass the medical entities obtained from the return value of the API interface in step 1 and the medical entities in the medical knowledge base as parameters to the FuzzyWuzzy library in the python environment; Pass the attributes obtained from the return value of the API interface in step 4 and the attributes in the medical knowledge base as parameters to the FuzzyWuzzy library in the Python environment; The FuzzyWuzzy library outputs the medical entity matching similarity and attribute matching similarity. If both the medical entity matching similarity and the attribute matching similarity are greater than or equal to 85%, it is considered a successful match and medical knowledge is obtained; If the medical entity matching similarity or attribute matching similarity is less than 85%, it is considered a match failure; The medical knowledge base is constructed based on the CMeKG traditional Chinese medicine knowledge graph.

7. The method for constructing a medical knowledge question-answering system based on a large language model according to claim 6, characterized in that: In the step 72, the length of the medical knowledge is cut; The specific process is: The maximum truncation length is set to 200, the length of the medical knowledge information is truncated, the last terminator in the truncated medical knowledge information is identified through a regular expression, and the medical knowledge information ending with the last terminator is returned.

8. The method for constructing a medical knowledge question-answering system based on a large language model according to claim 7, characterized in that: In the step 10, based on the trained medical entity extraction model, the trained medical entity attribute extraction model, and the trained medical answer generation model, the medical question to be tested is processed and a medical answer is output; The specific process is: 1) Format the medical question to be tested according to prompt2 to obtain the formatted medical question to be tested; Input the formatted medical question to be tested into the trained medical entity extraction model, and the medical entity extraction model outputs the medical entity; 2) Format the medical entity and the medical question to be tested according to prompt 3 to obtain the formatted medical entity and the medical question to be tested; Input the formatted medical entity and the medical question to be tested into the trained medical entity attribute extraction model, and the medical entity attribute extraction model outputs attributes; 3) Retrieve medical knowledge with the same medical entities as 1) and attributes as 2) in the medical knowledge base; If not found, the medical question to be tested is input into the trained medical answer generation model, and the trained medical answer generation model outputs a medical answer; If retrieved, obtain medical knowledge; Length truncation of medical knowledge; Format the medical knowledge and the medical question to be tested according to prompt4 to obtain the formatted medical knowledge and the medical question to be tested; 4) Input the formatted medical knowledge and the medical question to be tested into the trained medical answer generation model, and the trained medical answer generation model outputs the medical answer.

9. A system for constructing a medical knowledge question-answering system based on the large language model of claim 1, characterized in that: The medical knowledge question answering system based on the large language model includes: A medical entity extraction module is used to extract medical entities in the question text based on the medical entity extraction model constructed by the large language model according to the medical question text input by the user; A medical entity attribute extraction module is used to extract the medical entity attributes in the question text based on the medical question text and the medical entity input by the user and based on the medical entity attribute extraction model constructed by the large language model; A medical knowledge retrieval module is used to retrieve information in a medical knowledge base based on the medical question text, medical entities and medical entity attributes input by the user to obtain the same medical knowledge; A medical knowledge fusion module is used to fuse the medical knowledge based on the prompt words according to the medical question text and medical knowledge input by the user, and output the fused medical question text containing professional medical knowledge; The medical answer generation module is used to generate corresponding answers based on the fused medical question text and the medical answer generation model constructed by the large language model.

Citation Information

Cited By

  • Medical question answering system based on large language model

    CN119493848A

  • Medical big language model training and reasoning method and device, equipment and medium

    CN120046736A

  • Traditional Chinese medicine knowledge question-answering method based on pre-training and retrieval enhancement

    CN120429399A