Chinese medical question and answer method and device based on knowledge graph and large language model

By combining the knowledge graph with the large language model, using the structured knowledge of the knowledge graph and the text understanding ability of the large language model, the problem of poor accuracy of medical Q&A results in the existing technology is solved, and more accurate and reliable understanding and answering of medical knowledge is achieved.

CN119513232AInactive Publication Date: 2025-02-25HUNAN NORMAL UNIVERSITY
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510080828.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-20
Publication Date
2025-02-25
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, when medical Q&A is only reliant on large language models for medical Q&A, the generated Q&A results have poor accuracy, especially in providing precise medical knowledge.

Method used

Combining the knowledge graph and large language model, by inputting the initial question data into the first large language model for analysis, we obtain symptom information and symptom core entities, and match it with the pre-constructed knowledge graph to obtain the target entity and related knowledge triplets. Then, convert this information into text form, input it into the second largest language model for question-and-answer processing, and generate the target answer.

Benefits of technology

Through the combination of structured knowledge of the knowledge graph and text understanding ability of the large language model, more accurate and reliable understanding and answering of medical knowledge is achieved, and the accuracy of question-and-answer results is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119513232A_ABST
    Figure CN119513232A_ABST
Patent Text Reader

Abstract

The invention discloses a question and answer method, and particularly relates to a Chinese medical question and answer method and device based on a knowledge graph and a large language model.The method comprises the steps that initial question data are input into a first large language model to be analyzed, and symptom information, symptom core entities and question information are obtained; matching the symptom core entity with an entity in a pre-constructed knowledge graph to obtain a target entity, the target entity being an entity whose semantic matching degree with the symptom core entity is greater than a threshold in the knowledge graph; performing related knowledge retrieval in the knowledge graph based on the target entity to obtain a target triple; converting the target triad into input information in a text form; and inputting the input information, the symptom information and the question information into a second large language model for question and answer processing to obtain a target answer. According to the method, the Chinese medical question and answer result with higher accuracy can be obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a question-answering method, and specifically to a Chinese medical question-answering method and device based on a knowledge graph and a large language model. Background Art

[0002] The early field of Natural Language Processing (NLP) mainly relied on rule-based methods and statistical models. Although these methods have achieved certain results, they are unable to cope with complex medical language phenomena and large-scale medical data. With the introduction of deep learning technology, especially the Recurrent Neural Network (RNN), Long Short-Term Memory (LSTM) and the later Transformer neural network architecture based on the Self-Attention Mechanism, the capabilities of large language models have made a qualitative leap.

[0003] The emergence of the Transformer architecture is a key turning point in the development of the large language model field. It effectively captures the long-distance dependencies within sentences through the self-attention mechanism, greatly improving the language model's ability to understand and generate text. The Transformer-based language model (BERT) has pushed the pre-training-fine-tuning paradigm to a new level. Through unsupervised pre-training on a large-scale corpus, the language model (BERT) has achieved breakthrough performance in multiple NLP tasks, especially in the understanding and classification of medical texts.

[0004] Subsequently, the introduction of generative pre-trained models (GPT series models) further promoted the development of large language models. Models such as GPT-3 not only achieved unprecedented breakthroughs in scale, but also demonstrated amazing capabilities in multiple application scenarios such as text generation, dialogue systems, and text summarization. These models have learned rich language knowledge and reasoning capabilities through training on massive amounts of data, and can generate coherent and reasonable text in a variety of contexts, which is particularly suitable for the generation of medical consultations and diagnostic recommendations.

[0005] Although large language models can generate coherent medical texts, they may lack precision in providing accurate medical knowledge, mainly because the models rely on statistical methods and are easily affected by noise or misleading information mixed in the training data. Therefore, it can be seen that the existing technology that relies solely on large language models for question answering will have the problem of poor accuracy in the generated question answering results. Summary of the invention

[0006] The technical problem to be solved by the present invention is that the large language model commonly used in the prior art can generate coherent medical texts, but may lack accuracy in providing accurate medical knowledge, resulting in poor accuracy of the generated question and answer results. In order to solve the above problem, the present invention provides a Chinese medical question and answer method and device based on a knowledge graph and a large language model.

[0007] The content of the present invention includes: In a first aspect, an embodiment of the present invention provides a Chinese medical question-answering method based on a knowledge graph and a large language model, comprising: Input the initial question data into the first language model for parsing and processing to obtain symptom information, symptom core entities and question information; Match the symptom core entity with an entity in a pre-constructed knowledge graph to obtain a target entity, where the target entity is an entity in the knowledge graph whose semantic matching degree with the symptom core entity is greater than a threshold; Based on the target entity, relevant knowledge is retrieved in the knowledge graph to obtain a target triple; Convert the target triple into textual input information; The input information, the symptom information and the question information are input into the second largest language model for question-answering processing to obtain a target answer.

[0008] Optionally, matching the symptom core entity with an entity in a pre-constructed knowledge graph to obtain a target entity includes: The symptom core entity is input into a trained language model for entity matching to obtain a target entity, and the language model is constructed based on BERT.

[0009] Optionally, before inputting the symptom core entity into a trained language model for entity matching to obtain a target entity, the method further includes: Constructing a fine-tuning dataset, wherein the fine-tuning dataset includes a plurality of core entities and entities matched by the core entities in the knowledge graph; The pre-trained BERT model is fine-tuned based on the fine-tuning dataset to obtain the trained language model.

[0010] Optionally, the performing relevant knowledge retrieval in the knowledge graph based on the target entity to obtain a target triple includes: Based on the depth-first search algorithm, knowledge retrieval is performed on the target entity in the knowledge graph, and the pruning function is used for optimization during the search process to obtain the target triple.

[0011] Optionally, the depth-first search algorithm is used to perform knowledge retrieval on the target entity in the knowledge graph, and a pruning function is used for optimization during the search process to obtain a target triple, including: Taking the target entity as the currently processed entity, performing a search operation on the currently processed entity to obtain the target triple; In the case where the tail entity is obtained by performing the search operation, the search operation is performed using the tail entity as the entity currently being processed to obtain the target triple; Among them, the search operation includes: retrieving a relationship set associated with the currently processed entity from the knowledge graph, and calling a pruning function to filter the relationship set to obtain a target relationship, and obtaining a tail entity associated with the currently processed entity through the target relationship. The currently processed entity, the target relationship and the tail entity constitute the target triplet.

[0012] Optionally, converting the target triple into input information in text form includes: Pre-building a natural language template, where the natural language template is used to convert the triples into natural language sentences; The target triplet is converted into input information in text form based on the natural language template.

[0013] Optionally, inputting the input information, the symptom information and the question information into a second language model for question-answering processing to obtain a target answer includes: The input information and the question information are combined to obtain combined information; The combined information and the symptom information are input into the second largest language model as context information for question-answering processing to obtain the target answer.

[0014] In a second aspect, an embodiment of the present invention further provides a Chinese medical question-answering device based on a knowledge graph and a large language model, comprising: A data processing module, used for inputting the initial question data into the first language model for parsing and processing to obtain symptom information, symptom core entities and question information; A matching core entity module, used to match the symptom core entity with an entity in a pre-constructed knowledge graph to obtain a target entity, wherein the target entity is an entity in the knowledge graph whose semantic matching degree with the symptom core entity is greater than a threshold; A knowledge retrieval module, used to retrieve relevant knowledge in the knowledge graph based on the target entity to obtain a target triple; A conversion module, used for converting the target triple into input information in text form; The answer generation module is used to input the input information, the symptom information and the question information into the second largest language model for question-answering processing to obtain a target answer.

[0015] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a program stored in the memory and executable on the processor; the processor is used to read the program in the memory to implement the steps in the Chinese medical question-and-answer method based on a knowledge graph and a large language model as described in the first aspect.

[0016] In a fourth aspect, an embodiment of the present invention provides a readable storage medium for storing a program, which, when executed by a processor, implements the steps in the Chinese medical question-and-answer method based on a knowledge graph and a large language model as described in the first aspect.

[0017] The beneficial effect of the present invention is that, in an embodiment of the present invention, the initial question data is input into the first large language model for parsing and processing to obtain symptom information, symptom core entities and question information; the symptom core entities are matched with entities in a pre-constructed knowledge graph to obtain target entities; relevant knowledge is retrieved in the knowledge graph based on the target entity to obtain target triples; the target triples are converted into input information in text form; the input information, symptom information and question information are input into the second large language model for question and answer processing to obtain target answers. The present invention effectively combines the knowledge graph and the large language model together, processes Chinese medical problems in a collaborative manner, and realizes two-way reasoning driven by data and knowledge. It can not only extract useful information from the rich information it has, but also use the structured knowledge in the knowledge graph for logical reasoning to better understand and answer complex Chinese medical problems, thereby providing more accurate and reliable medical advice. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Attached Figure 1 One of the flowcharts of the Chinese medical question-answering method based on the knowledge graph and the large language model provided in the embodiment of the present invention; Attached Figure 2 A schematic diagram of the model fine-tuning process of the pre-trained BERT provided in an embodiment of the present invention; Attached Figure 3 A schematic diagram of a relevant knowledge retrieval process provided by an embodiment of the present invention; Attached Figure 4 A schematic diagram of a Chinese medical question-answering system based on a knowledge graph and a large language model provided in an embodiment of the present invention; Attached Figure 5 Flow chart 2 of the Chinese medical question-answering method based on knowledge graph and large language model provided in an embodiment of the present invention; Attached Figure 6A schematic diagram of a Chinese medical question-answering device based on a knowledge graph and a large language model provided in an embodiment of the present invention; Attached Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0019] In the embodiments of the present application, the term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In the embodiments of the present application, the term "multiple" refers to two or more, and other quantifiers are similar. The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first" and "second" are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more.

[0020] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0022] The embodiments of the present application provide a Chinese medical question-answering method and device based on a knowledge graph and a large language model, aiming to improve the accuracy of the generated question-answering results in the Chinese medical field.

[0023] See also Figure 1 , Figure 1 One of the flow charts of the Chinese medical question-answering method based on the knowledge graph and the large language model provided in the embodiment of the present invention, the method specifically includes the following steps: Step 101, input the initial question data into the first language model for parsing and processing to obtain symptom information, symptom core entities and question information.

[0024] Step 102, matching the symptom core entity with entities in a pre-constructed knowledge graph to obtain a target entity, wherein the target entity is an entity in the knowledge graph whose semantic matching degree with the symptom core entity is greater than a threshold.

[0025] Step 103, performing relevant knowledge retrieval in the knowledge graph based on the target entity to obtain a target triple.

[0026] Step 104: convert the target triplet into input information in text form.

[0027] Step 105: input the input information, the symptom information and the question information into the second largest language model for question-answering processing to obtain a target answer.

[0028] It should be understood that a large language model (LLM) refers to a deep learning model trained with a large amount of text data, which can generate natural language text or understand the meaning of language text. Its specific structure can be adjusted and set according to actual conditions, and is not limited here. In this embodiment, the first large language model and the second large language model are both LLMs, but their specific structures are different according to the different tasks they perform. They can be trained and adjusted according to actual needs, and are not limited here.

[0029] In step 101, the initial question data is input into the first language model for parsing and processing, and is decomposed into three key parts, namely, symptom information, symptom core entity and question information. The symptom core entity includes at least one of the following: disease name, drug name and medical term.

[0030] Exemplarily, in a specific implementation, the initial question data may be a patient description or a patient question, the symptom information is specific symptom information extracted from the patient description, and the symptom core entity is key entities identified to help answer the patient's questions. These entities may include disease names, drug names, medical terms, etc. The question information is used to clarify the specific questions raised by the patient for subsequent accurate answers.

[0031] In a specific implementation, before step 101, the method further includes: efficiently uploading conversational question and answer data in a large conversational question and answer dataset in the Chinese medical field (CMCQA) to a graph database in advance, and pre-building a knowledge graph to ensure the integrity and consistency of the data.

[0032] Optionally, in some embodiments, step 102 includes: The symptom core entity is input into a trained language model for entity matching to obtain a target entity, and the language model is constructed based on BERT.

[0033] In step 102, the purpose is to find the entity in the knowledge graph that has the best semantic match with the aforementioned extracted symptom core entity greater than a threshold (e.g., the entity with the highest match), that is, the target entity. In this embodiment, the language model is built based on BERT. BERT (Bidirectional Encoder Representations from Transformers) is a widely used deep learning model, especially in NLP tasks. Using the trained BERT for entity matching processing can obtain more accurate matching results.

[0034] Optionally, in some embodiments, before inputting the symptom core entity into a trained language model for entity matching to obtain a target entity, the method further includes: Constructing a fine-tuning dataset, wherein the fine-tuning dataset includes a plurality of core entities and entities matched by the core entities in the knowledge graph; The pre-trained BERT model is fine-tuned based on the fine-tuning dataset to obtain the trained language model.

[0035] Optionally, in some embodiments, the loss function used for fine-tuning the pre-trained BERT model based on the fine-tuning dataset is a cross entropy loss function, specifically: ; in, is the output of the model, with a shape of N×C, is the true label, with shape N, Represents the output value corresponding to the true category of each sample, Represents the exponential sum of the output values ​​of each sample on all categories. Assuming the model is a classification task, there are C categories, and the input is a tensor of size N×C, where N is the batch size and C is the number of categories. The target is a tensor of size N, containing the true category label of each sample.

[0036] Specifically, Figure 2As shown, in this embodiment, a large number of core entities are first collected, and the corresponding entities with the closest semantics in the knowledge graph are manually matched to obtain labeled data. A fine-tuning dataset is constructed based on these manually matched entity pairs. Using BERT, which has been pre-trained on a large-scale corpus, further fine-tuning is performed based on the above-mentioned fine-tuning dataset. In this way, BERT can better understand and capture the semantic relationship between core entities and knowledge graph entities. During the training process of BERT, the fine-tuned BERT can be applied to the semantic matching task of core entities to generate matching results, and then these automatic matching results are compared with the manually matched entities to evaluate the accuracy and performance of the model. According to the comparison results, the language model BERT is further optimized to improve its performance in semantic matching tasks.

[0037] In this embodiment, in order to achieve high-precision semantic matching, the language model (BERT) that has been pre-trained on a large-scale corpus is fine-tuned. The fine-tuning data set comes from a large number of manually matched core entities and their semantically closest entities. By comparing the matching results of the language model (BERT) with the manually matched entities, the performance of the language model (BERT) is continuously optimized to ensure that it achieves a higher accuracy rate in semantic matching in the medical field, further improving the accuracy of semantic matching.

[0038] Optionally, in some embodiments, step 103 includes: Based on the depth-first search algorithm, knowledge retrieval is performed on the target entity in the knowledge graph, and the pruning function is used for optimization during the search process to obtain the target triple.

[0039] In step 103, in order to efficiently find and process entities and relationships related to the initial question data in the knowledge graph, a depth-first search (DFS) algorithm is used. Specifically, a depth-first search function is constructed, which searches recursively and uses a pruning function to optimize the search process.

[0040] Since each entity may be connected to multiple relations, for example, the "oral ulcer" entity may be associated with multiple relations such as "suffering from a disease", "diagnosis and examination", "common medicines", "suitable to eat" and "avoid eating". However, not all relations are related to the initial question data. Therefore, in this embodiment, the high-value relations related to the initial question data are retained through the pruning function, while irrelevant relations are eliminated to reduce the invalid knowledge searched and reduce the complexity of the deep search.

[0041] It should be understood that, in a specific implementation, the pruning function can essentially understand a fine-tuned language model (such as BERT). In a specific implementation, a language model (such as BERT) used by the pruning function is constructed and the language model is fine-tuned. Exemplarily, a data set corresponding to a pruning function is first constructed, and the data set contains two types of samples, namely positive samples and negative samples. Among them, positive samples refer to relationship samples that are valuable for answering the initial question data, and negative samples refer to relationship samples that are useless for answering the initial question data. Based on the initial question data, the 12 relationship types of 520,000 triples in the knowledge graph are classified.

[0042] For example, for the initial question data "Do these symptoms belong to Yin deficiency?": Positive samples: The relationship "symptoms" associated with the "Yin deficiency" entity is marked as a positive sample.

[0043] Negative samples: Other relation types (such as “treatment plan”, “preventive measures”, etc.) are marked as negative samples.

[0044] Optionally, in some embodiments, the loss function used by the language model (eg, BERT) used by the fine-tuning pruning function is: ; Among them, the initial question data The corresponding relations converted from positive samples and negative samples are encoded and expressed as , , , It is a threshold that prevents the model from focusing too much on positive or negative samples. Through this fine-tuning process, the language model acquires the ability to capture useful knowledge and deviate from knowledge that is not valuable for answering questions.

[0045] Through the above settings, the data set covers relations that are both semantically related and semantically unrelated to the initial question data, ensuring that the language model used by the pruning function can learn relation types that are semantically connected to the initial question data, as well as relation types that are not semantically connected to the initial question data. Fine-tuning the language model used by the pruning function through the above data set can greatly improve the accuracy of the fine-tuned language model in judging the degree of relevance between relations and questions, thereby improving the efficiency of pruning.

[0046] Optionally, in some embodiments, the knowledge search for the target entity in the knowledge graph is performed based on a depth-first search algorithm, and a pruning function is used for optimization during the search process to obtain a target triple, including: Taking the target entity as the currently processed entity, performing a search operation on the currently processed entity to obtain the target triple; In the case where the tail entity is obtained by performing the search operation, the search operation is performed using the tail entity as the entity currently being processed to obtain the target triple; Among them, the search operation includes: retrieving a relationship set associated with the currently processed entity from the knowledge graph, and calling a pruning function to filter the relationship set to obtain a target relationship, and obtaining a tail entity associated with the currently processed entity through the target relationship. The currently processed entity, the target relationship and the tail entity constitute the target triplet.

[0047] It should be understood that in a specific implementation, the number of target relationships may be multiple, resulting in multiple tail entities. A search operation needs to be performed on each tail entity until all currently processed entities do not obtain a corresponding tail entity after performing the search operation, and the search is terminated.

[0048] In the specific implementation, first input entity A (i.e., target entity) in the knowledge graph, use Cypher statements to query the graph database, and obtain the relationship set (r1, r2, r3...) associated with entity A. The pruning function is used to filter and determine whether the relationships r1, r2, r3... are retained. In the specific implementation, the process of filtering through the pruning function can be understood as transmitting the relationship set (r1, r2, r3...) and question information (a, b, c...) to the language model used by the pruning function (such as BERT). The model will make semantic judgments on the relationship and each question. For example, if the relationship r1 is semantically related to question b, then the relationship will be retained, otherwise it will be filtered out, and other relationships will be filtered out. Exemplarily, the relationship set obtained after filtering may be (r1, r2).

[0049] Then select one of the relationships r1, and query the graph database through the Cypher statement to obtain the other end entity set (B, C, ...) associated with entity A through relationship r1, that is, (A, r1, B)(A, r1, C). Why can there be multiple entities on the other end? Because a symptom may be common to multiple diseases, such as A='oral ulcer', r1='may have a disease', and the other end may be B='yin deficiency and fire', C='small intestine heat'.

[0050] Then, recursively search, and select B as the entity to be searched. For entity B, use Cypher statements to query the graph database in the same way as entity A to obtain the set of relationships associated with entity B (t1, t2, t3...), and then use the fine-tuned BERT to filter the relationships. For example, only relationship (t1) is left. Then, through relationship t1, get the entities at the other end of entity B, such as M and K. Then the triplet obtained is (B, t1, M)(B, t1, K).

[0051] In the same way, entities M and K can be searched. The recursive end condition is that all the relationships associated with the current entity to be searched are filtered out. For example, the relationships associated with entity M are (n1, n2, n3). After screening, it is found that n1, n2, and n3 have no semantic connection with the question information, so M cannot be expanded. At this time, backtrack to the previous level and start searching from K. If all the relationships associated with K are also filtered out, continue to backtrack until you backtrack to the initial entity A, and the search ends. After the search is completed, many target triples will be formed, forming knowledge paths, such as (A, r1, B)(B, t1, M)(A, r1, C).

[0052] See also Figure 3 , a specific embodiment is used as an example to illustrate below.

[0053] S1: Build a depth-first search function to recursively find and process related entities and relations.

[0054] S2: Input parameters include the original entity (i.e., the entity in the knowledge graph) and the entity currently being processed (i.e., the target entity). Figure 3 As shown, illustratively, the retrieval starts from the entity of oral ulcer. Optionally, during the processing, a collection is used to record the processed entities to avoid repeated processing.

[0055] S3: Get all the relationships of the target entity, save them in the relationship list of the target entity, and call the pruning function to filter, filter out the relationships that are invalid for answering the patient's questions, and retain the valuable relationships. For example, Figure 3 The relationships associated with the entity of oral ulcer are: suitable to eat, unsuitable to eat, diagnosis and examination, possible disease, food harmful to disease, and food beneficial to disease. Then, after filtering by the pruning function, the relationships obtained are: suitable to eat, unsuitable to eat, food harmful to disease, and food beneficial to disease. If the relationship list of the filtered target entity is empty, terminate the recursion.

[0056] S4: For each filtered relationship, call the Cypher query statement of the graph database to obtain the related triples and tail entities. For example, Figure 3The entities obtained through the screening relationship are liquor and duck meat.

[0057] S5: Add the obtained triples to the list of knowledge path triples as target triples. Then remove duplicates from the obtained tail entities and continue to recursively process these tail entities.

[0058] Through the above method, on the one hand, the depth-first search algorithm can be used to efficiently find and process entities and relationships related to the initial question data in the knowledge graph. On the other hand, the pruning function is used to optimize the search process, which not only reduces the invalid information searched, but also significantly reduces the complexity of the search, thereby improving the overall performance of the system and user experience.

[0059] Optionally, in some embodiments, step 104 includes: Pre-building a natural language template, where the natural language template is used to convert the triples into natural language sentences; The target triplet is converted into input information in text form based on the natural language template.

[0060] It should be understood that large language models usually accept input in the form of text rather than structured data. Therefore, through step 104, the target triple is converted into text, that is, the target triple (subject, predicate, object) is converted into natural language form to simplify the input format and improve readability and comprehension. In the above manner, the input format can be significantly simplified, so that the model can directly process this information without additional parsing and conversion steps.

[0061] Specifically, first determine the target triple, which contains a subject, a predicate, and an object. Pre-construct multiple natural language templates to convert triples into natural language sentences. The natural language template should be able to flexibly adapt to different types of triples to ensure that the converted sentences are fluent and semantically clear. Using the pre-constructed natural language template, fill the subject, predicate, and object contained in the target triple into the corresponding positions of the natural language template to obtain the input information in text form. For example, the triple (subject: diabetes; predicate: common symptoms; object: polydipsia, polyphagia, polyuria) can be converted into a sentence: "Common symptoms of diabetes include polydipsia, polyphagia, and polyuria." In some embodiments, there are multiple target triples, each of which can be converted into a natural language sentence, and the generated multiple natural language sentences are integrated into a coherent text, thereby ensuring the integrity and logic of the information.

[0062] In this embodiment, by converting the triples in the knowledge graph into natural language form, not only the input format is simplified, readability and comprehension are improved, but also the large language model can process and utilize this information more efficiently.

[0063] Optionally, the step 105 includes: The input information and the question information are combined to obtain combined information; The combined information and the symptom information are input into the second largest language model as context information for question-answering processing to obtain the target answer.

[0064] The embodiment of the present invention also provides a collaboratively enhanced Chinese medical question-answering system based on knowledge graph and large language model, which can be used to implement the Chinese medical question-answering method based on knowledge graph and large language model provided in the embodiment of the present invention. The collaboratively enhanced Chinese medical question-answering system based on knowledge graph and large language model includes a data processing module, a core entity matching module, a knowledge retrieval module, a knowledge triple conversion module to natural language form, and an answer generation module. Figure 4 As shown below, combined Figure 4 The system shown illustrates the specific process of the method provided by the embodiment of the present invention.

[0065] S1: The initial question data (such as the initial data provided by the patient) is separated through the first language model to obtain three parts, namely: the patient's symptom information, the patient's symptom core entity and the patient's question information.

[0066] S2: The symptom core entity is input into the fine-tuned language model (BERT), which returns the entity that best semantically matches the symptom core entity in the pre-built knowledge graph, namely the target entity.

[0067] S3: Use the matched target entity to retrieve relevant knowledge in the knowledge graph. The retrieval process uses a depth-first search algorithm and a pruning function to ensure that the information obtained at each layer is helpful in solving the patient's problem. The retrieved knowledge is in the form of triples, namely the target triples.

[0068] S4: Since large language models usually accept text input and are more likely to understand text information rather than structured information, in this step the target triples obtained in S3 are converted into text input information through a natural language template.

[0069] S5: After obtaining the input information in text form, it is combined with the problem information initially described by the patient, and then transmitted to the large language model together with the symptom information obtained in S1 as context information. The large language model answers the patient's questions based on its rich knowledge and context information.

[0070] like Figure 5 As shown, for ease of understanding, a specific embodiment is taken as an example for description below.

[0071] The initial question data is the questions entered by the patient, as follows: "In the afternoon and evening, the palms and soles of the hands and feet are hot, the whole body is itchy, and there are frequent oral ulcers. Is this Yin deficiency? How to regulate and treat it? Please answer the Chinese medicine doctor (female, 26) I am thin, and I have had this symptom for three or four days. I don’t have back pain, weak legs, dry mouth, or bitter taste in the mouth. I have oral ulcers half of the time in a month. How to treat it? How to regulate it in life? What are the fasting foods?" The questions input by the above patients are input into the first language model for parsing and processing, and three parts of content are obtained, as shown below: Symptom information: "Hot palms and soles in the afternoon and evening, itchy body, frequent oral ulcers, (female, 26) thin body, this symptom has been there for three or four days, no back pain, weak legs, dry mouth, no bitter taste in the mouth". Symptom core entity: "Hot palms and soles, oral ulcers, dry mouth, itchy body". Question information: "1. Do these symptoms belong to Yin deficiency? 2. What are the dietary taboos? 3. How should we adjust our life to reduce the occurrence of oral ulcers? 4. How to adjust and treat through traditional Chinese medicine?".

[0072] The core symptom entities are input into the trained BERT for entity matching, and the target entities are obtained, which are: "fever hands and feet, oral ulcers, dry mouth and tongue, pruritus". Based on the target entity, knowledge retrieval is performed, and the target triples obtained are: "[oral ulcer, possible disease, epidemic hemorrhagic fever]; [oral ulcer, suitable food, duck meat]; [oral ulcer, avoid food, liquor]; [oral ulcer, diagnostic examination, oral endoscope]".

[0073] The target triples obtained are converted into input information in text form, as follows: "Symptom: oral ulcers, possible diseases include: hemorrhagic fever. Symptom: oral ulcers, suitable foods include: duck meat. Symptom: oral ulcers, foods that should not be eaten include: white wine. Symptom: oral ulcers, can be diagnosed through examination: oral endoscope".

[0074] The input information, the symptom information and the question information are integrated to obtain integrated question data. For example, part of the integrated question data is as follows: “1. Do these symptoms belong to Yin deficiency? Reference knowledge: Symptoms: Hot hands and feet, possible diseases include: Yin deficiency.

[0075] Symptoms: dry mouth and tongue. Possible diseases include: Yin deficiency and glossitis.

[0076] 2. What are the dietary taboos? Reference knowledge: Symptom: Oral ulcers, suitable foods to eat are: duck meat Symptoms: Oral ulcers, foods to avoid: white wine. " It should be understood that the aforementioned question information includes four questions. In a specific implementation, integrated question data corresponding to the four question information can be obtained. Here is only an example of integrated question data corresponding to two of the questions.

[0077] The above integrated question data is input into the second largest language model for question-answering processing, and the target answer is obtained as follows: “ 1. Do these symptoms belong to Yin deficiency? Hot palms and soles of feet in the afternoon and evening, itching all over the body, frequent mouth ulcers, and thin body are symptoms consistent with "yin deficiency" in traditional Chinese medicine.

[0078] Hot palms and soles of feet are a typical manifestation of yin deficiency.

[0079] Oral ulcers. Yin deficiency may cause dry mouth, which in turn causes oral ulcers.

[0080] 2. What are the dietary taboos? Avoid smoking and drinking: Tobacco and alcohol can irritate the oral mucosa and aggravate ulcers.

[0081] Avoid fried foods: such as fried peanuts, fried dough sticks, etc. These foods can easily cause internal heat and aggravate symptoms. " The Chinese medical question-answering method based on knowledge graph and large language model provided in the embodiment of the present application combines the large language model with the knowledge graph. The rich knowledge contained in the medical knowledge graph, such as the symptoms of the disease, the technology for diagnosing the disease, and the commonly used drugs for treating the disease, can provide more accurate relevant medical knowledge for the large language model, so that it can generate accurate and reliable diagnostic opinions and treatment methods when answering medical questions. At the same time, the knowledge in the knowledge graph exists in a structured form, which makes the results generated by the large language model more interpretable. The triples in the knowledge graph provide corresponding objective basis for the large language model in generating medical opinions and diagnostic techniques, which also effectively solves the distrust of doctors and patients for the answers of the large language model. On the other hand, the large language model is obtained by massive knowledge training, which can provide strong knowledge support for the medical question-answering system, so that the method can accurately answer the questions of patients and doctors when dealing with problems beyond the knowledge scope of the knowledge graph. The method provided by the embodiment of the present application achieves accurate entity matching and accurate knowledge search in the entire processing process, and the final result is also the most valuable knowledge for answering questions, and the large language model can fully play its strengths and avoid its weaknesses.

[0082] See also Figure 6 The embodiment of the present invention further provides a Chinese medical question-answering device 600 based on a knowledge graph and a large language model, comprising: The data processing module 601 is used to input the initial question data into the first language model for parsing and processing to obtain symptom information, symptom core entities and question information; A matching core entity module 602 is used to match the symptom core entity with an entity in a pre-constructed knowledge graph to obtain a target entity, where the target entity is an entity in the knowledge graph whose semantic matching degree with the symptom core entity is greater than a threshold; A knowledge retrieval module 603 is used to retrieve relevant knowledge in the knowledge graph based on the target entity to obtain a target triple; A conversion module 604, configured to convert the target triple into input information in text form; The answer generation module 605 is used to input the input information, the symptom information and the question information into the second largest language model for question-answering processing to obtain a target answer.

[0083] Optionally, the matching core entity module 602 is specifically used for: The symptom core entity is input into a trained language model for entity matching to obtain a target entity, and the language model is constructed based on BERT.

[0084] Optionally, the matching core entity module 602 is further used for: Constructing a fine-tuning dataset, wherein the fine-tuning dataset includes a plurality of core entities and entities matched by the core entities in the knowledge graph; The pre-trained BERT model is fine-tuned based on the fine-tuning dataset to obtain the trained language model.

[0085] Optionally, the knowledge retrieval module 603 is specifically used for: Based on the depth-first search algorithm, knowledge retrieval is performed on the target entity in the knowledge graph, and the pruning function is used for optimization during the search process to obtain the target triple.

[0086] Optionally, the depth-first search algorithm is used to perform knowledge retrieval on the target entity in the knowledge graph, and a pruning function is used for optimization during the search process to obtain a target triple, including: Taking the target entity as the currently processed entity, performing a search operation on the currently processed entity to obtain the target triple; In the case where the tail entity is obtained by performing the search operation, the search operation is performed using the tail entity as the entity currently being processed to obtain the target triple; Among them, the search operation includes: retrieving a relationship set associated with the currently processed entity from the knowledge graph, and calling a pruning function to filter the relationship set to obtain a target relationship, and obtaining a tail entity associated with the currently processed entity through the target relationship. The currently processed entity, the target relationship and the tail entity constitute the target triplet.

[0087] Optionally, the conversion module 604 is specifically configured to: Pre-building a natural language template, where the natural language template is used to convert the triples into natural language sentences; The target triplet is converted into input information in text form based on the natural language template.

[0088] Optionally, the answer generation module 605 is specifically used for: The input information and the question information are combined to obtain combined information; The combined information and the symptom information are input into the second largest language model as context information for question-answering processing to obtain the target answer.

[0089] The Chinese medical question-and-answer device 600 based on the knowledge graph and the large language model provided in the embodiment of the present application can execute the above method embodiment, and its implementation principle and technical effects are similar, which will not be repeated in this embodiment.

[0090] It should be noted that the division of units in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional unit in each embodiment of the present application may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0091] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a processor-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.

[0092] like Figure 7 As shown, an embodiment of the present application provides an electronic device 700, including: a memory 702, a processor 701, and a program stored in the memory 702 and executable on the processor 701; the processor 701 is used to read the program in the memory 702 to implement the steps in the Chinese medical question-and-answer method based on the knowledge graph and the large language model as described above.

[0093] The embodiment of the present application also provides a readable storage medium, on which a program is stored. When the program is executed by a processor, the various processes of the above-mentioned Chinese medical question-and-answer method embodiment based on the knowledge graph and the large language model are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here. Among them, the readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disk, hard disk, magnetic tape, magneto-optical disk (MO), etc.), optical storage (such as compact disk (CD), digital video disk (DVD), Blu-ray Disc (BD), high-definition versatile disc (HVD), etc.), and semiconductor memory (such as read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read only memory (EEPROM), non-volatile memory (NAND FLASH), solid-state drive (Solid State Disk or Solid State Drive, SSD)), etc.

[0094] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0095] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD), and includes a number of instructions for a terminal (which can be a mobile phone, computer, server, air conditioner, or network equipment, etc.) to execute the methods described in each embodiment of the present application.

[0096] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A Chinese medical question-answering method based on knowledge graph and large language model, characterized in that: include: Input the initial question data into the first language model for parsing and processing to obtain symptom information, symptom core entities and question information; Match the symptom core entity with an entity in a pre-constructed knowledge graph to obtain a target entity, where the target entity is an entity in the knowledge graph whose semantic matching degree with the symptom core entity is greater than a threshold; Based on the target entity, relevant knowledge is retrieved in the knowledge graph to obtain a target triple; Convert the target triple into textual input information; The input information, the symptom information and the question information are input into the second largest language model for question-answering processing to obtain a target answer.

2. The method according to claim 1, characterized in that: The symptom core entity is matched with an entity in a pre-built knowledge graph to obtain a target entity, including: The symptom core entity is input into a trained language model for entity matching to obtain a target entity, and the language model is constructed based on BERT.

3. The method according to claim 2, characterized in that: Before inputting the symptom core entity into the trained language model for entity matching processing to obtain the target entity, the method further includes: Constructing a fine-tuning dataset, wherein the fine-tuning dataset includes a plurality of core entities and entities matched by the core entities in the knowledge graph; The pre-trained BERT model is fine-tuned based on the fine-tuning dataset to obtain the trained language model.

4. The method according to claim 1, characterized in that: The performing relevant knowledge retrieval in the knowledge graph based on the target entity to obtain the target triple includes: Based on the depth-first search algorithm, knowledge retrieval is performed on the target entity in the knowledge graph, and the pruning function is used for optimization during the search process to obtain the target triple.

5. The method according to claim 4, characterized in that: The method of performing knowledge retrieval on the target entity in the knowledge graph based on the depth-first search algorithm and optimizing the search process using the pruning function to obtain the target triples includes: Taking the target entity as the currently processed entity, performing a search operation on the currently processed entity to obtain the target triple; In the case where the tail entity is obtained by performing the search operation, the search operation is performed using the tail entity as the entity currently being processed to obtain the target triple; Among them, the search operation includes: retrieving a relationship set associated with the currently processed entity from the knowledge graph, and calling a pruning function to filter the relationship set to obtain a target relationship, and obtaining a tail entity associated with the currently processed entity through the target relationship. The currently processed entity, the target relationship and the tail entity constitute the target triplet.

6. The method according to claim 1, characterized in that: The step of converting the target triple into textual input information includes: Pre-building a natural language template, where the natural language template is used to convert the triples into natural language sentences; The target triplet is converted into input information in text form based on the natural language template.

7. The method according to claim 1, characterized in that: The step of inputting the input information, the symptom information and the question information into the second language model for question-answering processing to obtain a target answer includes: The input information and the question information are combined to obtain combined information; The combined information and the symptom information are input into the second language model as context information for question-answering processing to obtain the target answer.

8. A Chinese medical question-answering device based on knowledge graph and large language model, characterized in that: include: A data processing module, used for inputting the initial question data into the first language model for parsing and processing to obtain symptom information, symptom core entities and question information; A matching core entity module, used to match the symptom core entity with an entity in a pre-constructed knowledge graph to obtain a target entity, wherein the target entity is an entity in the knowledge graph whose semantic matching degree with the symptom core entity is greater than a threshold; A knowledge retrieval module, used to retrieve relevant knowledge in the knowledge graph based on the target entity to obtain a target triple; A conversion module, used for converting the target triple into input information in text form; The answer generation module is used to input the input information, the symptom information and the question information into the second largest language model for question-answering processing to obtain a target answer.

9. An electronic device, comprising: A memory, a processor, and a program stored in the memory and executable on the processor; wherein the processor is used to read the program in the memory to implement the steps in the Chinese medical question-and-answer method based on a knowledge graph and a large language model as described in any one of claims 1 to 7.

10. A readable storage medium for storing a program, characterized in that: When the program is executed by the processor, the steps in the Chinese medical question-answering method based on knowledge graph and large language model are implemented as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Knowledge question-answering method and device based on domain knowledge graph, and electronic equipment

    CN117076688A

  • Data knowledge dual-drive intelligent medical dialogue system and method based on knowledge graph

    CN117077786A

  • Large language model enhanced question and answer generation method

    CN118013051A