Intestinal microorganism intelligent question-answering system based on knowledge graph and large model

By combining the intestinal microbial knowledge graph and large language model, an intelligent intestinal microbial question-and-answer system is constructed, which solves the limitations of traditional query methods, and achieves more efficient and flexible intestinal microbial information acquisition, improving knowledge Coverage and information density support in-depth answers to complex questions.

CN119226487AActive Publication Date: 2024-12-31SHANGHAI LISHAN BIOPHARMACEUTICAL CO LTD

Patent Information

Application Number
CN202411735666.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2024-12-31
Estimated Expiration
2044-11-29

AI Technical Summary

Technical Problem

The existing intestinal microbiology knowledge query methods have limitations, and cannot achieve flexible and natural language interactions, and it is difficult to deeply explore the complex relationship between intestinal microbials and human health, which limits new ideas for disease prevention, diagnosis and treatment.

Method used

Combining the intestinal microbial knowledge graph and the Big Language Model (LLM), using Graph RAG technology to build an intestinal microbial intelligent question-and-answer system based on the knowledge graph. By combining retrieval and generation, it provides more accurate and interpretable answers and supports multi-hop Query and multi-level answers.

Benefits of technology

It significantly improves the knowledge coverage and information density of Q&A, can obtain intestinal microbial-related information more intuitively, supports in-depth answers to complex questions, enhances the applicability and query efficiency of the scientific research environment, and reduces knowledge blind spots.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226487A_ABST
    Figure CN119226487A_ABST
Patent Text Reader

Abstract

The invention provides an intelligent question-answering system for enteric microorganisms based on a knowledge graph and a large model, and intelligent question-answering in the field of enteric microorganisms is realized based on a Graph RAG technology by calling an available LLM through a constructed Keying enteric microorganism knowledge base. In the intelligent question-answering system for intestinal microorganisms, the knowledge richness of question-answering is remarkably improved. By combining the knowledge graph and the large language model (LLM), the system not only can provide direct knowledge points, but also can supplement context and background information and multi-level scientific interpretation, so that the answer content is richer and more comprehensive.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a RAG question-answering system based on an intestinal microbial knowledge graph. Background Art

[0002] The intestinal flora is a collection of trillions of microorganisms living in our intestines, including bacteria, viruses, fungi and protozoa, which form a complex symbiotic relationship with our bodies. Maintaining the balance and diversity of the intestinal flora is essential for our health. First, the intestinal flora plays a vital role in the digestion of food and nutrient absorption. They help break down complex carbohydrates that we cannot digest and produce beneficial substances such as short-chain fatty acids, which can be absorbed and utilized by our bodies. Secondly, the intestinal flora is closely related to our immune system. They help train and regulate immune cells, enhance our immunity, and prevent infections and inflammatory diseases. In addition, the intestinal flora is also closely related to our brain and nervous system. They affect our emotions, cognition and behavior by producing neurotransmitters and metabolites. Finally, the intestinal flora is also related to our weight management, cardiovascular health and cancer prevention.

[0003] With the rise and widespread application of high-throughput sequencing technology, the barriers to human microbiome research have been greatly broken, and multi-omics and clinical research on intestinal microorganisms are now in high demand. Many studies have carried out detailed experimental verification and in-depth analysis of various associations. However, current findings are still very limited, and more mysteries about the specific functional characteristics of intestinal microorganisms on human hosts and their mechanisms of action remain to be further explored and revealed. In order to gain a deeper insight into the impact of intestinal microorganisms on human health and disease, researchers should not only rely on traditional but time-consuming and labor-intensive experimental methods, and efficient but limited microbiome methods, but also focus more on the mining and application of biomedical big data. By integrating and analyzing massive amounts of biomedical data, we hope to reveal more complex and subtle associations between intestinal microorganisms and human health, thereby providing new ideas and strategies for disease prevention, diagnosis and treatment.

[0004] By building a gut microbiome knowledge base, we can obtain knowledge related to gut microbes more efficiently and accurately, thereby promoting the in-depth development and utilization of gut microbiome resources, improving research efficiency, promoting cross-institutional cooperation and resource sharing, and strengthening the standardization and normalization of research. However, the traditional database-based knowledge query method has certain limitations. Its form is relatively fixed and can usually only be retrieved in a specific format. To overcome this limitation, we need to combine the knowledge base with a large language model (LLM) to achieve more flexible and natural language interaction, thereby providing intelligent question-and-answer services in the field of gut microbes. This combination will enable researchers to obtain the required information in a more intuitive and convenient way, further accelerating the progress of gut microbiome research.

[0005] Generative LLMs have made significant progress in recent years. The latest models such as GPT-4o, OpenAI o1 and Claude 3.5 launched by companies such as OpenAI and Anthropic have demonstrated excellent performance. Domestic companies such as Baidu, Huawei and iFlytek have also launched their own LLMs. Meta has led the development of open source LLMs by launching the Llama series, which has been updated to version 3.2. Alibaba has also actively invested in open source LLMs and recently launched the Qwen2.5 model, which has brought new breakthroughs in the field of Chinese natural language processing.

[0006] Retrieval Augmented Generation (RAG) of Large Language Models is a method that combines retrieval and generation techniques to improve the performance of LLM in handling specific tasks. Before generating answers, RAG retrieves information related to the question from a large knowledge base, and then inputs this information into LLM together with the question to generate more accurate and explainable answers.

[0007] General RAG is based on natural language text paragraphs, while Graph RAG (Graph Retrieval Augmented Generation) is based on the structured knowledge organized by the knowledge graph to achieve an upgrade of RAG technology. First, Graph RAG can more accurately represent the connections and contextual information between entities, thereby enhancing the depth and contextual relevance of retrieved information and being able to handle more complex multi-hop queries; second, Graph RAG can provide more explainable answers based on the clear structure and relationships of the knowledge graph, and its reasoning process is traceable. Summary of the invention

[0008] An intelligent question-answering system for intestinal microorganisms based on knowledge graphs and large models is based on the intestinal microorganism knowledge base previously constructed by the applicant (see CN118506887A), calls available LLMs, and implements intelligent question-answering in the field of intestinal microorganisms based on Graph RAG technology.

[0009] According to the record of CN118506887A, the inventor provides a gut microbial knowledge graph system, including a gut microbial knowledge base, a gut microbial small molecule drug treatment-related knowledge base, and a clinical medicine database to construct a gut microbial knowledge graph, and a knowledge graph multimodal uncertain reasoning system using the gut microbial knowledge graph; the three knowledge bases of "gut microbial knowledge base", "gut microbial small molecule drug treatment-related knowledge base", and "clinical medicine database" are combined and constructed to dock, align small molecules, drugs and disease entities, obtain the final gut microbial knowledge graph, and use the knowledge graph multimodal uncertain reasoning system of the "gut microbial knowledge graph" to predict potential associated diseases, drugs, genes, etc. for gut microorganisms. The present invention, based on the above-mentioned gut microbial knowledge graph system, establishes a gut microbial intelligent question-answering system based on knowledge graphs and large models.

[0010] Before generating an answer, RAG retrieves information related to the question from a large-scale knowledge base, and then inputs this information and the question into LLM to generate a more accurate and explainable answer. The large-scale knowledge base can be the microbial knowledge graph provided by the inventor in CN118506887A. The present invention realizes an intelligent question-answering system in the field of intestinal microorganisms based on Graph RAG technology by combining knowledge graph and large language model (LLM).

[0011] The specific steps include: (1) After receiving the user's query, the user's recent conversation records are retrieved through the conversation context to rewrite the query and analyze it, and a rewritten query string is returned; (2) Receive the rewritten query string, call the large language model (LLM) to analyze the complexity of the rewritten query, disassemble the query as needed, and return a list containing query questions, with each question as an item in the list; (3) Extract the head entity and tail entity. Receive the generated question list, identify and extract the head entity and tail entity for each question, perform entity recognition, check entity integrity, summarize entity pairs, and return a nested list. (4) Determine the entity classification, perform classification mapping on the extracted head entity and tail entity lists based on the predefined knowledge graph classification values, mark special entities, and return a nested list; (5) Search: For the head and tail entity pairs generated in the previous step, perform keyword and / or embedding search to find entities that match or are similar to the entity. (6) Classification and generation of Cypher queries: Based on the matching head and tail entity pairs and classification information found, use LLM to generate corresponding query statements; define query parameters according to different entity classifications, and pass these parameters to LLM to generate suitable queries, and finally return a list containing the Cypher query statements generated for each entity pair; (7) Execute the query and integrate the results: Connect to the knowledge graph through the GraphDatabase class of the neo4j library, execute the Cypher query statements generated in the previous step one by one, and integrate the query results of each query in Neo4j into a unified structure so that the final answer can be generated later; (8) The integrated query results and the user’s original query are passed as context to LLM through Langchain’s StrOutputParser module to generate the final query answer.

[0012] In a specific embodiment The rewritten query is implemented using the ChatOllama interface in the LangChain framework.

[0013] The on-demand decomposition further means that if the query is a complex question, it is decomposed into multiple simple questions; if it is a simple question, the question is directly returned.

[0014] The entity integrity check means that if the head entity or tail entity of a simple question cannot be identified, a network search tool is called to search the question, and the search result is passed as a supplementary context to LLM to regenerate the head and tail entities.

[0015] Preferably, the original query can be searched by calling the LangChain Community library's web search tool TavilySearchResults, and the search results can be passed to the LLM as supplementary context; The classification mapping refers to using the predefined knowledge graph classification to classify each pair of head and tail entities using the LLM called by ChatOllama. For example, classification can be performed based on dimensions such as microbial species, disease types, corresponding drug types, intermediates, drug structures, indications, target genes, target proteins, biomarkers, metabolites, etc., but is not limited to the above classifications.

[0016] The marking of special entities means that for each head and tail entity pair, if one of the entities is a category or a category expressed semantically, it is marked using a corresponding different method, so as to distinguish between category entities and specific entities.

[0017] The returned nested list includes a list of head and tail entity pairs, and at least two nested lists of classification lists for each pair of entities.

[0018] The search preferably performs keyword search and / or embedded search for specific entities. In a specific implementation, the search step uses keyword matching to search in the knowledge graph. If the keyword match is successful, the entity is retained and the embedded search is skipped. If the match fails, the embedded search is performed. The embedded search uses a model to match similar entities. In a specific implementation, keyword search and embedded search are preferably skipped for category entities, and only the original entity is retained. In a specific implementation, if the embedded search does not find a match, a network search tool can be started as needed to search the original query and pass the result to LLM.

[0019] The query parameter refers to setting a specific maximum number of hops and / or paths according to the classification of each pair of entities.

[0020] The query statement preferably generates a corresponding Neo4j Cypher query statement using LLM, and further, LLM is called to generate a Cypher query through a pre-written prompt.

[0021] Integration refers to integrating all query results into a unified string or structured data. In a specific implementation, if the query results are complex, you can choose to integrate them by entity pair or classification. The integrated results can be in JSON format, XML format, TSV format, etc. The final query answer may be text, a list, a paragraph, a link, etc.; further, the answer is formatted and output, and finally presented in natural language.

[0022] Beneficial Effects

[0023] In the intestinal microbiome intelligent question-answering system, the knowledge richness of questions and answers has been significantly improved. By combining the knowledge graph and the large language model (LLM), the system can not only provide direct knowledge points, but also supplement the context, background information and multi-level scientific explanations, making the answer content richer and more comprehensive. Thanks to the use of Graph RAG technology, the system can cite structured knowledge related to the user's question when answering, and combine the text answers generated by the model to provide users with more detailed information support.

[0024] Internal tests show that among 100 typical questions, the answers generated by the system have improved knowledge coverage and information density by more than 40% compared with traditional methods. This increase in knowledge richness greatly enhances the user's knowledge acquisition experience, allowing the system to not only answer simple questions, but also provide in-depth and detailed answers to complex multidisciplinary problems. The system uses LLM to decompose complex problems and iteratively retrieves answers to each sub-question until the termination condition is reached. This decomposition reasoning process can reduce complexity and support multi-hop queries, enabling the system to better handle complex problems with strong correlations and multiple levels, such as disease-microbiome, microbiome-metabolite, metabolite-symptom. In order to improve the timeliness of queries, the system quickly matches relevant entities in the knowledge graph through a combination of keyword retrieval and embedded search to avoid retrieval delays caused by complex document structures. GraphRAG technology combines the structured information of the knowledge graph to make the reasoning path and the source of the answer clearly visible.

[0025] For example, the system can annotate the head and tail entities and corresponding relationships involved in each query step in the output, ensuring that each step is well documented and users can intuitively trace the reasoning path, further enhancing the applicability of the system in scientific research environments. The system supports the structured management of multidimensional information in the field of intestinal microorganisms by introducing multiple entity classification methods.

[0026] For example, the system can label the "drug" category as Drug*, and flexibly match multiple drug subsets for this category label through Cypher queries, making it more adaptable in complex queries and avoiding the need to manually configure each specific entity, thereby improving query efficiency. If the knowledge base cannot fully answer the user's question, the system can supplement the information through web searches (such as TavilySearchResults), pass the web data as context to LLM, and provide users with comprehensive answers. This strategy ensures the coverage of the system and effectively reduces the blind spots in question-answering caused by limited knowledge base data. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 A technical roadmap for intelligent question-answering in the field of intestinal microorganisms based on Graph RAG technology DETAILED DESCRIPTION

[0028] 1. The specific operation steps of the intelligent question-answering system for intestinal microorganisms based on Graph RAG technology involved in the present invention are as follows: 1 Receive user queries for analysis Receive the query entered by the user to obtain the user's conversation context, and retrieve the user's recent conversation records from the database through user_id.

[0029] (1) Processing flow a) Retrieve conversation records: query the database based on the user's user_id to obtain the user's most recent conversation records, which will serve as background information for understanding the user's current query; b) Rewrite query: Rewrite query will use the ChatOllama interface in the LangChain framework. LangChain is a Python framework for building language model-based applications, which simplifies the process of interacting with large language models (LLMs). LangChain provides a rich set of tools and interfaces. In LangChain, ChatOllama is an interface class for interacting with the Ollama series of large language models. This call to the large language model rewrites the query entered by the user. The purpose of the rewrite is to better understand the query intent and make it more clear and specific. This process will utilize the user's conversation context information to more accurately generate subsequent query steps.

[0030] (2) Input format a) Receive a user's query string, such as "I want to understand the relationship between disease X and drug Y", and obtain the user's conversation context b) At the same time, user_id is used as the user identifier to retrieve the corresponding conversation record.

[0031] (3) Output format Returns a rewritten query string, which will be used as input for the subsequent steps. This step will be performed by StrOutputParser in the LangChain framework. In the LangChain framework, StrOutputParser is a parser for processing language model output, helping to convert the text output generated by the model into a usable data format.

[0032] 2. Decomposing the query Receive the rewritten query in the first step and determine the complexity of the query. If the query is a complex question, break it down into multiple simple questions; if it is a simple question, return the question directly.

[0033] (1) Processing flow a) Analyze query complexity: Use the ChatOllama interface in the LangChain framework to call the Large Language Model (LLM) to analyze the rewritten query to determine its complexity. This can be based on factors such as the structure of the query and the number of entities involved; b) Decomposing complex queries: If a query is determined to be a complex problem, it is decomposed into multiple smaller simple problems so that they can be processed step by step; c) Keep simple queries as they are: If the query is determined to be a simple question, there is no need to further decompose it and the question is directly used as the output.

[0034] (2) Input format Receives a rewritten query string, such as "I want to understand the relationship between disease X and drug Y".

[0035] (3) Output format Returns a list of one or more query questions, with each question as an item in the list. For example, for complex queries, the output may be [Simple Question 1, Simple Question 2, …]; for simple queries, the output may be [Simple Question]. The output format will be constrained by the BaseModel class and Field helper function of the pydantic library. Here, pydantic is a Python library dedicated to data validation and data model definition, which can help developers easily define and validate structured data formats in Python. BaseModel is a core class, usually used as the base class of data models. By inheriting BaseModel, developers can define data models with type constraints, and pydantic will automatically verify whether the type and format of the input data conform to the definition. Field is an auxiliary function provided by pydantic to further refine the constraints of the field. Through Field, developers can specify default values, descriptions, maximum or minimum lengths, numerical ranges, and more constraints for fields.

[0036] 3 Extract the head entity and the tail entity Receive the simple question list generated in the second step, identify and extract the head entity and tail entity of each question. For questions where the head and tail entities cannot be identified, call the network search tool to supplement them to obtain relevant context and pass it to LLM.

[0037] (1) Processing flow a) Entity Recognition: For each simple question, use the ChatOllama interface to call LLM to identify the head entity (main starting point) and the tail entity (main target); b) Check entity integrity: If the head entity or tail entity of a simple question cannot be identified, call the network search tool to search for the question, and pass the search results as supplementary context to LLM to regenerate the head and tail entities; c) Summarize entity pairs: Output the head entity and tail entity of each simple question in pairs.

[0038] (2) Input format The input is a list of simple questions output by the second step, for example [Simple Question 1, Simple Question 2, …].

[0039] (3) Output format Returns a nested list containing the head entity and tail entity of each simple question. For example, [[head entity 1, tail entity 1], [head entity 2, tail entity 2], …]. The output format here will be constrained by the BaseModel class and Field auxiliary function of the pydantic library. ) 4. Determine entity classification Based on the head entity and tail entity extracted in the third step, determine the classification of each pair of entities. The classification needs to be based on the predefined knowledge graph classification values ​​(such as Disease, Drug, Human Gene, Human Protein). The classification value will be stored in the yaml file. If an entity itself is a category (such as Drug) or semantically expresses a category (such as drug category), the classification of the entity will be marked as Drug*, indicating that it is a category label rather than a specific entity.

[0040] (1) Processing flow a) Classification mapping: Using the predefined knowledge graph classification, each pair of head and tail entities is classified using the LLM called by ChatOllama. The specific classification values ​​include Disease, Drug, Human Gene, and Human Protein; b) Marking special entities: For each head-tail entity pair, if one of the entities is a category (e.g., Drug) or a semantically expressed category (e.g., drug category), it is marked as Drug*. For example, if the tail entity is a "drug" category, its classification should be Drug*. For specific entities, such as "aspirin", it should be marked as Drug to indicate a specific entity; c) Output classification results: Summarize each pair of head and tail entities and their corresponding classification information to form two lists: one is a list of head and tail entity pairs, and the other is a corresponding classification list.

[0041] (2) Input format The input is a list of head and tail entity pairs output by the third step, for example [[head entity 1, tail entity 1], [head entity 2, tail entity 2], … ].

[0042] (3) Output format a) Returns two nested lists: one is a list of head and tail entity pairs, for example [ [head entity 1, tail entity 1], [head entity 2, tail entity 2], … ].

[0043] b) Another is a categorical list of each pair of entities, for example [[Disease, Drug], [Human Gene, HumanProtein], …], or [[Disease, Drug*], [Human Gene, HumanProtein], …] if it contains categorical entities. The output format will be constrained by the BaseModel class and Field helper function of the pydantic library.

[0044] 5 Search For the head and tail entity pairs generated in step 4, perform keyword and embedding searches for the entities not marked with * to find entities that match the entity. If the keyword search does not find a match, use the embedding search to find items similar to the entity in the knowledge graph. For entities marked with *, skip the keyword and embedding search for the entity, but continue to search for the other entities in the entity pair.

[0045] (1) Processing flow a) Skip entities marked with *: For each pair of head and tail entities, if an entity is marked with * (indicating that the entity is a category entity and is tagged with a category), skip the keyword and embedding search for the entity and only keep the original entity. At this time, only the other unmarked entity is matched; b) Keyword search: For entities without a * mark, first try to find the corresponding entity in the knowledge graph using keyword matching. If the keyword matches successfully, keep the entity and skip the embedding search; if the keyword does not find a match, proceed to the next step; c) Embedding search: When no results are found for keyword matching, use the OpenAIEmbeddings class, or call the embedding model through ChatOllama to generate embeddings for the entity and find the entity with the most similar embedding in the knowledge graph; d) Embedded search will return the first y matching entities whose similarity to the target entity is higher than the set threshold x, where the specific values ​​of x and y need to be defined according to the actual application; e) Calling a web search tool (if necessary): If the embedded search also fails to find a match, the original query is searched by calling the LangChain Community library's web search tool TavilySearchResults, and the search results are passed to the LLM as supplementary context to assist it in identifying and understanding entities. The main function of the TavilySearchResults class or interface is to process the results obtained from the Tavily search engine. Typically, when a language model needs to refer to an external data source (for example, to find specific information or documents), LangChain can use Tavily for real-time search. TavilySearchResults standardizes and formats the raw data returned by Tavily for ease of model processing or application use.

[0046] (2) Input format The input is two lists output by the fourth step: a list of head and tail entity pairs (for example, [[head entity 1, tail entity 1], [head entity 2, tail entity 2], …]) and a list of categories (for example, [[Disease, Drug], [Human Gene, HumanProtein], …] or [ [Disease, Drug*], [Human Gene, Human Protein], …]).

[0047] (3) Output format a) Returns a nested list containing the matching entity pairs found (possibly with multiple matches). For example, if multiple matching entities are found, the output may be: [[head entity 1.a, tail entity 1.a], [head entity 1.b, tail entity 1.b], [head entity 2.a, tail entity 2.a], … ]; b) Returns a corresponding classification list, such as [ [Disease, Drug], [Disease, Drug], [Human Gene, Human Protein], …]. The output format will be constrained by the BaseModel class and Field helper function of the pydantic library.

[0048] 6 Classification and Generation of Cypher Queries Based on the matching head and tail entity pairs and classification information found in step 5, LLM is used to generate the corresponding Neo4jCypher query statements. According to different entity classifications, the maximum number of hops and the number of paths are defined, and these parameters are passed to LLM to generate appropriate queries.

[0049] (1) Processing flow a) Define query parameters: Set specific maximum hops and paths for each pair of entities according to their classification. For example, for the entity pair classified as [Human Gene, Human Protein], set the maximum hops to 5 and the maximum paths to 20; for the entity pair classified as [Disease, Drug], set the maximum hops to 3 and the maximum paths to 15; for the entity pair classified as [Disease, Drug*], set the maximum hops to 2 and the maximum paths to 100; b) Generate Cypher query: Use these parameters and the classification information of entity pairs to generate Cypher query by calling LLM through a pre-written prompt; c) Processing of category label entities: If one of the head and tail entity pairs is a category label (i.e. marked with *), the category label is used as a matching condition when generating a Cypher query. For example, if the tail entity is the category label Drug*, the Cypher query will target the specific head entity, while the tail entity can be any value in the category.

[0050] (2) Input format The input is two lists output by the fifth step: a list of matching entity pairs (for example, [ [head entity 1.a, tail entity 1.a], [head entity 1.b, tail entity 1.b], [head entity 1.b, tail entity 1.b], … ]) and a list of categories (for example, [[Disease, Drug], [Disease, Drug], [Human Gene, Human Protein], … ]).

[0051] (3) Output format Returns a list containing the Cypher query statements generated for each entity pair. For example, [cypher1,cypher2, cypher3, …], each query corresponds to an entity pair and its classification. The output format will be constrained by the BaseModel class and Field helper function of the pydantic library.

[0052] 7 Execute the query and integrate the results Connect to the knowledge graph through the GraphDatabase class of the neo4j library, execute the Cypher query statements generated in the sixth step one by one, and integrate the query results of each query in Neo4j into a unified structure so as to generate the final answer later.

[0053] (1) Processing flow a) Execute Cypher query: For each Cypher query statement generated in step 6, execute it one by one in the Neo4j database and obtain the query results. The information returned by each query will be temporarily stored for subsequent processing; b) Integrate query results: Integrate all query results into a unified string or structured data (such as JSON format). If the query results are complex, you can choose to integrate them by entity pairs or categories to make them easier to read and understand; c) Error handling: During the query process, if a query fails (such as timeout and no results), the error information is recorded and other queries are processed to ensure that the final result is as complete as possible.

[0054] (2) Input format Enter the Cypher query list generated for step 6, for example [cypher1, cypher2, cypher3, … ].

[0055] (3) Output format Define and return an integrated string or structured data containing all the queried information through Langchain's PromptTemplate module and pydantic library. For example: {"results": [ { "query": "cypher1", "data": "result 1"}, { "query": "cypher2", "data": "result 2"}, ... ]}.

[0056] 8 Generate the final result The query results integrated in step 7 and the user's original query are passed to LLM as context through Langchain's StrOutputParser module to generate the final query answer. LLM will generate a natural language answer or explanation based on the query results and the user's original intention.

[0057] In the LangChain framework, StrOutputParser is a parser used to process language model output, helping to convert the text output generated by the model into a usable data format.

[0058] (1) Processing flow a) Passing context information: The integrated query results and the user's original query are passed as input to LLM. LLM will generate the final answer based on the query results and context information; b) Generate answers: LLM generates clear and coherent answers based on the context and the user's query. The answer can be a simple conclusion and detailed explanation, or a summary of information in multiple parts; c) Formatted output: Depending on the specific needs, the answers generated by LLM can be output in a variety of formats such as text, lists, and paragraphs. If necessary, format the output to ensure that it is easy to understand and use.

[0059] (2) Input format The input is the integrated query result in JSON format from step 7 and the user's original query.

[0060] (3) Output format Return a final natural language answer that explains the query result and meets the user's original needs. For example: "According to your query, the relationship between disease X and drug Y is as follows: ..."

[0061] 2. Comparison of Dialogue Examples The following exemplary questions are used to demonstrate the detailed answers given by the Graph RAG intelligent question-answering system of the present invention to user questions, and are compared with the answers given by a common question-answering system that does not include the Graph RAG computing language of the present invention.

[0062] The following only shows Chinese and English questions and answers, but it is not limited to English. As long as it is a language that can be processed by a computer, it is within the scope of protection and can present the same question and answer effect.

[0063] (1) "Which small molecules does the HSD17B4 gene regulate?" Answer (based on Graph RAG): The HSD17B4 gene regulates several small molecules, including valproate sodium salt, ribose 5-triphosphate compounds, a certain benzamide variant, and glucocorticoids (drug metabolites of prednisone).

[0064] After examining the background provided, it became apparent that the HSD17B4 gene interacts with a variety of small molecules. These include valproate sodium salt, a compound used to treat epilepsy and bipolar disorder. It also interacts with ribose 5-triphosphate compounds, a molecule that plays an important role in a variety of biological processes, including RNA synthesis and energy metabolism. In addition, it interacts with a certain type of benzamide, an organic compound that often acts as a building block in organic synthesis. Finally, it interacts with glucocorticoids, a type of steroid hormone that reduces inflammation and suppresses the immune system. This particular glucocorticoid is a drug metabolite of prednisone, a drug commonly used to treat inflammatory conditions such as arthritis and severe allergies.

[0065] Answer (not based on Graph RAG): The HSD17B4 gene regulates the metabolism of small molecules called steroids, specifically sex hormones such as testosterone and estradiol.

[0066] (2)'HSD17B4 gene regulates which small molecules?' ANS_WITH_Graph RAG: The HSD17B4 gene regulates several small molecules, including thesodium salt of valproic acid, a ribose 5-triphosphate compound, a certain benzamide variant, and a glucocorticoid which is a drug metabolite ofprednisone. Upon examining the provided context, it is evident that the HSD17B4gene interacts with a variety of small molecules. These include the sodiumsalt of valproic acid, a compound involved in the treatment of epilepsy andbipolar disorder. It also interacts with a ribose 5-triphosphate compound, amolecule that plays a significant role in several biological processes,including RNA synthesis and energy metabolism. Additionally, it interactswith a certain type of benzamide, which is an organic compound that oftenserves as a building block in organic synthesis. Lastly, it interacts with aglucocorticoid, a type of steroid hormone that can reduce inflammation andsuppress the immune system. This particular glucocorticoid is a drugmetabolite of prednisone, a medication commonly used to treat inflammatoryconditions like arthritis and severe allergies. ANS_WITHOUT_Graph RAG: The HSD17B4 gene regulates small molecules known as steroids, specifically regulating the metabolism of sex hormones such as testosterone and estradiol. (3) “What are the diseases associated with the ACE2 gene?” Answer (based on Graph RAG): The ACE2 gene has been linked to a variety of diseases, including liver cancer, hepatocellular carcinoma, myocardial cancer, infarction, leiomyoma, early pregnancy problems, and squamous cell carcinoma.

[0067] Reference to the background provided: The gene ACE2 shows interactions with other genes such as SLC7A8 and SLC43A2 and has been identified as a biomarker for diseases including hepatocellular carcinoma, myocardial infarction, leiomyoma, problems related to early pregnancy, and squamous cell carcinoma. Other related genes such as ECE2, ACOT2, and ACE have also been associated with various diseases including cervical malignancy, cervical cancer, colorectal cancer, type 2 diabetes, pneumonia, lung parenchymal inflammation, granulomatosis with polyangiitis, focal segmental glomerulosclerosis, color blindness, DEUTAN series, and arthritis, juvenile. Meanwhile, the gene CES2 shows interactions with PTGDR and is associated with diseases such as rhinitis, allergies, and central neuroblastoma.

[0068] Answer (not based on Graph RAG): The ACE2 gene has been linked to a variety of diseases. Most notably, it is of importance in Covid-19 because the virus uses ACE2 as a receptor to enter cells. In addition, variations in the ACE2 gene have been linked to cardiovascular disease, particularly high blood pressure, as well as diabetes.

[0069] (4) 'what are the disease associated with gene ACE2?' ANS_WITH_Graph RAG: The ACE2 gene has been associated with a variety of diseases,including Carcinoma, Hepatocellular, Myocardial Infarction, Leiomyoma, earlypregnancy issues, and Carcinoma, Squamous Cell. Upon referring to the provided context: The gene ACE2 showsinteraction with other genes such as SLC7A8 and SLC43A2 and has beenidentified as a biomarker in diseases including Hepatocellular Carcinoma,Myocardial Infarction, Leiomyoma, issues related to early pregnancy, andSquamous Cell Carcinoma. Other connected genes such as ECE2, ACOT2, and ACEare also associated with various diseases, including Malignant tumor ofcervix, Cervix carcinoma, Colorectal Cancer, Diabetes Mellitus, Type 2,Pneumonitis, Pneumonia, Granulomatosis With Polyangiitis, Focal SegmentalGlomerulosclerosis, COLORBLINDNESS, DEUTAN SERIES, and Arthritis, Juvenile.Meanwhile, gene CES2 shows interaction with PTGDR and is associated withdiseases like Rhinitis, Allergic, and Central neuroblastoma, among others. ANS_WITHOUT_Graph RAG: The ACE2 gene has been associated with several diseases. Mostnotably, it is significant in Covid-19 as the virus uses ACE2 as a receptor to enter cells. Additionally, variations in the ACE2 gene have been implicated in cardiovascular disease, particularly hypertension, as well as diabetes. (5)“Which genes are associated with high blood pressure?” Answer (based on Graph RAG): Several genes have been associated with hypertension, including EDN2 (endothelin 2), RELA (RELA proto-oncogene, NF-kB subunit), PITX2 (paired homeodomain 2), MAZ (MYC-associated zinc finger protein), HSF1 (heat shock transcription factor 1), COMT (catechol-O-methyltransferase), SNCA (synuclein alpha), SNAP29 (synaptosome-associated protein 29), SNAP25 (synaptosome-associated protein 25), SNAP23 (synaptosome-associated protein 23), WNK4 (WNK Lysine-deficient protein kinase 4), COA3 (cytochrome c oxidase assembly factor 3), SLC12A3 (solute carrier family 12 member 3), SGK1 (serum / glucocorticoid-regulated kinase 1), RUNX1 (dwarf-related transcription factor 1), ALOX12 (arachidonic acid 12 lipoxygenase, type 12S), SLC27A5 (solute carrier family 27 member 5), PRMT1 (protein arginine methyltransferase 1), PLB1 (phospholipase B1), and PLA2G4B (phospholipase A2 group IVB).

[0070] Answer (not based on Graph RAG): Various genes are thought to be involved in hypertension, including genes for AGT (angiotensinogen), ACE (angiotensin-converting enzyme), NOS3 (nitric oxide synthase 3), and various sodium channels. The exact role and impact of these genes on hypertension can vary and often involve complex interactions with environmental factors.

[0071] (6)'Which genes are involved in hypertension?' ANS_WITH_Graph RAG: Several genes have been associated with hypertension, including EDN2(endothelin 2), RELA (RELA proto-oncogene, NF-kB subunit), PITX2 (paired likehomeodomain 2), MAZ (MYC associated zinc finger protein), HSF1 (heat shocktranscription factor 1), COMT (catechol-O-methyltransferase), SNCA (synucleinalpha), SNAP29 (synaptosome associated protein 29), SNAP25 (synaptosomeassociated protein 25), SNAP23 (synaptosome associated protein 23), WNK4 (WNKlysine deficient protein kinase 4), COA3 (cytochrome c oxidase assemblyfactor 3), SLC12A3 (solute carrier family 12 member 3), SGK1 (serum / glucocorticoid regulated kinase 1), RUNX1 (runt related transcription factor1), ALOX12 (arachidonate 12-lipoxygenase, 12S type), SLC27A5 (solute carrierfamily 27 member 5), PRMT1 (protein arginine methyltransferase 1), PLB1(phospholipase B1), and PLA2G4B (phospholipase A2 group IVB). ANS_WITHOUT_Graph RAG: Various genes are thought to be involved in hypertension including AGT (angiotensinogen), ACE (angiotensin-converting enzyme), NOS3 (nitricoxide synthase 3), and genes for various sodium channels. The exact role and impact of these genes on hypertension can vary and often involves complexinteraction with environmental factors. For the above answers, we compared the knowledge richness of the answers based on the following three aspects: (1) Entity types and numbers as a measure of richness: Especially in the fields of bioinformatics and medicine, the diversity of entities (such as genes, drugs, diseases, small molecules, etc.) can often illustrate the depth and breadth of the answer; (2) Number and diversity of relationships: The more relationships between entities (such as gene-disease, gene-drug relationships), the richer the answer is in describing biological networks or interactions. Different types of relationships (such as "regulation" and "metabolic effect") also increase the richness of the answer. A deep learning-based model (RoBERTa) will be used for evaluation, which performs well in NER tasks and is particularly suitable for identifying professional terms in customized fields (such as biology and medicine). Named Entity Recognition (NER) is a natural language processing technology used to identify specific entities (such as names of people, places, time, organizations, genes, diseases, etc.) from text; (3) Depth of knowledge level: Analyze the depth of the information level in the answer. For example, the basic information level (such as "Gene A regulates molecule B") and the extended information level (such as "The specific role or therapeutic use of molecule B"). Depth scoring: Some answers will explain in depth the function, metabolic process or pharmacological effect of a certain entity. If an answer goes into more detailed biological processes, mechanisms of action or molecular functions, it means that it can provide a deeper level of knowledge.

Claims

1. An intelligent question-answering system for intestinal microorganisms based on knowledge graph and large model, comprising the following steps: (1) After receiving the user's query, the user's recent conversation records are retrieved through the conversation context to rewrite the query and analyze it, and a rewritten query string is returned; (2) Receive the rewritten query string, call the large language model (LLM) to analyze the complexity of the rewritten query, disassemble the query as needed, and return a list containing query questions, with each question as an item in the list; (3) Extract the head entity and tail entity. Receive the generated question list, identify and extract the head entity and tail entity for each question, perform entity recognition, check entity integrity, summarize entity pairs, and return a nested list. (4) Determine the entity classification, perform classification mapping on the extracted head entity and tail entity lists based on the predefined knowledge graph classification values, mark special entities, and return a nested list; (5) Search: For the head and tail entity pairs generated in the previous step, perform keyword and / or embedding search to find entities that match or are similar to the entity. (6) Classification and generation of Cypher queries: Based on the matching head and tail entity pairs and classification information found, use LLM to generate corresponding query statements; define query parameters according to different entity classifications, and pass these parameters to LLM to generate suitable queries, and finally return a list containing the Cypher query statements generated for each entity pair; (7) Execute the query and integrate the results: Connect to the knowledge graph through the GraphDatabase class of the neo4j library, execute the Cypher query statements generated in the previous step one by one, and integrate the query results of each query in Neo4j into a unified structure so that the final answer can be generated later; (8) The integrated query results and the user’s original query are passed as context to LLM through Langchain’s StrOutputParser module to generate the final query answer.

2. According to the system of claim 1, the rewriting query is implemented using the ChatOllama interface in the LangChain framework.

3. According to the system of claim 1, the on-demand decomposition further means that if the query is a complex question, it is decomposed into multiple simple questions; if it is a simple question, the question is directly returned.

4. According to the system of claim 1, the checking entity integrity means that if the head entity or tail entity of a simple question cannot be identified, a network search tool is called to search for the question, and the search results are passed as supplementary context to the LLM to regenerate the head and tail entities.

5. The system according to claim 4 can search the original query by calling the network search tool TavilySearchResults of the LangChain Community library, and pass the search results to the LLM as supplementary context.

6. According to the system of claim 1, the classification mapping refers to using a predefined knowledge graph classification to classify each pair of head and tail entities using the LLM called by ChatOllama.

7. According to the system of claim 1, the marking of special entities means that for each head and tail entity pair, if one of the entities is a category or a category expressed semantically, it is marked using corresponding different methods, so as to distinguish between category entities and specific entities.

8. According to the system of claim 1, the returned nested list comprises a list of head and tail entity pairs, and at least two nested lists of classification lists for each pair of entities.

9. According to the system of claim 1, the search performs keyword search and / or embedded search for specific entities. Preferably, the search step uses keyword matching to search in the knowledge graph. If the keyword match is successful, the entity is retained and the embedded search is skipped. If the match fails, the embedded search is performed. The embedded search uses a model to match similar entities. More preferably, keyword search and embedded search are preferably skipped for category entities, and only the original entity is retained. More preferably, if the embedded search does not find a match, the network search tool can be started as needed to search the original query and pass the result to LLM.

10. The system according to claim 1, wherein the query parameter is to set a specific maximum number of hops and / or paths according to the classification of each pair of entities.

11. The system according to claim 1, wherein the query statement preferably uses LLM to generate a corresponding Neo4jCypher query statement, and preferably, a pre-written prompt is used to call LLM to generate a Cypher query.

12. The system according to claim 1, wherein the integration is to integrate all query results into a unified string or structured data. If the query results are relatively complex, the integration is performed by entity pairs or classification blocks as needed.

Citation Information

Patent Citations

  • Intestinal microorganism knowledge graph system

    CN118506887A

  • Disease question-answering method, system and device based on knowledge graph and storage medium

    CN115438162A

  • Intelligent text information processing system

    CN115455935A

  • Knowledge graph construction method and device and readable storage medium

    CN116955634A

  • Bridge management and cultivation question-answering method based on cooperation of large model and knowledge graph

    CN118410145A

Cited By

  • Human-computer interaction method, computing device, server, storage medium and program product

    CN120123501A

  • Microbial secondary metabolite retrieval method based on knowledge graph

    CN121478844A

  • A knowledge graph-based microbial secondary metabolite retrieval method

    CN121478844B