A knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping
By employing semantic adaptive filtering and relation sequence grouping methods, the problems of inadequate relation filtering and duplicate paths in knowledge graph subgraph retrieval are solved, achieving efficient evidence subgraph generation and resource optimization in multi-hop query and large-scale knowledge graph scenarios.
Patent Information
- Application Number
- CN202611327692.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-11-17
AI Technical Summary
Existing knowledge graph subgraph retrieval methods struggle to adapt to the differences in the number and semantic distribution of relationships in local regions under multi-hop query or large-scale knowledge graph scenarios. This results in incomplete retrieval results or the inclusion of irrelevant information, wasted computational resources on repetitive paths, and difficulty in forming traceable evidence subgraphs.
A method based on semantic adaptive filtering and relation sequence grouping is adopted. By adaptively adjusting the candidate relation filtering range, grouping paths and allocating search resources, a traceable evidence subgraph is generated. This includes steps A1 to A8, generating step-by-step query constraints using semantic relevance and query constraints, grouping paths and sorting them according to local constraint matching degree and target type consistency.
It improves the ability to retain key relationships and effective evidence paths, reduces the expansion of semantically less relevant relationships and duplicate paths, controls computational overhead, and improves the continuity of the retrieval process and the traceability of results.
Smart Images

Figure CN123115332A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of knowledge graph and natural language processing technology, specifically to a knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping. Background Technology
[0002] Knowledge graphs represent structured facts using entity nodes and the edges connecting them. For local knowledge graph subgraphs related to natural language query retrieval and query semantics, they can provide evidence with clear entity relationships for question answering, information retrieval, and knowledge reasoning tasks, and support candidate answer generation, answer verification, and answer explanation. Especially in multi-hop graph question answering, whether the subgraph retrieval results contain a complete and relevant reasoning path directly affects whether the system can obtain the correct answer and explain its source.
[0003] Existing knowledge graph subgraph retrieval methods typically start with the topic entity in the query, perform semantic matching on candidate relations within the topic entity's neighborhood, and select a fixed number of top-ranked relations for subsequent expansion. However, the number and semantic distribution of relations vary across different local regions of a knowledge graph, and a fixed-number relation selection method is ill-suited to these differences: when the preset retention number is small, relations that are ranked lower but are needed for subsequent reasoning may be missed; when the preset retention number is large, many weakly related relations may be retained. This can easily lead to incomplete evidence paths or the inclusion of a lot of irrelevant information, causing issues such as missing candidate answers and mismatches between answers and query constraints in the knowledge graph question answering system, thus affecting the accuracy and completeness of the question answering results.
[0004] In multi-level graph search, a fixed number of paths to retain is also insufficient to adapt to changes in local connectivity density. When searching for nodes with numerous connections, multiple tail entities connected by the same relation may generate candidate paths with identical relation sequences, thus repeatedly consuming search resources. Other potentially relevant relational directions may be prematurely terminated due to a lack of retention positions. This problem reduces the coverage of valid evidence and consumes significant computational resources on repetitive paths with similar semantic structures. In practical graph question-answering services, this may manifest as increased retrieval time for complex questions, and the system struggling to balance response efficiency with answer quality.
[0005] Furthermore, ranking candidate paths solely based on semantic similarity between the current relation and the query fails to simultaneously reflect the query constraints of the current search layer, the degree of relevance between the complete path and the query, the discriminative power of the relation itself, and the consistency between the tail entity and the query's target answer type. As the search layer increases, local matching errors may accumulate layer by layer along the path, making it difficult for locally related candidate paths to form complete evidence that effectively supports the correct answer. The resulting candidate answers may be semantically relevant to the question on the surface, but their entity types, relational chains, or overall semantics may not meet the query requirements, hindering subsequent answer selection and evidence interpretation by the question-answering module.
[0006] When the initial path expansion fails to yield a valid path, existing processes typically terminate directly or re-examine using the same parameters, making it difficult to adjust for situations such as premature filtering of key relationships, unreasonable path retention, or insufficient search depth. Therefore, it is necessary to provide a knowledge graph subgraph retrieval method that can adapt to the semantic distribution of candidate relationships and the workload of frontier expansion, while reducing the repeated consumption of search resources by the same paths in the relationship sequence.
[0007] Therefore, how to improve the retention of key relationships and effective evidence paths, suppress the invalid expansion of semantically unrelated relationships and duplicate paths, and form traceable evidence subgraphs while controlling computational overhead and response latency in complex multi-hop query or large-scale knowledge graph scenarios are problems that existing knowledge graph subgraph retrieval technologies need to solve. Summary of the Invention
[0008] In view of this, the present invention proposes a knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping. The method enables the filtering range of candidate relations to be adjusted according to the query semantics, the distribution of candidate relations and the search depth. By grouping relation sequences and allocating search resources based on frontier expansion load, the method reduces the repeated occupation of search resources by candidate paths with the same relation structure, while forming a traceable evidence subgraph.
[0009] The technical solution adopted in this invention is:
[0010] A knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping includes the following steps:
[0011] A1. Obtain natural language queries, identify at least one topic entity from the natural language queries, and link the topic entity to the entity node in the knowledge graph;
[0012] A2. Obtain the local reachability directional relations of entity nodes, and use the query constraint generation module to generate step-by-step query constraints and target answer types arranged by search layer based on natural language queries, topic entities and local reachability directional relations, and perform relational semantic reachability verification on the step-by-step query constraints;
[0013] A3. Starting from the entity node, expand the path layer by layer. In the current search layer, determine the relationship admission threshold based on the corresponding step-by-step query constraints, the global semantics of the natural language query, the current search depth, and the semantic relevance distribution of the candidate directional relationships. Add the candidate directional relationships with semantic relevance not lower than the relationship admission threshold to the set of filtered relationships.
[0014] A4. Perform compensatory candidate retention on candidate relations that have not entered the filter relation set, and add candidate relations that meet the compensation conditions to the filter relation set;
[0015] A5. Generate candidate paths using the filtered relation set, and group the candidate paths into relation sequences according to the starting entity of the candidate path and the directional relation sequences of each search layer to obtain multiple relation sequence path groups;
[0016] A6. Determine the number of path groups to retain based on the number of scalable directional relations of each node in the current search frontier, and determine the ranking score of each relation sequence path group based on the local constraint matching degree, complete path relevance, relation frequency suppression amount and target type consistency, and retain the corresponding number of relation sequence path groups according to the ranking score;
[0017] A7. Select a preset number of tail entities within each retained relation sequence path group to participate in the next search layer expansion, and repeat steps A3 to A7 if the maximum search depth is not reached, the current search frontier is not empty, and the current search layer does not obtain tail entities that match the target answer type.
[0018] A8. Merge the retained paths corresponding to each topic entity, delete duplicate paths and retain the entity nodes and directional relation edges in the paths, generate and output the evidence subgraph, which includes the directional relation paths connecting topic entities and candidate answer entities.
[0019] Furthermore, prior to step A1, each underlying relation in the knowledge graph is combined with the forward traversal identifier and the reverse traversal identifier to form a directional relation; a natural language semantic description corresponding to the traversal direction is established for each directional relation, and the semantic description is vector-encoded and normalized to construct a directional relation semantic index; the normalized relation frequency suppression amount is determined based on the frequency of occurrence of the underlying relation in the knowledge graph.
[0020] Further, step A2 includes: selecting anchor relationships based on the semantic relevance and frequency suppression of the local reachability of the natural language query and the topic entity; assembling the natural language query, topic entity, and anchor relationship semantic description into a structured input, and having the query constraint generation module output step-by-step query constraints arranged by search layer and the target answer type; matching the step-by-step query constraints with the directional relation semantic index, and deleting step-by-step query constraints with a maximum matching degree lower than the reachability threshold.
[0021] Furthermore, in step A3, the current step-by-step query constraint vector and the global semantic vector of the natural language query are weighted and combined to form a filtering center vector; the semantic relevance between each candidate relation and the filtering center vector is calculated; and the relation admission threshold is determined based on the mean, dispersion, filtering width parameter that varies with search depth, and minimum filtering threshold of the semantic relevance.
[0022] Furthermore, in step A4, the compensation relevance between the candidate relations that have not entered the filter relation set and the global semantic vector is calculated, sorted according to the compensation relevance, and a preset number of candidate relations that meet the compensation threshold are added to the filter relation set.
[0023] Furthermore, in step A5, when the starting entities of two candidate paths are the same and the directional relations of each search layer are the same in sequence, the two candidate paths are divided into the same relation sequence path group; the same path group occupies one reserved position in the number of reserved paths.
[0024] Further, in step A6, the sum of the number of incoming edges and outgoing edges of each node in the current search frontier is counted. The sum of the number of incoming edges and outgoing edges is used as the number of scalable directional relations for the corresponding node. The frontier expansion load and the number of path groups to be retained are determined based on the number of scalable directional relations for each node. For each relation sequence path group, the semantic relevance between the current directional relation of the path group and the current step-by-step query constraint is used as the local constraint matching degree. The maximum value of the semantic relevance between each complete path in the path group and the natural language query is used as the complete path relevance. The relation frequency suppression amount corresponding to the current underlying relation of the path group is obtained. The target type consistency is determined based on the matching result between the tail entity type of the termination search layer and the target answer type. The ranking score of each relation sequence path group is determined based on the local constraint matching degree, complete path relevance, relation frequency suppression amount, and target type consistency. The relation sequence path groups corresponding to the number of path groups to be retained are retained according to the ranking score.
[0025] Furthermore, in step A7, within each retained path group, a preset number of tail entities are selected to participate in the next search layer expansion based on the relevance between the tail entities and the natural language query, and the remaining tail entities are retained as evidence subgraph candidates.
[0026] Furthermore, in step A8, intersection node detection is performed on the paths corresponding to multiple topic entities, and paths containing intersection nodes are retained first; when the retained path is empty or the tail entities of the retained path do not meet the target answer type, the relationship admission threshold is lowered or the maximum search depth is increased and the path expansion is re-executed.
[0027] The beneficial effects of this invention are:
[0028] (1) The selection range is adaptively determined based on the semantic relevance distribution of candidate relations, reducing the possibility of missing effective relations due to fixed-number truncation.
[0029] (2) Group candidate paths according to the starting entity and the directional relation sequence to reduce the repeated use of search resources by paths with the same relation structure.
[0030] (3) Based on the extended load of the search front, the number of path groups to be retained is allocated and sorted in combination with query constraints, complete path relevance and target entity type to improve the adaptability of path selection under different graph connection environments.
[0031] (4) When there is insufficient evidence, adjust the screening conditions or search depth, and output an evidence subgraph containing entities and directional relationship connection paths to improve the continuity of the retrieval process and the traceability of the results. Attached Figure Description
[0032] Figure 1 This is an overall flowchart of the knowledge graph subgraph retrieval method of the present invention;
[0033] Figure 2 This is a flowchart of the semantic adaptive filtering and compensatory candidate retention process of the present invention;
[0034] Figure 3 This is a flowchart of the relation sequence grouping and search resource allocation process of the present invention. Detailed Implementation
[0035] The embodiments of the present invention will be further described below with reference to the accompanying drawings. This embodiment employs a knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping to obtain evidence subgraphs corresponding to natural language queries from a knowledge graph. The overall process is as follows: Figure 1 As shown.
[0036] Example:
[0037] This embodiment uses an industrial equipment fault knowledge graph question-and-answer system as an example to illustrate the specific implementation process of the method of the present invention. The system includes a graph database for storing the industrial equipment knowledge graph and a question-and-answer server for performing natural language query processing and subgraph retrieval. Entity nodes in the industrial equipment knowledge graph may include equipment model, fault code, equipment component, fault cause, and maintenance measures. Directed relation edges can be used to represent the association between fault codes and equipment components, equipment components and fault causes, and fault causes and maintenance measures. During system initialization or knowledge graph update, step 1 is executed first to establish a directional relation semantic index and calculate relation frequency suppression. After receiving the fault query input by the equipment maintenance personnel, the question-and-answer server executes steps 2 to 8 to retrieve evidence subgraphs connecting the query topic entity and candidate answer entities from the graph database, and provides the evidence subgraphs to the question-and-answer module to generate a response. The above entity types and relation types are only used to illustrate the specific implementation process of the present invention and do not constitute a limitation on the scope of protection of the present invention.
[0038] Step 1: Establish a directional relation semantic index. This step aims to provide basic index support for subsequent semantic filtering.
[0039] Step 11: Generate Directed Relations: Read the relation set in the knowledge graph and use each relation in the relation set as a bottom-level relation. For any bottom-level relation... Establish positive directional relationships respectively. (positive) and reverse directional relationships ( (Reverse). Directional relations are used to identify the way to traverse from the current entity along outgoing or incoming edges.
[0040] Step 12: Establish Natural Language Semantic Descriptions for Directed Relations: Establish a natural language semantic description for each directed relation. For the same underlying relation, the semantic description of the corresponding forward directed relation expresses the meaning of traversing along the outgoing edges of the underlying relation by the current entity, while the semantic description of the reverse directed relation expresses the meaning of traversing along the incoming edges of the underlying relation by the current entity. Thus, the same underlying relation corresponds to independent semantic descriptions for directed relations under different traversal directions.
[0041] Step 13: Construct a relational semantic index: Use a text vector encoder to encode the semantic description of each directional relation into... A dimensional relation vector is generated, and its length is normalized. A semantic index of the relation is then built according to the directional relation identifier.
[0042] Step 14: Calculate relation frequency suppression: Count the frequency of occurrence of each underlying relation in the knowledge graph. Let any underlying relation... The number of times it appears is The most frequently occurring underlying relation in the knowledge graph appears the following number of times: The frequency suppression of the relationship Defined as ,make The value of is between 0 and 1, and the more frequently the relationship occurs, the higher the value of . The larger the value, the more positively correlated the frequency suppression of the relationship is with the frequency of occurrence of the underlying relationship. The frequency suppression value is used in subsequent anchor point selection and path sorting steps to suppress the bias caused by high-frequency relationships.
[0043] Step 2: Topic Entity Identification, Link and Local Reachability Directed Relationship Acquisition. This step is used to locate the starting entity node in the knowledge graph from the natural language query and obtain its surrounding traversable relation set. Specifically, it includes the following sub-steps:
[0044] Step 21: Identify Subject Entities: Receive Natural Language Queries ,right Perform null value checks, character normalization, and length checks, and obtain the subject entity text set through the entity recognition module.
[0045] For example, equipment maintenance personnel input a natural language query: "What maintenance measures should be taken for the abnormal component corresponding to fault code E101?". The entity recognition module identifies "fault code E101" as the subject entity text from the natural language query. Step 22 links it to the corresponding fault code entity node in the industrial equipment knowledge graph. Step 23 obtains the locally reachable directional relationship of this entity node. The expected answer to this query is the maintenance measure. The aforementioned fault code is only used to illustrate the query processing procedure and does not constitute a limitation on entity names, relationship types, or knowledge graph content.
[0046] Step 22, Topic Entity Linking: Based on the entity name, alias, and description information, candidate entity nodes are retrieved. By combining text matching degree, semantic relevance, and the relevance of the candidate entity local relationship to the query, the entity node corresponding to the topic entity text is determined from the candidate entity nodes, thereby completing the link from the topic entity to the knowledge graph entity node.
[0047] Step 23: Obtain locally reachable directional relationships: Perform a one-level bidirectional neighborhood query on each linked entity node to obtain all locally reachable directional relationships for that entity node. Specifically:
[0048] For each outgoing edge of an entity node, the positive directional relationship corresponding to that outgoing edge is determined as a locally reachable directional relationship.
[0049] For each incoming edge of an entity node, the reverse directionalization relation corresponding to that incoming edge is determined as a locally reachable directionalization relation.
[0050] The locally reachable directional relations obtained in this sub-step are output as a candidate relation set for subsequent anchor point relation selection steps.
[0051] Step 3: Generate step-by-step query constraints and perform reachability checks. This step specifically includes the following sub-steps:
[0052] Step 31, Anchor Relationship Selection: Encode the natural language query into a global semantic vector. For each local reachability relation of the subject entity, the anchor selection score is calculated according to the following formula:
[0053]
[0054] Where q is the global semantic vector of the natural language query. Directional Relationship The normalized relation vector, Represents the global semantic vector With directional relation vector Cosine similarity between them; Directional Relationship The corresponding underlying relationships, This is the frequency suppression factor for the underlying relationship. This is the adjustment coefficient for relation frequency suppression. A preset number of directional relations are selected based on the anchor point selection score, from highest to lowest, to obtain the anchor point relation set for the topic entity.
[0055] Step 32, Structured Input and Constraint Generation: The natural language query, topic entity text, and natural language semantic descriptions of anchor relationships are written into preset query fields, entity fields, and local relation fields, respectively, forming structured input. The query constraint generation module reads the structured input and outputs a step-by-step query constraint sequence. and the type of target answer Each step-by-step query constraint must include at least a search layer number and a relational semantic description; the target answer type is represented by an entity type phrase. The step-by-step query constraints are arranged sequentially according to their search layer numbers. After completing the relational semantic reachability check, the valid step-by-step query constraints maintain their original order; then proceed to the next step. When filtering relationships in the search layer, the data read from the order of... The number of valid step-by-step query constraints is determined. When the search depth exceeds the number of valid step-by-step query constraints, a global semantic vector is used to replace the current step-by-step query constraint vector, as per step 41. The target answer type is used for subsequent target type consistency calculations and search termination determination. The query constraint generation module can be implemented using a natural language processing model that outputs structured results according to the fields described.
[0056] For the aforementioned fault queries, the query constraint generation module can generate step-by-step query constraints arranged by search layer. The first search layer's step-by-step query constraints express "fault code associated with equipment component," the second search layer's step-by-step query constraints express "equipment component corresponding to fault cause," and the third search layer's step-by-step query constraints express "fault cause corresponding to maintenance measures," with "maintenance measures" identified as the target answer type. These step-by-step query constraints are still matched and reachedability verified with the directional relation semantic index according to step 33.
[0057] Step 33, Relational Semantic Reachability Verification: Encode each step query constraint into a constraint vector and calculate its similarity with the relation vectors in the relational semantic index. If the maximum similarity of a step query constraint with all directional relations is lower than the reachability threshold, then delete the step query constraint. The maximum similarity represents the highest degree of matching that the step query constraint can obtain in the relational semantic index. A similarity below the reachability threshold indicates that the existing directional relations in the knowledge graph are insufficient to support the step query constraint, and therefore it will not be used for subsequent search layer filtering center calculations.
[0058] Step 34: Setting Alternative Query Constraints: If all step-by-step query constraints corresponding to a topic entity are deleted, the natural language query is set as a single-step alternative constraint for that topic entity to avoid subsequent retrievals terminating due to an empty constraint set.
[0059] Step 4: Perform semantic adaptive filtering. The specific process is as follows: Figure 2 As shown.
[0060] Step 41, Determine the filtering center vector: in the... Search layer, based on the first The filtering center vector is determined by a valid step-by-step query constraint vector and a global semantic vector, and its calculation formula is as follows:
[0061]
[0062]
[0063] in, Indicates L2 normalization operation These are the initial constraint weights, and their values are greater than 0 and not greater than 1. The attenuation coefficient has a value greater than 0 and less than 1.
[0064] As can be seen from the above formula, the combined weight of the step-by-step query constraint vectors With search depth The weight of the global semantic vector increases exponentially with search depth, meaning the combined weight of the step-by-step query constraint vectors decreases as search depth increases, while the weight of the global semantic vector increases accordingly. Therefore, in the early search layers, the filtering center primarily reflects the current step-by-step query constraints to highlight the local relational requirements of the current layer. As search depth increases, the filtering center gradually strengthens its preservation of the complete natural language query semantics, reducing the impact of the continuous accumulation of local constraint errors along the path. When the search depth exceeds the number of step-by-step query constraints, the global semantic vector replaces the current step-by-step query constraint vector.
[0065] Step 42: Calculate semantic relevance: Obtain all scalable directional relations in the current search frontier, calculate the cosine similarity between each candidate relation vector and the normalized screening center vector, and obtain the candidate relevance set for the current search layer. For each node in the current search frontier, obtain the incoming and outgoing edges connected to that node, and obtain the corresponding scalable directional relations according to the traversal direction determined in Step 11. Each candidate directional relation corresponds to its source frontier node so that candidate paths can be generated by the corresponding node after relation screening is completed.
[0066] Step 43: Determine the relation admission threshold: Determine the relation admission threshold for the current search layer based on the candidate relevance set.
[0067]
[0068]
[0069] in, This represents the arithmetic mean of the relevance scores of all candidates at the current search frontier. This indicates that the standard deviation of the relevance scores over all the candidates is calculated. The minimum screening threshold, Based on the width parameter for filtering, This is a non-negative width adjustment amount.
[0070] The current relation admission threshold is calculated separately for each search layer and varies with the mean and standard deviation of the candidate relevance set for that search layer. The initial screening results formed by the relation admission threshold are no longer determined solely based on a fixed number or a fixed relevance threshold, but rather the relation screening range is adjusted according to the distribution of candidate relevance in different search layers and different local regions.
[0071] Step 44: Generate a set of filtered relations: Add directional relations with a relevance no lower than the current relation admission threshold to the set of filtered relations. That is, for each candidate directional relation in the current search frontier, if its semantic relevance meets the current relation admission threshold, then the relation is included in the set of filtered relations.
[0072] Step 45, Compensatory Candidate Retention: This sub-step aims to retain candidate relations that are semantically relevant to the complete query but not selected by the current step-by-step query constraints. The specific process includes:
[0073] Step 451: Calculate the compensation relevance: For all candidate relations that have not entered the set of filtered relations described in step 44, i.e., candidate relations whose semantic relevance is lower than the relation admission threshold, calculate the cosine similarity between their normalized relation vector and the global semantic vector of the natural language query, and use the cosine similarity as the compensation relevance.
[0074] Step 452: Perform compensatory candidate retention: Sort the unselected candidate relationships according to their compensatory relevance from high to low, select the candidate relationships with the highest compensatory relevance, and ensure that the compensatory relevance of the selected candidate relationships is not lower than a preset compensatory threshold. The number of selected candidate relationships is a preset number. Add the candidate relationships that simultaneously meet the requirements of being ranked high in compensatory relevance, not lower than the compensatory threshold, and not exceeding the preset number limit to the filtered relationship set to obtain the final filtered relationship set.
[0075] In this embodiment, the compensatory candidate retention only applies to candidate relations that have not reached the current relation admission threshold, and is simultaneously limited by the compensation relevance ranking, the compensation threshold, and a preset number. This process is used to retain candidate relations that are semantically relevant to the complete query but have not been selected by the current step-by-step query constraints and meet the compensation conditions.
[0076] In the aforementioned industrial equipment fault Q&A scenario, fault code entity nodes may simultaneously connect to different types of entities, such as equipment model, alarm level, occurrence time, and equipment component. Step 43 determines the relationship admission threshold based on the semantic relevance distribution of the current search layer candidate relationships. Step 44 adds directional relationships with semantic relevance not lower than the relationship admission threshold to the filter relationship set. For candidate relationships that are semantically relevant to the complete fault query but do not reach the current relationship admission threshold, step 45 compensates and retains them if their compensated relevance is not lower than the compensation threshold and meets the preset quantity limit. This process does not use a fixed quantity as the sole basis for relationship filtering; the filtering result is jointly determined by the processes described in steps 41 to 45.
[0077] Step 5: Establish relation sequence path groups and allocate subsequent search resources. The process for relation sequence grouping and subsequent search resource allocation is as follows: Figure 3 As shown.
[0078] Step 51: Generate candidate paths: Expand the current search frontier using the filtered relation set. Assume one candidate path. It consists of a starting entity, directional relations for each search layer, intermediate entities, and a tail entity, in sequence. For any node in the current search frontier, the directional relations corresponding to that node in the set of filtering relations are traversed, and the entities reached are identified as new tail entities. The directional relations and the new tail entities are then added to the current path in sequence to form the candidate path for the current search layer.
[0079] Step 52: Group the relation sequences according to the following deterministic conditions, as follows:
[0080] If two candidate paths have the same starting entity and the directional relations from the first search layer to the current search layer are sequentially identical, then the two candidate paths belong to the same relation sequence path group. The grouping condition is expressed as follows:
[0081]
[0082] This relation sequence grouping follows a deterministic rule, without calculating inter-sample distances or iteratively updating the grouping results using cluster centers. Candidate paths with different intermediate or tail entities but the same relation sequence are grouped into the same path group; thus, each relation sequence path group is uniquely determined by the starting entity and the directional relation sequence from the first search layer to the current search layer. Within each group, candidate paths conforming to the relation sequence and their tail entities are stored, and paths with the same relation structure share a path group reservation position.
[0083] For example, when fault code E101 connects multiple device component entities through the same first search layer directional relationship, and each device component is connected to different fault cause entities through the same second search layer directional relationship, the starting entities of each candidate path are the same, and the directional relationships in the corresponding search layers are sequentially the same, but the entity node sequences are different. Step 52 divides the candidate paths into the same relation sequence path group, so that they all occupy a path group reservation position, while retaining the evidence branches corresponding to different device components and fault causes within the group.
[0084] Step 53, Subsequent Search Resource Allocation: Perform search resource allocation for each relation sequence path group that has been grouped. Within a single relation sequence path group, calculate the semantic relevance between each tail entity in the group and the natural language query; sort according to semantic relevance, and select a preset number of tail entities to participate in the path expansion of the next search layer; the remaining unselected tail entities will no longer participate in the path expansion of the next layer, but will be retained as candidates for evidence subgraphs, thereby preserving the evidence branches formed by different entity node sequences.
[0085] Step 6: Allocate search resources and sort multi-factor path groups. This step specifically includes the following sub-steps:
[0086] Step 61: Count the number of incoming edges and outgoing edges of each node in the current search frontier, and use the sum of the two as the number of node expandable relationships. Calculate the average value of all frontier nodes as the frontier expansion load.
[0087] Step 62: Determine the number of path groups to retain in the current search layer based on the frontier expansion load.
[0088]
[0089] in, Indicates when When less than l, take l; when Greater than Time to take In other cases, take ; Base quantity to retain This is the load scaling factor. and These represent the lower and upper limits for the number of path groups to retain. The number of path groups to retain is calculated based on the current frontier expansion load, and its value range is limited by these lower and upper limits. For different search layers, the number of scalable relationships for each node in the current search frontier is recalculated to ensure that the number of path groups to retain changes with the current local graph structure. When there are no scalable relationships in the current search frontier, path expansion for the corresponding topic entity ends.
[0090] Step 63: For each relation sequence path group Calculate the multi-factor ranking score. Local constraint matching degree. , For this path group in the th Cosine similarity between the directional relation vector of the search layer and the constraint vector of the current step-by-step query. Complete path relevance. , This is the maximum cosine similarity between the complete path text vectors contained in the path group and the natural language query vectors. The complete path texts are constructed in the order of the starting entity name, the semantic description of each layer of directional relations, and the corresponding entity name. The target type is consistent. In the terminating search layer: the value is 1 when the semantic relevance of the type description of at least one tail entity in the path group to the target answer type is not less than the type threshold, otherwise it is 0; in the non-terminating search layer, the value is 0.
[0091] The path group ranking score of the current search layer can be expressed as:
[0092]
[0093]
[0094] in, These are the initial local constraint weights, and their values are between 0 and 1. The attenuation coefficient has a value greater than 0 and less than 1; This is the frequency suppression coefficient for the relation. For type consistency weights, For path groups In the The underlying relationships corresponding to the directional relationships shared by the search layer.
[0095] The frequency suppression coefficient of the relationship The pre-defined non-negative coefficient is used to adjust the penalty intensity of relation frequency suppression on the path group ranking score. The relation frequency suppression coefficient is pre-determined based on the distribution of the frequency of occurrence of each underlying relation in the knowledge graph and the degree of influence of high-frequency relations on the number of candidate path expansions; the more obvious the repeated path expansion caused by high-frequency relations, the larger the value of the relation frequency suppression coefficient. The relation frequency suppression coefficient is determined before the path expansion corresponding to a natural language query begins and remains unchanged in each search layer of that path expansion.
[0096] Step 64: Retain the path groups corresponding to the current number of path groups to be retained, sorted by path group score from highest to lowest. Within each retained path group, using the same method as in Step 53, select path groups based on the semantic relevance between the tail entity name or description and the natural language query, not exceeding the tail entity expansion limit. Tail entities that participate in the next search layer expansion are retained as candidates for evidence subgraphs; tail entities that do not participate in the expansion are retained as candidates for evidence subgraphs. For tail entities that participate in the next search layer expansion, their correspondence with their respective relation sequence path groups and current candidate paths is retained, and they are added to the search frontier of the next search layer. For tail entities that do not participate in the expansion, they are no longer used to generate subsequent paths, but the already formed entity node sequences and directional relation sequences are retained.
[0097] When there are many directional relationships connecting fault code entity nodes or equipment component entity nodes, step 61 determines the front-end expansion load based on the number of incoming and outgoing edges of each node in the current search front. Step 62 adjusts the number of path groups to be retained accordingly. Steps 63 and 64 then combine local constraint matching degree, complete path relevance, relationship frequency suppression amount, and target type consistency to sort and retain each relationship sequence path group, so that relevant evidence paths leading to maintenance measure entities can enter subsequent search layers.
[0098] Step 7: Control the tail entity expansion and determine whether the search terminates.
[0099] Step 71: The tail entities selected in step 64 form the search frontier of the next search layer, and the currently retained path is added to the evidence path candidate set.
[0100] Step 72: When the preset maximum search depth is reached, the search frontier of the next search layer is empty, or the current search layer has obtained at least one tail entity whose type description matches the target answer type, terminate the path expansion of the corresponding topic entity; otherwise, increment the search layer number by 1 and re-execute steps 4 to 7.
[0101] Step 8: Merge candidate paths and construct evidence subgraph.
[0102] Step 81: When a natural language query contains multiple topic entities, execute steps 3 to 7 starting from the entity node corresponding to each topic entity, ensuring that each branch uses the same global semantic vector and target answer type. Detect entity nodes that are covered by two or more topic entity branches, identify them as intersection nodes, and prioritize retaining paths containing intersection nodes.
[0103] Step 82: When all retained paths for all topic entity branches are empty, or when the tail entities of all retained paths do not conform to the target answer type, lower the minimum filtering threshold by a preset adjustment amount, or increase the maximum search depth by a preset number of layers, and then re-execute steps 4 to 7. This re-path expansion is an optional implementation method, and the number of executions does not exceed the preset number of re-examinations.
[0104] Step 83: Merge the paths obtained from the initial path expansion and the re-path expansion, and delete duplicate paths where both the entity node sequence and the directional relation sequence are the same; for paths where the starting entity and directional relation sequences are the same but the entity node sequences are different, continue to save them as relation sequence path groups.
[0105] Step 84: Construct an evidence subgraph from the entity nodes and directional relation edges involved in the retained paths. When constructing the evidence subgraph, merge identical entity nodes and directional relation edges involved in each retained path, while maintaining the connection order of each directional relation path from the topic entity to the corresponding tail entity. Each retained path serves as a directional relation path in the evidence subgraph. The evidence subgraph can serve as structured evidence input for question-answering models, information retrieval systems, or graph reasoning systems.
[0106] In the aforementioned industrial equipment fault question-and-answer scenario, the generated evidence subgraph can contain a directional relationship path of "Fault Code E101—Equipment Component—Fault Cause—Maintenance Measures". The question-and-answer module generates a maintenance measure response based on the type of candidate answer entity and the corresponding evidence path, and outputs or saves the directional relationship path as the basis for the response. If the initial path expansion does not obtain a tail entity of the maintenance measure type, the minimum screening threshold is lowered or the maximum search depth is increased in step 82, and the search is repeated. Thus, without changing the processing flow described in steps 1 to 8, the expansion of relationships unrelated to fault queries and the repeated occupation of search resources by paths with the same relationship sequence can be reduced, the intermediate path processing volume in the graph database can be reduced, and traceable entity relationship evidence can be provided for the fault question-and-answer results.
[0107] Although the present invention has been described herein with reference to embodiments thereof, the above embodiments are merely preferred embodiments of the present invention, and the implementation of the present invention is not limited to the above embodiments. It should be understood that those skilled in the art can design many other modifications and implementations, which will fall within the scope and spirit of the principles disclosed in this application.
Claims
1. A knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping, characterized in that, Includes the following steps: A1. Obtain a natural language query, identify at least one topic entity from the natural language query, link the topic entity to an entity node in the knowledge graph, and perform a neighborhood query on the entity node to obtain the local reachability direction relationship of the entity node. A2. Using the query constraint generation module, generate step-by-step query constraints and target answer types arranged by search layer based on natural language queries, topic entities, and locally reachable directional relations, and perform relational semantic reachability verification on the step-by-step query constraints; A3. Starting from the entity node, perform layer-by-layer path expansion, obtain the global semantic vector of the natural language query in the current search layer, determine the filtering center vector based on the step-by-step query constraints of the current search layer and the global semantic vector, calculate the semantic relevance between each candidate directional relation and the filtering center vector, determine the relation admission threshold based on the semantic relevance distribution of all candidate directional relations in the current search layer, and add candidate directional relations with semantic relevance not lower than the relation admission threshold to the filtering relation set. A4. For candidate relations that are not included in the filter relation set, calculate their compensation relevance with the global semantic vector, select candidate relations whose compensation relevance meets the preset threshold and quantity requirements and add them to the filter relation set to obtain the final filter relation set. A5. Generate candidate paths using the final filtered relationship set, and group the candidate paths into relationship sequences according to the starting entity of the candidate path and the directional relationship sequence of each search layer to obtain multiple relationship sequence path groups; A6. Determine the number of path groups to retain based on the number of scalable directional relations of each node in the current search frontier, and determine the ranking score of each relation sequence path group based on the local constraint matching degree, complete path relevance, relation frequency suppression amount and target type consistency, and retain the corresponding number of relation sequence path groups according to the ranking score; A7. Select a preset number of tail entities within each retained relation sequence path group to participate in the next search layer expansion, and repeat steps A3 to A7 if the maximum search depth is not reached, the current search frontier is not empty, and the current search layer does not obtain tail entities that match the target answer type. A8. Merge the retained paths corresponding to each topic entity, delete duplicate paths and retain the entity nodes and directional relation edges in the paths, generate and output the evidence subgraph, which includes the directional relation paths connecting topic entities and candidate answer entities.
2. The knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping as described in claim 1, characterized in that, Step A1 is preceded by the creation of a directional relation semantic index: Read the relation set in the knowledge graph, take each original relation in the relation set as the underlying relation, and combine it with the forward traversal identifier and the reverse traversal identifier respectively to obtain the corresponding forward directional relation and reverse directional relation; A natural language semantic description corresponding to the traversal direction is established for each directional relation. The natural language semantic description is vector-encoded and normalized. Based on the normalized vectors of all directional relations, a directional relation semantic index is constructed. The normalized relation frequency suppression amount is determined based on the frequency of occurrence of each underlying relation in the knowledge graph. The higher the frequency of occurrence of the underlying relation, the greater the relation frequency suppression amount.
3. The knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping as described in claim 2, characterized in that, Step A2 specifically includes: A21. Calculate the semantic relevance between the natural language query and each local reachability relation of the topic entity, and select the anchor relation in combination with the relation frequency suppression amount; A22. The semantic descriptions of the natural language query, topic entity, and anchor relationship are arranged into a structured input according to preset fields, and the query constraint generation module outputs the step-by-step query constraints and target answer types arranged according to the search layer. A23. Match the vectors of each step query constraint with the directional relation semantic index, and delete the step query constraints whose maximum matching degree is lower than the reachability threshold; A24. When all step-by-step query constraints corresponding to a topic entity are deleted, the natural language query is set as the alternative query constraint for that topic entity.
4. The knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping as described in claim 1, characterized in that, Step A3 specifically includes: A31. Determine the filtering center vector based on the step-by-step query constraint vector corresponding to the current search layer and the global semantic vector of the natural language query. The combined weight of the step-by-step query constraint vector decreases as the search depth increases. A32. Calculate the semantic relevance between the current candidate relation vector and the filtering center vector; A33. Determine the relation admission threshold for the current search layer based on the mean semantic relevance, the dispersion of semantic relevance, the filtering width parameter that varies with search depth, and the minimum filtering threshold of all current candidate relations. A34. Candidate relations with semantic relevance not lower than the relation admission threshold are determined as the set of filtered relations.
5. The knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping as described in claim 4, characterized in that, Step A4 specifically includes: For candidate relations that are not included in the filtered relation set, calculate the compensation relevance between their relation vectors and the global semantic vector; A preset number of candidate relationships are selected from high to low based on the compensation relevance, and candidate relationships with compensation relevance not lower than the compensation threshold are added to the set of filtered relationships.
6. The knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping as described in claim 1, characterized in that: When grouping relation sequences in step A5: if the starting entities of two candidate paths are the same, and the directional relations corresponding to the two candidate paths in each search layer are the same in sequence, then the two candidate paths are assigned to the same relation sequence path group; the same relation sequence path group occupies only one retention position in the statistics of the number of path groups retained. In step A7, for each relation sequence path group retained after filtering in step A6, a preset number of tail entities are selected to participate in the next search layer expansion based on the semantic relevance of the tail entities to the natural language query, and the remaining unselected tail entities are retained as evidence subgraph candidates.
7. The knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping as described in claim 6, characterized in that, Step A6 specifically includes: Calculate the sum of the number of incoming edges and the number of outgoing edges for each node in the current search front, and determine the front expansion load based on the average of the sum of the number of incoming edges and the number of outgoing edges. The number of path group reservations is determined based on the aforementioned front-end extended load, basic reservation quantity, scaling factor, minimum reservation quantity, and maximum reservation quantity; For each relation sequence path group, the ranking score of the relation sequence path group is determined based on the local constraint matching degree between the current directional relation and the current step query constraint of the path group, the maximum relevance between each complete path in the path group and the natural language query, the relation frequency suppression amount corresponding to the current underlying relation of the path group, and the target type consistency between the tail entity type of the termination search layer and the target answer type.
8. A knowledge graph subgraph retrieval method based on semantic adaptive filtering and relation sequence grouping as described in any one of claims 1 to 7, characterized in that, Step A8 specifically includes: When a natural language query contains multiple topic entities, path expansion is performed on each topic entity. Nodes that are covered by candidate paths corresponding to different topic entities are identified as intersection nodes, and candidate paths containing intersection nodes are retained first. Delete duplicate paths where both the entity node sequence and the directional relation sequence are the same, and retain paths where the starting entity and the directional relation sequence are the same but the entity node sequences are different; When the retained path is empty or the tail entities of the retained path do not match the target answer type, the path expansion is re-executed after lowering the relation admission threshold or increasing the maximum search depth. The paths obtained from the initial path expansion and the re-path expansion are merged. The path groups of the relation sequence are retained according to the number of path groups retained in the corresponding search layer, and an evidence subgraph containing directional relation paths is generated.
