RAG method of knowledge graph enhanced by iterative search reasoning based on introspection mechanism
By combining iterative retrieval reasoning and Self-RAG introspection techniques, a knowledge graph is constructed, which solves the problems of incomplete information and inaccurate reasoning in large-scale pre-trained models in complex tasks, and achieves more efficient and accurate answer generation, which is applicable to fields such as intelligent question answering and decision support.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-10
- Publication Date
- 2026-04-07
AI Technical Summary
Existing large-scale pre-trained models suffer from incomplete information, broken reasoning chains, or inaccurate answers when faced with complex reasoning, multi-domain question answering, or tasks requiring external knowledge supplementation, especially in demanding scenarios such as technical document question answering, medical diagnosis, and legal reasoning.
It introduces iterative retrieval reasoning technology and Self-RAG introspection technology. Through chain reasoning mechanism, it conducts multi-round retrieval and self-feedback mechanism, combines knowledge graph to build introspection mechanism, gradually expands knowledge acquisition path, and evaluates the relevance and support of generated content through introspection tagging.
It improves the knowledge coverage and generation quality in complex tasks, ensuring the coherence and accuracy of answers, and is suitable for scenarios such as intelligent question answering systems, technical document parsing, and intelligent decision support.
Smart Images

Figure CN120216732B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence and natural language processing technology, specifically to the knowledge graph RAG method based on introspection mechanism-enhanced iterative retrieval and reasoning. Background Technology
[0002] In the fields of artificial intelligence and natural language processing (NLP), the rapid development of large-scale pre-trained models in recent years has led to unprecedented performance in tasks such as text generation, question answering systems, and knowledge reasoning. However, despite their powerful language understanding and generation capabilities, these models primarily rely on training data for their knowledge base. This results in incomplete information, broken reasoning chains, or inaccurate answers when faced with complex reasoning, multi-domain question answering, or tasks requiring external knowledge supplementation. This limitation becomes a significant factor affecting model performance and generalization ability in practical applications, especially in scenarios with extremely high requirements for knowledge rigor and completeness, such as technical document question answering, medical diagnosis, and legal reasoning. Existing models may generate answers with missing technical details or omitted key steps.
[0003] To address this issue, Retrieval-Enhanced Generation (RAG) technology has emerged. RAG combines knowledge retrieval with a generative model, dynamically invoking external knowledge bases during the generation process. Retrieved information serves as supplementary context, enhancing the model's knowledge coverage and generation quality. This approach effectively avoids the limitations of models generating answers solely based on internal parameters, significantly improving the accuracy of answers to complex questions. However, traditional RAG systems mostly rely on static knowledge bases for single-round retrieval, directly inputting the results into the generative model for answer generation. While this method performs well in simple question-answering scenarios, it often falls short in complex tasks requiring multi-step reasoning or multi-level knowledge connections. Static retrieval mechanisms can lead to incomplete information acquisition, failing to fully capture the multi-dimensional features of the question, thus affecting the completeness and accuracy of the final generated results.
[0004] Knowledge graphs, as a structured representation of knowledge, have been widely applied in various fields in recent years, especially in natural language understanding and reasoning tasks. Unlike traditional text data, knowledge graphs represent information through explicit entities and relationships, enabling machines to reason and query complex world knowledge. Introducing knowledge graphs into RAG systems can significantly improve the accuracy and diversity of retrieval, especially in tasks requiring explicit entity and relationship reasoning, where knowledge graphs can provide more accurate and rigorous answers.
[0005] To address the aforementioned issues, iterative retrieval and reasoning techniques have been proposed to further enhance the retrieval capabilities and information completeness of RAG systems in complex reasoning tasks. Its core lies in introducing a chain-like reasoning mechanism, simulating the step-by-step reasoning process humans use to solve complex problems through multiple rounds of retrieval and progressively expanding the retrieval scope. The specific process includes: first, performing an initial retrieval based on the user's question to obtain preliminarily relevant document paragraphs; then, the model generates an intermediate reasoning (CoT) based on the retrieved information, using this CoT as a new retrieval query to further expand the retrieval scope and continuously obtain more relevant paragraphs. This process iterates until the retrieval results meet the knowledge requirements of the question or reach a predetermined termination condition. In this way, iterative retrieval and reasoning ensures that the model can progressively improve the knowledge acquisition path in complex problems, avoiding information loss or retrieval bias caused by the limitations of single-round retrieval, and making the final answer generated by the model more coherent and comprehensive.
[0006] While iterative retrieval reasoning improves information coverage and relevance during the retrieval process, the answers generated by generative models based on multiple rounds of retrieval results may still suffer from uncertainty or incomplete reasoning chains. This is because the generation process relies on the content of an existing knowledge base, which itself may have knowledge gaps or uncovered areas. Therefore, to further improve the accuracy and completeness of the generated results, the Self-RAG introspection technique is introduced.
[0007] Self-RAG, building upon traditional RAG and iterative retrieval inference, adds a self-feedback mechanism. This technology allows the retrieved paragraphs and its own generated content to reflect on their content using special markers (reflection markers). Generating these reflection markers enables the language model to perform controlled operations during the inference phase, allowing its behavior to be customized according to different task requirements. Self-RAG introspection technology gives the generative model better task adaptability, stronger factual accuracy, and greater realism when handling complex tasks, ensuring that the final output more closely reflects actual needs.
[0008] In summary, the inventors proposed a knowledge graph RAG method that integrates iterative retrieval and reasoning techniques with Self-RAG introspection. This method aims to comprehensively improve the model's reasoning ability and generation quality in complex tasks by constructing a knowledge graph and combining chained multi-turn retrieval with a self-feedback mechanism. In practical applications, this method not only effectively addresses the shortcomings of traditional RAG systems in multi-turn reasoning tasks but also plays a crucial role in scenarios such as intelligent question answering systems, technical document parsing, and intelligent decision support, providing an efficient and reliable solution for large-scale knowledge question answering and complex reasoning tasks. Summary of the Invention
[0009] To address the issues of knowledge gaps, uncertainties, and incomplete reasoning steps that may exist in existing retrieval-enhanced generation techniques, this invention provides a knowledge graph RAG method based on an introspection mechanism that enhances iterative retrieval and reasoning. By combining iterative retrieval and reasoning techniques and Self-RAG techniques from the RAG enhancement method, and utilizing chain reasoning and self-reflection mechanisms, it improves the efficiency and accuracy of large-scale knowledge graph retrieval and generation models in complex reasoning tasks.
[0010] To achieve the above objectives, the present invention adopts the following technical solution: a knowledge graph RAG method based on introspection mechanism for iterative retrieval and reasoning enhancement, comprising the following steps:
[0011] Step 1: Construction of the Knowledge Graph
[0012] Collect and clean multi-source heterogeneous data and preprocess the data through natural language processing. Then, identify entities from the text through named entity recognition, extract the relationships between entities to construct triples (h,r,e), where h is the head entity, r is the relation, and e is the tail entity.
[0013] The semantic vector v for each entity is generated using the Sentence-BERT model. i , represented as: v i =Sentence-BERT(h), v i The data is stored in entities. At the same time, a knowledge graph is constructed based on triples, the Leiden algorithm is used to identify the community structure of entities, and the BERT language model is used to generate community summaries.
[0014] Step 2: Perform retrieval based on iterative retrieval reasoning techniques
[0015] The initial question Q0 input by the user is processed by Named Entity Recognition to extract entities from the question. The extracted entities are then retrieved from a graph database. The initial question Q0 is encoded using the Sentence-BERT model to obtain the query vector q. The semantic vector v of each entity is then calculated. i Based on the similarity score, K entities are initially retrieved. Searcher R K Returns at most K entities, represented as
[0016] The process involves multiple rounds of iterative retrieval and reasoning until the termination condition is met. In each iteration, a chained reasoner T is first used in conjunction with the current problem Q. i and the retrieved entity P i K The information carried is used to generate a new CoT sentence C. iThe reasoning summary used to address the current question and the retrieved paragraph is represented as C. i =T(P i K Q i ), and the CoT sentence C i As a new question query Q i+1 , represented as Q i+1 =NextQuery(C i Using the search engine R K Retrieving information related to Q from a knowledge graph i+1 The K most relevant entities are represented as The iterative retrieval and reasoning algorithm is then expressed as:
[0017]
[0018] In the formula, n represents the maximum number of iterations;
[0019] Step 3: Enhance generation based on the Self-RAG introspection algorithm
[0020] For the generative model, based on the K retrieved paragraphs and the question, K continuations are generated at each timestamp t, and the K continuations are scored. The output of the highest-scoring continuation is selected as the final result.
[0021] In evaluating the quality f(y) of each continuation t When considering the generation probability p(y, d, Critique), the probability of this segment being generated is taken into account. t |x,d,y<t), and introduce the critical score S(Critique), where y t d represents the currently generated candidate paragraph, d represents the relevant knowledge retrieved from the knowledge graph, x represents the initial question Q0, and y represents the content generated before timestamp t. The calculation formula is as follows:
[0022] f(y t ,d,Critique)=p(y t |x,d,y<t)+S(Critique)
[0023] In the generative model, by introducing introspection tokens as marker tokens, the generative model will give the generation probability of each token in the logprobs, and calculate the critique score S based on these probabilities.
[0024] Step 4: Constructing an Iterative Retrieval and Reasoning Knowledge Graph (RAG) Framework with an Introspection Mechanism
[0025] By combining iterative retrieval and reasoning techniques with the Self-RAG introspection algorithm, a novel knowledge graph RAG framework is constructed. Knowledge fragments are obtained through iterative retrieval and reasoning, and the generation process is optimized through the Self-RAG introspection algorithm. The optimal continuation is selected as the output to generate the final answer.
[0026] Furthermore, in step one, when constructing the knowledge graph, statements or attribute information about entities are added to the triples to enrich the structured knowledge, and this structured knowledge is stored in the Neo4j graph database. In the knowledge graph, nodes represent entities, edges represent relations, and triples and their additional information are stored as attributes of nodes and edges.
[0027] Furthermore, the termination conditions for the multi-round iterative retrieval and reasoning process in step two are divided into two types:
[0028] Condition 1: Set a maximum number of iterations. If the maximum number of iterations is not reached, continue to the next round of iterations. If the maximum number of iterations is reached, stop iterating.
[0029] Condition 2: After each iteration, generate the current CoT sentence C. i And the CoT sentence C from the previous round i-1 The two CoT sentences are converted into semantic vectors by the pre-trained model Sentence-BERT. The similarity between the two semantic vectors is determined by calculating the distance between them using the Euclidean distance formula. If the Euclidean distance is less than a preset threshold, the iteration stops.
[0030] Furthermore, in step three, the formula for calculating the critical score S is as follows:
[0031]
[0032] In the formula, G represents the critique marker group, W G This represents the weight hyperparameter for each critique tag group. This represents the score for each critical marker group within the timestamp t.
[0033] Furthermore, the aforementioned The calculation formula is as follows:
[0034]
[0035] In the formula, This represents the most desired reflection marker within timestamp t. The probability of occurrence, P t (r i N represents the probability of generating all possible tags within timestamp t. G The number of reflective markers in the critical marker group.
[0036] Compared with the prior art, the beneficial effects of the present invention are:
[0037] 1. Enhanced retrieval quality and accuracy: In traditional retrieval methods, the retrieval process may lack sufficient relevance and easily retrieve incomplete information. This invention introduces iterative retrieval reasoning technology, which alternates between recursive reasoning and retrieval to obtain more relevant and complete information. Through multiple rounds of retrieval and reasoning, irrelevant or one-sided information is effectively avoided, improving the relevance and completeness of retrieval results. In addition, by generating CoT sentences and using them as the basis for subsequent queries, the breadth of information can be expanded, which helps to understand the problem more comprehensively from multiple perspectives, thereby improving the accuracy of the answer.
[0038] 2. Enhancement of Reasoning and Generation Process: Traditional generative models are prone to producing inaccurate or incomplete answers during the generation process. This invention adopts the Self-RAG introspection algorithm, which evaluates the quality of each generated paragraph through a critical scoring mechanism. It combines generation probability and critical tags (such as support, usability, etc.) for evaluation, thereby improving the accuracy and factuality of the generated content. In addition, by introducing introspection tokens, the model can perform reflective evaluation to ensure that the generated content is not only logical but also meets diverse needs, thereby optimizing the generation process.
[0039] 3. Progressive Information Integration: In multi-step reasoning tasks, models face the problem of insufficient knowledge or inaccurate reasoning. This invention combines iterative retrieval reasoning technology with Self-RAG, enabling the generative model to continuously improve information based on each reasoning and retrieval, gradually approaching the correct answer. The alternation of chain reasoning and generation effectively avoids the problems of knowledge gaps and incomplete information, ensuring the accuracy of the reasoning process and the reliability of the answer. Attached Figure Description
[0040] Figure 1 This is an architectural diagram of the method of the present invention;
[0041] Figure 2 This is a schematic diagram of the method of the present invention;
[0042] Figure 3 This is a result diagram from Example 1;
[0043] Figure 4 This is a result diagram of Example 2. Detailed Implementation
[0044] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the invention, not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0045] like Figures 1-2 As shown, the knowledge graph RAG method based on introspection mechanism and iterative retrieval reasoning enhancement includes the following steps:
[0046] Step 1: Construction of the Knowledge Graph
[0047] To ensure data quality, multi-source heterogeneous data (such as technical documents, papers, and forum Q&A) is collected and cleaned. Natural Language Processing (NLP) techniques are used for data preprocessing. Then, Named Entity Recognition (NER) is used to identify entities from the text and extract relationships between entities to construct triples (h, r, e), where h is the head entity, r is the relation, and e is the tail entity. A semantic vector v for each entity is generated using the Sentence-BERT model. i , represented as: v i =Sentence-BERT(h), where v i It is a high-dimensional vector, which represents v i The information is stored in the entity. At the same time, statements or attribute information about the entity are attached to the triples to enrich the structured knowledge. This structured knowledge is then stored in the Neo4j graph database to construct a knowledge graph. In the knowledge graph, nodes represent entities, edges represent relations, and triples and their attached information are stored as attributes of nodes and edges.
[0048] To further explore the potential information in the knowledge graph, the Leiden algorithm is used to analyze the graph and identify closely related groups of entities that form communities. The objective function of the Leiden algorithm is expressed as:
[0049]
[0050] In the formula, A ij k represents the edge weight between nodes i and j. i and, k j Let i and j represent the degrees of nodes i and j respectively, m represent the total edge weights of the network, and δ(c i ,c j The value is 1 when nodes i and j belong to the same community, and 0 otherwise.
[0051] The Leiden algorithm can efficiently identify the community structure in the graph. Then, the BERT language model is used to extract and summarize the information of each community to generate a community summary.
[0052] Step 2: Perform retrieval based on iterative retrieval reasoning techniques
[0053] Iterative retrieval reasoning technology combines retrieval with chained reasoning to achieve multiple rounds of iterative retrieval, gradually expanding relevant knowledge and ultimately generating a complete and accurate answer. The detailed process of retrieval enhancement based on the iterative retrieval reasoning algorithm is as follows:
[0054] First, the user inputs an initial question Q0. Then, Named Entity Recognition (NER) technology is used to extract entities from the question. The extracted entities are then retrieved using a graph database. Because communities have already been built, the search goes beyond just finding a single entity directly related to the query; it operates across various communities related to the query. The initial question Q0 is encoded using the Sentence-BERT model to obtain a query vector q. The semantic vector v of each entity is then calculated from the query vector q. i The similarity is expressed as follows:
[0055]
[0056] Based on similarity scores, the K most relevant entities are retrieved: N represents the total number of entities in the knowledge graph, and the retrieval function R... K Returns at most K entities, denoted as This process can be represented as... in These are the entities obtained from the initial retrieval.
[0057] Next, the system enters a multi-round iterative retrieval and reasoning process. In each round of iteration, a chained reasoner T is first used in conjunction with the current question Q. i and the retrieved entity P i K The information carried is used to generate a new CoT sentence C. i This represents a reasoned summary of the current question and the retrieved paragraph, used to guide the next round of searching. This process can be represented as C. i =T(P i K Q i Then, the CoT sentence C... i As a new question query Q i+1 Q i+1 =NextQuery(C i ).
[0058] Using searcher R KRetrieving information related to Q from a knowledge graph i+1 The K most relevant entities are denoted as This process can be represented as...
[0059] The iterative retrieval and reasoning algorithm is represented as:
[0060]
[0061] In the formula, n represents the maximum number of iterations.
[0062] After each iteration, the system checks whether the termination condition is met. There are two types of termination conditions:
[0063] Condition 1: Set a maximum number of iterations (usually set to 10). If the maximum number of iterations is not reached, continue to the next round of iterations. If the maximum number of iterations is reached, stop iterating.
[0064] Condition 2: After each iteration, generate the current CoT sentence C. i And the CoT sentence C from the previous round i-1 The two CoT sentences are transformed into semantic vectors using the pre-trained Sentence-BERT model. The similarity between the two semantic vectors is then determined using the Euclidean distance formula, as shown below:
[0065]
[0066] In the formula, C i-1,l and C i,l They represent C respectively i-1 and C i The semantic vector is the quantity in the l-th dimension, where o represents the dimension of the semantic vector, which is 768 in this paper.
[0067] If the Euclidean distance is less than the preset threshold, it means that the answers from the two rounds of iteration are very close, indicating that the system has converged, and the iteration stops.
[0068] Step 3: Enhance generation based on the Self-RAG introspection algorithm
[0069] To enhance the generative model, Self-RAG's self-reflection technique is used. The generative model takes knowledge fragments retrieved through iterative retrieval and reasoning as contextual input. For the generative model, based on the retrieved K paragraphs and the question, K continuations are generated at each timestamp t, and these K continuations are scored. The output of the highest-scoring continuation is selected as the final result. The quality f(y) of each continuation is then evaluated. t When considering the generation probability p(y, d, Critique), in addition to taking into account the generation probability p(y) of this segment, t|x,d,y<t) also introduces the critical score S (Critique), where y t d represents the currently generated candidate paragraph, d represents the relevant knowledge retrieved from the knowledge graph, x represents the initial question Q0, and y represents the content generated before timestamp t. The formula for calculating the segment score is as follows:
[0070] f(y t ,d,Critique)=p(y t |x,d,y<t)+S(Critique)
[0071] In the generative model, new "introspection tokens" are introduced as marker tokens. The generative model provides the generation probability of each token in the logprobs and calculates the critique score S based on these probabilities. In the calculation of the critique score S, G is the critique token group, which contains {ISREL, ISSUP, ISUSE}. Each critique token has several reflection tokens. For example, ISREL includes {[Relevant], [Irrelevant]}, which indicate whether the retrieved content is relevant to the question; ISSUP includes {[Fully supported], [Partially supported], [Nosupport]}, which indicate the degree to which the output content is supported by the retrieved knowledge; ISUSE includes [Utility:x], which indicates the effectiveness of the generated content in answering the question, and is scored from 1 to 5. The score of each critique token group within the timestamp t is denoted as S. t G The weight hyperparameter of each critique group is denoted as W. G The formula for calculating the critical score S is as follows:
[0072]
[0073] exist middle, The most desired reflection marker within timestamp t The probability of occurrence, P t (r i N represents the probability of generating all possible tags within timestamp t. G To determine the number of reflective markers in the critical marker group, then The calculation formula is as follows:
[0074]
[0075] Through Self-RAG's self-reflection technique and multifaceted criticism mechanism, it is possible to improve the factuality and quality of language models without sacrificing their diversity.
[0076] Step 4: Constructing an Iterative Retrieval and Reasoning Knowledge Graph (RAG) Framework with an Introspection Mechanism
[0077] By combining iterative retrieval and reasoning techniques with the Self-RAG introspection algorithm, a novel knowledge graph RAG framework is constructed. The core idea of this framework is to obtain high-quality knowledge fragments through iterative retrieval and reasoning, and to optimize the generation process through the Self-RAG introspection algorithm, thereby generating high-quality final answers.
[0078] In the retrieval section, the system utilizes iterative retrieval and reasoning techniques for iterative retrieval and reasoning. After the user inputs the initial question Q0, the system uses the retrieval tool R... K Relevant paragraphs are retrieved from knowledge sources and combined with a chained inference engine T to generate new queries, gradually expanding the relevant knowledge fragments. This process continuously optimizes the retrieval results through multiple iterations, ensuring that the generative model can obtain high-quality contextual input. The core of retrieval enhancement lies in dynamically expanding the knowledge scope through iterative retrieval and inference, thereby providing the generative model with more comprehensive and accurate information support.
[0079] In the generation part, the system introduces the Self-RAG introspection algorithm to enhance the generation model through a self-reflection mechanism. The generation model takes the retrieved paragraph set and user questions as contextual input, generates multiple continuation candidates at each timestamp t, and dynamically evaluates them. By introducing "introspection tokens" and a critical score S, the generation model can evaluate the relevance, support, and usability of the content during the generation process, thereby selecting the optimal continuation as the output. The core of generation enhancement lies in dynamically optimizing the quality of the generated content through a self-reflection mechanism, ensuring that the generated results are both factual and diverse.
[0080] Finally, the system combines the high-quality paragraph set obtained through retrieval enhancement with the generated results optimized by generation enhancement to produce the final answer.
[0081] Example 1
[0082] Based on the method of this invention, the experimental environment in this embodiment is a high-performance laboratory server equipped with eight NVIDIA GeForce RTX 4090 GPUs. This server has powerful parallel computing capabilities and can efficiently support the training and inference tasks of large-scale deep learning models. In this experiment, we focus on comparing the performance differences between the framework combining introspection techniques and iterative retrieval inference and the introspection algorithm combined with traditional knowledge graph RAG technology.
[0083] Combination Figure 3 As shown, on different datasets, we found that the introspective iterative retrieval and reasoning knowledge graph (RAG) framework exhibits significant advantages across several key performance indicators. Specifically, in terms of retrieval recall, the introspective iterative retrieval and reasoning knowledge graph (RAG) framework improves the average recall by 15.3% compared to the introspective algorithm combined with traditional knowledge graph (RAG) technology. This result demonstrates that the iterative retrieval and reasoning enhancement mechanism, with the help of multiple rounds of iterative retrieval and reasoning, can more comprehensively and accurately capture knowledge fragments related to the question, dynamically expand the retrieval scope, and gradually mine deeper levels of relevant knowledge, thereby significantly improving retrieval performance.
[0084] Example 2
[0085] Based on the method of this invention, the experimental environment in this embodiment is a high-performance laboratory server equipped with eight NVIDIA GeForce RTX 4090 GPUs. This server has powerful parallel computing capabilities and can efficiently support the training and inference tasks of large-scale deep learning models. In this experiment, we focus on comparing the question-answering accuracy of the framework combining introspection techniques and iterative retrieval inference with the framework of different generative models (including Llama2-7b and Alpaca-7b) + iterative retrieval inference techniques on multiple datasets, in order to comprehensively evaluate the performance of different generative models under the retrieval enhancement framework.
[0086] Combination Figure 4 As shown, on different datasets, we found that the Self-RAG framework for iterative retrieval and reasoning knowledge graphs with an introspective mechanism exhibits significant advantages across multiple key performance metrics. Specifically, in terms of question-answering accuracy, the Self-RAG framework achieves higher accuracy across all datasets compared to iterative retrieval and reasoning + Llama2-7B and iterative retrieval and reasoning + Alpaca-7B. These results demonstrate that the Self-RAG's introspective mechanism further optimizes the factual accuracy and semantic coherence of the generated results by dynamically evaluating the relevance, support, and usability of the generated content. In contrast, while Llama2-7B and Alpaca-7B possess strong generation capabilities, their lack of an introspective mechanism results in relatively lower quality and accuracy of the generated results.
[0087] In summary, the method of this invention enhances the knowledge retrieval process through iterative retrieval and reasoning techniques combined with chain-like reasoning, ensuring the acquisition of the most relevant knowledge segments in multiple rounds of retrieval and reasoning. By alternating recursive reasoning and retrieval, the system can dynamically expand the retrieval scope, gradually uncovering deeper levels of relevant knowledge, thereby optimizing the relevance and completeness of information, avoiding the retrieval of irrelevant knowledge, and significantly improving the accuracy of the final reasoning result. To further improve the quality of the generated answer, this invention introduces Self-RAG introspection technology, using special markers (called introspection markers) to reflect on the retrieved segments and generated content. These introspection markers enable the language model to perform controllable operations during the reasoning stage, thus customizing its behavior according to different task requirements. Through this self-feedback mechanism, the system can identify and fill knowledge gaps in the generated answer, initiate new retrievals, and ultimately generate a more accurate and complete answer. This closed-loop optimization mechanism not only achieves self-correction but also continuously improves the accuracy and reliability of the generated answer, making it widely applicable in fields such as intelligent question answering, decision support, and automatic knowledge completion.
[0088] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered illustrative and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of the equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.
[0089] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A knowledge graph RAG method based on introspection mechanism and enhanced iterative retrieval and reasoning, characterized by: Includes the following steps: Step 1: Construction of the Knowledge Graph Collect and clean multi-source heterogeneous data and preprocess the data through natural language processing. Then, identify entities from the text through named entity recognition, extract the relationships between entities to construct triples (h,r,e), where h is the head entity, r is the relation, and e is the tail entity. Generate semantic vectors for each entity using the Sentence-BERT model. , represented as: ,Will The data is stored in entities. At the same time, a knowledge graph is constructed based on triples, the Leiden algorithm is used to identify the community structure of entities, and the BERT language model is used to generate community summaries. Step 2: Perform retrieval based on iterative retrieval reasoning techniques Initial problem with user input Entities are extracted from the problem using named entity recognition. These extracted entities are then retrieved from a graph database, and the Sentence-BERT model is used to process the initial problem. Encode to obtain the query vector Calculate the query vector semantic vectors of each entity Based on the similarity score, a preliminary retrieval is obtained. individual entities Search engine Return most An entity, represented as ; The process involves multiple rounds of iterative retrieval and reasoning until the termination condition is met. In each iteration, a chained reasoner is first used. In light of the current issues and retrieved entities The information carried is used to generate a new CoT sentence. A summary of reasoning regarding the current question and the retrieved paragraphs, expressed as: , to CoT sentence As a new question query , represented as Using a search engine Retrieving from knowledge graphs Most relevant An entity, represented as The iterative retrieval and reasoning algorithm is then expressed as: In the formula, Indicates the maximum number of iterations; Step 3: Enhance generation based on the Self-RAG introspection algorithm For generative models, based on the retrieved... Each paragraph is combined with a question, at each timestamp Generated in A continuation, and on Each continuation of the story is scored, and the output of the highest-scoring continuation is selected as the final result. In evaluating the quality of each continuation When considering the generation probability of this segment. And introduce critical scoring ,in, These are the currently generated candidate paragraphs. It is relevant knowledge retrieved from a knowledge graph. It is the initial problem , In timestamp The calculation formula for the previously generated content is as follows: In the generative model, introspective tokens are introduced as marker tokens. The generative model provides the generation probability of each token in the logprobs, and calculates the critique score based on these probabilities. In the formula, Indicates a critical marker group, This represents the weight hyperparameter for each critique tag group. Indicates the timestamp The score for each critical marker group within the range, Indicates the timestamp Inner most desired reflection mark The probability of occurrence Indicates the timestamp The probability of generating all possible labels within the context. The number of reflective markers in the critical marker group; Step 4: Constructing an Iterative Retrieval and Reasoning Knowledge Graph (RAG) Framework with an Introspection Mechanism By combining iterative retrieval and reasoning techniques with the Self-RAG introspection algorithm, a novel knowledge graph RAG framework is constructed. Knowledge fragments are obtained through iterative retrieval and reasoning, and the generation process is optimized through the Self-RAG introspection algorithm. The optimal continuation is selected as the output to generate the final answer.
2. The knowledge graph RAG method based on introspection mechanism with enhanced iterative retrieval and reasoning as described in claim 1, characterized in that: In step one, when constructing the knowledge graph, statements or attribute information about entities are added to the triples to enrich the structured knowledge, and this structured knowledge is stored in the Neo4j graph database. In the knowledge graph, nodes represent entities, edges represent relations, and triples and their additional information are stored as attributes of nodes and edges.
3. The knowledge graph RAG method based on introspection mechanism with enhanced iterative retrieval and reasoning as described in claim 1, characterized in that: The termination conditions for the multi-round iterative retrieval and reasoning process in step two are divided into two types: Condition 1: Set a maximum number of iterations. If the maximum number of iterations is not reached, continue to the next round of iterations. If the maximum number of iterations is reached, stop iterating. Condition 2: After each iteration, generate the current CoT sentence. And the CoT sentences from the previous round The two CoT sentences are converted into semantic vectors by the pre-trained model Sentence-BERT. The similarity between the two semantic vectors is determined by calculating the distance between them using the Euclidean distance formula. If the Euclidean distance is less than a preset threshold, the iteration stops.
Citation Information
Patent Citations
Knowledge graph construction method and management system based on large language model
CN117556054A
Intelligent traditional Chinese medicine auxiliary diagnosis system based on knowledge graph retrieval enhanced generation
CN119170258A