A knowledge graph-based large language model question and answer method and system

CN123030726APending Publication Date: 2026-11-03SHANGSHANG (SUZHOU) DIGITAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611465399.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-20
Publication Date
2026-11-03

AI Technical Summary

Technical Problem

Existing knowledge graph question answering methods suffer from inaccurate semantic parsing, imprecise error location, and poor evidence consistency during user question parsing, error query structure localization, and answer generation. They also struggle to maintain the correspondence between query targets, semantic constraints, and answer types.

Method used

We employ an improved Coarse2Fine model, counterfactual semantic sketches, restricted graph rewriting, and bidirectional closure fixed point methods. By parsing user questions and knowledge graph data, we construct a topological semantic sketch, decompose the sketch atoms, change the connection relationships one by one, locate erroneous nodes, and perform restricted graph rewriting and bidirectional closure fixed point generation to ensure the accuracy and interpretability of the answer.

Benefits of technology

It improves the efficiency of query structure correction, enhances the accuracy of semantic parsing and the interpretability of question-and-answer results, ensures the consistency between answers and evidence paths, and reduces answer content that deviates from the facts of the knowledge graph.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123030726A_ABST
    Figure CN123030726A_ABST
Patent Text Reader

Abstract

The application discloses a kind of big language model question and answer method and system based on knowledge graph, it is related to natural language processing technical field, including following steps: step one: collection user question and knowledge graph data, generate question semantic record;Step two: build improved Coarse2Fine model, generate topological semantic sketch and sketch atom set;Step three: change the connection of target sketch atom, generate counterfactual semantic sketch set;Step four: according to execution result difference determines minimum error-prone atomic set;Step five: extract semantic invariants and execute restricted graph rewriting, generate rewritten semantic sketch;Step six: establish forward query state and reverse answer state, form relationship combination signature;Step seven: spread constraint and form two-way closure fixed point;Step eight: generate answer proposition set and evidence path, drive big language model to generate question and answer result.The application improves the accuracy of question and answer and evidence traceability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, and in particular to a question-answering method and system based on a knowledge graph and a large language model. Background Technology

[0002] With the increasing demand for knowledge graph technology and large language models, semantic parsing, graph querying, and answer generation technologies for user-oriented questions have received widespread attention. Existing knowledge graph question answering methods mainly rely on fixed query templates, one-way path search, and direct answer generation from large language models. However, these methods commonly suffer from the following problems in practical applications: The complex relationships between query targets, semantic constraints, and answer types in user questions make it difficult for traditional semantic parsing methods to reliably map to entity nodes and relation edges in the knowledge graph. This can easily lead to query structures with incorrect connection directions and mismatched node types, reducing the accuracy of question understanding. Existing query sketch generation methods lack interpretable localization mechanisms for incorrect connection locations. They typically use overall reconstruction and repeated searches to correct the query structure, making it difficult to distinguish between local connection errors and overall semantic shifts. This results in a wider correction range and decreased query efficiency. Furthermore, the lack of bidirectional consistency checks between the forward query path and the candidate answer backtracking path in the knowledge graph makes it difficult to maintain the correspondence between query targets, semantic constraints, and answer types during the answer generation process. This can easily lead to problems such as broken evidence paths, inconsistencies between answer propositions and graph facts, and generated content exceeding the scope of entity nodes and relation edges.

[0003] Therefore, how to provide a question-answering method and system based on knowledge graphs for large language models is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0004] One objective of this invention is to propose a question-answering method and system based on a knowledge graph-based large language model. This invention employs an improved Coarse2Fine model, counterfactual semantic sketches, restricted graph rewriting, and bidirectional closure fixed-point methods to achieve user question parsing, error query structure location and correction, evidence path generation, and answer generation. It has the advantages of accurate semantic parsing, precise error location, high evidence consistency, and interpretable question-answering results.

[0005] A question-answering method based on a knowledge graph and a large language model according to an embodiment of the present invention includes the following steps: Step 1: Collect user questions and knowledge graph data, analyze query targets, semantic constraints and answer types, and generate question semantic records; Step 2: Construct an improved Coarse2Fine model based on the semantic records of the questions, combine it with knowledge graph data to generate a topological semantic sketch and decompose it into a set of sketch atoms; Step 3: Maintain the structural state of the uninterrupted sketch atoms, change the connection relationships of the target sketch atoms one by one, and generate a counterfactual semantic sketch set; Step 4: Execute the topological semantic sketch and counterfactual semantic sketch set, generate counterfactual execution responses based on the differences in execution results, and determine the minimum set of fault-causing atoms; Step 5: Extract semantic conservation quantities from the problem semantic record, perform restricted graph rewriting on the sketch region where the minimum fault-causing atom set is located, and generate a rewritten semantic sketch; Step 6: Based on the rewritten semantic sketch, establish a forward query state that expands candidate answers from the query target, and establish a reverse answer state that traces back to the query target from the candidate answers based on the answer type, forming a relational composite signature; Step 7: Based on semantic conservation quantities and relational combination signatures, propagate constraints between the forward query state and the reverse answer state to form a bidirectional closure fixed point; Step 8: Generate the answer proposition set and evidence path based on the bidirectional closure fixed points, and drive the large language model to generate question-and-answer results.

[0006] Optionally, step one specifically includes: Acquire user questions and knowledge graph data, encode entity nodes, relation edges and node types in the knowledge graph data, and generate a knowledge graph pattern index; The system performs word segmentation, part-of-speech tagging, and dependency parsing on user questions. Based on the knowledge graph pattern index, it maps noun components to entity nodes and predicate components to relation edges, generating question graph mapping records. The query target is determined based on the dependency path between the question component and the entity node in the question graph mapping record, and semantic constraints are generated based on the attachment position between the modifying component and the relation edge. The answer type is determined based on the node type and question component corresponding to the query target. The query target, semantic constraints and answer type are associated according to the dependency path to generate a question semantic record.

[0007] Optionally, step two specifically involves: The query target, semantic constraints, and answer type in the question semantic record are parsed. The query target is mapped to the query target node, the semantic constraints are mapped to the constraint node, and the answer type is mapped to the answer type node. The query target node, constraint node, and answer type node are connected according to the relationship in the question semantic record to generate a semantic node sequence. Extract node type relationships and relation edge connection directions from knowledge graph data, limit the node connection positions in the semantic node sequence based on node type relationships, limit the node connection order based on relation edge connection directions, and generate a coarse-grained topology structure. An improved Coarse2Fine model is constructed, which includes a coarse-grained topology generation layer and a fine-grained slot instantiation layer. The coarse-grained topology generation layer processes the semantic node sequence and coarse-grained topology structure, while the fine-grained slot instantiation layer fills entity slots and relation slots based on knowledge graph data and binds semantic constraints to the corresponding node connection positions to generate a topological semantic sketch. Traverse the node connection relationships in the topological semantic sketch, divide the topological semantic sketch according to the scope of influence of a single connection change, and determine the sketch region that retains the connection interface and contains a single variable connection relationship as the sketch atom, and generate the sketch atom set.

[0008] Optionally, step three specifically includes: Select a sketch atom as the target sketch atom according to the connection order of the sketch atom set in the topological semantic sketch, and mark the remaining sketch atoms in the sketch atom set as uninterrupted sketch atoms; Lock the structural state and connection relationships of uninterrupted sketch atoms, preserve the connection interfaces of target sketch atoms, and filter the relationship edges of the start node type and end node type to match the node types at both ends of the connection interface from the knowledge graph data to form a candidate connection relationship set; According to the order of the candidate connection relationship set, each candidate connection relationship replaces the original connection relationship of the target sketch atom. Based on the connection interface, the target sketch atom that has been replaced is embedded into the topological semantic sketch to form the counterfactual semantic sketch corresponding to the target sketch atom. Each sketch atom in the sketch atom set is selected sequentially as the target sketch atom, and the resulting counterfactual semantic sketches are used to generate a counterfactual semantic sketch set.

[0009] Optionally, step four specifically involves: A baseline query path is formed according to the node connection order in the topological semantic sketch. Node matching and relation edge jumps are performed along the baseline query path in the knowledge graph data. The path termination position, the number of candidate answers, and the semantic constraint satisfaction status are recorded to generate a baseline execution record. Counterfactual query paths are formed according to the order of the counterfactual semantic sketch set. The counterfactual query paths are executed one by one in the knowledge graph data. The path termination position, the number of candidate answers and the semantic constraint satisfaction status are associated with the target sketch atom and candidate connection relationship to generate a counterfactual execution record set. The counterfactual execution record set is compared with the baseline execution record according to the node connection position. The differences in path termination position, number of candidate answers, and semantic constraint satisfaction state are calculated. The node connection positions that produce differences are marked as abnormal node connection positions, and a counterfactual execution response is generated. The filtering path extends to the node corresponding to the answer type and the counterfactual execution response is executed when the semantic constraint is satisfied and the state is changed to satisfied. The associated target sketch atom is identified as a fault-causing candidate atom. From the fault-causing candidate atoms, the atom combination that covers all abnormal node connection positions and has the fewest atoms is selected to determine the minimum fault-causing atom set.

[0010] Optionally, step five specifically includes: The relationships between query targets, semantic constraints, and answer types are read from the question semantic record. The semantic conservation quantities are generated by encoding the relationships between query targets and answer types according to the order of their pointers and the positions of the semantic constraints. The sketch region is determined based on the connection position of the minimum fault-causing atom set in the topological semantic sketch, the node connection relationship outside the sketch region is fixed, and the connection interface between the sketch region and adjacent sketch atoms is preserved. From the counterfactual execution response, candidate connections that are associated with the minimum fault-causing atom set and whose semantic constraints are satisfied are selected. Based on the connection interface, the candidate connections replace the original connections in the sketch area to generate a rewritten candidate sketch. Extract the pointer order from the query target to the answer type and the limiting position of semantic constraints in the candidate rewrite sketch, compare them item by item with the semantic conservation quantity, retain the candidate rewrite sketches that match the comparison, and generate a rewrite semantic sketch.

[0011] Optionally, step six specifically includes: The query target in the rewritten semantic sketch is mapped to the entity node in the knowledge graph data and determined as the positive starting node. Relationship edge jumps are performed according to the node connection order in the rewritten semantic sketch. The entity node and relationship edge formed by each jump are recorded to generate a positive node sequence and a positive relationship sequence. Entity nodes are filtered from the positive node sequence based on the answer type, and candidate answers are determined. The positive node sequence, positive relation sequence, and candidate answers are associated according to the node connection order to establish a positive query state. The candidate answer is determined as the reverse starting node. The relation edges are backtracked in reverse order of node connection in the rewritten semantic sketch until the entity node corresponding to the query target is reached. The entity nodes and relation edges formed by the backtracking are recorded, the reverse node sequence and reverse relation sequence are generated, and the reverse answer state is established. Align the forward and reverse relation sequences according to the node connection positions, extract the relation edge connection direction, entity node type, and semantic constraint position, and encode them according to the connection order from the query target to the candidate answer to form a relation combination signature.

[0012] Optionally, step seven specifically includes: Based on the relation combination signature, align the positive node sequence and positive relation sequence in the positive query state with the reverse node sequence and reverse relation sequence in the reverse answer state according to the node connection position, filter the node connection relationships with the same relation edge connection direction, the same entity node type, and the same semantic constraint limitation position, and generate bidirectional matching relationships; Based on the bidirectional matching relationship, delete entity nodes and relation edges in the forward query state that do not match the reverse answer state, and delete entity nodes and relation edges in the reverse answer state that do not match the forward query state, and update the forward query state and the reverse answer state. Based on the semantic conservation quantity, the updated forward query state and reverse answer state are verified. The node connection relationship between the query target and the answer type is kept in the same order and the semantic constraint is consistent. The bidirectional matching relationship generation and state update are executed in a loop. By comparing the forward query state and the reverse answer state formed by two adjacent state updates, a bidirectional closure fixed point is formed when the entity nodes, relation edges, and candidate answers remain consistent, and the candidate answer in the forward query state is consistent with the reverse starting node in the reverse answer state.

[0013] Optionally, step eight specifically includes: Read candidate answers and their corresponding entity nodes and relation edges from bidirectional closure fixed points, and associate the query target, semantic constraints, candidate answers and answer types according to the connection order from the query target to the candidate answers to generate an answer proposition set; Extract the entity node identifiers and relation edge identifiers from the bidirectional closure fixed points according to the node connection order from the query target to the candidate answer. Connect the entity node identifiers and relation edge identifiers in sequence to generate the evidence path corresponding to each answer proposition. Establish the correspondence between the answer proposition set and the evidence path based on the candidate answer identifier, and generate question and answer generation records according to the association order of query target, semantic constraints, candidate answers and evidence paths; Based on the question-and-answer generation records, the entity generation scope and relation generation scope of the large language model are limited. The answer text is generated according to the order of the answer proposition set. The answer text is associated with the evidence path to generate the question-and-answer result.

[0014] According to an embodiment of the present invention, a large language model question-answering system based on a knowledge graph includes: The semantic parsing module is used to collect user questions and knowledge graph data, parse query targets, semantic constraints and answer types, and generate question semantic records; The sketch building module is used to build the improved Coarse2Fine model, generating topological semantic sketches and sketch atom sets; The counterfact generation module is used to change the connection relationships of atoms in the target sketch and generate a counterfact semantic sketch set; The execution attribution module compares the execution results of the topological semantic sketch with the counterfactual semantic sketch set, and generates the counterfactual execution response and the minimum set of fault-causing atoms. The restricted rewrite module is used to extract semantic conservation quantities and perform restricted graph rewrite on the sketch region where the minimum fault-causing atom set is located, generating a rewritten semantic sketch. The bidirectional state module is used to establish a forward query state and a reverse answer state based on the rewritten semantic sketch, forming a relational composite signature. The closure propagation module is used to propagate constraints based on semantically conserved quantities and relational combination signatures to form bidirectional closure fixed points. The question-and-answer generation module is used to generate answer proposition sets and evidence paths based on bidirectional closure fixed points, driving the large language model to generate question-and-answer results.

[0015] The beneficial effects of this invention are: This invention parses the query target, semantic constraints, and answer type in user questions, and uses an improved Coarse2Fine model to construct a topological semantic sketch, transforming complex question-and-answer requests into a graph structure with clearly defined node connections. By decomposing the topological semantic sketch into sketch atoms, changing the connections of the target sketch atoms one by one, and executing the counterfactual semantic sketch, the abnormal node connection positions can be located based on the differences in execution results. This further determines the minimum set of error-causing atoms, avoiding indiscriminate reconstruction of the complete query structure, thereby narrowing the error location range and improving the efficiency of query structure correction and the accuracy of semantic parsing.

[0016] This invention employs constrained graph rewriting of the sketch region containing the minimum error-causing atom set by semantic conservation constraints. This ensures that the rewritten semantic sketch maintains consistency in the order of pointers from the query target to the answer type and the position of semantic constraints, reducing semantic shifts caused by query structure modifications. By establishing forward query states and reverse answer states, and forming bidirectional closure fixed points based on relation combination signature propagation constraints, entity nodes, relation edges, and candidate answers lacking bidirectional support can be filtered out, ensuring consistency between the answer proposition set and the evidence path. The large language model limits the scope of entity generation and relation generation based on question-and-answer generation records, reducing answer content that deviates from the facts of the knowledge graph and improving the accuracy, interpretability, and traceability of the question-and-answer results. Attached Figure Description

[0017] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a flowchart of a large language model question-answering method based on knowledge graphs proposed in this invention; Figure 2This is a schematic diagram illustrating the bidirectional closure fixed point formation of a large language model question-answering method based on knowledge graphs proposed in this invention. Detailed Implementation

[0018] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0019] refer to Figures 1-2 A question-answering method based on a knowledge graph and a large language model includes the following steps: Step 1: Collect user questions and knowledge graph data, analyze query targets, semantic constraints and answer types, and generate question semantic records; Step 2: Construct an improved Coarse2Fine model based on the semantic records of the questions, combine it with knowledge graph data to generate a topological semantic sketch and decompose it into a set of sketch atoms; Step 3: Maintain the structural state of the uninterrupted sketch atoms, change the connection relationships of the target sketch atoms one by one, and generate a counterfactual semantic sketch set; Step 4: Execute the topological semantic sketch and counterfactual semantic sketch set, generate counterfactual execution responses based on the differences in execution results, and determine the minimum set of fault-causing atoms; Step 5: Extract semantic conservation quantities from the problem semantic record, perform restricted graph rewriting on the sketch region where the minimum fault-causing atom set is located, and generate a rewritten semantic sketch; Step 6: Based on the rewritten semantic sketch, establish a forward query state that expands candidate answers from the query target, and establish a reverse answer state that traces back to the query target from the candidate answers based on the answer type, forming a relational composite signature; Step 7: Based on semantic conservation quantities and relational combination signatures, propagate constraints between the forward query state and the reverse answer state to form a bidirectional closure fixed point; Step 8: Generate the answer proposition set and evidence path based on the bidirectional closure fixed points, and drive the large language model to generate question-and-answer results.

[0020] In this embodiment, step one specifically includes: Acquire user questions and knowledge graph data, read the entity identifier and node type of each entity node in the knowledge graph data, establish entity node codes based on entity identifiers, read the start node, end node and connection direction of each relation edge, establish relation edge codes according to the connection order from start node to end node, arrange entity node codes, relation edge codes and node types according to connection position, and generate knowledge graph pattern index. The system performs word segmentation on user questions based on character boundaries and word combination relationships. It completes part-of-speech tagging based on the grammatical function of each word in the user question. It constructs a dependency syntax tree based on the modification and dominance relationships between words. It extracts nominal and predicate components from the dependency syntax tree. It matches nominal components with entity node codes in the knowledge graph pattern index and predicate components with relation edge codes. It records the matching positions and connection directions and generates question graph mapping records. Locate the dependency node corresponding to the question component from the question graph mapping record, trace the dominance link between the question component and the entity node along the dependency syntax tree, determine the entity node pointed to by the dominance link as the query target, read the attachment node and attachment direction of the modifier in the dominance link, limit the relation edge of the modifier's effect based on the attachment node, determine the constraint position of the relation edge based on the attachment direction, and generate semantic constraints. The system reads the node type corresponding to the query target in the knowledge graph schema index, determines the answer type based on the matching relationship between the object category pointed to by the question component and the node type, establishes the connection relationship between the query target, semantic constraints and answer type according to the dominance link in the dependency syntax tree, and records the connection relationship according to the word order in the user question to generate a question semantic record.

[0021] In this embodiment, step two specifically involves: The query target, semantic constraints, and answer type in the question semantic record are analyzed. Query target nodes are established according to the position of the query target in the question semantic record, constraint nodes are established according to the limiting objects corresponding to the semantic constraints, and answer type nodes are established according to the result categories corresponding to the answer types. Then, the query target nodes, constraint nodes, and answer type nodes are connected according to the association position between the query target and semantic constraints in the question semantic record and the pointing relationship between the query target and the answer type, generating a semantic node sequence of the record node arrangement order and node connection relationship. Read the node type of entity nodes and the connection direction of the relation edges from the knowledge graph data. Establish node type relationship based on the node type corresponding to the start end of the relation edge and the node type corresponding to the end end of the relation edge. Use the node type relationship to verify whether adjacent nodes in the semantic node sequence can be connected by the relation edge. Determine the node position that satisfies the node type relationship as the connection position. Then arrange the node connection order according to the direction of the relation edge from the start end to the end end to generate a coarse-grained topology structure. An improved Coarse2Fine model is constructed, which includes a coarse-grained topology generation layer and a fine-grained slot instantiation layer. The coarse-grained topology generation layer processes the coarse-grained topology structure according to the node arrangement order in the semantic node sequence and fixes the connection framework between the query target node, constraint node, and answer type node. The fine-grained slot instantiation layer selects entity nodes with the same relationship as the node type from the knowledge graph data to fill the entity slots and selects relation edges with the same relationship order as the node connection to fill the relation slots. Then, according to the constraint object corresponding to the semantic constraint, the semantic constraint is bound to the node connection position in the connection framework to generate a topological semantic sketch. Traverse the node connections in the topological semantic sketch, determine the sketch region that a single connection change can affect with each node connection as the change center, preserve the connection interface between the sketch region and the adjacent sketch region, determine the sketch region that contains only one variable node connection and whose external connection interface remains fixed as the sketch atom, and arrange all sketch atoms according to the connection order of the sketch atoms in the topological semantic sketch to generate the sketch atom set.

[0022] In this embodiment, step three specifically includes: Establish a sketch atom position sequence according to the connection order of the sketch atom set in the topological semantic sketch, select a sketch atom from the sketch atom position sequence and mark it as the target sketch atom, mark the sketch atoms that are not selected in the sketch atom set as uninterrupted sketch atoms, and record the original connection relationship of the target sketch atom and the structural state of the uninterrupted sketch atom. Lock the node positions, connection directions, and connection relationships of the uninterrupted sketch atoms, preserve the connection interfaces between the target sketch atom and its adjacent sketch atoms, read the node types at both ends of the connection interface from the knowledge graph data, determine the relationship edges whose starting node type matches the starting node type of the connection interface and whose ending node type matches the ending node type of the connection interface as candidate connection relationships, and form a set of candidate connection relationships according to the arrangement of the relationship edges in the knowledge graph data; Candidate connection relationships are extracted one by one according to the order of the candidate connection relationship set. Before each replacement, the original connection relationship of the target sketch atom is restored, and the original connection relationship is replaced by the current candidate connection relationship. The target sketch atom that has been replaced is connected to the topological semantic sketch according to the connection interface, while keeping the structural state of the uninterrupted sketch atom unchanged, thus forming the counterfactual semantic sketch corresponding to the current candidate connection relationship. Each sketch atom is selected as the target sketch atom according to the sequence of sketch atom positions. The process of candidate connection filtering and connection replacement is repeated. The counterfactual semantic sketches formed each time are collected in the order of target sketch atom positions and candidate connections to generate a counterfactual semantic sketch set.

[0023] In this embodiment, step four specifically includes: Entity slots and relation slots are read according to the node connection order in the topological semantic sketch. The node corresponding to the query target is taken as the starting node and the node corresponding to the answer type is taken as the ending node. Adjacent nodes are connected in sequence to form a baseline query path. In the knowledge graph data, entity nodes are matched starting from the starting node and jumps are performed along the relation edges. When a node match fails, the current node connection position is recorded as the path termination position. When the path reaches the termination node, the number of entity nodes that meet the answer type is counted as the number of candidate answers. The matching results of the nodes and relation edges corresponding to the semantic constraints are checked one by one and the semantic constraint satisfaction status is marked. The path termination position, the number of candidate answers, and the semantic constraint satisfaction status are collected to generate a baseline execution record. Each counterfactual semantic sketch is read according to the order of arrangement in the counterfactual semantic sketch set. A counterfactual query path is formed according to the node connection order. Entity node matching and relation edge jumps are performed from the node corresponding to the query target in the knowledge graph data. The path termination position of the counterfactual query path is recorded. The number of candidate answers reaching the node corresponding to the answer type is counted. The matching results of the nodes and relation edges corresponding to the semantic constraints are checked. The execution results are marked according to the target sketch atoms and candidate connection relationships associated with the counterfactual semantic sketch, and a counterfactual execution record set is generated. Align each counterfactual execution record in the counterfactual execution record set with the baseline execution record according to the node connection position. Use the difference in the position of the path termination position in the node connection order as the path termination position difference. Use the difference in the number of candidate answers in the counterfactual execution record minus the number of candidate answers in the baseline execution record as the candidate answer number difference. Determine the node connection position where the semantic constraint satisfaction state is inconsistent as the constraint state difference position. Mark the node connection positions where there are path termination position differences, candidate answer number differences, and constraint state differences as abnormal node connection positions. Associate the target sketch atoms to form the counterfactual execution response. From the counterfactual execution responses, select response records whose path termination position reaches the node corresponding to the answer type and whose semantic constraints are satisfied. Identify the target sketch atoms associated with the response records as candidate fault-causing atoms. Construct atomic coverage records based on the correspondence between the connection positions of abnormal nodes and candidate fault-causing atoms. Examine the coverage status of atomic combinations on the connection positions of abnormal nodes in ascending order of the number of candidate fault-causing atoms. I identify the first atomic combination that covers all connection positions of abnormal nodes as the minimum set of fault-causing atoms.

[0024] In this embodiment, step five specifically includes: The relationship between query target, semantic constraints and answer type is read from the question semantic record. The pointing order is determined according to the starting position of the query target in the relationship and the ending position of the answer type in the relationship. The limiting position is determined according to the binding position between the corresponding node of the semantic constraint and the connection relationship. The pointing order is encoded as a node arrangement identifier and the limiting position is encoded as a connection position identifier. The node arrangement identifier and the connection position identifier are combined to generate a semantic conservation quantity. Based on the node connection positions of each sketch atom in the minimal error-causing atom set in the topological semantic sketch, the topological range between the first node connection position and the last node connection position is determined as the sketch region. The node connection direction and node connection order outside the sketch region are locked, and the connection positions between the boundary nodes of the sketch region and adjacent sketch atoms are recorded to form a connection interface. Read the target sketch atom, candidate connection relationship and semantic constraint satisfaction status from the counterfactual execution response. Filter the candidate connection relationship that the target sketch atom belongs to the minimum fault-causing atom set and the semantic constraint satisfaction status is satisfied. Verify the candidate connection relationship according to the node type and connection direction at both ends of the connection interface. Replace the original connection relationship in the sketch area with the candidate connection relationship that passes the verification, keep the node connection relationship outside the sketch area unchanged, and generate a rewritten candidate sketch. Extract the pointer order from the query target to the answer type in the candidate rewrite sketch according to the node connection order. Extract the constraint position according to the binding relationship between semantic constraints and node connection positions. Compare the extracted pointer order and constraint position with the node arrangement identifier and connection position identifier in the semantic conservation quantity item by item. Retain the candidate rewrite sketches with consistent comparison results and generate the rewrite semantic sketch.

[0025] In this embodiment, step six specifically includes: The query target in the rewritten semantic sketch is matched with the entity nodes in the knowledge graph data according to the entity identifier. The entity nodes with the same entity identifier are determined as the positive starting node. The node connection order between the query target and the answer type in the rewritten semantic sketch is read. The connection direction of the relation edge and the type of the adjacent entity node are extracted in sequence according to the node connection position. Starting from the positive starting node, relation edges with the same connection direction and the same terminal node type are selected. The selected relation edges are jumped to the terminal entity node. The starting entity node, relation edge and terminal entity node formed by each jump are arranged according to the node connection position to generate the positive node sequence and the positive relation sequence. Read the node type corresponding to each entity node in the forward node sequence, compare the node type with the answer type in the question semantic record item by item, determine the entity node whose node type matches the answer type as the candidate answer, establish the connection relationship between the candidate answer and the forward relation sequence according to the position in the forward node sequence, arrange the forward node sequence, the forward relation sequence and the candidate answer according to the connection order from the query target to the candidate answer, and record the position of the entity node and the position of the relation edge corresponding to each candidate answer to establish the forward query state; The entity nodes corresponding to the candidate answers in the forward query state are determined as the reverse starting nodes. The connection direction of the relation edges is read backward from the position of the answer type to the position of the query target according to the node connection order in the rewritten semantic sketch. Starting from the reverse starting node, relation edges with the connection direction consistent with the reverse reading direction and matching start node type are selected. The selected relation edges are backtracked to the adjacent entity nodes. The entity nodes and relation edges are recorded according to the backtracking order until the entity node is consistent with the entity node corresponding to the query target. The reverse node sequence and reverse relation sequence are generated, and the reverse answer state is established according to the backtracking order between the candidate answer and the query target. Based on the node connection positions in the rewritten semantic sketch, the forward relation sequence and the reverse relation sequence are aligned item by item. The relation edge connection direction, the type of the starting entity node, the type of the ending entity node, and the semantic constraint position corresponding to each node connection position are read. The relation edge connection direction, entity node type, and semantic constraint position are sequentially encoded according to the connection order from the query target to the candidate answer. The encoding results are then correlated with the candidate answers to form a relation combination signature.

[0026] In this embodiment, step seven specifically includes: Based on the relation combination signature, read the relation edge connection direction, entity node type, and semantic constraint limitation position corresponding to each node connection position. Arrange the positive node sequence and positive relation sequence in the positive query state according to the connection order from the query target to the candidate answer. Transform and arrange the reverse node sequence and reverse relation sequence in the reverse answer state according to the connection order from the query target to the candidate answer. Compare the relation edge connection direction, entity node type, and semantic constraint limitation position of the same node connection position item by item. Establish the corresponding node connection relationship when all three items are consistent, and generate a bidirectional matching relationship. Based on the bidirectional matching relationship, retrieve the corresponding results of each entity node in the forward node sequence and each relation edge in the forward relation sequence in the reverse node sequence and reverse relation sequence, delete entity nodes and relation edges that lack corresponding results, then retrieve the corresponding results of each entity node in the reverse node sequence and each relation edge in the reverse relation sequence in the forward node sequence and forward relation sequence, delete entity nodes and relation edges that lack corresponding results, rearrange the forward node sequence, forward relation sequence, reverse node sequence and reverse relation sequence according to the retained node connection relationship, filter candidate answers based on the retained forward node sequence, and update the forward query status and reverse answer status; Based on the node arrangement identifier in the semantic conservation quantity, check the pointing order from the query target to the answer type in the updated forward query state and reverse answer state. Based on the connection position identifier in the semantic conservation quantity, check the semantic constraint limitation position. Delete node connection relationships with inconsistent pointing order and inconsistent semantic constraint limitation position. Regenerate bidirectional matching relationship using the retained node connection relationship and update the forward query state and reverse answer state. Repeatedly execute bidirectional matching relationship generation, node connection relationship filtering and state update. Record the forward query state and reverse answer state formed by two consecutive state updates. Compare the forward node sequence and reverse node sequence according to the entity node identifier and node connection position. Compare the forward relation sequence and reverse relation sequence according to the relation edge identifier and node connection position. Compare the candidate answer according to the entity node identifier. When the entity nodes, relation edges and candidate answers in two consecutive state updates are consistent, and the candidate answer in the forward query state is consistent with the reverse starting node in the reverse answer state, the stable connection structure formed by the forward query state and the reverse answer state is determined as a bidirectional closure fixed point.

[0027] In this embodiment, step eight specifically includes: Read the entity node identifiers corresponding to the candidate answers from the bidirectional closure fixed points, extract the relation edges and semantic constraint positions along the stable connection structure between the candidate answers and the query target, arrange the query target, semantic constraints, candidate answers and answer types according to the connection order from the query target to the candidate answers, and record each set of arrangement results as an answer proposition, and collect the answer propositions to generate an answer proposition set; Read the entity nodes and relation edges in the bidirectional closure fixed points one by one according to the node connection order from the query target to the candidate answer. Convert the entity nodes into entity node identifiers in the knowledge graph data and the relation edges into relation edge identifiers in the knowledge graph data. Establish the connection chain according to the alternating order of entity node identifiers and relation edge identifiers in the stable connection structure, and determine the connection chain as the evidence path of the corresponding answer proposition. Read the candidate answer identifier corresponding to each answer proposition in the answer proposition set, find the termination entity node identifier in the evidence path based on the candidate answer identifier, establish a correspondence between the answer propositions that match the same candidate answer identifier and the evidence path, and then arrange the correspondence according to the order of association of query target, semantic constraints, candidate answers and evidence paths to generate question and answer generation records; The entity content that the large language model can generate is limited by the entity node identifiers in the question-and-answer generation record, and the relation content that the large language model can generate is limited by the relation edge identifiers. Candidate answers and semantic constraints are organized according to the order of the answer proposition set to form the answer text. The answer text is then associated with the corresponding evidence path to generate the question-and-answer result.

[0028] A knowledge graph-based large language model question-answering system includes: The semantic parsing module is used to collect user questions and knowledge graph data, parse query targets, semantic constraints and answer types, and generate question semantic records; The sketch building module is used to build the improved Coarse2Fine model, generating topological semantic sketches and sketch atom sets; The counterfact generation module is used to change the connection relationships of atoms in the target sketch and generate a counterfact semantic sketch set; The execution attribution module compares the execution results of the topological semantic sketch with the counterfactual semantic sketch set, and generates the counterfactual execution response and the minimum set of fault-causing atoms. The restricted rewrite module is used to extract semantic conservation quantities and perform restricted graph rewrite on the sketch region where the minimum fault-causing atom set is located, generating a rewritten semantic sketch. The bidirectional state module is used to establish a forward query state and a reverse answer state based on the rewritten semantic sketch, forming a relational composite signature. The closure propagation module is used to propagate constraints based on semantically conserved quantities and relational combination signatures to form bidirectional closure fixed points. The question-and-answer generation module is used to generate answer proposition sets and evidence paths based on bidirectional closure fixed points, driving the large language model to generate question-and-answer results.

[0029] Example 1: To verify the feasibility of this invention in practice, it was applied to a simulated infusion monitoring scenario. A dropper detection device and a medicine bottle level detection device were installed on an infusion stand. Infrared transmitters and receivers were respectively positioned on both sides of the dropper. The dropper level detection unit was attached to the outer wall of the dropper, and the medicine bottle level detection unit was attached to the outer wall of the medicine bottle. The output values ​​of the infrared receivers, the dielectric response values ​​of the dropper and the medicine bottle were read according to a fixed sampling period, and the sampling time was written using a unified clock to form droplet pulse signals, dropper level signals, and medicine bottle level signals. This example mainly simulates the problems of blurred droplet pulse edges, amplitude fluctuations, and false jumps caused by changes in ambient light, dropper oscillation, air bubbles, and sensor drift. It also simulates abnormal drip rate, interrupted dripping, insufficient dropper level, and insufficient medicine bottle level to verify the ability to identify and issue early warnings for abnormal infusion states.

[0030] The test was set with four target drip rates: 20, 40, 60, and 80 drops per minute. For each target drip rate, 120 monitoring sequences were collected, each lasting 60 seconds, resulting in a total of 480 monitoring sequences and 28,800 seconds of continuous sampling data. The test data included 240 segments of normal infusion, 60 segments of ambient light changes, 50 segments of dripper oscillation, 40 segments of air bubble passage, 30 segments of drip interruption, 30 segments of abnormal dripper level, and 30 segments of abnormal medicine bottle level. Ambient light changes were determined by adjusting the illuminance around the infrared receiver; dripper oscillation was determined by causing small reciprocating movements of the dripper; air bubble passage was determined by air segments passing through the infrared detection area; drip interruption was determined by clamping the infusion tubing; and abnormal level was determined by gradually lowering the dripper or medicine bottle level. The testers used drop-by-drop verification results as reference values ​​for valid droplet events and recorded the actual liquid level using calibrated instruments as the basis for verifying abnormal states.

[0031] When applying this invention, the baseline of the droplet pulse signal is first corrected and normalized. A normalized pulse sequence and a droplet interval sequence are generated based on the negative and positive jump positions. Then, the droplet arrival position is predicted based on the droplet interval sequence, and droplet phase coefficient, edge confidence coefficient, and projection radius sequence are generated by combining local gradients. The projection radius sequence is incorporated into the dual constraints of the improved Chambolle projection algorithm, ensuring a smaller projection radius near the droplet arrival position and a larger projection radius at stable sampling positions, thus generating a transient recovery signal. Candidate edge pairs are extracted from the transient recovery signal, and the double-edge closure residual is calculated. A local baseline is then established based on the candidate edge pairs. The cumulative shading area difference between the normalized pulse sequence and the transient recovery signal is calculated, and a shading area residual is generated. These two types of residuals jointly correct the re-projection process, and the droplet recovery signal is generated through iterative updates. Finally, valid droplet events are extracted from the droplet recovery signal, and a drop rate sequence is generated. The drop rate sequence is time-registered with the two types of liquid level signals to identify abnormal infusion states and output early warning results.

[0032] To clearly compare the processing effects of this invention, a 5-point moving average and a fixed dual-threshold counting method were used as comparative methods. The comparative method first calculates the average value of five consecutive droplet pulse samples, then extracts droplet events using fixed negative and positive jump thresholds, and directly calculates the droplet velocity based on the time interval between adjacent droplet events. The comparative method does not generate droplet phase coefficients, edge confidence coefficients, or projection radius sequences, does not perform improved Chambolle projection processing, and does not utilize the dual-edge closure residual and shading area residual to correct droplet pulses. Both methods used the same 480 monitoring segments, the same sampling period, the same anomaly detection threshold, and the same reference results for processing. The test results are shown in Table 1. Table 1. Results of Infusion Monitoring

[0033] As shown in Table 1, the 5-point moving average and fixed double threshold counting methods easily identify amplitude fluctuations caused by ambient light changes and dropper oscillations as droplet events. Furthermore, the filtering process weakens the droplet pulse edges, leading to missed detections, duplicate counting, and droplet rate deviations. This invention implements differentiated constraints on different sampling positions using a projection radius sequence and corrects the edge amplitude and cumulative shading area of ​​the droplet pulse using the double edge closure residual and the shading area residual. This improves the accuracy of effective droplet event recognition to 98.5%, reduces the absolute error of the average droplet rate to 1.1 drops / minute, reduces the false alarm rate for ambient light changes to 1.7%, and reduces the false alarm rate for dropper oscillation to 2.0%. Simultaneously, through time-series registration of the droplet rate sequence with the dropper level signal and the medicine bottle level signal, the accuracy of droplet interruption recognition reaches 100%, the accuracy of abnormal level recognition reaches 98.3%, and the average warning response time is shortened to 0.9 seconds. This demonstrates that this invention effectively solves the problems of inaccurate droplet pulse counting after interference, large deviations in droplet rate calculation, and untimely warnings of infusion anomalies.

[0034] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A question-answering method for a large language model based on knowledge graphs, characterized in that, Includes the following steps: Step 1: Collect user questions and knowledge graph data, analyze query targets, semantic constraints and answer types, and generate question semantic records; Step 2: Construct an improved Coarse2Fine model based on the semantic records of the questions, combine it with knowledge graph data to generate a topological semantic sketch and decompose it into a set of sketch atoms; Step 3: Maintain the structural state of the uninterrupted sketch atoms, change the connection relationships of the target sketch atoms one by one, and generate a counterfactual semantic sketch set; Step 4: Execute the topological semantic sketch and counterfactual semantic sketch set, generate counterfactual execution responses based on the differences in execution results, and determine the minimum set of fault-causing atoms; Step 5: Extract semantic conservation quantities from the problem semantic record, perform restricted graph rewriting on the sketch region where the minimum fault-causing atom set is located, and generate a rewritten semantic sketch; Step 6: Based on the rewritten semantic sketch, establish a forward query state that expands candidate answers from the query target, and establish a reverse answer state that traces back to the query target from the candidate answers based on the answer type, forming a relational composite signature; Step 7: Based on semantic conservation quantities and relational combination signatures, propagate constraints between the forward query state and the reverse answer state to form a bidirectional closure fixed point; Step 8: Generate the answer proposition set and evidence path based on the bidirectional closure fixed points, and drive the large language model to generate question-and-answer results.

2. The question-answering method based on a knowledge graph and a large language model according to claim 1, characterized in that, Step one specifically involves: Acquire user questions and knowledge graph data, encode entity nodes, relation edges and node types in the knowledge graph data, and generate a knowledge graph pattern index; The system performs word segmentation, part-of-speech tagging, and dependency parsing on user questions. Based on the knowledge graph pattern index, it maps noun components to entity nodes and predicate components to relation edges, generating question graph mapping records. The query target is determined based on the dependency path between the question component and the entity node in the question graph mapping record, and semantic constraints are generated based on the attachment position between the modifying component and the relation edge. The answer type is determined based on the node type and question component corresponding to the query target. The query target, semantic constraints and answer type are associated according to the dependency path to generate a question semantic record.

3. The question-answering method based on a knowledge graph and a large language model according to claim 1, characterized in that, Step two specifically involves: The query target, semantic constraints, and answer type in the question semantic record are parsed. The query target is mapped to the query target node, the semantic constraints are mapped to the constraint node, and the answer type is mapped to the answer type node. The query target node, constraint node, and answer type node are connected according to the relationship in the question semantic record to generate a semantic node sequence. Extract node type relationships and relation edge connection directions from knowledge graph data, limit the node connection positions in the semantic node sequence based on node type relationships, limit the node connection order based on relation edge connection directions, and generate a coarse-grained topology structure. An improved Coarse2Fine model is constructed, which includes a coarse-grained topology generation layer and a fine-grained slot instantiation layer. The coarse-grained topology generation layer processes the semantic node sequence and coarse-grained topology structure, while the fine-grained slot instantiation layer fills entity slots and relation slots based on knowledge graph data and binds semantic constraints to the corresponding node connection positions to generate a topological semantic sketch. Traverse the node connection relationships in the topological semantic sketch, divide the topological semantic sketch according to the scope of influence of a single connection change, and determine the sketch region that retains the connection interface and contains a single variable connection relationship as the sketch atom, and generate the sketch atom set.

4. The question-answering method based on a knowledge graph and a large language model according to claim 1, characterized in that, Step three specifically involves: Select a sketch atom as the target sketch atom according to the connection order of the sketch atom set in the topological semantic sketch, and mark the remaining sketch atoms in the sketch atom set as uninterrupted sketch atoms; Lock the structural state and connection relationships of uninterrupted sketch atoms, preserve the connection interfaces of target sketch atoms, and filter the relationship edges of the start node type and end node type to match the node types at both ends of the connection interface from the knowledge graph data to form a candidate connection relationship set; According to the order of the candidate connection relationship set, each candidate connection relationship replaces the original connection relationship of the target sketch atom. Based on the connection interface, the target sketch atom that has been replaced is embedded into the topological semantic sketch to form the counterfactual semantic sketch corresponding to the target sketch atom. Each sketch atom in the sketch atom set is selected sequentially as the target sketch atom, and the resulting counterfactual semantic sketches are used to generate a counterfactual semantic sketch set.

5. The question-answering method based on a knowledge graph and a large language model according to claim 1, characterized in that, Step four specifically involves: A baseline query path is formed according to the node connection order in the topological semantic sketch. Node matching and relation edge jumps are performed along the baseline query path in the knowledge graph data. The path termination position, the number of candidate answers, and the semantic constraint satisfaction status are recorded to generate a baseline execution record. Counterfactual query paths are formed according to the order of the counterfactual semantic sketch set. The counterfactual query paths are executed one by one in the knowledge graph data. The path termination position, the number of candidate answers and the semantic constraint satisfaction status are associated with the target sketch atom and candidate connection relationship to generate a counterfactual execution record set. The counterfactual execution record set is compared with the baseline execution record according to the node connection position. The differences in path termination position, number of candidate answers, and semantic constraint satisfaction state are calculated. The node connection positions that produce differences are marked as abnormal node connection positions, and a counterfactual execution response is generated. The filtering path extends to the node corresponding to the answer type and the counterfactual execution response is executed when the semantic constraint is satisfied and the state is changed to satisfied. The associated target sketch atom is identified as a fault-causing candidate atom. From the fault-causing candidate atoms, the atom combination that covers all abnormal node connection positions and has the fewest atoms is selected to determine the minimum fault-causing atom set.

6. The question-answering method based on a knowledge graph and a large language model according to claim 1, characterized in that, Step five specifically involves: The relationships between query targets, semantic constraints, and answer types are read from the question semantic record. The semantic conservation quantities are generated by encoding the relationships between query targets and answer types according to the order of their pointers and the positions of the semantic constraints. The sketch region is determined based on the connection position of the minimum fault-causing atom set in the topological semantic sketch, the node connection relationship outside the sketch region is fixed, and the connection interface between the sketch region and adjacent sketch atoms is preserved. From the counterfactual execution response, candidate connections that are associated with the minimum fault-causing atom set and whose semantic constraints are satisfied are selected. Based on the connection interface, the candidate connections replace the original connections in the sketch area to generate a rewritten candidate sketch. Extract the pointer order from the query target to the answer type and the limiting position of semantic constraints in the candidate rewrite sketch, compare them item by item with the semantic conservation quantity, retain the candidate rewrite sketches that match the comparison, and generate a rewrite semantic sketch.

7. The question-answering method based on a knowledge graph and a large language model according to claim 1, characterized in that, Step six specifically involves: The query target in the rewritten semantic sketch is mapped to the entity node in the knowledge graph data and determined as the positive starting node. Relationship edge jumps are performed according to the node connection order in the rewritten semantic sketch. The entity node and relationship edge formed by each jump are recorded to generate a positive node sequence and a positive relationship sequence. Entity nodes are filtered from the positive node sequence based on the answer type, and candidate answers are determined. The positive node sequence, positive relation sequence, and candidate answers are associated according to the node connection order to establish a positive query state. The candidate answer is determined as the reverse starting node. The relation edges are backtracked in reverse order of node connection in the rewritten semantic sketch until the entity node corresponding to the query target is reached. The entity nodes and relation edges formed by the backtracking are recorded, the reverse node sequence and reverse relation sequence are generated, and the reverse answer state is established. Align the forward and reverse relation sequences according to the node connection positions, extract the relation edge connection direction, entity node type, and semantic constraint position, and encode them according to the connection order from the query target to the candidate answer to form a relation combination signature.

8. The question-answering method based on a knowledge graph and a large language model according to claim 1, characterized in that, Step seven specifically involves: Based on the relation combination signature, align the positive node sequence and positive relation sequence in the positive query state with the reverse node sequence and reverse relation sequence in the reverse answer state according to the node connection position, filter the node connection relationships with the same relation edge connection direction, the same entity node type, and the same semantic constraint limitation position, and generate bidirectional matching relationships; Based on the bidirectional matching relationship, delete entity nodes and relation edges in the forward query state that do not match the reverse answer state, and delete entity nodes and relation edges in the reverse answer state that do not match the forward query state, and update the forward query state and the reverse answer state. Based on the semantic conservation quantity, the updated forward query state and reverse answer state are verified. The node connection relationship between the query target and the answer type is kept in the same order and the semantic constraint is consistent. The bidirectional matching relationship generation and state update are executed in a loop. By comparing the forward query state and the reverse answer state formed by two adjacent state updates, a bidirectional closure fixed point is formed when the entity nodes, relation edges, and candidate answers remain consistent, and the candidate answer in the forward query state is consistent with the reverse starting node in the reverse answer state.

9. The question-answering method based on a knowledge graph and a large language model according to claim 1, characterized in that, Step eight specifically involves: Read candidate answers and their corresponding entity nodes and relation edges from bidirectional closure fixed points, and associate the query target, semantic constraints, candidate answers and answer types according to the connection order from the query target to the candidate answers to generate an answer proposition set; Extract the entity node identifiers and relation edge identifiers from the bidirectional closure fixed points according to the node connection order from the query target to the candidate answer. Connect the entity node identifiers and relation edge identifiers in sequence to generate the evidence path corresponding to each answer proposition. Establish the correspondence between the answer proposition set and the evidence path based on the candidate answer identifier, and generate question and answer generation records according to the association order of query target, semantic constraints, candidate answers and evidence paths; Based on the question-and-answer generation records, the entity generation scope and relation generation scope of the large language model are limited. The answer text is generated according to the order of the answer proposition set. The answer text is associated with the evidence path to generate the question-and-answer result.

10. A knowledge graph-based large language model question-answering system, executing the knowledge graph-based large language model question-answering method according to any one of claims 1 to 9, characterized in that, include: The semantic parsing module is used to collect user questions and knowledge graph data, parse query targets, semantic constraints and answer types, and generate question semantic records; The sketch building module is used to build the improved Coarse2Fine model, generating topological semantic sketches and sketch atom sets; The counterfact generation module is used to change the connection relationships of atoms in the target sketch and generate a counterfact semantic sketch set; The execution attribution module compares the execution results of the topological semantic sketch with the counterfactual semantic sketch set, and generates the counterfactual execution response and the minimum set of fault-causing atoms. The restricted rewrite module is used to extract semantic conservation quantities and perform restricted graph rewrite on the sketch region where the minimum fault-causing atom set is located, generating a rewritten semantic sketch. The bidirectional state module is used to establish a forward query state and a reverse answer state based on the rewritten semantic sketch, forming a relational composite signature. The closure propagation module is used to propagate constraints based on semantically conserved quantities and relational combination signatures to form bidirectional closure fixed points. The question-and-answer generation module is used to generate answer proposition sets and evidence paths based on bidirectional closure fixed points, driving the large language model to generate question-and-answer results.