Intelligent construction and retrieval method for medical knowledge graph based on GraphRAG and LLM

By combining GraphRAG and LLM technologies, medical knowledge graphs are constructed and retrieved, and the problem that traditional medical search methods are difficult to understand complex queries is solved, and efficient and accurate medical information retrieval is achieved.

CN119719383AActive Publication Date: 2025-03-28JINYE TIANCHENG BEIJING TECH CO LTD

Patent Information

Application Number
CN202411766494.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-03
Publication Date
2025-03-28
Estimated Expiration
2044-12-03

AI Technical Summary

Technical Problem

Traditional medical search methods rely on keyword matching, making it difficult to understand complex queries, resulting in insufficient relevance and accuracy of search results.

Method used

The intelligent construction and search method of medical knowledge graph based on GraphRAG and LLM is adopted to construct and retrieve medical knowledge graphs through steps such as data collection and processing, entity and relationship extraction, entity analysis, weakly connected component recognition, word distance filtering, LLM evaluation, element abstract generation, graph community division and community abstract generation.

Benefits of technology

It significantly improves the accuracy and efficiency of medical literature search, can intelligently identify the user's inquiry intentions, provide highly relevant medical information, shorten the search time, and improve the accuracy of search.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119719383A_ABST
    Figure CN119719383A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent construction and retrieval method for a medical knowledge graph based on GraphRAG and LLM. The intelligent construction method of the medical knowledge graph comprises the steps of data collection and processing, text segmentation, entity and relation extraction, entity analysis, weak connected component identification, word distance filtering, LLM evaluation, element abstract generation, graph community generation and community abstract generation. The intelligent retrieval method comprises the steps of knowledge graph vector library construction, text vector library construction, user question entity extraction and vectorization processing, multi-layer entity and relation retrieval, text retrieval, LLM summarization, result output and user feedback collection. According to the method, the GraphRAG and the LLM large model technology are combined, and efficient retrieval and accurate presentation of the medical information are achieved. According to the system, the accuracy and efficiency of medical literature retrieval are remarkably improved through deep integration of graph structured data and natural language processing capacity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a medical knowledge graph construction and retrieval method, and in particular to a medical knowledge graph intelligent construction and retrieval method based on GraphRAG and LLM, belonging to the technical field of natural language processing. Background Art

[0002] In the contemporary medical field, medical information retrieval systems are important tools for improving medical efficiency and ensuring medical quality. Doctors, researchers, and other medical professionals often need to find, evaluate, and apply large amounts of medical literature, case reports, and research data in order to make scientific and accurate medical decisions. However, with the continuous development of the medical field, the massive growth and complexity of medical information has brought challenges to doctors and researchers, who need to filter out the most relevant and accurate information from a large amount of data within a limited time.

[0003] Traditional medical retrieval methods often rely on keyword matching, which encounters some limitations when faced with complex query requirements. It is difficult to understand users' complex queries, resulting in insufficient relevance and accuracy of retrieval results.

[0004] In recent years, with the rapid development of artificial intelligence and natural language processing technology, large language models (LLM) have provided new solutions for medical literature retrieval. GraphRAG uses knowledge graphs to organize and represent entities and their relationships in the medical field. By linking entities in medical literature to corresponding entries in the knowledge graph, document content can be more accurately identified and understood, the retrieval context can be enriched, and the relevance and precision of retrieval can be improved. Summary of the invention

[0005] The purpose of the present invention is to provide a medical knowledge graph intelligent construction and retrieval method based on GraphRAG and LLM.

[0006] To achieve the above purpose, the first technical solution adopted by the present invention is:

[0007] A method for intelligently constructing a medical knowledge graph based on GraphRAG and LLM, comprising the following steps:

[0008] Step 1: Data collection and processing: Data sources include academic papers, clinical guidelines, drug instructions, health information and expert interviews; it consists of the following specific steps:

[0009] Step 1-1: Convert the data into text data in a preset format to form more than one record;

[0010] Step 1-2: Data cleaning: Calculate the hash value of each record, keep one record with the same hash value, remove useless information in the retained records, including special symbols, garbled characters, headers, footers, dates, and convert the retained records into corresponding medical texts;

[0011] Step 2: Segment the text: segment each medical text using period, semicolon, question mark, exclamation mark, and line break as markers to obtain one or more text blocks; the number of tokens in each text block is less than the preset value of the text block; the number of overlapping tokens between two adjacent text blocks is the preset number of overlapping tokens;

[0012] Step 3: Extract entities and relationships: Use LLM to extract entity-relationship triples, and merge the same entity-relationship triples from different data sources to build a graph database;

[0013] Step 4: Entity resolution: consists of the following specific steps:

[0014] Step 4-1: Obtain the entities and description attributes contained in the triples in the graph database, and obtain the text embedding vector corresponding to the entity;

[0015] Step 4-2: Construct K-nearest neighbor graph:

[0016] Project all entities and their corresponding text embedding vectors into a graph database;

[0017] Set the predefined number of neighbors topk, where topk is the number of relationships of each entity;

[0018] The similarity between entities is measured using cosine similarity, which is calculated as follows:

[0019]

[0020] Where n represents the dimension of the vector, i represents the index from 1 to n, and x i Represents the value of vector x in the i-th dimension, y i Represents the value of vector y in the i-th dimension;

[0021] Establish a connection between two entities that meet the preset conditions of topk number of neighbors and similarity; construct a K-nearest neighbor graph;

[0022] Step 5: Identify weakly connected components: Identify at least one weakly connected component in the K-nearest neighbor graph, where there is a relationship between any two entities in the weakly connected component;

[0023] Step 6: Word distance filtering: The word distance is:

[0024]

[0025] in, is the indicator function, when a i =b j When , the value is 0, otherwise it is 1; a, b are two entities with weakly connected components; i, j are the position numbers in entities a and b respectively;

[0026] Reduce the weakly connected components so that the word distances of entities in the weakly connected components are all less than the preset distance threshold;

[0027] Step 7: LLM evaluation: Use LLM to evaluate whether the entities in the weakly connected components of the decision are merged, merge the entities merged by the decision and the corresponding relationships to obtain an updated knowledge graph;

[0028] Step 8: Generate element summary: Use LLM to generate element summary for each entity and relationship in the updated knowledge graph, and store the element summary as the attribute of the entity;

[0029] Step 9: Generate graph communities: Use the Leiden algorithm to divide entities into hierarchical communities and establish corresponding community entities for each level of community;

[0030] Step 10: Generate community summary: Use LLM to generate community summary based on community entities and relationships, and store the community summary as an attribute of the community entity; obtain the medical knowledge graph.

[0031] The second technical solution adopted by the present invention is:

[0032] An intelligent retrieval method for a medical knowledge graph constructed using the technical solution described in technical solution 1 comprises the following steps:

[0033] Step 1: Build a knowledge graph vector library: Use the Embedding model to convert the entities and attributes of the medical knowledge graph in the knowledge graph library constructed in Technical Solution 1 into vector representations as knowledge graph vectors, and build a knowledge graph vector database;

[0034] Step 2: Build a text vector library: Use the Embedding model to represent the text blocks obtained in the process of building the knowledge graph library in Technical Solution 1 as text vectors to build a text vector library;

[0035] Step 3: User question entity vectorization and question vectorization:

[0036] Step 3-1: Use LLM to extract at least one entity entity0 in the user question as the initial root node; use the Embedding model to convert entity entity0 into an entity vector entity0_vector;

[0037] Step 3-2: Use the Embedding model to convert the user question into a question vector query_vector;

[0038] Step 4: Multi-layer entity and relationship retrieval:

[0039] Step 4-1: Determine whether entity entity0 exists in the medical knowledge graph. If so, go to step 4-2; otherwise, go to step 4-3.

[0040] Step 4-2: Retrieve the first-level entity entity1 and its relationship relationship1 that are related to entity entity0, and obtain at least one top-level triple (entity0, relationship1, entity1); then retrieve the second-level entity entity2 and relationship relationship2 that are related to each first-level entity entity1, and obtain at least one first-level triple (entity1, relationship2, entity2); output the top-level triples, the first-level triples, the first-level entity entity1 and its element summary, the second-level entity entity1 and its element summary; go to step 5;

[0041] Step 4-3: Search for entity entity0 in the medical knowledge graph vector library that reaches or exceeds the preset semantic relevance threshold as a similar entity; if it exists, go to step 4-4; otherwise, go to step 4-5;

[0042] Step 4-4: Sort the graph communities: Sort the communities according to the number of similar entities in the communities from most to least, select a preset number of communities from most to least, output the communities and community summaries; go to step 5;

[0043] Step 4-5: If it is a global problem, the communities and their community summaries are output from high to low levels according to the preset token quantity limit;

[0044] Step 5: Text retrieval: Search the text vector library for text blocks whose semantic similarity with the question vector query_vector is greater than a preset semantic similarity threshold, and use them as similar text blocks. Sort similar text blocks from high to low according to similarity; output a preset number of similar text blocks;

[0045] Step 6: LLM summary: construct prompt text according to the preset prompt template with the top triples, the first layer triples, the first layer entity entity1 and its element summary, the second layer entity entity1 and its element summary, similar text blocks and user questions, input the prompt text into LLM, and LLM outputs LLM search results;

[0046] Step 7: Output the results, and output the LLM search results and similar text blocks as search information.

[0047] Furthermore, the method further includes step 8: user feedback collection: collecting user evaluations of the retrieved information.

[0048] Furthermore, in step 6, the prompt template is "

Instructions

Known information

Question

[0049] The context is the similar triples returned by the retrieval, the element summary of the entity, the summary of the community and the similar text segment, and the question is the question entered by the user.

[0050] By adopting the above technical solution, the beneficial effects achieved by the present invention are:

[0051] The present invention combines GraphRAG with LLM large model technology to achieve efficient retrieval and accurate presentation of medical information. The system significantly improves the accuracy and efficiency of medical literature retrieval by deeply integrating graph-structured data and natural language processing capabilities. Users can quickly locate the required medical information through simple interactions. The system can intelligently identify the user's query intent and provide highly relevant medical information, greatly shortening the search time and improving the accuracy of retrieval. Medical researchers and clinicians can use this system to quickly access the latest research results and clinical guidelines, accelerate the dissemination and application of knowledge, and provide strong support for research and practice in the medical field. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 is a flow chart of Embodiment 1 of the present invention;

[0053] Figure 2 is the medical knowledge graph constructed in Example 1 of the present invention;

[0054] Figure 3 It is a hierarchical community graph divided by the Leiden algorithm in Example 1 of the present invention;

[0055] Figure 4 This is a flow chart of Embodiment 2 of the present invention. DETAILED DESCRIPTION

[0056] Embodiment 1:

[0057] A method for intelligently constructing a medical knowledge graph based on GraphRAG and LLM, comprising the following steps:

[0058] Step 1: Data collection and processing: Data sources include academic papers, clinical guidelines, drug instructions, health information and expert interviews; it consists of the following specific steps:

[0059] In this embodiment, academic papers obtain the latest research literature through the PubMed database; clinical guidelines are downloaded from official agencies such as the National Institute for Health and Clinical Excellence (NICE) of the United Kingdom and the Food and Drug Administration (FDA) of the United States; drug instructions are obtained from the official websites of pharmaceutical companies or drug regulatory departments; health information is collected from authoritative medical news websites and professional blogs; expert interviews: record expert opinions and experience sharing.

[0060] Step 1-1: Convert the data into text data in a preset format to form more than one record;

[0061] In this embodiment, for PDF files containing plain text, the Python library PyMuPDF is used to extract text; for PDF files containing images, OCR technology is used in combination with libraries such as Python Imaging Library to perform image recognition and text extraction.

[0062] Step 1-2: Data cleaning: Calculate the hash value of each record, keep one record with the same hash value, remove useless information in the retained records, including special symbols, garbled characters, headers, footers, dates, and convert the retained records into corresponding medical texts;

[0063] This embodiment converts the text into a unified UTF-8 encoding to ensure that the text encoding is consistent.

[0064] Step 2: Segment the text: segment each medical text using period, semicolon, question mark, exclamation mark, and line break as markers to obtain one or more text blocks; the number of tokens in each text block is less than the preset value of the text block; the number of overlapping tokens between two adjacent text blocks is the preset number of overlapping tokens;

[0065] In this embodiment, each text block is divided into a maximum of 600 tokens. To avoid losing the context and referential relationship of specific entities scattered in the document, the number of overlapping tokens between two adjacent text blocks is 50.

[0066] Step 3: Extract entities and relationships: Use LLM to extract entity-relationship triples, and merge the same entity-relationship triples from different data sources to build a graph database;

[0067] For example, from the relevant information about diabetes, we can extract ("diabetes", "clinical symptoms and signs", "thirst"), which means that "diabetes" is a disease entity, and one of its "clinical symptoms and signs" is "thirst". We extracted about 489,337 entities and 657,996 relationships and stored them in the neo4j graph database.

[0068] In this embodiment, the prompt for extracting entities and relationships input into LLM is:

[0069] "'Some text is provided below. Based on the text, extract the knowledge triples of disease, drug, diagnosis and treatment, symptom, and attribute in the form of (entity, relationship, entity). Avoid using stop words and only output triples without redundant explanations and descriptions.

[0070] ---------------------------------------

[0071] Example:

[0072] Medical text: Typical clinical symptoms of diabetes usually appear within a few days to weeks before diagnosis and include polyuria, polydipsia, weight loss, fatigue, and blurred vision caused by lens swelling due to the osmotic effect of high blood sugar.

[0073] Triplet:

[0074] Diabetes mellitus, clinical symptoms, polyuria

[0075] Diabetes, clinical symptoms, polydipsia

[0076] Diabetes, clinical symptoms, weight loss

[0077] Diabetes, Clinical symptoms, Fatigue

[0078] Diabetes, clinical symptoms, blurred vision

[0079] High blood sugar causes lens swelling

[0080] ---------------------------------------

[0081] Text: {text}

[0082] Triple: "'

[0083] Step 4: Entity resolution: consists of the following specific steps:

[0084] Step 4-1: Get the entities and description attributes contained in the triples in the graph database, and use the Embedding model to obtain the text embedding vector corresponding to the entity;

[0085] Step 4-2: Construct K-nearest neighbor graph:

[0086] Project all entities and their corresponding text embedding vectors into a graph database;

[0087] Set the predefined number of neighbors topk, where topk is the number of relationships of each entity;

[0088] The similarity between entities is measured using cosine similarity, which is calculated as follows:

[0089]

[0090] Where n represents the dimension of the vector, i represents the index from 1 to n, and x i Represents the value of vector x in the i-th dimension, y i Represents the value of vector y in the i-th dimension;

[0091] Establish a connection between two entities that meet the preset conditions of topk number of neighbors and similarity; construct a K-nearest neighbor graph.

[0092] The purpose of entity resolution is to identify and merge records from different data sources that refer to the same real-world object. This helps ensure that each entity is uniquely and accurately represented in a knowledge graph, thereby preventing duplicate or erroneous associations. A similarity threshold is set to filter the relationship between entities, where a relationship is established between two entities only when the similarity between the entities is greater than or equal to the similarity threshold; wherein the topk is set to 10 and the similarity threshold is set to 0.95. This embodiment uses cosine similarity as a metric to measure the similarity between entities.

[0093] Step 5: Identify weakly connected components: Identify a local K-nearest neighbor graph in which any two entities are mutually reachable as a weakly connected component in the K-nearest neighbor graph; a weakly connected component is defined as a component in which any two vertices are mutually reachable when the directionality of all edges in the graph is ignored; the entities in the identified weakly connected components are regarded as a set of potentially similar entities.

[0094] Step 6: Word distance filtering: The word distance is:

[0095]

[0096] in, is the indicator function, when a i =b j When , the value is 0, otherwise it is 1; a, b are two entities with weakly connected components; i, j are the position numbers in entities a and b respectively;

[0097] Reduce the weakly connected components so that the word distances of entities in the weakly connected components are all less than the preset distance threshold;

[0098] Text embedding alone cannot accurately distinguish different entities. In order to improve the accuracy of entity resolution, a word distance filter condition is added to further filter candidate entities. The word distance used in this embodiment is the edit distance, and entities with an edit distance greater than 3 are filtered from the weakly connected component set. Other word distances can also be used.

[0099] Step 7: LLM evaluation: Use LLM to evaluate whether the entities in the weakly connected components of the decision are merged, merge the entities merged by the decision and the corresponding relationships to obtain an updated knowledge graph;

[0100] Enter the LLM prompt for assessment:

[0101] “You are a professional knowledge graph analyst. Please evaluate the following weakly connected components and determine whether the entities should be merged. Please analyze according to the following criteria:

[0102] 1. Similarity: The degree to which entities are similar in name, attributes, or other characteristics.

[0103] 2. Contextual relevance: whether these entities can be used interchangeably in a specific context.

[0104] 3. Duplication: whether there are identical or nearly identical entities.

[0105] Please evaluate the following weakly connected components and provide a recommendation for merging (merge or not) and your reasons. Please be as detailed as possible in your evaluation and make sure to provide sufficient reasons to support your recommendation.

[0106] Weakly connected component set: {set_info}"

[0107] Among them, set_info represents the weakly connected component set information.

[0108] Step 8: Generate element summaries: Use LLM to generate element summaries for each entity and relationship in the updated knowledge graph, and store the element summaries as attributes of the entities; element summaries can more efficiently index this information and entities for more accurate retrieval, and store the element summaries as entity attributes.

[0109] Step 9: Generate graph communities: Use the Leiden algorithm to divide entities into communities and establish corresponding community entities for the communities; use the Leiden algorithm to divide them into hierarchical communities. The Leiden algorithm is an efficient community detection algorithm used to identify community structures in complex networks. The results of the graph community are stored as entity attributes, and a separate entity is created for each community. We generated 97,446 communities. The communities are divided into different levels from low to high. The higher the level, the fewer communities at the same level and the more node information they contain.

[0110] Step 10: Generate community summary: Use LLM to generate community summary based on community entities and relationships, and store the community summary as an attribute of the community entity; obtain the medical knowledge graph.

[0111] With the help of community summaries, the global topic structure and semantics of the dataset can be understood. The prompt of the community summary is: "Generate a natural language summary of the provided information based on the provided nodes and relationships belonging to the same graph community. The summary should be concise and clear, while covering all key information and ensuring coherence and readability.

[0112] Output requirements:

[0113] 1. Conciseness: The summary should be concise and avoid redundancy.

[0114] 2. Completeness: Make sure all important nodes and relationships are covered.

[0115] 3. Coherence: Use language that flows naturally and makes the summary easy to understand.

[0116] 4. Focus: Emphasize core concepts and important relationships in the community.

[0117] {community_info}

[0118] Summary: ", where community_info represents the triple information within the community.

[0119] Embodiment 2:

[0120] An intelligent retrieval method using the medical knowledge graph described in technical solution 1 comprises the following steps:

[0121] Step 1: Construct a knowledge graph vector library: Use the Embedding model to convert the entities and attributes of the medical knowledge graph in the medical knowledge graph library constructed in Example 1 into vector representations as knowledge graph vectors, and construct a knowledge graph vector database;

[0122] In this embodiment, the knowledge graph vector is stored in the Milvus vector database to construct a knowledge graph vector database. Milvus is an open source vector database developed by Zilliz and is one of the solutions currently widely used in approximate neighbor search.

[0123] Step 2: Construct a text vector library: Use the Embedding model to represent the text blocks in the medical knowledge graph library constructed in Example 1 as text vectors to construct a text vector library; in this embodiment, the text vectors are stored in the Milvus vector database.

[0124] Step 3: User question entity vectorization and question vectorization: Step 3-1: Use LLM to extract at least one entity entity0 in the user question as the initial root node; use the Embedding model to convert entity entity0 into an entity vector entity0_vector;

[0125] Step 3-2: Use the Embedding model to convert the user question into a question vector query_vector;

[0126] Step 4: Multi-layer entity and relationship retrieval:

[0127] Step 4-1: Determine whether entity entity0 exists in the medical knowledge graph. If so, go to step 4-2; otherwise, go to step 4-3.

[0128] Step 4-2: Retrieve the first-level entity entity1 and its relationship relationship1 that are related to entity entity0, and obtain at least one top-level triple (entity0, relationship1, entity1); then retrieve the second-level entity entity2 and relationship relationship2 that are related to each first-level entity entity1, and obtain at least one first-level triple (entity1, relationship2, entity2); output the top-level triples, the first-level triples, the first-level entity entity1 and its element summary, the second-level entity entity1 and its element summary; go to step 5;

[0129] Step 4-3: Search for entities whose entity0 reaches or exceeds a preset semantic relevance threshold in the medical knowledge graph vector library as similar entities; in this embodiment, the semantic relevance is calculated using cosine similarity, and the preset semantic relevance threshold is 0.85; if it exists, go to step 4-4; otherwise, go to step 4-5;

[0130] Step 4-4: Invert the graph community index based on the number of similar entities in the community: select a preset number of communities, output the communities and community summaries; go to step 5;

[0131] Step 4-5: If it is a global problem, the communities and their community summaries are output from high to low levels according to the preset token quantity limit;

[0132] Step 5: Text retrieval: Search the text vector library for text blocks whose semantic similarity with the question vector query_vector is greater than a preset semantic similarity threshold, and use them as similar text blocks. Sort similar text blocks from high to low according to similarity; output a preset number of similar text blocks;

[0133] Step 6: LLM summary: construct prompt text according to the preset prompt template from the top triples, first-layer triples, first-layer entity entity1 and its element summary, second-layer entity entity1 and its element summary, similar text blocks and user questions, input the prompt text into LLM, and output the search results; in this embodiment, the first 10 similar text segments and user questions found in step 5 are input into the prompt template, the prompt is input into the LLM large model, and the results are output after being polished by the large model. In the prompt template, it is restricted not to generate answers that are not related to the question to prevent misleading users.

[0134] Generate summary prompt template:

[0135] "

Instructions

Known Information

Question

[0136] Among them, context is the information returned by the search, and question is the question entered by the user.

[0137] Step 7: Output the results, and output the LLM search results and similar text blocks as search information.

[0138] Embodiment 3: The difference from Embodiment 2 is that it also includes step 8: user feedback collection: collecting user evaluations of the searched information. It provides a feedback mechanism to allow users to evaluate whether the provided information is helpful to them, and records user questions, provided answers, and user feedback in order to continuously optimize the search algorithm and answer generation strategy.

[0139] The present invention aims to achieve efficient retrieval and intelligent question-answering functions for medical information by integrating GraphRAG and large model technology, and provide accurate and timely information support for medical professionals and researchers. The present invention captures the complex relationships between entities such as diseases, drugs, and symptoms by constructing a medical knowledge graph, and uses GraphRAG technology to achieve effective retrieval and utilization of this knowledge. In addition, by integrating the powerful generation capabilities of LLM, it is possible to retrieve the most relevant information fragments from existing medical literature based on understanding user queries and generate high-quality answers.

[0140] The present invention can not only enhance the understanding and processing capabilities of medical literature, but also support more complex queries and provide more in-depth analysis and insights. This will greatly improve the information retrieval efficiency of medical professionals, help them better cope with the growing amount of medical information, and ultimately improve the quality and effectiveness of medical services.

Claims

1. A method for intelligently constructing a medical knowledge graph based on GraphRAG and LLM, characterized by: The following steps are involved: Step 1: Data collection and processing: Data sources include academic papers, clinical guidelines, drug instructions, health information and expert interviews; it consists of the following specific steps: Step 1-1: Convert the data into text data in a preset format to form more than one record; Step 1-2: Data cleaning: Calculate the hash value of each record, keep one record with the same hash value, remove useless information in the retained records, including special symbols, garbled characters, headers, footers, dates, and convert the retained records into corresponding medical texts; Step 2: Text segmentation: Each medical text is segmented by period, semicolon, question mark, exclamation mark, and line break to obtain more than one text block; the number of tokens in each text block is less than the preset value of the text block; the number of overlapping tokens between two adjacent text blocks is the preset number of overlapping tokens; Step 3: Extract entities and relationships: Use LLM to extract entity-relationship triples, and merge the same entity-relationship triples from different data sources to build a graph database; Step 4: Entity resolution: consists of the following specific steps: Step 4-1: Obtain the entities and description attributes contained in the triples in the graph database, and obtain the text embedding vector corresponding to the entity; Step 4-2: Construct K-nearest neighbor graph: Project all entities and their corresponding text embedding vectors into a graph database; Set the predefined number of neighbors topk, where topk is the number of relationships of each entity; The similarity between entities is measured using cosine similarity, which is calculated as follows: Where n represents the dimension of the vector, i represents the index from 1 to n, and x i Represents the value of vector x in the i-th dimension, y i Represents the value of vector y in the i-th dimension; Establish a connection between two entities that meet the preset number of neighbors topk and similarity preset conditions; construct a K-nearest neighbor graph Step 5: Identify weakly connected components: Identify at least one weakly connected component in the K-nearest neighbor graph, where there is a relationship between any two entities in the weakly connected component; Step 6: Word distance filtering: The word distance is: in, is the indicator function, when a i =b j When , the value is 0, otherwise it is 1; a, b are two entities with weakly connected components; i, j are the position numbers in entities a and b respectively; Reduce the weakly connected components so that the word distances of entities in the weakly connected components are all less than the preset distance threshold; Step 7: LLM evaluation: Use LLM to evaluate whether the entities in the weakly connected components of the decision are merged, merge the entities merged by the decision and the corresponding relationships to obtain an updated knowledge graph; Step 8: Generate element summary: Use LLM to generate element summary for each entity and relationship in the updated knowledge graph, and store the element summary as the attribute of the entity; Step 9: Generate graph communities: Use the Leiden algorithm to divide entities into hierarchical communities and establish corresponding entities for each level of community; Step 10: Generate community summary: Use LLM to generate community summary based on community entities and relationships, and store the community summary as an attribute of the community entity; obtain the medical knowledge graph.

2. The information retrieval method using the medical knowledge graph according to claim 1 is characterized in that: The following steps are involved: Step 1: Construct a knowledge graph vector library: Use the Embedding model to convert the entities and attributes of the medical knowledge graph in the knowledge graph library constructed in claim 1 into vector representations as knowledge graph vectors, and construct a knowledge graph vector database; Step 2: Build a text vector library: Use the Embedding model to represent the text blocks obtained in the process of building the knowledge graph library of claim 1 as text vectors, and build a text vector library; Step 3: User question entity vectorization and question vectorization: Step 3-1: Use LLM to extract at least one entity entity0 in the user question as the initial root node; use the Embedding model to convert entity entity0 into an entity vector entity0_vector; Step 3-2: Use the Embedding model to convert the user question into a question vector query_vector; Step 4: Multi-layer entity and relationship retrieval: Step 4-1: Determine whether entity entity0 exists in the medical knowledge graph. If so, go to step 4-2; otherwise, go to step 4-3. Step 4-2: Retrieve the first-level entity entity1 and its relationship relationship1 that are related to entity entity0, and obtain at least one top-level triple (entity0, relationship1, entity1); then retrieve the second-level entity entity2 and relationship relationship2 that are related to each first-level entity entity1, and obtain at least one first-level triple (entity1, relationship2, entity2); output the top-level triples, the first-level triples, the first-level entity entity1 and its element summary, the second-level entity entity1 and its element summary; go to step 5; Step 4-3: Find entity 0 in the medical knowledge graph vector library that reaches or exceeds the preset semantic relevance threshold as a similar entity; if it exists, go to step 4-4; Otherwise, go to step 4-5; Step 4-4: Sort the graph communities: Sort the communities according to the number of similar entities in the community from most to least, select a preset number of communities from most to least, and output the communities and community summaries; Go to step 5; Step 4-5: If it is a global problem, the communities and their community summaries are output from high to low levels according to the preset token quantity limit; Step 5: Text retrieval: Search the text vector library for text blocks whose semantic similarity with the question vector query_vector is greater than a preset semantic similarity threshold, and use them as similar text blocks. Sort similar text blocks from high to low according to similarity; output a preset number of similar text blocks; Step 6: LLM summary: construct prompt text according to the preset prompt template based on the top triples, the first layer triples, the first layer entity entity1 and its element summary, the second layer entity entity1 and its element summary, similar text blocks and user questions, input the prompt text into LLM, and output the search results; Step 7: Output the results, and output the LLM search results and similar text blocks as search information.

3. The information retrieval method according to claim 2, characterized in that: It also includes step 8: user feedback collection: collecting users' evaluations of the retrieved information.

4. The information retrieval method according to claim 2, characterized in that: In step 6, the prompt template is: [Instructions] Answer the question professionally based on the known information; if you cannot get the answer from it, please say "I cannot answer this question based on the known information", it is not allowed to add fabricated elements to the answer, give corresponding explanations for the answer, and the answer should be in Chinese; \n\n[Known information] {context}\n\n[Question] {question}". Among them, context is the similar triples returned by the retrieval, the element summary of the entity, the summary of the community and the similar text segment, and question is the question entered by the user.

Citation Information

Patent Citations

  • Domain knowledge graph-oriented entity alignment method

    CN116578654A

  • Knowledge graph entity alignment method and device, equipment and storage medium

    CN116610820A

  • Novel scientific and technological talent intelligent evaluation method based on hypergraph attention mechanism

    CN117314266A

  • Knowledge graph-based scientific research community mining method, model and system

    CN117725221A

  • Medical literature intelligent question answering system and method based on RAG and LLM technologies

    CN118364088A

Cited By

  • Interrogation session information processing method and device and electronic equipment

    CN120432197A

  • Power industry dynamic knowledge base construction method and system based on large language model

    CN120705130A

  • Implementation method of chat robot based on canal field

    CN120706542A

  • Hierarchical knowledge network construction and retrieval method for intelligent electric charge questions and answers

    CN120744073A

  • A hierarchical knowledge network construction and retrieval method for electricity fee intelligent question and answer

    CN120744073B