A GraphRAG-based intelligent question answering method, apparatus, device, and medium
By performing directed graph scoring and matching on GraphRAG search results, key components are filtered out and useless components are eliminated, which solves the problems of low reasoning efficiency and high risk of illusion caused by subgraph noise interference, and achieves more efficient and accurate question answering.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-09
- Publication Date
- 2026-03-10
AI Technical Summary
In existing GraphRAG technology, subgraph noise interference leads to problems such as low inference efficiency of large language models, impaired answer accuracy, and high risk of illusion.
By representing the search results with a directed graph, key components are selected using node correlation, relationship bridging, and confidence scores. Then, useless and redundant components are eliminated through the thought chain matching and verification of the large language model, thus optimizing the input text of the large language model.
It improves the reasoning efficiency of large language models, reduces the risk of hallucinations, and enhances the quality of question answering and user experience.
Smart Images

Figure CN121278069B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of large model technology, and in particular to an intelligent question-answering method, apparatus, device and medium based on GraphRAG. Background Technology
[0002] GraphRAG (Graph Retrieval-Augmented Generation) is a combination of "structured representation of knowledge graphs" and "retrieval-enhanced generation," and its core logic can be broken down into three steps:
[0003] 1. KG (Knowledge Graph) Construction and Storage: Transform unstructured text (such as documents and web pages) into structured knowledge graphs (such as "Einstein - proposed - relativity" and "relativity - belongs to - physics theory") through "entity recognition - relation extraction - attribute completion" and store them in databases that support graph retrieval (such as Neo4j and NebulaGraph).
[0004] 2. Subgraph Retrieval: For user questions, "subgraphs related to the question" are filtered from the global KG through "entity matching - semantic vector retrieval - graph topology matching" (for example, for the question "Who proposed the theory of relativity?", the retrieved subgraphs must contain core components such as "Einstein", "relativity", and "proposed").
[0005] 3. LLM (Large Language Model) Reasoning and Generation: The retrieved subgraphs are transformed into natural language text (e.g., "Entity: Einstein; Relation: Proposal; Entity: Relativity"), and the text associated with the subgraphs is used as the input context for LLM to help LLM generate accurate answers.
[0006] In GraphRAG technology, which integrates Large Language Models (LLM) and Knowledge Graphs (KG), the "knowledge graph subgraph" is the core carrier connecting external knowledge with LLM reasoning. By retrieving subgraphs relevant to the question, LLM can obtain structured knowledge support, avoiding "unfounded illusions." However, current GraphRAG technology generally faces the problem of "subgraph noise interference": the retrieved subgraphs often contain a large number of non-critical, useless, or even side-effect-causing entities and relationships. These "noise components" lead to redundant text in the LLM input, triggering a chain reaction of decreased reasoning efficiency, impaired answer accuracy, and increased risk of illusions. This also reduces question-answering quality and user experience. Summary of the Invention
[0007] In view of this, the purpose of this invention is to provide a GraphRAG-based intelligent question-answering method, apparatus, device, and medium that can accurately identify and eliminate non-critical, useless, and side-effect components, solving the core pain points of traditional technologies such as low reasoning efficiency and high risk of illusion caused by input redundancy, and continuously improving question-answering quality and user experience. The specific solution is as follows:
[0008] Firstly, this application discloses an intelligent question-answering method based on GraphRAG, including:
[0009] Obtain the retrieval results returned by GraphRAG based on the input question, represent the retrieval results as a directed graph, extract the target entity nodes from the input question and the initial question response generated by the large language model, and mark the target entity nodes in the directed graph to obtain marked nodes;
[0010] The types of relations in the directed graph are vectorized using natural language to obtain target vectors. A first score for the target component is determined based on the target relevance and degree centrality of each node in the directed graph, as well as the relation bridging degree and relation confidence of each relation. The target relevance represents the shortest path length from the node to the labeled node; the relation bridging degree represents the total number of paths containing the relation among all possible paths from the question node to the answer node; the target component includes nodes and / or relations.
[0011] Based on the target vector, the nodes and relationships in the thought chain generated when the large language model generates the initial question answer are matched with the nodes and relationships in the directed graph. A first initial score is generated based on the corresponding matching results and the first score. A second initial score of the target component is determined based on the directed graph after deleting the corresponding nodes and relationships. A second score is determined based on the weighted average of the first initial score and the second initial score.
[0012] Determine whether there is semantic duplication between any two nodes or two relations in the directed graph, and determine the third score of the target component based on the corresponding judgment result, the first score and the second score;
[0013] The target score is determined based on the weighted average of the first score, the second score, and the third score. The relationships and nodes in the directed graph are then filtered according to the target score, and the target question answer is determined based on the corresponding filtering results.
[0014] Optionally, determining the first score of the target component based on the target correlation degree and degree centrality of each node in the directed graph, as well as the relation bridging degree and relation confidence of each relation, includes:
[0015] The relevance score corresponding to the target relevance is determined based on the shortest path length from the node to the marked node; wherein, the shortest path length and the relevance score are inversely correlated.
[0016] Determine the degree centrality of the node and normalize the corresponding centrality value to obtain the normalized value;
[0017] The nodes are sorted from high to low based on the normalized values, and the nodes are divided into different percentage intervals according to the sorting results. Different degree centrality scores are assigned to the nodes in different percentage intervals.
[0018] Determine the total number of paths containing the relationship among all possible paths from the question node to the answer node, and determine the bridging score of the relationship based on the total number of paths; wherein, the total number of paths and the bridging score of the relationship are positively correlated.
[0019] Determine the confidence interval to which the relationship confidence level belongs, and configure different confidence scores for the relationship based on different confidence intervals;
[0020] The first score of the node is determined based on the weighted average of the correlation score and the degree centrality score;
[0021] The first score of the relationship is determined based on the weighted average of the bridging score and the confidence score.
[0022] Optionally, the step of matching the nodes and relationships in the thought chain generated when the large language model generates the initial question answer based on the target vector with the nodes and relationships in the directed graph, and generating a first initial score based on the corresponding matching results and the first score, includes:
[0023] Based on the entity node names and relationship types, the nodes and relationships in the thought chain generated when the large language model generates the initial question answer are matched with the nodes and relationships in the directed graph. Semantic vector matching is then performed on the nodes and relationships in the thought chain generated when the large language model generates the initial question answer, based on the target vector, to obtain the corresponding matching results.
[0024] Based on the matching results and the relationship between the first score corresponding to the node or relationship and the preset threshold, the first initial score of the node and relationship in the directed graph is determined.
[0025] Optionally, the step of determining the second initial score of the target component based on the directed graph after deleting the corresponding nodes and relationships includes:
[0026] For each node and relation in the directed graph, generate a first subgraph by deleting any node and a second subgraph by deleting any relation, respectively;
[0027] A new response is generated based on the first subgraph and the second subgraph using a large language model, and the accuracy, completeness and consistency of the new response are determined based on the initial question response;
[0028] Based on whether the accuracy of the new response has changed, whether its completeness is missing, and the relationship between its consistency and the preset value, a second initial score is determined for the node or relationship to be deleted corresponding to the new response.
[0029] Optionally, determining the third score of the target component based on the corresponding judgment result, the first score, and the second score includes:
[0030] If there is semantic duplication between any two nodes or two relations in the directed graph, the node or relation is determined to be a redundant component, and the difference between the sum of the first score and the second score and the target value is determined as the third score of the target component.
[0031] Otherwise, the sum of the first score and the second score is determined as the third score of the target component.
[0032] Optionally, the step of filtering the relationships and nodes in the directed graph based on the target score, and determining the target question answer based on the corresponding filtering results, includes:
[0033] If the target score is greater than or equal to the first value, the corresponding relationship or node will be marked as a core component.
[0034] If the target score is greater than or equal to the second value and less than the first value, then the corresponding relationship or node will be marked as an auxiliary component.
[0035] If the target score is less than the second value, the corresponding relationship or node will be deleted.
[0036] The target question answer is determined based on the core component and the auxiliary component.
[0037] Optionally, the method further includes:
[0038] The large language model is optimized and adjusted using the core components, the input question, the target question answer, and the thought chain to obtain an adjusted model, which is then used for intelligent question answering.
[0039] Secondly, this application discloses a GraphRAG-based intelligent question-answering device, comprising:
[0040] The labeled node acquisition module is used to acquire the retrieval results returned by GraphRAG based on the input question, represent the retrieval results as a directed graph, extract the target entity nodes from the input question and the initial question response generated by the large language model, and label the target entity nodes in the directed graph to obtain labeled nodes;
[0041] The first scoring module is used to perform natural language vectorization on the types of each relation in the directed graph to obtain a target vector, and to determine the first score of the target component based on the target relevance degree and degree centrality of each node in the directed graph, as well as the relation bridging degree and relation confidence degree of each relation; the target relevance degree represents the shortest path length from the node to the labeled node; the relation bridging degree represents the total number of paths containing the relation in all possible paths from the question node to the answer node; the target component includes nodes and / or relations;
[0042] The second scoring determination module is used to match the nodes and relationships in the thought chain generated when the large language model generates the initial question answer with the nodes and relationships in the directed graph based on the target vector, generate a first initial score according to the corresponding matching results and the first score, determine a second initial score of the target component according to the directed graph after deleting the corresponding nodes and relationships, and determine a second score according to the weighted average result of the first initial score and the second initial score.
[0043] The third scoring module is used to determine whether there is semantic duplication between any two nodes or two relations in the directed graph, and to determine the third score of the target component based on the corresponding judgment result, the first score and the second score.
[0044] The target question answer determination module is used to determine a target score based on a weighted average of the first score, the second score, and the third score, filter the relationships and nodes in the directed graph according to the target score, and determine the target question answer based on the corresponding filtering results.
[0045] Thirdly, this application discloses an electronic device, including:
[0046] Memory, used to store computer programs;
[0047] A processor is used to execute computer programs to implement the GraphRAG-based intelligent question answering method described above.
[0048] Fourthly, this application discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the aforementioned GraphRAG-based intelligent question-answering method.
[0049] This application first obtains the retrieval results returned by GraphRAG based on the input question, represents the retrieval results as a directed graph, extracts target entity nodes from the input question and the initial question answer generated by the large language model, and marks the target entity nodes in the directed graph to obtain marked nodes; performs natural language vectorization on the types of each relation in the directed graph to obtain target vectors, and determines the first score of the target component based on the target relevance degree and degree centrality of each node in the directed graph, as well as the relation bridging degree and relation confidence degree of each relation; the target relevance degree represents the shortest path length from the node to the marked node; the relation bridging degree represents the total number of paths containing the relation in all possible paths from the question node to the answer node; the target component includes nodes and / or relations; based on the target... The vector matches the nodes and relationships in the thought chain generated when the large language model generates the initial question answer with the nodes and relationships in the directed graph. Based on the matching results and the first score, a first initial score is generated. A second initial score for the target component is determined based on the directed graph after deleting the corresponding nodes and relationships. A second score is determined based on the weighted average of the first and second initial scores. It then determines whether there is semantic overlap between any two nodes or relationships in the directed graph, and a third score for the target component is determined based on the determination result, the first score, and the second score. Finally, a target score is determined based on the weighted average of the first, second, and third scores. The target score is then used to filter the relationships and nodes in the directed graph, and the target question answer is determined based on the filtering results. As can be seen, this application filters topologically related components by anchoring node correlation and relationship bridging indicators, and relies on thought chain matching and matching verification to lock in the core elements actually involved in answer derivation. The semantic verification dimension uses the semantic understanding of the large model to make up for the rigidity of structural rules, which not only avoids the incorporation of useless components, but also captures implicit semantic relationships, ensuring the high purity of the input text of the large language model from the source, and completely solving the core pain points of low reasoning efficiency and high risk of illusion caused by input redundancy in traditional technologies. It enables accurate subgraph filtering results in different types of question-answering scenarios, and solves the contradictions of excessive noise in factual questions and missing key components in multi-hop questions in traditional technologies. Attached Figure Description
[0050] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0051] Figure 1 This is a flowchart of a GraphRAG-based intelligent question answering method disclosed in this application;
[0052] Figure 2 This is a schematic diagram of the structure of a GraphRAG-based intelligent question-answering device disclosed in this application;
[0053] Figure 3 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0054] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0055] In GraphRAG technology, which combines Large Language Models (LLM) with knowledge graphs, the technical defects and shortcomings caused by subgraph noise interference have become the core bottleneck restricting its performance implementation. Specifically, this can be reflected in four aspects: inference efficiency, inference quality, interpretability, and deep-seated limitations in technical design. First, a large number of non-critical and useless components in the subgraph directly lead to a significant decrease in LLM inference efficiency. Since LLM inference speed is positively correlated with the length of the input context, the text transformed from redundant entities and relations will greatly increase the amount of tokens processed—for example, a redundant subgraph containing 50 nodes and 80 relations may occupy 2000+ tokens, which increases the inference time compared to the core subgraph. This not only causes excessive system response latency in high-concurrency scenarios but also leads to a waste of GPU / CPU resources, resulting in a surge in long-term enterprise-level application costs. Secondly, noisy components dilute LLM's focus and disrupt the coherence of reasoning logic: non-critical information (such as "film adaptations of relativity") may obscure core knowledge such as "spacetime curvature," causing LLM answers to deviate from the focus; while irrelevant relationships (such as "relativity - mentioned in - a science fiction novel") can disrupt the key logical chain of "equivalence principle → derivation of relativity," causing logical jumps in the answer. More seriously, erroneous components with side effects (such as "Einstein - proposed - quantum mechanics") or ambiguous entities (such as "Mars" being associated with both planets and car brands) can become illusion triggers, causing LLM to generate conclusions based on incorrect knowledge, or to answer irrelevantly due to insufficient ambiguity resolution, completely deviating from GraphRAG's core value of "suppressing illusions." At the interpretability level, noisy components can confuse the answer's tracing chain—erroneous conclusions may point to invalid relationships such as "relativity - associated with - patent office," while key derivation basis (such as "equivalence principle") is hidden by redundant information, making it impossible for users to verify the accuracy of the answer and significantly reducing trust. To address the aforementioned technical issues, this application discloses a GraphRAG-based intelligent question-answering method, apparatus, device, and medium that can accurately identify and eliminate non-critical, useless, and side-effect components. This solves the core pain points of traditional technologies, such as low reasoning efficiency and high risk of illusion caused by input redundancy, and continuously improves question-answering quality and user experience.
[0056] See Figure 1 As shown, this embodiment of the invention discloses an intelligent question-answering method based on GraphRAG, including:
[0057] Step S11: Obtain the retrieval results returned by GraphRAG based on the input question, represent the retrieval results as a directed graph, extract the target entity nodes from the input question and the initial question response generated by the large language model, and mark the target entity nodes in the directed graph to obtain marked nodes.
[0058] In this embodiment, the knowledge graph subgraph is first imported with the corresponding data. Then, a question is input, and relevant subgraphs are retrieved through entity matching and semantic retrieval. The subgraphs returned by GraphRAG retrieval are then standardized to provide a basic data structure for subsequent quantization. During the standardization process, the retrieval subgraph is first represented as a directed graph G=(V, E), where... For entity nodes (containing attributes such as "entity type" and "description text"), Define relation edges (including attributes such as "relation type", "confidence level", and "source document"); extract the core entities from question Q using LLM. (e.g., "Einstein" in the question "What theories did Einstein propose?") The core entity in answer A (e.g., the answer "relativity"), and mark these "anchor nodes" in subgraph G to obtain the marked nodes.
[0059] Step S12: Perform natural language vectorization on the types of each relation in the directed graph to obtain the target vector. Determine the first score of the target component based on the target relevance degree and degree centrality of each node in the directed graph, as well as the relation bridging degree and relation confidence degree of each relation. The target relevance degree represents the shortest path length from the node to the labeled node. The relation bridging degree represents the total number of paths containing the relation in all possible paths from the question node to the answer node. The target component includes nodes and / or relations.
[0060] In this embodiment, for each relationship The types (such as "proposed", "belongs to", "found in") are semantically encoded and converted into vectors (such as using the LLM Embedding interface, such as GPT-4o's text-embedding-3-large) for subsequent semantic similarity calculation.
[0061] Then, based on the topological characteristics of the knowledge graph, the fundamental importance of nodes and relationships in the "connection problem - answer anchor node" process is evaluated. First, the relevance score corresponding to the target relevance is determined based on the shortest path length from the node to the labeled node; wherein, the shortest path length and the relevance score are inversely correlated. Next, the degree centrality of the node is determined (degree centrality is an indicator of node importance in a knowledge graph network, mainly evaluated by calculating the number of connections between the node and other nodes. The more connections a node has, the higher its degree centrality, and the more important its position in the knowledge graph network). The corresponding centrality value is then normalized to obtain a normalized value. Based on the normalized value, the nodes are sorted from high to low order to divide the nodes into different percentages according to the sorting results. The relationship is defined as follows: a range is defined, and different degree centrality scores are assigned to nodes within different percentage ranges; the total number of paths containing the relationship between the question node and the answer node is determined, and a bridging score for the relationship is determined based on the total number of paths; wherein the total number of paths is positively correlated with the bridging score of the relationship; the confidence interval to which the relationship confidence belongs is determined, and different confidence scores are assigned to the relationship according to different confidence intervals; a first score for the node is determined based on the weighted average of the association score and the degree centrality score; and a first score for the relationship is determined based on the weighted average of the bridging score and the confidence score.
[0062] In one specific embodiment, the relevance score corresponding to the target relevance is determined based on the shortest path length from the node to the marked node; wherein, if the shortest path length is 0, the relevance score is 10; if the shortest path length is 1, the relevance score is 8; if the shortest path length is 2, the relevance score is 5; if the shortest path length is greater than or equal to 3, the relevance score is 0; the degree centrality of the nodes is determined, and the corresponding centrality value is normalized to obtain a normalized value; the nodes are sorted in descending order based on the normalized value, and the degree centrality score of the nodes ranked in the top 10% is 8; the degree centrality score of the nodes ranked in the top 10% to 30% is 5; the degree centrality score of the nodes ranked in the top 30% to 50% is... 3. Nodes ranking between 50% and 100% have a degree centrality score of 1. Determine the total number of paths containing a relation between the question node and the answer node. If the total number of paths is greater than or equal to 2, the relation's bridging score is 9; if the total number of paths is equal to 1, the relation's bridging score is 7; if the total number of paths is equal to 0, the relation's bridging score is 0. If the relation's confidence is greater than or equal to 0.9, the relation's confidence score is 10; if the relation's confidence is greater than or equal to 0.7 and less than 0.9, the relation's confidence score is 7; if the relation's confidence is greater than or equal to 0.5 and less than 0.7, the relation's confidence score is 4; if the relation's confidence is less than 0.7, the relation's confidence score is 1. Finally, determine the node's first score based on the weighted average of the association score and degree centrality score; determine the relation's first score based on the weighted average of the bridging score and confidence score. In other words, for node v, a weighted average of "relevance" and "degree centrality" is taken (the weights can be adjusted according to the scenario, such as 0.7 for "relevance" and 0.3 for "degree centrality" in factual question answering); for relations... The weighted average of "relationship bridging degree" and "relationship confidence degree" is taken ("bridging degree" has a weight of 0.6 and "confidence degree" has a weight of 0.4 in multi-hop scenarios). The specific calculation logic and scoring rules for the correlation score, degree centrality score, bridging degree score, and confidence degree score are shown in Table 1 below:
[0063] Table 1. Scoring Calculation Logic and Scoring Rules
[0064]
[0065] Step S13: Based on the target vector, match the nodes and relationships in the thought chain generated when the large language model generates the initial question answer with the nodes and relationships in the directed graph. Generate a first initial score based on the corresponding matching results and the first score. Determine a second initial score for the target component based on the directed graph after deleting the corresponding nodes and relationships. Determine a second score based on the weighted average of the first initial score and the second initial score.
[0066] In this embodiment, based on the GraphRAG reasoning process (such as the LLM's thought chain for generating answers using subgraphs), the evaluation assesses whether nodes and relationships actually participate in the derivation of "question → answer". First, based on the entity node name and relationship type, string matching is performed on the nodes and relationships in the thought chain generated when the large language model generates the initial question answer, and on the nodes and relationships in the directed graph. Then, based on the target vector, semantic vector matching is performed on the nodes and relationships in the thought chain generated when the large language model generates the initial question answer, and on the nodes and relationships in the directed graph, to obtain the corresponding matching results. Based on the matching results and the size relationship between the first score corresponding to the node or relationship and a preset threshold, the first initial score of the node and relationship in the directed graph is determined. Specifically, when LLM generates a response, it includes a Chain-of-Thought (CoT) that explicitly marks the entities and relations relied upon in the reasoning process (e.g., CoT: "First, Einstein (entity A) proposed (relation R1) the special theory of relativity (entity B) in 1905; second, he proposed (relation R2) the general theory of relativity (entity C) in 1915"). The entities / relations in the CoT are matched with the V / E in the subgraph G (based on string matching of entity name and relation type + semantic vector matching, with a similarity threshold of 0.85). The scoring rules are as follows: Successfully matched nodes / relations receive 10 points (determined as "necessary components for reasoning"); unmatched nodes / relations with a static score S1 ≥ 7 receive 5 points (determined as "potentially relevant components," possibly implicitly used in LLM reasoning); unmatched nodes / relations with S1 < 7 receive 0 points (determined as "irrelevant components for reasoning").
[0067] Then, for each node and relation in the directed graph, a first subgraph is generated after deleting any node and a second subgraph is generated after deleting any relation. A new response is generated based on the first and second subgraphs using a large language model. The accuracy, completeness, and consistency of the new response are determined based on the initial question response. A second initial score is determined for the deleted node or relation corresponding to the new response based on whether the accuracy has changed, whether the completeness is missing, and the relationship between the consistency and preset values. The core logic is to evaluate contribution by "observing changes in response quality after deleting subgraph components"—if the accuracy and completeness of the response significantly decrease after deleting a node / relation, then the component has a high contribution. In a specific embodiment, for each node v and relation e in the retrieval subgraph G, "subgraph Gv- after deleting v" and "subgraph Ge- after deleting e" are generated respectively. The LLM-based Gv- / Ge- response was regenerated, and compared with the original response in terms of accuracy (whether it conforms to the facts), completeness (whether key information is missing), and consistency (whether it is similar to the original conclusion). Scoring rules (0-10 points): Change in accuracy or loss of completeness: 10 points (core contributing component); No change in accuracy, loss of completeness: 7 points (important contributing component); No significant change in accuracy / completeness, consistency <50%: 3 points (auxiliary component); Other: 0 points (useless component). The second score was finally determined based on the weighted average of the first and second initial scores. In other words, for each node and relation in the directed graph, a first subgraph is generated after deleting any node and a second subgraph is generated after deleting any relation. A new response is generated based on the first and second subgraphs using a large language model. The accuracy, completeness, and consistency of the new response are determined based on the initial question response. If the accuracy of the new response changes or its completeness is missing, the second initial score for the deleted node or relation corresponding to the new response is 10. If the accuracy of the new response remains unchanged but its completeness is missing, the second initial score for the deleted node or relation corresponding to the new response is 7. If the accuracy of the new response remains unchanged, its completeness is not missing, and its consistency is less than a preset value, the second initial score for the deleted node or relation corresponding to the new response is 3. Otherwise, the second initial score for the deleted node or relation corresponding to the new response is 0.
[0068] Step S14: Determine whether there is semantic repetition between any two nodes or two relations in the directed graph, and determine the third score of the target component based on the corresponding judgment result, the first score and the second score.
[0069] In this embodiment, components exhibiting "semantic redundancy" or "information overload" (such as two nodes having completely identical descriptions, or a relationship that can be derived from multiple other relationships) are identified. Specifically, it is determined whether semantic redundancy exists between any two nodes or relationships in the directed graph. If semantic redundancy exists between any two nodes or relationships in the directed graph, the node or relationship is determined to be a redundant component, and the difference between the sum of the first and second scores and the target value is determined as the third score of the target component. Otherwise, the sum of the first and second scores is determined as the third score of the target component. Specifically, given two entities {v1_name} (description: {v1_desc}) and {v2_name} (description: {v2_desc}) / two relationships {e1_type} and {e2_type} in a knowledge graph subgraph, it is determined whether semantic redundancy exists (i.e., the information of one can be completely covered by the other). If so, it is determined to be a redundant component (low contribution); otherwise, it indicates the unique value of both. Scoring rules: Nodes / relationships judged as "redundant components" will have 3 points deducted from S1+S2 (minimum 0 points); non-redundant components will retain their original score.
[0070] Step S15: Determine the target score based on the weighted average of the first score, the second score, and the third score; filter the relationships and nodes in the directed graph according to the target score; and determine the target question answer based on the corresponding filtering results.
[0071] In this embodiment, the target score is determined based on a weighted average of the first score, the second score, and the third score. The final contribution of the node / relationship is then calculated by combining the scores from these three dimensions. =α*S1+β*S2+γ*S3, where α+β+γ=1, and the weights can be adaptively adjusted according to the scenario: Factual question answering (e.g., "What is Newton's nationality?"): alpha=0.3, beta=0.5, gamma=0.2 (prioritizing inference association); Multi-hop inference question answering (e.g., "Who proposed the theory to explain black holes?"): alpha=0.4, beta=0.4, gamma=0.2 (emphasizing both structural bridging and inference association); Causal analysis question answering (e.g., "Why do apples fall to the ground?"): alpha=0.2, beta=0.3, gamma=0.5 (prioritizing semantic understanding).
[0072] Finally, if the target score is greater than or equal to a first value, the corresponding relationship or node is marked as a core component; if the target score is greater than or equal to a second value and less than the first value, the corresponding relationship or node is marked as an auxiliary component; if the target score is less than the second value, the corresponding relationship or node is deleted; the target question answer is determined based on the core components and the auxiliary components. In a specific embodiment, the high-contribution component is: ≥7 — Reserved for subsequent LLM reasoning and answer generation, marked as "core supporting component"; Potential contributing components: 3≤ <7 — Optional to retain (to supplement if subgraph information is insufficient), labeled as "Auxiliary Support Component"; Unused components: <3 — Delete to avoid consuming reasoning resources or introducing noise. The entities and relationships that are ultimately retained serve as the refined generation logic.
[0073] Furthermore, this application optimizes and adjusts the large language model using core components, the input question, the target question answer, and the thought chain to obtain an adjusted model for intelligent question answering. Specifically, it accumulates historical question data ("purified subgraph + reasoning link + dynamic scoring") to construct a high-quality dataset for long-term optimization of the GraphRAG system: LLM fine-tuning: The LLM is fine-tuned using only samples of "core logic components + corresponding question-answer-reasoning chain" to more accurately identify reasoning logic components and reduce focus on auxiliary / noise components; GraphRAG purification: Entities / relationships that are consecutively identified as "logical noise components" (e.g., "film adaptation of a theory") are statistically analyzed, automatically reducing their retrieval priority in the knowledge graph (e.g., ranking them lower during retrieval) or directly removing them from GraphRAG to avoid subsequent retrieval recall; Retrieval strategy update: The characteristics of high-frequency core logic components are analyzed (e.g., "in scientific question answering, 90% of 'theory-explanation-phenomenon' relationships are core components") to update the prompts and constraint rules in the retrieval stage, improving the accuracy of the initial retrieval.
[0074] In summary, this application first obtains the retrieval results returned by GraphRAG based on the input question, represents the retrieval results as a directed graph, extracts target entity nodes from the input question and the initial question answer generated by the large language model, and marks the target entity nodes in the directed graph to obtain marked nodes; it then performs natural language vectorization on the types of each relation in the directed graph to obtain target vectors, and determines the first score of the target component based on the target relevance degree and degree centrality of each node in the directed graph, as well as the relation bridging degree and relation confidence degree of each relation; the target relevance degree represents the shortest path length from the node to the marked node; the relation bridging degree represents the total number of paths containing the relation in all possible paths from the question node to the answer node; the target component includes nodes and / or relations; based on the... The target vector is used to match the nodes and relationships in the thought chain generated when the large language model generates the initial question answer with the nodes and relationships in the directed graph. A first initial score is generated based on the corresponding matching results and the first score. A second initial score of the target component is determined based on the directed graph after deleting the corresponding nodes and relationships. A second score is determined based on the weighted average of the first and second initial scores. It is then determined whether there is semantic duplication between any two nodes or two relationships in the directed graph. A third score of the target component is determined based on the corresponding determination results, the first score, and the second score. A target score is determined based on the weighted average of the first score, the second score, and the third score. The relationships and nodes in the directed graph are filtered based on the target score. The target question answer is determined based on the corresponding filtering results. As can be seen, this application filters topologically related components by anchoring node correlation and relationship bridging indicators, and relies on thought chain matching and matching verification to lock in the core elements actually involved in answer derivation. The semantic verification dimension uses the semantic understanding of the large model to make up for the rigidity of structural rules, which not only avoids the incorporation of useless components, but also captures implicit semantic relationships, ensuring the high purity of the input text of the large language model from the source, and completely solving the core pain points of low reasoning efficiency and high risk of illusion caused by input redundancy in traditional technologies. It enables accurate subgraph filtering results in different types of question-answering scenarios, and solves the contradictions of excessive noise in factual questions and missing key components in multi-hop questions in traditional technologies.
[0075] As can be seen from the previous embodiment, this application discloses a GraphRAG-based intelligent question answering method, which can solve the problems of low reasoning efficiency and high risk of illusion caused by input redundancy in traditional technologies. The GraphRAG-based intelligent question answering method will now be described in detail with reference to specific embodiments.
[0076] User Question: What impact will the People's Bank of China's (PBOC) reserve requirement ratio (RRR) cut in 2024 have on commercial banks' net profits? Solution Objective: From the financial knowledge graph retrieved by GraphRAG, accurately select entities and relationships that contribute significantly to the answer, eliminating redundant / irrelevant components (such as "2023 RRR cut data" or "PBOC office address"), ultimately generating a logically clear and reliable answer. Prerequisites: The financial knowledge graph has already imported data on PBOC policies, commercial bank financial indicators, and monetary policy transmission relationships.
[0077] First, input the question "What impact will the central bank's reserve requirement ratio (RRR) cut in 2024 have on the net profits of commercial banks?" into the graph database, and retrieve relevant subgraphs through "entity matching + semantic retrieval". Search keywords include "2024 RRR cut", "commercial banks", "net profit", and "monetary policy transmission", while filtering out older data with timestamps earlier than 2023 (time validity rules in the financial scenario). Represent the search results as a directed graph G=(V, E), where: entity node V (including attributes):
[0078] v1 = (ID1, Bank A, Regulatory Authority, {Established in 1948}).
[0079] v2 = (ID2, 2024 central bank reserve requirement ratio cut, monetary policy, {Amount: 0.5%, Implementation time: March 15, 2024, Source: Official website announcement});
[0080] v3 = (ID3, Commercial Bank, Financial Institution, {Sample Range: A-share Listed Banks}).
[0081] v4 = (ID4, net profit, financial indicators, {2023 industry average: 0.85 trillion yuan});
[0082] v5 = (ID5, reserve requirement ratio, monetary policy tool, {before the RRR cut: 8.5%, after the RRR cut: 8.0%}).
[0083] v6 = (ID6, credit scale, business indicators, {industry incremental growth in Q1 2024: 1.2 trillion yuan}).
[0084] v7 = (ID7, Net Interest Margin, Financial Metrics, {2023 Industry Average: 1.74%});
[0085] v8 = (ID8, 2023 central bank reserve requirement ratio cut, monetary policy, {amount: 0.25%, implementation time: September 2023}).
[0086] (Redundant candidate) relation edge E (including attributes):
[0087] e1,2 = (ID12, v1, v2, implementation, confidence level: 0.98, source: announcement);
[0088] e2,5 = (ID25, v2, v5, decreased, confidence level: 0.99, source: policy interpretation);
[0089] e5,6 = (ID56, v5, v6, expanded, confidence level: 0.92, source: quarterly report);
[0090] e6,7 = (ID67, v6, v7, increase, confidence level: 0.88, source: brokerage research report "Analysis of the impact of the 2024 RRR cut");
[0091] e7,4 = (ID74, v7, v4, growth, confidence level: 0.95, source: annual reports of listed banks);
[0092] e1,8 = (ID18, v1, v8, implementation, confidence level: 0.98, source: central bank announcement) (redundant candidate).
[0093] Extracting the core entity VQ from the problem: Using LLM to extract key entities from the problem, limiting the types to "monetary policy, financial institutions, and financial indicators": VQ = LLMextract(Q) = {2024 central bank reserve requirement ratio cut (v2), commercial banks (v3), net profit (v4)}. Let LLM generate a preliminary answer first, then extract the core entities (financial indicators, influencing factors): Preliminary answer: "The 2024 central bank reserve requirement ratio cut releases bank liquidity, expands credit scale, increases net interest margin, and ultimately promotes the growth of commercial bank net profit by lowering the deposit reserve ratio." VA = LLMextract(preliminary answer) = {deposit reserve ratio (v5), credit scale (v6), net interest margin (v7), net profit (v4)}.
[0094] For each relationship The `text-embedding-3-large` interface is used to generate semantic vectors in the format "relation type|subject entity|object entity". For example, `vec(e2,5)` encodes "reduce|2024 central bank reserve requirement ratio reduction|deposit reserve ratio". The vector dimension is 1536, which is used to determine the semantic similarity of the relations. Then, the scores for each component are calculated according to Table 2 below.
[0095] Table 2 Scoring Rules for Each Component
[0096]
[0097] Among them, high static contribution components (S1≥7): v2, v5, e2,5, v6, v7, e5,6, e6,7, e7,4 (to be retained later); low static contribution components (S1<7): v8, e1,8 (initially marked as redundant candidates). The LLM output labeled inference chain: "1. Bank A (v1) implements (e1,2) a reserve requirement ratio cut in 2024 (v2); 2. The 2024 reserve requirement ratio cut (v2) lowers (e2,5) the deposit reserve ratio (v5), releasing bank funds; 3. The decrease in the deposit reserve ratio (v5) expands (e5,6) the credit scale (v6); 4. The increase in credit scale (v6) pushes up (e6,7) the net interest margin (v7); 5. The growth of the net interest margin (v7) drives (e7,4) the increase in the net profit of commercial banks (v4). The matching degree between entities / relations and subgraph components in CoT is calculated using cosine similarity (threshold 0.85): e2,5 matching degree = 0.96 ≥ 0.85 → S21(e2,5) = 10 points; v8 does not appear in CoT, and S1(v8) = 3.1 < 7 → S21(v8) = 0 points; v3 (commercial bank) does not appear in CoT, but S1(v3) = 7.5 ≥ 7 → S21(v3) = 5 points.
[0098] Then, the component was deleted and the answer was regenerated. Taking e2,5 (RRR cut - reduction - reserve requirement ratio) as an example: Before deletion, the answer was: "The 2024 RRR cut will expand the scale of credit, increase the net interest margin, and drive net profit growth of about 5%-8%" (100% accuracy, 100% completeness); After deletion, the answer was: "The 2024 RRR cut may expand the scale of credit and drive net profit growth, but the specific mechanism is unclear" (80% accuracy, 60% completeness, missing the key link of "reserve requirement ratio"). Finally, according to the formula, the completeness of e2,5 after deletion is <0.5 → S22(e2,5) = 7 points; the final S2(e2,5) = (10+7) / 2 = 8.5 points (taking the mean, the weight of the financial scenario can be adjusted to CoT matching 0.6, counterfactual 0.4, the result is 8.8 points, which is simplified to the mean here). Comparing redundant components: After deleting v8 (2023 reserve requirement ratio cut), the answer remains unchanged → S22(v8) = 0 points, S2(v8) = 0 points. Next, identify "semantic redundancy": Assume the subgraph contains v9 = (statutory reserve requirement ratio, monetary policy tool, {definition: the reserve requirement ratio stipulated by the central bank}), compared with v5 (reserve requirement ratio); LLM prompts: "Determine whether 'reserve requirement ratio' (v5) and 'statutory reserve requirement ratio' (v9) are semantically redundant—does the former completely cover the information of the latter?". LLM determination: "The required reserve ratio is the core type of the required reserve ratio. The information in v5 already includes v9, and v9 is a redundant component." Scoring calculation: S1(v9) = 6.5, S2(v9) = 4.0 → S3(v9) = 6.5 + 4.0 − 3 = 7.5 points (minus 3 points); Without redundant component v5: S3(v5) = 8.0 (S1) + 8.2 (S2) = 16.2 points. Final determination of redundant components in the case: v8 (2023 reserve requirement ratio cut) and v2 (2024 reserve requirement ratio cut): LLM determination: "The 2023 reserve requirement ratio cut is irrelevant to the 2024 issue and does not affect the current reasoning" → v8 is a redundant component, S3(v8) = 3.1 + 0 − 3 = 0.1 points (minimum 0 points). Finally, a comprehensive score is calculated based on the three scores, as shown in Table 3 below:
[0099] Table 3 Comprehensive Score Calculation
[0100]
[0101] Finally, based on the comprehensive score, the subgraphs were refined as follows: Components retained: v1, v2, v3, v4, v5, v6, v7; e1,2, e2,5, e5,6, e6,7, e7,4; Components deleted: v8, v9; e1,8. The target question answer was determined based on the retained components.
[0102] In this way, this application achieves dynamic adaptation through a scenario-based weight adjustment mechanism: for factual questions and answers, it prioritizes dynamic reasoning dimensions to quickly locate core components of the "entity-attribute" type, avoiding redundant background interference; for multi-hop reasoning questions and answers, it strengthens the relationship bridging degree of the static structure and the counterfactual verification of dynamic reasoning to ensure the integrity of the multi-hop logic chain; when processing causal analysis questions and answers, it increases the weight of the semantic verification dimension to identify implicit causal relationships, so that different types of question and answer scenarios can obtain accurate subgraph filtering results, solving the contradiction of excessive noise in factual questions and the lack of key components in multi-hop questions in traditional technologies.
[0103] Furthermore, this application utilizes a closed loop of "data accumulation-distillation-optimization" to continuously improve the performance of the GraphRAG system over time—extracting high-value information from historical question-answering data to feed back into LLM inference, knowledge graph purification, and retrieval strategies, ultimately addressing the pain points of traditional systems such as "staticity and easy performance degradation." The process is explained in detail in four steps, using a financial scenario as an example:
[0104] Step 1: Accumulation and initial screening of historical Q&A data (data pool construction):
[0105] First, a complete set of historical question-and-answer data needs to be collected to establish a basic data pool, providing material for subsequent distillation. Data collection scope: covering "user question Q, retrieval subgraph G (original), purification subgraph G (final), LLM inference chain CoT, generated answer A, user feedback rating (1-5 points), and rating logs for each module (S1 / S2 / S3 / ... The data is categorized into seven core information types. Taking a financial scenario as an example, at least 1000 similar questions need to be accumulated (e.g., the impact of monetary policy on bank financial indicators, the effect of interest rate adjustments on the stock market, etc.). The initial screening rules are: remove low-quality data and retain "valid samples" that meet the following requirements: user feedback rating ≥ 4 points (accurate and useful answers); core component coverage of the purified subgraph Gfinal ≥ 90% (no missing key logic); consistency between the inference chain CoT and answer A ≥ 0.85 (semantic matching degree, evaluated using LLM). For example, if a user rating for a question about "2024 reserve requirement ratio cut" is 3 points (considering the answer's logic ambiguous), it is directly removed to avoid low-quality data interfering with distillation. Simultaneously, structured storage (such as a hybrid storage of MySQL (My Structured Query Language, an open-source relational database management system) + Neo4j) is used. "Question Q, Answer A, Inference Chain CoT" stores text, "Subgraph G Original / Gfinal" stores graph structure data, and "Rating Log" stores numerical data, facilitating subsequent rapid querying and analysis.
[0106] Step 2: High-quality sample distillation (core value extraction):
[0107] From the selected valid samples, further refine "high-value supervisory data," which is the core link in system evolution and requires focusing on "reasoning logic purification" and "component contribution verification." Distillation Dimensions and Operations: Reasoning Logic Chain Distillation: For each valid sample, extract the mapping relationship of "Question Q → Purified Subgraph Gfinal → Reasoning Chain CoT → Answer A" to form a "logic template." For example, from the sample "2024 RRR cut affects bank net profit," distill out the general logic template for the transmission of financial and monetary policies: "[Monetary Policy Tools] → [Affecting Intermediate Indicators (such as the Reserve Requirement Ratio)] → [Affecting Business Indicators (such as Credit Scale)] → [Related Financial Indicators (such as Net Profit)]," and mark the core entities / relationships of each link (such as "RRR cut → Reserve Requirement Ratio → Credit Scale → Net Profit"). Component Contribution Verification and Labeling: Based on historical scoring logs, the characteristics of high-frequency core components are statistically analyzed. For example, in 100 samples of "monetary policy affecting bank finances," entities such as "reserve requirement ratio," "net interest margin," and "credit scale" have an Sfinal score of ≥7 in 92% of cases, and the average confidence score of the relationship from "central bank announcements" is 0.95. These characteristics are labeled as "high-contribution component tags in financial scenarios" for subsequent optimization. Redundant Component Feature Summary: Features that are judged as "useless components" three times consecutively are statistically analyzed, such as "outdated policy data (e.g., the 2023 reserve requirement ratio cut)," "non-core institutional information (e.g., the address of the central bank's office building)," and "non-related financial indicators (e.g., the number of bank employees)" in financial scenarios, forming a "noisy component feature library." Distillation Tools and Output: Distillation is performed using LLM combined with a rule engine, outputting three types of data: a "problem type - logic template" mapping library (e.g., "monetary policy impact problems → general transmission template"); a "scenario - high-contribution component feature" library; and a "noisy component feature - filtering rule" library.
[0108] Step 3: Multi-dimensional system optimization:
[0109] The high-value data obtained from distillation is used for LLM fine-tuning, knowledge graph purification, and retrieval strategy updates to achieve end-to-end system optimization. LLM inference capability optimization (fine-tuning training): Training data construction: 1000 high-quality samples after distillation are selected. Each sample is formatted as "Input: Question Q + purified subgraph Gfinal (textualized), Output: Inference chain CoT + Answer A," ensuring that both input and output contain accurate logical connections. Fine-tuning process: The basic LLM is fine-tuned. The training goal is to enable the LLM to more accurately identify the "question-subgraph component" relationship and reduce attention to noisy components. For example, after fine-tuning, when dealing with the question of "2024 reserve requirement ratio cut," the LLM can more quickly focus on the core logic of "reserve requirement ratio → credit scale → net profit," rather than getting bogged down in redundant information such as "2023 reserve requirement ratio cut." Redundant Component Cleanup: Based on the "noisy component feature library," the global knowledge graph is automatically scanned, and components marked as "useless" three times consecutively are processed—Entities / Relationships: If they are "outdated data (such as the 2023 reserve requirement ratio cut)," their retrieval priority is reduced (they are ranked later during retrieval); if they are "irrelevant information (such as the address of the central bank's office building)," they are directly deleted from the knowledge graph to reduce redundancy in subsequent retrievals. Core Component Enhancement: For high-frequency, high-contribution components (such as "reserve requirement ratio" and "net interest margin"), their attribute information (such as historical values and industry averages) is supplemented, and their index weight in the knowledge graph is increased to ensure priority recall during retrieval. Retrieval Template Optimization: The distilled "logical templates" are embedded in the retrieval process. For example, when processing "money policy impact questions," the retrieval template of "money policy tools → intermediary indicators → business indicators → financial indicators" is automatically loaded, and only subgraphs that conform to this structure are recalled, reducing noise in the initial retrieval. Filtering threshold adjustment: Based on historical scoring data, the thresholds of each module are dynamically adjusted. For example, in a financial scenario, if it is found that "when the relationship confidence score is ≥0.95, the component contribution rate reaches 98%", then the relationship confidence score threshold during retrieval will be increased from 0.9 to 0.92 to further improve the initial retrieval quality.
[0110] Step 4: Validation and Iteration of Results
[0111] After optimization, the effectiveness must be verified and continuously iterated to avoid over-optimization. Verification metrics: Three core metrics are set: Reasoning quality: Answer accuracy (≥15% improvement compared to before optimization), illusion rate (≥20% decrease); Efficiency: Retrieval time (≥30% decrease), reasoning time (≥25% decrease); User experience: User feedback rating (≥4.5 points). Taking a financial scenario as an example, after optimization, the retrieval time for the question "2024 reserve requirement ratio cut" decreased from 2.5 seconds to 1.7 seconds, and the answer accuracy increased from 82% to 96%. Iteration mechanism: Every 500 new valid samples are accumulated, the "data filtering-distillation-optimization-verification" process is repeated, and the metrics are re-evaluated after each iteration. If a certain type of optimization leads to a decrease in a metric (such as the accidental deletion of core components during knowledge graph purification), the previous version is rolled back and the rules are corrected. For example, if it is found that the completeness of answers to some "comparison of reserve requirement ratio reduction policies" questions decreases after deleting "2023 reserve requirement ratio reduction", the rule will be adjusted to "filter outdated data only in the 'single year policy impact' question, and retain the 'policy comparison' question".
[0112] Through the above four steps, the GraphRAG system achieves "data-driven self-evolution"—gradually upgrading from "passively handling problems" to "actively optimizing performance," especially in scenarios such as finance where accuracy and efficiency are highly demanding, continuously improving the quality of question answering and user experience.
[0113] In this way, this application constructs a complete closed loop of "interpretability-traceability-self-optimization": high-contribution components come with scoring criteria, and the subgraph S_q can generate a visual reasoning flowchart, allowing users to clearly trace the answer derivation chain. If an error is reported, the problem in the retrieval or filtering stage can be located in reverse. At the same time, high-quality samples distilled from high-contribution components can be used for LLM fine-tuning, reducing model bias. Furthermore, the knowledge graph can be dynamically purified based on feedback from useless components, strengthening the confidence of core relationships and cleaning up redundant error information. This allows the GraphRAG system to continuously improve its performance with use, making up for the shortcomings of traditional technologies such as poor interpretability, static nature, and easy performance degradation. This provides a more efficient, reliable, and sustainable technical path for the integration and implementation of LLM and GraphRAG.
[0114] See Figure 2 As shown, this embodiment of the invention discloses an intelligent question-answering device based on GraphRAG, comprising:
[0115] The labeled node acquisition module 11 is used to acquire the retrieval results returned by GraphRAG based on the input question, represent the retrieval results as a directed graph, extract the target entity nodes from the input question and the initial question response generated by the large language model, and label the target entity nodes in the directed graph to obtain labeled nodes.
[0116] The first scoring module 12 is used to perform natural language vectorization on the types of each relation in the directed graph to obtain a target vector, and to determine the first score of the target component based on the target relevance degree and degree centrality of each node in the directed graph, as well as the relation bridging degree and relation confidence degree of each relation; the target relevance degree represents the shortest path length from the node to the labeled node; the relation bridging degree represents the total number of paths containing the relation in all possible paths from the question node to the answer node; the target component includes nodes and / or relations;
[0117] The second scoring determination module 13 is used to match the nodes and relationships in the thought chain generated when the large language model generates the initial question answer with the nodes and relationships in the directed graph based on the target vector, generate a first initial score according to the corresponding matching results and the first score, determine the second initial score of the target component according to the directed graph after deleting the corresponding nodes and relationships, and determine the second score according to the weighted average result of the first initial score and the second initial score.
[0118] The third scoring module 14 is used to determine whether there is semantic repetition between any two nodes or two relations in the directed graph, and to determine the third score of the target component based on the corresponding judgment result, the first score and the second score.
[0119] The target question answer determination module 15 is used to determine a target score based on the weighted average of the first score, the second score, and the third score, filter the relationships and nodes in the directed graph according to the target score, and determine the target question answer according to the corresponding filtering results.
[0120] Since the embodiments of the device part correspond to the embodiments described above, please refer to the embodiments described in the method part for the embodiments of the device part, and will not be repeated here.
[0121] As can be seen, this application filters topologically related components by anchoring node correlation and relationship bridging indicators, and relies on thought chain matching and matching verification to lock in the core elements actually involved in answer derivation. The semantic verification dimension uses the semantic understanding of the large model to make up for the rigidity of structural rules, which not only avoids the incorporation of useless components, but also captures implicit semantic relationships, ensuring the high purity of the input text of the large language model from the source, and completely solving the core pain points of low reasoning efficiency and high risk of illusion caused by input redundancy in traditional technologies. It enables accurate subgraph filtering results in different types of question-answering scenarios, and solves the contradictions of excessive noise in factual questions and missing key components in multi-hop questions in traditional technologies.
[0122] Furthermore, embodiments of this application also disclose an electronic device, Figure 3This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0123] Figure 3 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the GraphRAG-based intelligent question-answering method disclosed in any of the foregoing embodiments. Alternatively, the electronic device 20 in this embodiment may specifically be a computer.
[0124] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0125] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0126] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the GraphRAG-based intelligent question-answering method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.
[0127] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned GraphRAG-based intelligent question-answering method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0128] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0129] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0130] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0131] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0132] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A GraphRAG-based intelligent question answering method, characterized in that, The method comprises the following steps: acquiring a retrieval result returned by GraphRAG based on an input question, representing the retrieval result as a directed graph, extracting target entity nodes in the input question and an initial question answer generated by a large language model through the large language model, and marking the target entity nodes in the directed graph to obtain marked nodes; performing natural language vectorization on the types of each relationship in the directed graph to obtain a target vector, determining a first score of a target component based on a target correlation degree of each node in the directed graph, a degree centrality of the node, a relationship bridging degree of each relationship, and a relationship confidence of each relationship; the target correlation degree represents a shortest path length from the node to the marked node; the relationship bridging degree represents a total number of paths containing the relationship among all possible paths between a question node and an answer node; and the target component comprises nodes and / or relationships; matching nodes and relationships in a thought chain generated when the large language model generates the initial question answer with nodes and relationships in the directed graph based on the target vector, generating a first initial score according to a corresponding matching result and the first score, determining a second initial score of the target component according to the directed graph after deleting corresponding nodes and relationships, and determining a second score according to a weighted average result of the first initial score and the second initial score; determining whether semantic repetition exists between any two nodes or two relationships in the directed graph, and determining a third score of the target component according to a corresponding determination result, the first score, and the second score; determining a target score based on a weighted average of the first score, the second score, and the third score, screening each relationship and node in the directed graph according to the target score, and determining a target question answer according to a corresponding screening result; wherein the first score of the target component is determined based on the target correlation degree of each node in the directed graph, the degree centrality of the node, the relationship bridging degree of each relationship, and the relationship confidence of each relationship, comprising: determining an association degree score corresponding to the target correlation degree according to a shortest path length from the node to the marked node; wherein the shortest path length and the association degree score are in an inverse correlation relationship; determining the degree centrality of the node, normalizing the corresponding centrality value to obtain a normalized value; sorting the nodes in a high-to-low order based on the normalized value, dividing the nodes into different percentage intervals according to a sorting result, and configuring different degree centrality scores for the nodes in different percentage intervals; determining a total number of paths containing the relationship among all possible paths between a question node and an answer node, and determining a bridging degree score of the relationship based on the total number of paths; wherein the total number of paths and the bridging degree score of the relationship are in a positive correlation relationship; determining a confidence interval to which the relationship confidence of the relationship belongs, and configuring different confidence scores for the relationship according to different confidence intervals; determining a first score of the node according to a weighted average result of the association degree score and the degree centrality score. determine a first score of the relationship according to a weighted average result of the bridging score and the confidence score; the second initial score of the target component determined according to the directed graph after deleting the corresponding nodes and relationships comprises: generating a first subgraph of deleting any node and a second subgraph of deleting any relationship for each node and relationship in the directed graph respectively; generating a new reply based on the first subgraph and the second subgraph by using the large language model, and determining the accuracy, completeness and consistency of the new reply based on the initial problem reply; determining the second initial score of the deleted node or relationship corresponding to the new reply based on whether the accuracy of the new reply changes, whether the completeness is missing, and the size relationship between the consistency and the preset value; the third score of the target component determined according to the corresponding judgment result, the first score and the second score comprises: if there is semantic repetition between any two nodes or two relationships in the directed graph, it is determined that the node or relationship is a redundant component, and the difference between the sum of the first score and the second score and the target value is determined as the third score of the target component; otherwise, the sum of the first score and the second score is determined as the third score of the target component.
2. The GraphRAG-based intelligent question answering method of claim 1, wherein, the nodes and relationships in the thought chain generated by the large language model when generating the initial problem reply based on the target vector are matched with the nodes and relationships in the directed graph, and the first initial score is generated according to the corresponding matching result and the first score, comprising: the nodes and relationships in the thought chain generated by the large language model when generating the initial problem reply are matched with the nodes and relationships in the directed graph according to the entity node name and the relationship type, and the nodes and relationships in the thought chain generated by the large language model when generating the initial problem reply are matched with the nodes and relationships in the directed graph based on the target vector, to obtain the corresponding matching result; the first initial score of the nodes and relationships in the directed graph is determined based on the matching result and the size relationship between the first score of the node or relationship and the preset threshold.
3. The GraphRAG based intelligent question answering method of claim 1, wherein, the relationships and nodes in the directed graph are screened according to the target score, and the target problem reply is determined according to the corresponding screening result, comprising: if the target score is greater than or equal to a first value, the corresponding relationship or node is marked as a core component; if the target score is greater than or equal to a second value and less than the first value, the corresponding relationship or node is marked as an auxiliary component; if the target score is less than the second value, the corresponding relationship or node is deleted; determining the target problem reply according to the core component and the auxiliary component.
4. The GraphRAG-based intelligent question answering method of claim 1, wherein, It also includes: optimizing and adjusting the large language model based on the core component, the input question, the target problem reply and the thought chain to obtain an adjusted model, so as to perform intelligent question and answer based on the adjusted model.
5. A GraphRAG-based intelligent question answering device, characterized in that, It includes: The marking node acquisition module is configured to acquire a search result returned by GraphRAG based on an input question, represent the search result as a directed graph, extract target entity nodes in the input question and an initial question answer generated by the large language model through the large language model, mark the target entity nodes in the directed graph to obtain marked nodes, and determine a first score of a target component based on a target correlation degree of each node in the directed graph, a degree centrality of the node, a relationship bridging degree of each relationship, and a relationship confidence degree. The first score determination module is configured to perform natural language vectorization on types of relationships in the directed graph to obtain a target vector, and determine the first score of the target component based on the target correlation degree of each node in the directed graph, the degree centrality of the node, the relationship bridging degree of each relationship, and the relationship confidence degree. The target correlation degree represents a shortest path length from a node to the marked node. The relationship bridging degree represents a total number of paths containing the relationship among all possible paths between a question node and an answer node. The second score determination module is configured to match nodes and relationships in a thinking chain generated when the large language model generates the initial question answer with nodes and relationships in the directed graph based on the target vector, generate a first initial score according to a corresponding matching result and the first score, determine a second initial score of the target component according to the directed graph after deleting corresponding nodes and relationships, and determine a second score according to a weighted average result of the first initial score and the second initial score. The third score determination module is configured to determine whether semantic repetition exists between any two nodes or two relationships in the directed graph, and determine a third score of the target component according to a corresponding determination result, the first score, and the second score. The target question answer determination module is configured to determine a target score based on a weighted average of the first score, the second score, and the third score, filter each relationship and node in the directed graph according to the target score, and determine a target question answer according to a corresponding filtering result. The first score determination module is configured to determine a correlation degree score corresponding to a target correlation degree according to a shortest path length from a node to the marked node; the shortest path length and the correlation degree score are in an inverse correlation relationship; determine a degree centrality of the node, normalize the corresponding centrality value, and obtain a normalized value; sort the nodes in a descending order based on the normalized value, divide the nodes into different percentage intervals according to the sorting result, and configure different degree centrality scores for the nodes in different percentage intervals; determine a total number of paths containing the relationship among all possible paths between the question node and the answer node, and determine a bridging degree score of the relationship based on the total number of paths; the total number of paths and the bridging degree score of the relationship are in a positive correlation relationship; determine a confidence interval to which a relationship confidence of the relationship belongs, and configure different confidence scores for the relationship according to different confidence intervals; determine a first score of the node according to a weighted average result of the correlation degree score and the degree centrality score; and determine a first score of the relationship according to a weighted average result of the bridging degree score and the confidence score. The second score determination module is configured to generate a first subgraph by deleting any node and a second subgraph by deleting any relationship for each node and relationship in the directed graph; generate a new reply based on the first subgraph and the second subgraph by using a large language model, determine the accuracy, completeness and consistency of the new reply based on the initial question reply; and determine a second initial score of a deleted node or relationship corresponding to the new reply based on whether the accuracy of the new reply is changed, whether the completeness is missing, and the size relationship between the consistency and a preset value. The third score determination module is configured to determine that the node or the relationship is a redundant component if there is semantic repetition between any two nodes or two relationships in the directed graph, determine a third score of the target component as a difference between a sum of the first score and the second score and a target value, or otherwise, determine the third score of the target component as the sum of the first score and the second score.
6. An electronic device, comprising: The method comprises: a memory for storing a computer program; a processor for executing the computer program to implement the GraphRAG-based intelligent question answering method according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, A computer program is stored on a computer readable storage medium, and the computer program is executed by a processor to implement the GraphRAG-based intelligent question answering method according to any one of claims 1 to 4.
Citation Information
Patent Citations
GraphRAG-based large model question and answer method, system and equipment, medium and product
CN119558401A
Retrieval enhancement generation method and device based on knowledge graph and storage medium
CN120849581A