Medical question and answer method and system based on knowledge graph and intelligent agent

By employing a medical question-answering method based on knowledge graphs and intelligent agents, combined with associative reasoning and neighbor path exploration, the problem of poor accuracy in drug recommendation in existing technologies is solved, thereby improving the accuracy of disease diagnosis and drug recommendation and reducing the hallucination risk of LLM models.

CN121122680AActive Publication Date: 2025-12-12QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES)

Patent Information

Application Number
CN202511675908.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-17
Publication Date
2025-12-12
Estimated Expiration
2045-11-17

AI Technical Summary

Technical Problem

Existing knowledge graph-based medical question answering methods neglect the path relationships within the knowledge graph, resulting in poor accuracy in drug recommendations.

Method used

A medical question-answering method based on knowledge graphs and intelligent agents is adopted. Through keyword extraction, entity retrieval, vectorization representation, entity matching and ranking, the method explores the path of association reasoning and the path of neighbor. The method uses an LLM model for natural language conversion and diagnostic reasoning, and outputs the diagnostic results.

Benefits of technology

It improves the accuracy of the disease diagnosis chain and the reliability of drug recommendations, reduces the hallucination risk of LLM models through a dual guarantee mechanism, enhances the quality and rationality of generated text, and significantly improves the GPT-4 Ranking index.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121122680A_ABST
    Figure CN121122680A_ABST
Patent Text Reader

Abstract

The invention discloses a medical question and answer method and system based on a knowledge graph and an intelligent agent, and relates to the technical field of natural language processing. The method comprises the following steps: firstly, identifying a core entity related to patient description information from a medical knowledge graph, and obtaining an optimized entity set; performing association reasoning path and neighbor path exploration on entities in the optimized entity set to obtain an association reasoning path set and a second-order neighbor reasoning path set; then, paths in the associated reasoning path set and the second-order neighbor reasoning path set are converted into natural language description information based on prompt words of natural language conversion, and the natural language description information forms a knowledge text set; and finally, performing diagnosis reasoning on the patient description information and the information in the knowledge text set according to reasoning prompts, and outputting a diagnosis result. The method has remarkable advantages in the aspects of fact accuracy, disease diagnosis accuracy and drug recommendation accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of natural language processing technology, specifically relating to a medical question-answering method and system based on knowledge graphs and intelligent agents. Background Technology

[0002] Existing medical question answering methods include knowledge graph-based methods. These methods typically use knowledge graphs to help large language models (LLMs) understand the logical relationships between diseases, symptoms, and drugs. While these methods have achieved some success in improving the knowledge support for medical question answering, they often directly convert the structured information of the knowledge graph into text input models, neglecting the path relationships within the knowledge graph. This leads to insufficient knowledge utilization and consequently, poor drug recommendation accuracy. Therefore, this application proposes a medical question answering method and system based on knowledge graphs and intelligent agents. Summary of the Invention

[0003] To address the shortcomings and deficiencies in the existing technologies, this application proposes a medical question-answering method and system based on knowledge graphs and intelligent agents.

[0004] To achieve the above-mentioned objectives, the present invention adopts the following technical solution: A medical question-answering method based on knowledge graphs and intelligent agents includes the following steps: S1. Sequentially perform keyword extraction, entity retrieval, vectorization representation acquisition, entity matching, entity filtering, and sorting to identify core entities related to patient description information from the medical knowledge graph and obtain an optimized entity set; S2. Explore the association reasoning path and the neighbor path for the entities in the optimized entity set to obtain the association reasoning path set and the second-order neighbor reasoning path set. S3. Write natural language conversion prompts for the second LLM model. Use the natural language conversion prompts of the second LLM model to convert the paths in the set of related reasoning paths and the set of second-order neighbor reasoning paths into natural language description information. The natural language description information constitutes a knowledge text set. S4. Write inference prompts for the third LLM model. The third LLM model performs diagnostic inference based on the patient description information and the information in the knowledge text set, and outputs the diagnostic results.

[0005] Preferably, step S1 specifically includes the following steps: S1-1. Use the first LLM model to extract medical-related keywords from patient description information and obtain a keyword set. S1-2. Use Cypher query language to call the Neo4j database, perform entity retrieval based on medical knowledge graph, and obtain candidate entity set; S1-3: Map the entities in the candidate entity set to the keywords in the keyword set, and then use the pre-trained Word2Vec model to convert them into vector representations. S1-4. Perform entity matching based on keyword vector representation and entity vector representation to obtain a set of semantically similar entities; S1-5. The first agent filters and sorts entities in the semantically similar entity set based on the patient description information and the first agent prompt.

[0006] Preferably, in steps S1-3, the pre-trained Word2Vec model is obtained by pre-training the Word2Vec model.

[0007] Preferably, in step S2, the entities in the optimized entity set are explored for related reasoning paths, including the exploration of continuous related reasoning paths and the exploration of non-continuous related reasoning paths.

[0008] Preferably, the continuous association reasoning path exploration for entities in the optimized entity set specifically includes the following steps: 1) Starting with the first entity in the optimized entity set, update the optimized entity set to obtain set one. The only difference between set one and the optimized entity set is that set one lacks the first entity in the optimized entity set. Use the Cypher query language to call the Neo4j database and retrieve all entities connected to the first entity from the medical knowledge graph. When the second entity in the optimized entity set is included among all entities connected to the first entity retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between the first and second entities in the optimized entity set. 2) Using the second entity in the optimized entity set as the new starting entity, and updating set one, we obtain set two. The only difference between set two and the optimized entity set is that set two lacks the first and second entities in the optimized entity set. Using the Cypher query language to call the Neo4j database, we retrieve all entities connected to the second entity from the medical knowledge graph. When the third entity in the optimized entity set is included among all entities connected to the second entity retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between the second and third entities in the optimized entity set. At this time, there is a continuous association reasoning path between the first, second, and third entities in the optimized entity set. 3) Using the third entity in the optimized entity set as the new starting entity, update set two to obtain set three. The only difference between set three and the optimized entity set is that set three lacks the first, second, and third entities from the optimized entity set. Using the Cypher query language to call the Neo4j database, retrieve all entities connected to the third entity from the medical knowledge graph. When the fourth entity from the optimized entity set is included among all entities connected to the third entity retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between the third and fourth entities in the optimized entity set. At this time, there is a continuous association reasoning path between the first, second, third, and fourth entities in the optimized entity set. 4) Using the fourth entity as the new starting entity, update set three to obtain set four, which is an empty set. At this point, the process of exploring the associated reasoning path ends, and the continuous associated reasoning path between the first, second, third, and fourth entities in the optimized entity set is saved.

[0009] Preferably, the exploration of non-continuous association reasoning paths for entities in the optimized entity set specifically includes the following steps: a) Starting with the first entity in the optimized entity set, update the optimized entity set to obtain set five. The only difference between set five and the optimized entity set is that set five lacks the first entity from the optimized entity set. Use the Cypher query language to call the Neo4j database and retrieve all entities connected to the first entity from the medical knowledge graph. When the second entity from the optimized entity set is included among all entities connected to the first entity retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between the first entity and the second entity. b) Using the second entity in the optimized entity set as the new starting entity, and updating set five, we obtain set six. The only difference between set six and the optimized entity set is that set six lacks the first and second entities in the optimized entity set. Using the Cypher query language, we call the Neo4j database to retrieve all entities connected to the second entity from the medical knowledge graph. When the third entity in the optimized entity set is not included among all entities connected to the second entity retrieved from the medical knowledge graph, it indicates that there is no association reasoning path between the second and third entities in the optimized entity set. Since there is an association reasoning path between the first and second entities, we save the association reasoning path between the first and second entities in the optimized entity set. c) Using the third entity in the optimized entity set as the new starting entity, update set six to obtain set seven. The only difference between set seven and the optimized entity set is that set seven lacks the first, second, and third entities in the optimized entity set. Using the Cypher query language to call the Neo4j database, retrieve all entities connected to the third entity from the medical knowledge graph. When the fourth entity in the optimized entity set is included among all entities connected to the third entity retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between the third and fourth entities in the optimized entity set. d) Using the fourth entity as the new starting entity, update set seven to obtain set eight, which is an empty set. At this point, the process of exploring the associated reasoning path ends, and the associated reasoning path between the third and fourth entities in the optimized entity set is saved.

[0010] Preferably, neighbor path exploration is performed on the entities in the optimized entity set, including first-order neighbor path exploration and second-order neighbor path expansion for the entities in the optimized entity set in sequence.

[0011] Preferably, the first-order neighbor path exploration specifically includes the following steps: sequentially performing first-order neighbor path exploration on entities in the optimized entity set based on primary neighbor relationship comparison and filtering and semantic relevance filtering to obtain a first-order neighbor path set.

[0012] Preferably, the second-order neighbor path expansion specifically includes the following steps: expanding the first-order neighbor path set with second-order neighbors to obtain a second-order neighbor path set; optimizing the paths connecting entities in the entity set, first-order neighbor entities in the first-order neighbor path set, and second-order neighbor entities in the second-order neighbor entity set to form second-order neighbor paths, and these second-order neighbor paths constitute the second-order neighbor path set; using a second agent to verify and sort the second-order neighbor paths in the second-order neighbor path set to obtain a second-order neighbor inference path set.

[0013] A medical question-answering system based on knowledge graphs and intelligent agents, the system being used to implement a medical question-answering method based on knowledge graphs and intelligent agents, the system comprising: The entity extraction module is used for keyword extraction, entity retrieval, obtaining vectorized representations, entity matching, and entity filtering and sorting to identify core entities related to patient description information from the medical knowledge graph and obtain an optimized entity set. The knowledge reasoning path exploration module is used to explore the associated reasoning path and the neighbor path respectively for the entities in the optimized entity set output by the entity extraction module, and obtain the associated reasoning path set and the second-order neighbor reasoning path set. The knowledge conversion module is used to associate the set of reasoning paths P with prompts based on natural language conversion. A and the set of second-order neighbor inference paths P final The paths in the text are converted into natural language description information, and the natural language description information constitutes a knowledge text set. The reasoning module is used to perform diagnostic reasoning based on the patient description information and information in the knowledge text set, and output the diagnostic results.

[0014] Compared with the prior art, the beneficial technical effects of this application are as follows: In this application, the entity-level screening by the first intelligent agent and the path-level medical verification by the second intelligent agent together constitute a dual guarantee mechanism, greatly reducing the illusion risk of the LLM model. The set of related reasoning paths obtained in this application effectively improves the accuracy of the diagnostic chain from symptoms to diseases, while the set of second-order neighbor reasoning paths obtained after clinical value verification provides a reliable basis for drug recommendation. This is then converted into natural language description information through a knowledge conversion module, jointly contributing to the synergistic improvement of the generated text in three major indicators: factual accuracy, disease diagnosis accuracy, and drug recommendation accuracy. Furthermore, testing shows that the method described in this application achieves a significant improvement on the GPT-4 Ranking index, mainly due to the following: First, the first intelligent agent filters redundant entities and sorts them according to clinical value through a dual dimension of "clinical relevance + clinical usability," outputting an optimized entity set to reduce noise from the source; Second, through continuous and non-continuous related reasoning path exploration, multi-hop relationships between entities are effectively mined, and the second intelligent agent, based on the second intelligent agent prompts, department labels D, and patient description information, optimizes the second-order neighbor path set. The second agent verifies and sorts the second-order neighbor paths. It retains only the second-order neighbor paths that conform to the clinical value verification rules in the second agent's prompts, and sorts them according to the sorting prompts in the second agent's prompts to obtain a set of second-order neighbor inference paths, effectively ensuring the medical compliance of the inference logic. Thirdly, the second LLM model uses natural language processing prompts to associate the inference path set P. A and the set of second-order neighbor inference paths P final The path in the process is converted into natural language description information, which constitutes a knowledge text set. The third LLM model performs diagnostic reasoning based on the patient description information and the information in the knowledge text set, so that the third LLM model can effectively take into account both external medical knowledge (i.e., text information in the knowledge text set) and the internal knowledge of the third LLM model itself, ultimately improving the quality and rationality of the generated text, resulting in a significant improvement in the GPT-4 Ranking index. Attached Figure Description

[0015] Figure 1 This is a schematic diagram of the medical question-answering system based on knowledge graphs and intelligent agents in this application; Figure 2 This is a structural diagram of the related reasoning path exploration submodule in this application; Figure 3 This is a structural diagram of the neighbor path exploration submodule in this application. Detailed Implementation

[0016] The present invention will be further described below with reference to the accompanying drawings and examples; This invention provides a medical question-answering system based on knowledge graphs and intelligent agents, such as... Figure 1 As shown, it includes an entity extraction module, a knowledge reasoning path exploration module, a knowledge transformation module, and a reasoning module; the method for medical question answering based on knowledge graphs and intelligent agents includes the following steps: S1. The entity extraction module includes the first LLM model and a pre-trained Word2Vec model. The input to the entity extraction module is patient description information and a medical knowledge graph. The module is used for keyword extraction, entity retrieval, obtaining vectorized representations, entity matching, and entity filtering and ranking to identify core entities related to patient description information from the medical knowledge graph and obtain an optimized entity set. This includes the following steps: S1-1. Utilize the first LLM model to extract medically relevant keywords from patient descriptions, obtaining a keyword set. Specifically, the first LLM model receives patient descriptions, which are typically expressed in everyday consultation language, such as "My vision has been blurry lately, accompanied by dizziness and nausea." The first LLM model extracts keywords from the patient descriptions based on pre-written prompts, extracting medically relevant keywords k1, k2, ..., k. n Keywords k1, k2, ..., k n The keyword set K = {k1, k2, ..., k} is composed of... n In this embodiment, the pre-written prompts for the first LLM model include role-setting prompts and task prompts; wherein, the role-setting prompt is: You are a medical assistant; the task prompt is: Extract medical-related keywords from the following medical questions.

[0017] In this embodiment, medically related keywords are extracted from patient description information, including but not limited to disease names, symptom descriptions, medication usage, and diagnostic testing plans. The first LLM model used in this application has the same structure as the GPT-3.5 model disclosed in the paper "How Robust is GPT-3.5 to Predecessors? A Comprehensive Study on Language Understanding Tasks," but their functions are different; the first LLM model in this application is used to extract keywords.

[0018] S1-2. The Neo4j database is accessed using the Cypher query language to perform entity retrieval based on the medical knowledge graph, obtaining a candidate entity set. In this embodiment, the Neo4j database is accessed using the Cypher query language to retrieve all entities e1, e2, ..., e from the medical knowledge graph. n Where entities e1, e2, ..., e n Constitute a candidate entity set ; S1-3: Map the entities in the candidate entity set to the keywords in the keyword set, and then use a pre-trained Word2Vec model to convert them into vector representations; specifically: First, the entities in the candidate entity set and the keywords in the keyword set are mapped to the same semantic space, resulting in mapped keywords and mapped entities, respectively. Then, the mapped keywords and mapped entities are transformed into vector representations using a pre-trained Word2Vec model, resulting in corresponding keyword vector representations and entity vector representations, respectively. In this application, transforming the mapped keywords and mapped entities into vector representations can more effectively capture the potential semantic connections and contextual information between medical terms, thereby effectively improving the accuracy of subsequent calculations of the cosine similarity between keyword vector representations and entity vector representations. The Word2Vec model used in this application has the same structure and function as the Word2Vec model disclosed in "Efficient Estimation of WordRepresentations in Vector Space". The pre-trained Word2Vec model in this application is obtained by pre-training the Word2Vec model, specifically including the following steps: 1) Obtaining medical training data: 1-1) Select the top 99 diseases and their corresponding symptoms, medical examinations, and drug information from the disease database. Then, format the data according to the order of disease, symptoms, medical examinations, and drug information to obtain the formatted data. The disease database used in this application can be obtained from the URL: https: / / github.com / Kent0n-Li / ChatDoctor / blob / main / format_dataset.csv. Taking one disease and its corresponding symptoms, medical examinations, and medication information as an example, its formatted form is as follows: Panic disorder,"['Anxiety and nervousness', 'Depression', 'Shortnessof breath', 'Depressive or psychotic symptoms', 'Sharp chest pain', 'Dizziness', 'Insomnia', 'Abnormal involuntary movements', 'Chest tightness','Palpitations', 'Irregular heartbeat', 'Breathing fast']","['Psychotherapy','Mental health counseling', 'Electrocardiogram', 'Depression screen(Depression screening)', 'Toxicology screen', 'Psychological and psychiatric evaluation and therapy']","['Lorazepam', 'Alprazolam (Xanax)', 'Clonazepam','Paroxetine (Paxil)', 'Venlafaxine (Effexor)', 'Mirtazapine', 'Buspirone(Buspar)', 'Fluvoxamine (Luvox)', 'Imipramine', 'Desvenlafaxine (Pristiq)', 'Clomipramine', 'Acamprosate (Campral)']"; 1-2) The formatted data is converted into natural language descriptive text using the GPT-3.5 model, which serves as the document text; the GPT-3.5 model used in this application has the same structure as the GPT-3.5 model disclosed in the paper "How Robust is GPT-3.5 to Predecessors? A Comprehensive Study on Language Understanding Tasks"; 1-3) Extract question text from the first 99 dialogues in the GenMedGPT-5k dataset; these 99 extracted question texts involve 99 diseases, which correspond one-to-one with the first 99 diseases selected in the disease database; in this application, the GenMedGPT-5k dataset is a medical domain dataset consisting of 5000 doctor-patient dialogues; the GenMedGPT-5k dataset can be obtained from https: / / github.com / Kent0n-Li / ChatDocto; 1-4) Merge the document texts and question texts for the same disease to obtain the merged training data, which is the medical training data. 2) The Word2Vec model is pre-trained using medical training data to obtain a pre-trained Word2Vec model. The difference between the method of pre-training the Word2Vec model in this application and the method of training the Word2Vec model disclosed in the paper "MindMap: Knowledge Graph Prompting Sparks Graph of Thoughts in Large Language Models" is only that the input for pre-training the Word2Vec model in this application is the medical training data obtained in step 1).

[0019] S1-4. Perform entity matching based on keyword vector representation and entity vector representation to obtain a set of semantically similar entities. This includes the following steps: First, calculate the keyword vector representation. and entity vector representation The cosine similarity is used to measure the keyword vector representation. With entity vector representation The semantic relevance between them is determined; then, the cosine similarity value is compared with a preset similarity threshold. The comparison is performed when the cosine similarity value is greater than or equal to a preset similarity threshold. If the entity matches the corresponding keyword, it is considered to be retained; otherwise, it is discarded. All retained entities and their corresponding keywords together constitute a semantically similar entity set. The above steps achieve the purpose of matching keywords with entities based on keyword vector representation and entity vector representation, effectively filtering out entities that match the keywords.

[0020] Among them, keyword vector representation With entity vector representation cosine similarity The calculation method is shown in equation (1): (1) In equation (1), This indicates the calculation of the dot product. Keyword vector representation The length of the mold, Entity vector representation The length of the mold, Keyword vector representation Magnitude and entity vector representation The product of moduli; Keyword vector representation With entity vector representation cosine similarity This represents the keyword vector representation in the vector space. With entity vector representation The cosine of the angle between them, cosine similarity The value range is [-1, 1]; the closer the cosine similarity value is to 1, the stronger the keyword vector representation in the vector space. With entity vector representation The closer the directions are to each other, the more semantically similar the keywords and entities are; the closer the cosine similarity value is to 0, the better the keyword vector representation in the vector space. With entity vector representation The closer the direction is to vertical, the weaker the semantic connection between the keyword and the entity; the closer the cosine similarity value is to -1, the weaker the keyword vector representation in the vector space. With entity vector representation The closer the direction is to the opposite, the more semantically opposed or unrelated the keywords are to the entity.

[0021] S1-5, the entity filtering and ranking submodule takes the semantically similar entity set and patient description information as input. The first agent in the entity filtering and ranking submodule filters and ranks the entities in the semantically similar entity set based on the patient description information and the first agent's prompts, obtaining an optimized entity set. In this application, the setting of step S1-5 can effectively improve the accuracy and efficiency of the reasoning process. Step S1-5 specifically includes the following steps: S1-5-1, Entity screening, specifically including the following steps: writing prompts for the first agent, which include filtering rules and sorting rules; then, the first agent, according to the filtering rules set in the prompts, screens the clinical relevance and clinical usability between the patient description information and entities in the semantically similar entity set, and obtains entities with high clinical relevance and clinical usability. The filtering rules include: (1) Retain clinically relevant entities and delete entities that are not clinically relevant; where clinically relevant entities refer to entities in the patient description information that are medically related to the condition. Entities that are medically related to the condition include at least disease-related entities, symptom-related entities, and treatment-related entities, and these shall be retained. In this embodiment, entities that are medically related to the condition include disease-related entities (such as "hypertension" and "retinopathy" entities), symptom-related entities (such as "weight loss" and "elevated blood sugar" entities), treatment-related entities (such as "metformin" and "fundus examination" entities), and location-related entities (such as "fundus" and "retina" entities). These disease-related entities, symptom-related entities, treatment-related entities, and location-related entities are retained. Entities without clinical relevance refer to entities in the patient description information that have no medical connection to the condition; in this embodiment, entities without medical connection to the condition (such as the "shortness of breath" entity and the "seasonal allergy" entity) are removed.

[0022] (2) Select clinically useful entities from the retained clinically relevant entities and delete entities that are not clinically useful; among them, clinically useful entities refer to entities that can provide reference value for diagnosis or treatment, including disease-related entities, symptom-related entities, and treatment-related entities; wherein: Disease-related entities include disease entities, symptom entities, and syndrome entities, such as "hypertension" and "retinopathy" entities; Symptom-related entities refer to symptoms or signs mentioned in the patient's description that are related to their health condition; for example, "weight loss" or "elevated blood sugar". Treatment-related entities include drug entities and medical procedure entities; for example, the "metformin" entity and the "fundus examination" entity; S1-5-2. Entity Sorting: The first agent sorts the selected entities with high clinical relevance and clinical usability according to the sorting rules in the prompt, resulting in an optimized entity set; the sorting rules are as follows: (1) Prioritize disease-related entities as the first priority; (2) Prioritize symptom-related entities as secondary priority; (3) Prioritize treatment-related entities as Level 3.

[0023] S2. The knowledge reasoning path exploration module explores the association reasoning path and the neighbor path respectively for the entities in the optimized entity set output by the entity extraction module, and obtains the association reasoning path set and the second-order neighbor reasoning path set; specifically, it includes the following steps: S2-1, the association reasoning path exploration submodule utilizes the existing structured relationships in the medical knowledge graph to explore association reasoning paths for entities in the optimized entity set, resulting in an optimized set of association reasoning paths; among which, the association reasoning path exploration for entities in the optimized entity set includes exploring continuous association reasoning paths and non-continuous association reasoning paths. S2-1-1, the submodule for exploring associative reasoning paths utilizes existing structured relationships in the medical knowledge graph to explore continuous associative reasoning paths for entities in the optimized entity set. Specifically, it includes the following: 1) Starting with the first entity in the optimized entity set, update the optimized entity set to obtain set one. The only difference between set one and the optimized entity set is that set one lacks the first entity in the optimized entity set. Use the Cypher query language to call the Neo4j database and retrieve all entities connected to the first entity from the medical knowledge graph. When the second entity in the optimized entity set is included among all entities connected to the first entity retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between the first and second entities in the optimized entity set. 2) Using the second entity in the optimized entity set as the new starting entity, and updating set one, we obtain set two. The only difference between set two and the optimized entity set is that set two lacks the first and second entities in the optimized entity set. Using the Cypher query language to call the Neo4j database, we retrieve all entities connected to the second entity from the medical knowledge graph. When the third entity in the optimized entity set is included among all entities connected to the second entity retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between the second and third entities in the optimized entity set. At this time, there is a continuous association reasoning path between the first, second, and third entities in the optimized entity set. 3) Using the third entity in the optimized entity set as the new starting entity, update set two to obtain set three. The only difference between set three and the optimized entity set is that set three lacks the first, second, and third entities from the optimized entity set. Using the Cypher query language to call the Neo4j database, retrieve all entities connected to the third entity from the medical knowledge graph. When the fourth entity from the optimized entity set is included among all entities connected to the third entity retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between the third and fourth entities in the optimized entity set. At this time, there is a continuous association reasoning path between the first, second, third, and fourth entities in the optimized entity set. 4) Using the fourth entity as the new starting entity, update set three to obtain set four, which is an empty set. At this point, the process of exploring the associated reasoning path ends, and the continuous associated reasoning path between the first, second, third, and fourth entities in the optimized entity set is saved. Taking the optimized entity set {v1, v2, v3, v4} as an example, where v1, v2, v3, and v4 all represent entities, the continuous association reasoning path is explored for the entities in the optimized entity set, such as... Figure 2 As shown, the specific steps include: 1) Starting with entity v1 in the optimized entity set {v1,v2,v3,v4}, update the optimized entity set to obtain set one {v2,v3,v4}; use the Cypher query language to call the Neo4j database and retrieve all entities connected to entity v1 from the medical knowledge graph; when entity v2 from the optimized entity set is included among all entities connected to v1 retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between entity v1 and entity v2. 2) Using entity v2 as the new starting entity, update set one to obtain set two {v3, v4}; use Cypher query language to call the Neo4j database to retrieve all entities connected to entity v2 from the medical knowledge graph. When entity v3 in the optimized entity set is included among all entities connected to v2 retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between entity v2 and entity v3. As can be seen from step 1), there is an association reasoning path between entity v1 and entity v2. Therefore, there is a continuous association reasoning path between entities v1, v2, and v3. 3) Using entity v3 as the new starting entity, update set two to obtain set three {v4}; use the Cypher query language to call the Neo4j database and retrieve all entities connected to entity v3 from the medical knowledge graph. When entity v4 from the optimized entity set is included among all entities connected to entity v3 retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between entity v3 and entity v4. In addition, as can be seen from step 2), there is a continuous association reasoning path between entities v1, v2, and v3. Therefore, there is a continuous association reasoning path between entities v1, v2, v3, and v4. 4) Using entity v4 as the new starting entity, update set three to obtain set four, which is an empty set. At this point, the process of exploring the related reasoning path ends, and the continuous related reasoning paths between entities v1, v2, v3 and v4 are saved. S2-1-2, the submodule for exploring associative reasoning paths utilizes existing structured relationships in the medical knowledge graph to explore non-continuous associative reasoning paths for entities in the optimized entity set. Specifically, it includes the following: a) Starting with the first entity in the optimized entity set, update the optimized entity set to obtain set five. The only difference between set five and the optimized entity set is that set five lacks the first entity from the optimized entity set. Use the Cypher query language to call the Neo4j database and retrieve all entities connected to the first entity from the medical knowledge graph. When the second entity from the optimized entity set is included among all entities connected to the first entity retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between the first entity and the second entity. b) Using the second entity in the optimized entity set as the new starting entity, and updating set five, we obtain set six. The only difference between set six and the optimized entity set is that set six lacks the first and second entities in the optimized entity set. Using the Cypher query language, we call the Neo4j database to retrieve all entities connected to the second entity from the medical knowledge graph. When the third entity in the optimized entity set is not included among all entities connected to the second entity retrieved from the medical knowledge graph, it indicates that there is no association reasoning path between the second and third entities in the optimized entity set. Since there is an association reasoning path between the first and second entities, we save the association reasoning path between the first and second entities in the optimized entity set. c) Using the third entity in the optimized entity set as the new starting entity, update set six to obtain set seven. The only difference between set seven and the optimized entity set is that set seven lacks the first, second, and third entities in the optimized entity set. Using the Cypher query language to call the Neo4j database, retrieve all entities connected to the third entity from the medical knowledge graph. When the fourth entity in the optimized entity set is included among all entities connected to the third entity retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between the third and fourth entities in the optimized entity set. d) Using the fourth entity as the new starting entity, update set seven to obtain set eight, which is an empty set. At this point, the process of exploring the associated reasoning path ends, and the associated reasoning path between the third and fourth entities in the optimized entity set is saved.

[0024] Taking the optimized entity set {v1, v2, v3, v4} as an example, where v1, v2, v3, and v4 all represent entities, the exploration of non-continuous association reasoning paths is performed on the entities in the optimized entity set, such as... Figure 2 As shown, the specific steps include: a) Starting with entity v1 in the optimized entity set {v1,v2,v3,v4}, update the optimized entity set to obtain set five {v2,v3,v4}; use the Cypher query language to call the Neo4j database and retrieve all entities connected to entity v1 from the medical knowledge graph; when entity v2 from the optimized entity set is included among all entities connected to entity v1 retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between entity v1 and entity v2. b) Using entity v2 as the new starting entity, and updating set five to obtain set six {v3, v4}; using the Cypher query language to call the Neo4j database, retrieve all entities connected to entity v2 from the medical knowledge graph. When entity v3 in the optimized entity set is not included among all entities connected to entity v2 retrieved from the medical knowledge graph, it indicates that there is no association reasoning path between entity v2 and entity v3, but there is an association reasoning path between entity v1 and entity v2. At this time, the association reasoning path between entity v1 and entity v2 is saved. c) Using entity v3 as the new starting entity, update set six to obtain set seven {v4}; use the Cypher query language to call the Neo4j database and retrieve all entities connected to entity v3 from the medical knowledge graph. When entity v4 in the optimized entity set is included among all entities connected to entity v3 retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between entity v3 and entity v4. d) Using entity v4 as the new starting entity, update set seven to obtain set eight, which is an empty set. At this point, the process of exploring the related reasoning path ends, and the related reasoning path between entities v3 and v4 is saved. In this application, in step c), when the entity v4 in the optimized entity set is not included among all entities connected to entity v3 retrieved from the medical knowledge graph, it indicates that there is no associated reasoning path between entity v3 and entity v4. In this case, there is no associated reasoning path between entity v2, entity v3 and entity v4, only a continuous associated reasoning path between entity v1 and entity v2. Since the associated reasoning path between entity v1 and entity v2 has been saved in step b), the associated reasoning path exploration process can end when the entity v4 in the optimized entity set is not included among all entities connected to entity v3 retrieved from the medical knowledge graph in step c). All the related reasoning paths obtained in steps S2-1-1 and S2-1-2 of this application together constitute the related reasoning path set.

[0025] This application utilizes a joint exploration mechanism that combines continuous and non-continuous associative reasoning path exploration to automatically discover and save associative reasoning paths and corresponding entities in a knowledge graph, generating a set of associative reasoning paths. This mechanism provides high-quality path foundation support for subsequent knowledge reasoning.

[0026] S2-2, the Neighbor Reasoning Path Exploration submodule utilizes the existing structured relationships in the medical knowledge graph to explore neighbor paths for entities in the optimized entity set, obtaining a set of second-order neighbor reasoning paths; among them, exploring neighbor paths for entities in the optimized entity set includes sequentially exploring first-order neighbor paths and expanding second-order neighbor paths for entities in the optimized entity set. Taking the optimized entity set as {v1,v2,v3,v4} as an example, the working principle of the neighbor inference path exploration submodule is as follows: Figure 3 As shown, it includes the following steps: S2-2-1. Based on primary neighbor relationship comparison and semantic relevance filtering, first-order neighbor paths are explored for entities in the optimized entity set to obtain a set of first-order neighbor paths; specifically, the following steps are included: S2-2-1-1. Based on primary neighbor relationship comparison and filtering, first-order neighbor path exploration is performed on entities in the optimized entity set, specifically including the following steps: When entity v1 in the optimized entity set establishes connections with multiple first-order neighbor entities through multiple relations; for the case where entity v1 connects with multiple first-order neighbor entities through multiple identical relations, only the first-order neighbor path between entity v1 and the first-order neighbor entity located on the association inference path is retained; for the case where entity v1 connects with multiple first-order neighbor entities through other relations that do not have the same relation, the first-order neighbor path between entity v1 and the first-order neighbor entity connected by entity v1 through other relations is retained. Take entity v1 establishing connections with multiple first-order neighbor entities through relations r1, r2, r3, and r4 as an example; When an entity v1 in the optimized entity set establishes connections with multiple first-order neighbor entities through relations r1, r2, r3, and r4; for the case where entity v1 connects to multiple first-order neighbor entities through multiple identical relations r1, only the first-order neighbor paths between entity v1 and the first-order neighbor entities located on the association inference path are retained; at the same time, the first-order neighbor paths between entity v1 and the first-order neighbor entities connected by entity v1 through other relations are also retained; where other relations refer to relations different from relation r1, in this case, other relations refer to relations r2, r3, and r4; similarly, for the case where entity v1 connects to multiple first-order neighbor entities through multiple identical relations r2, r3, or r4, the method of retaining the first-order neighbor paths is the same as the method of retaining the first-order neighbor paths when entity v1 connects to multiple first-order neighbor entities through multiple identical relations r1. Similarly, the way to preserve first-order neighbor paths when other entities in the optimized entity set (i.e., entities v2, v3, v4) establish connections with multiple first-order neighbor entities through relations r1, r2, r3, r4 is the same as the way to preserve first-order neighbor paths when entity v1 in the optimized entity set establishes connections with multiple first-order neighbor entities through relations r1, r2, r3, r4. By setting step S2-2-1-1, this application can effectively reduce the redundancy of first-order neighbor entities caused by relationship conflicts, thereby improving the determinism and logical consistency of neighbor paths. S2-2-1-2. Based on semantic relevance filtering, filter the first-order neighbor paths retained in step S2-2-1-1 to obtain a set of first-order neighbor paths; specifically, this includes the following steps: The semantic similarity between patient description information Q and the first-order neighbor path p retained in step S2-2-1-1 is calculated using the BERT model. The first-order neighbor path refers to the path that starts from an entity in the optimized entity set and reaches its directly connected node along an edge (here, the edge refers to a relation). Then, first-order neighbor paths with semantic similarity not lower than a preset threshold are selected to form a first-order neighbor path set P. v The set is constructed as shown in equation (2): (2) In equation (2), p represents the first-order neighbor path retained in step S2-2-1-1, and Q represents the patient description information. This represents the semantic similarity calculated using the BERT model, where δ is a preset similarity threshold. In this embodiment, δ is set to 0.7. v It is the set of first-order neighbor paths; The BERT model used in this application has the same structure and function as the one disclosed in the paper "BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding"; the semantic similarity calculation method based on BERT in this application is the same as the calculation method disclosed in the paper "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks"; S2-2-2, For the set of first-order neighbor paths P v Perform second-order neighbor expansion to obtain the second-order neighbor path set. A path connecting entities in the entity set, first-order neighbor entities in the first-order neighbor path set, and second-order neighbor entities in the second-order neighbor entity set is called a second-order neighbor path. These second-order neighbor paths constitute the second-order neighbor path set. Using a second agent to analyze the set of second-order neighbor paths The second-order neighbor paths are verified and sorted to obtain a set of second-order neighbor inference paths. P final Specifically, it includes the following steps: 1) For the first-order neighbor path set P v Perform second-order neighbor expansion to obtain the second-order neighbor path set. Specifically, this includes the following steps: using the Cypher query language to call the Neo4j database, retrieving the set of first-order neighbor paths P from the medical knowledge graph. v The set of second-order neighbors consists of all entities that are directly connected to first-order neighbors along an edge (where the edge refers to a relation). 2) Since selecting first-order neighbor paths based on semantic similarity only selects those with semantic similarity not lower than a preset threshold at the semantic level, and cannot guarantee the medical rationality of the selected first-order neighbor paths in terms of medical knowledge, this application specifically introduces a second intelligent agent to further ensure the medical rationality of the second-order neighbor path set obtained by expanding the first-order neighbor paths. The second intelligent agent acts as a proxy doctor, and the second intelligent agent manages the second-order neighbor path set. The second-order neighbor paths in the data are verified and sorted, specifically including the following steps: 2-1) Department Label Recognition: Specifically, the GPT-4 model (with the same structure as the GPT-4 model disclosed in the paper "GPT-4 Technical Report") is used to perform semantic analysis on the patient description information to identify the department label D; for example, when the patient description information is "elevated blood sugar accompanied by blurred vision", the department label D is "endocrinology department". This department label D is used to set the medical department to which the second agent belongs. 2-2) Clinical Value Validation and Ranking: Specifically, a second agent prompt is written for the second agent. The second agent then uses the second agent prompt, the department label D, and the patient description information to evaluate the second-order neighbor path set. The second agent verifies and sorts the second-order neighbor paths. It retains only the second-order neighbor paths that conform to the clinical value verification rules in the second agent's prompts, and sorts them according to the sorting prompts in the second agent's prompts, thus obtaining a set of second-order neighbor inference paths. P final ; P finalThe method for obtaining is shown in equation (3): (3) In equation (3), P final Let represent the set of second-order neighbor inference paths, D represent the identified department label, and Q represent the patient description information. Let B represent the set of second-order neighbor paths, and let B represent the prompt from the second agent.

[0027] The second agent prompts developed in this application include clinical value verification rules and ranking prompts; In this application, the clinical value verification rules include diagnostic support rules and treatment plan support rules. Specifically, when verifying the clinical value of second-order neighbor paths in the second-order neighbor set, if a second-order neighbor path in the second-order neighbor set conforms to either the diagnostic support rule or the treatment plan support rule, then that second-order neighbor path is a second-order neighbor path that conforms to the clinical value verification rules and will be retained by the second intelligent agent. The diagnostic support rule is: only retain paths that can directly support disease diagnosis (such as symptoms-symptom-related diseases, diseases-related complications); for example, when the patient's description is "elevated blood sugar accompanied by blurred vision", the second-order neighbor path "elevated blood sugar → diabetes" is retained; The treatment plan support rules are: retain pathways that can prompt patients to take medication and pathways that can prompt patients to undergo examinations; for example, second-order neighbor pathways such as "diabetes → retinopathy → fundus examination", "elevated blood sugar → diabetes → nephropathy → dialysis required", "diabetes → insulin injection", and "diabetes → foot infection → wound treatment" are retained; The second agent sorts and outputs the retained second-order neighbor paths according to the sorting prompt in the prompt. These output second-order neighbor paths constitute the second-order neighbor inference path set. P final The output of these second-order neighbor paths can assist in diagnosis and decision-making; In this application, the ranking prompt is: based on the patient description information, evaluate the contribution of the same type of second-order neighbor path to diagnosis and decision-making, and the path with the higher contribution is ranked higher in the same type of second-order neighbor path; wherein, the type of second-order neighbor path includes medication type and examination type; For example, when the second agent sorts the examination type paths "diabetes → retinopathy → fundus examination", "hyperglycemia → diabetes → nephropathy → dialysis required", and "diabetes → foot infection → wound treatment" in the second-order neighbor paths according to the sorting prompts, it will determine that the examination type path "diabetes → retinopathy → fundus examination" has a higher contribution to diagnosis and decision-making based on the patient's description information (hyperglycemia + blurred vision), and will rank it higher. For example, when the second agent sorts the medication type paths "diabetes → elevated blood sugar → intensive insulin therapy" and "diabetes → foot infection → antibiotic treatment" in the second-order neighbor paths according to the sorting prompts, it will determine that the medication type path "diabetes → elevated blood sugar → intensive insulin therapy" contributes more to the diagnosis and decision-making based on the patient description information (elevated blood sugar), and will be ranked higher.

[0028] S3, Knowledge Conversion Module, such as Figure 1 As shown, the set of related reasoning paths P output by the knowledge reasoning path exploration module is... A and the set of second-order neighbor inference paths P final As input, the set of related reasoning paths P A and the set of second-order neighbor inference paths P final The paths depict medical entities and their relationships. In this application, the set of association reasoning paths P A and the set of second-order neighbor inference paths P final The paths are all structured, for example, diabetes → retinopathy → fundus examination; the knowledge conversion module of this application includes a second LLM model; this application first writes natural language conversion prompts for the second LLM model, and then uses the second LLM model based on the natural language conversion prompts to connect the set of related reasoning paths P A and the set of second-order neighbor inference paths P final The paths in the text are converted into natural language description information, and the natural language description information constitutes a knowledge text set. In this application, the specific prompts for natural language conversion written for the second LLM model are as follows: Task: Here are some reasoning paths that follow the format "entity → relation → entity". For each reasoning path, please convert it into a description that conforms to natural language usage. The expression should be coherent and fluent, avoiding literal translation. Refer to the following example format: Reasoning path: Diabetes mellitus → Retinopathy → Fundus examination; Natural Language: Having "diabetes" may cause "retinopathy," requiring a "fundus examination" to rule out related problems.

[0029] S4. Reasoning Module; In this application, the reasoning module includes a third LLM model; This application provides reasoning prompts for the third LLM model, which performs diagnostic reasoning on patient description information and text information in the knowledge text set based on the reasoning prompts, and outputs diagnostic results; wherein, the text information in the knowledge text set serves as external medical knowledge; The inference hints written for the third LLM model in this application are as follows: Task: Designate an LLM model as an "AI doctor" that uses patient description information, knowledge text sets as an external medical knowledge base, and internal knowledge of the LLM model for reasoning. Patient input: {Patient description information}; External medical knowledge: {a collection of knowledge texts}; Output: The LLM model is required to output diagnostic results using a stepwise reasoning approach, and the diagnostic results must cover at least the following three items: 1. What disease might the patient have? 2. What tests are needed to confirm the diagnosis? 3. What medications or treatments are recommended for this disease? test: To verify the effectiveness of the medical question-answering method described in this application, this application tested six existing medical question-answering methods and the medical question-answering method described in this application based on test set 1 and test set 2 to obtain generated text. Then, the generated text was tested using the BERT model (accessible at https: / / github.com / google-research / bert) to obtain evaluation results for Precision, Recall, and F1 Score. The generated text was also tested using the GPT-4 model to obtain three evaluation indicators: GPT-4 Ranking, Total Factuality, Disease Diagnosis, and Drug Recommendation. The above evaluation results are shown in Tables 1 to 4. The evaluation metrics in Tables 1 and 2 include Precision, Recall, F1 Score, GPT-4 Ranking, Total factuality, Disease diagnosis, Drug recommendation, and Average. Precision measures the proportion of accurate and relevant words in the generated text; Recall measures whether the generated text covers important information in the reference text; F1 Score is the harmonic mean of Precision and Recall; GPT-4 Ranking is achieved by the GPT-4 model (the GPT-4 model in this application has the same structure and function as the GPT-4 model disclosed in the paper "GPT-4 Technical Report") ranking the generated texts obtained by different methods based on the reference text, assessing the quality and reasonableness of the generated text; Total factuality, Disease diagnosis, and Drug recommendation are the scores obtained by the GPT-4 model, respectively demonstrating the factual accuracy, disease diagnosis accuracy, and drug recommendation accuracy of the generated text obtained by different methods; Average refers to the total... The average values ​​of the three assessment indicators: factuality, disease diagnosis, and drug recommendation.

[0030] The six existing medical question-answering methods selected in this application include: MindMap (from "MindMap: Knowledge Graph Prompting Sparks Graph of Thoughts in Large Language Models"), GPT-3.5 (from "Evaluating open question answering evaluation"), GPT-4 (from "GPT4Graph: Can large language models understand graph structured data? an empirical evaluation and benchmarking"), BM25 Retriever (from "The probabilistic relevance framework: Bm25 and beyond"), Embedding Retriever (from "Ontology-based semantic retrieval of documents using word2vecmodel"), and KG Retriever (from "ERNIE 3.0: Large-scale knowledge enhanced pre-training for language understanding and generation").

[0031] In this application, the test set 1 is obtained by randomly selecting 477 dialogue data from the 100th and subsequent dialogue data in the GenMedGPT-5k dataset to form the test set 1. The second test set was obtained by randomly selecting 394 dialogue data from the 100th and subsequent dialogue data in the CMCQA dataset to form the second test set.

[0032] Before testing, this application constructs the EMCKG medical knowledge graph and the CMCKG medical knowledge graph respectively. The EMCKG medical knowledge graph is specifically used for the testing task of test set one, and the CMCKG medical knowledge graph is specifically used for the testing task of test set two. That is, when the method described in this application and the aforementioned six existing medical question-answering methods are tested based on test set one, they use the data in test set one and the EMCKG medical knowledge graph as input; when the method described in this application and the aforementioned six existing medical question-answering methods are tested based on test set two, they use the data in test set two and the CMCKG medical knowledge graph as input. The EMCKG medical knowledge graph was constructed by using the knowledge graph implementation method disclosed in the open-source website https: / / github.com / wylwilling / MindMap to build the EMCKG medical knowledge graph from scratch based on the data in the disease database. The CMCKG medical knowledge graph is constructed as follows: It utilizes the knowledge graph implementation method publicly available at the open-source website https: / / github.com / wylwilling / MindMap to construct a medical knowledge graph from medical data based on a knowledge graph question-answering system, thus obtaining the CMCKG medical knowledge graph. The URL for obtaining the medical data from the knowledge graph question-answering system is: https: / / github.com / liuhuanyong / QASystemOnMedicalKG / blob / master / data / medical.json.

[0033] Table 1. Evaluation results of Precision, Recall, F1 Score, and GPT-4 Ranking for each method in this application based on test set 1.

[0034] As can be seen from Table 1, when tested on test set 1, the MindMap method achieves better evaluation metrics compared to other existing medical question-answering methods. Therefore, this application focuses on comparing the evaluation metrics obtained by the MindMap method and the method described in this application, as follows: When tested on test set 1, compared with the MindMap method, the precision evaluation index of the method described in this application is improved by (0.7922-0.7596) / 0.7596=4.29%; Compared to the MindMap method, the Recall evaluation metric of the method described in this application is reduced by (0.7979-0.7977) / 0.7979=0.25%; Compared to the MindMap method, the F1 Score of the method described in this application is improved by (0.8115-0.7729) / 0.7729=4.99%; Compared to the MindMap method, the GPT-4 Ranking evaluation index of the method described in this application is improved by (2.88-2.09) / 2.09=27.43%; Clearly, when the method described in this application is tested on test set 1, the generated text obtained achieves improvements over the MindMap method in key evaluation metrics such as Precision, F1 Score, and GPT-4 Ranking. In particular, the improvement in the GPT-4 Ranking metric reaches 27.43%, which fully demonstrates that the generated text obtained by the method described in this application has better quality and reasonableness.

[0035] Table 2. Evaluation results of each method based on test set 2: Precision, Recall, F1 Score, and GPT-4 Ranking.

[0036] As shown in Table 2, when tested on test set 2, the MindMap method achieves better evaluation metrics compared to other existing medical question-answering methods. Therefore, this application focuses on comparing the evaluation metrics obtained by the MindMap method with those of the method described in this application, as follows: Compared to the MindMap method, the precision evaluation index of the method described in this application is improved by (0.9417-0.9392) / 0.9392=0.26%; Compared to the MindMap method, the Recall evaluation metric of the method described in this application is improved by (0.9316-0.9281) / 0.9281=0.37%; Compared to the MindMap method, the F1 Score of the method described in this application is improved by (0.9466-0.9335) / 0.9335=1.40%; Compared to the MindMap method, the GPT-4 Ranking evaluation index of the method described in this application is improved by (2.80-2.35) / 2.35=16.07%; Clearly, when the method described in this application is tested on test set 2, the generated text obtained achieves improvements over the MindMap method in key evaluation metrics such as Precision, Recall, F1 Score, and GPT-4 Ranking. In particular, the improvement in the GPT-4 Ranking metric reaches 16.07%, which fully demonstrates that the generated text obtained by the method described in this application has better quality and reasonableness.

[0037] As can be seen from Tables 1 and 2, regardless of whether the test is conducted on test set 1 or test set 2, the method described in this application achieves a significant improvement over the MindMap method in the GPT-4 Ranking metric. This is mainly due to the following factors: First, the first agent filters redundant entities and sorts them according to clinical value through a dual dimension of "clinical relevance + clinical usability," outputting an optimized entity set and reducing noise at the source. Second, by exploring continuous and non-continuous association reasoning paths, multi-hop relationships between entities are effectively mined. The second agent, based on the second agent prompt, department label D, and patient description information, analyzes the second-order neighbor path set. The second agent verifies and sorts the second-order neighbor paths. It retains only the second-order neighbor paths that conform to the clinical value verification rules in the second agent's prompts, and sorts them according to the sorting prompts in the second agent's prompts to obtain a set of second-order neighbor inference paths, effectively ensuring the medical compliance of the inference logic. Thirdly, the second LLM model uses natural language processing prompts to associate the inference path set P. A and the set of second-order neighbor inference paths P final The path in the process is converted into natural language description information, which constitutes a knowledge text set. The third LLM model performs diagnostic reasoning based on the patient description information and the information in the knowledge text set, so that the third LLM model can effectively take into account both external medical knowledge (i.e., text information in the knowledge text set) and the internal knowledge of the third LLM model itself, ultimately improving the quality and rationality of the generated text, resulting in a significant improvement in the GPT-4 Ranking index.

[0038] Table 3. Total factuality, disease diagnosis, drug recommendation, and average assessment results of the method described in this application compared to the MindMap method, GPT-3.5 method, and GPT-4 method based on test set 1.

[0039] Table 4. Total factuality, disease diagnosis, drug recommendation, and average assessment results of the method described in this application compared to the BM25 Retriever method, Embedding Retriever method, and KG Retriever method based on test set 1.

[0040] In Tables 3 and 4, Win represents the percentage by which the method described in this application outperforms existing medical question-answering methods, Tie represents the percentage by which the method described in this application is on par with existing medical question-answering methods, and Lose represents the percentage by which the method described in this application is inferior to existing medical question-answering methods. As can be seen from Tables 3 and 4, the MindMap method achieves better evaluation metrics compared to other existing medical question-answering methods. Therefore, this application focuses on comparing the evaluation metrics obtained by the MindMap method with those obtained by the method described in this application, as follows: As mentioned above, Average refers to the average of the four assessment indicators: Total factuality, Disease diagnosis, and Drug recommendation; therefore, it means: The data 55.28% in the rightmost of the second row of Table 3 represents the average percentage of the method described in this application that outperforms existing medical question-answering methods in terms of Total factuality, Disease diagnosis, and Drug recommendation. This application refers to this method as the average win rate. Similarly, the data 22.25% on the far right of the third row in Table 3 represents the average percentage of the method described in this application that is on par with existing medical question-answering methods in terms of Total factuality, Disease diagnosis, and Drug recommendation. This application refers to this method as the average equalization rate. Similarly, the rightmost data in the fourth row of Table 3, 22.48%, represents the average percentage of the method described in this application that is inferior to existing medical question-answering methods in terms of Total factuality, Disease diagnosis, and Drug recommendation metrics. This application refers to this method as the average failure rate.

[0041] As can be seen from Table 3, 1) The method described in this application achieves an average win rate of 55.28% compared to the MindMap method. Moreover, from the other data in the first row of Table 3 (52.71%, 54.58%, and 58.54%), it can be seen that the method described in this application achieves more than half the performance advantage in multiple dimensions such as factual accuracy, disease diagnosis accuracy, and drug recommendation accuracy, especially in drug recommendation accuracy.

[0042] Clearly, the method described in this application outperforms existing MindMap methods in several key evaluation metrics, particularly in factual accuracy, disease diagnosis accuracy, and drug recommendation accuracy. In this application, the entity-level screening by the first agent and the path-level medical verification by the second agent together constitute a dual-protection mechanism, greatly reducing the illusionary risk of the LLM model. The set of associative reasoning paths obtained in this application effectively improves the accuracy of the diagnostic chain from symptoms to diseases, while the set of second-order neighbor reasoning paths obtained after clinical value verification provides a reliable basis for drug recommendations. These are then converted into natural language description information through a knowledge conversion module, collectively contributing to the synergistic improvement of the generated text in the three major metrics of factual accuracy, disease diagnosis accuracy, and drug recommendation accuracy.

Claims

1. A medical question-answering method based on knowledge graphs and intelligent agents, characterized in that: Includes the following steps: S1. Sequentially perform keyword extraction, entity retrieval, vectorization representation acquisition, entity matching, entity filtering, and sorting to identify core entities related to patient description information from the medical knowledge graph and obtain an optimized entity set; S2. Explore the association reasoning path and the neighbor path for the entities in the optimized entity set to obtain the association reasoning path set and the second-order neighbor reasoning path set. S3. The prompts based on natural language conversion convert the paths in the set of related reasoning paths and the set of second-order neighbor reasoning paths into natural language description information, and the natural language description information constitutes a set of knowledge text. S4. Based on the reasoning prompts, perform diagnostic reasoning on the patient description information and the information in the knowledge text set, and output the diagnostic results.

2. The medical question-answering method based on knowledge graphs and intelligent agents according to claim 1, characterized in that: Step S1 specifically includes the following steps: S1-1. Extract medical-related keywords from patient description information to obtain a keyword set; S1-2. Use Cypher query language to call the Neo4j database, perform entity retrieval based on medical knowledge graph, and obtain candidate entity set; S1-3: Map the entities in the candidate entity set to the keywords in the keyword set, and then use the pre-trained Word2Vec model to convert them into vector representations. S1-4. Perform entity matching based on keyword vector representation and entity vector representation to obtain a set of semantically similar entities; S1-5. The first intelligent agent filters and sorts entities in the semantically similar entity set based on its prompts and patient description information.

3. The medical question-answering method based on knowledge graphs and intelligent agents according to claim 2, characterized in that: In steps S1-3, the pre-trained Word2Vec model is obtained by pre-training the Word2Vec model.

4. The medical question-answering method based on knowledge graphs and intelligent agents according to claim 1, characterized in that: In step S2, the entities in the optimized entity set are explored for related reasoning paths, including the exploration of continuous related reasoning paths and non-continuous related reasoning paths.

5. A medical question-answering method based on knowledge graphs and intelligent agents according to claim 4, characterized in that: The exploration of continuous association reasoning paths for entities in the optimized entity set includes the following steps: 1) Starting with the first entity in the optimized entity set, update the optimized entity set to obtain set one. The only difference between set one and the optimized entity set is that set one lacks the first entity in the optimized entity set. Use the Cypher query language to call the Neo4j database and retrieve all entities connected to the first entity from the medical knowledge graph. When the second entity in the optimized entity set is included among all entities connected to the first entity retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between the first and second entities in the optimized entity set. 2) Using the second entity in the optimized entity set as the new starting entity, and updating set one, we get set two. The only difference between set two and the optimized entity set is that set two is missing the first and second entities in the optimized entity set. When all entities connected to the second entity are retrieved from the medical knowledge graph, including the third entity in the optimized entity set, it indicates that there is a continuous association reasoning path between the first and third entities in the optimized entity set. 3) Using the third entity in the optimized entity set as the new starting entity, update set two to obtain set three. The only difference between set three and the optimized entity set is that set three lacks the first to third entities in the optimized entity set. When the fourth entity in the optimized entity set is found to be among all entities connected to the third entity in the medical knowledge graph, it indicates that there is a continuous association reasoning path between the first to fourth entities in the optimized entity set. 4) Using the fourth entity as the new starting entity, update set three to obtain set four, which is an empty set. At this point, the process of exploring the associated reasoning path ends, and the continuous associated reasoning path between the first to fourth entities in the optimized entity set is saved.

6. The medical question-answering method based on knowledge graphs and intelligent agents according to claim 4, characterized in that: The exploration of non-continuous association reasoning paths for entities in the optimized entity set includes the following steps: a) Starting with the first entity in the optimized entity set, the optimized entity set is updated to obtain set five. The only difference between set five and the optimized entity set is that set five lacks the first entity in the optimized entity set. The Neo4j database is called using the Cypher query language to retrieve all entities connected to the first entity from the medical knowledge graph. When the second entity in the optimized entity set is included among all entities connected to the first entity retrieved from the medical knowledge graph, it indicates that there is an association reasoning path between the first and second entities. b) Using the second entity in the optimized entity set as the new starting entity, and updating set five, we obtain set six. The only difference between set six and the optimized entity set is that set six lacks the first and second entities in the optimized entity set. When the third entity in the optimized entity set is not found among all the entities connected to the second entity retrieved from the medical knowledge graph, it indicates that there is no association reasoning path between the second and third entities in the optimized entity set, and the association reasoning path between the first and second entities is saved. c) Using the third entity in the optimized entity set as the new starting entity, update set six to obtain set seven. The only difference between set seven and the optimized entity set is that set seven lacks the first to third entities in the optimized entity set. When all entities connected to the third entity are retrieved from the medical knowledge graph, including the fourth entity in the optimized entity set, it indicates that there is an associated reasoning path between the third and fourth entities in the optimized entity set. d) Using the fourth entity as the new starting entity, update set seven to obtain set eight, which is an empty set. At this point, the process of exploring the related reasoning path ends, and the related reasoning path between the third and fourth entities in the optimized entity set is saved.

7. The medical question-answering method based on knowledge graphs and intelligent agents according to claim 1, characterized in that: The process involves exploring neighbor paths for entities in the optimized entity set, including sequentially exploring first-order neighbor paths and expanding second-order neighbor paths for each entity in the optimized entity set.

8. A medical question-answering method based on knowledge graphs and intelligent agents according to claim 7, characterized in that: The first-order neighbor path exploration includes the following steps: first-order neighbor path exploration is performed on the entities in the optimized entity set based on primary neighbor relationship comparison and semantic relevance filtering to obtain the first-order neighbor path set.

9. A medical question-answering method based on knowledge graphs and intelligent agents according to claim 7, characterized in that: The second-order neighbor path expansion specifically includes the following steps: expanding the first-order neighbor path set with second-order neighbors to obtain a second-order neighbor path set; optimizing the paths connecting entities in the entity set, first-order neighbor entities in the first-order neighbor path set, and second-order neighbor entities in the second-order neighbor entity set to form second-order neighbor paths, and these second-order neighbor paths constitute the second-order neighbor path set; using a second agent to verify and sort the second-order neighbor paths in the second-order neighbor path set to obtain a second-order neighbor inference path set.

10. A medical question-answering system based on knowledge graphs and intelligent agents, characterized in that: The knowledge graph-based and agent-based medical question-answering system is used to implement the knowledge graph-based and agent-based medical question-answering method as described in claim 1. The knowledge graph-based and agent-based medical question-answering system includes: The entity extraction module is used for keyword extraction, entity retrieval, obtaining vectorized representations, entity matching, and entity filtering and sorting to identify core entities related to patient description information from the medical knowledge graph and obtain an optimized entity set. The knowledge reasoning path exploration module is used to explore the associated reasoning path and the neighbor path respectively for the entities in the optimized entity set output by the entity extraction module, and obtain the associated reasoning path set and the second-order neighbor reasoning path set. The knowledge conversion module is used to convert the paths in the set of related reasoning paths and the set of second-order neighbor reasoning paths into natural language description information based on prompts based on natural language conversion. The natural language description information constitutes a set of knowledge text. The reasoning module is used to perform diagnostic reasoning based on the patient description information and information in the knowledge text set, and output the diagnostic results.

Citation Information

Patent Citations

  • Intelligent question-answering system based on medical knowledge graph

    CN111046272A

  • Elderly disease health question and answer method based on multi-agent and knowledge graph

    CN120542573A

  • Cardiovascular disease diagnosis system based on knowledge graph

    CN120727253A

  • Multi-center knowledge graph joint decision support method and system

    WO2023061377A1

Cited By

  • Dynamic knowledge graph construction and diagnosis reasoning method for intelligent inquiry

    CN121706915A