Knowledge graph reasoning method based on double-branch feature extraction and relation guided fusion

CN122655992APending Publication Date: 2026-08-28RES INST OF XIAN JIAOTONG UNIV & SUZHOU
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610928838.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-25
Publication Date
2026-08-28

AI Technical Summary

Technical Problem

[0005]本发明的目的在于解决现有知识图谱推理方法难以同时捕捉全局与局部结构特征,并且未充分利用查询关系引导作用,降低了知识图谱推理的准确性的问题,提供一种基于双分支特征提取和关系引导融合的知识图谱推理方法及系统

Benefits of technology

本发明公开了一种基于双分支特征提取和关系引导融合的知识图谱推理方法,在对全局上下文特征和邻域结构特征进行提取时,通过两个并行的特征学习分支,在同一查询条件下分别学习实体间的跨距离依赖关系与邻域结构证据,解决了单一模式难以同时充分捕获全局与局部结构信息的缺陷,有效缓解了特征过度平滑问题,以查询关系表征作为约束对全局上下文特征和邻域结构特征进行交叉融合,在候选实体每个维度生成自适应融合权重,使局部与全局分支对表征的贡献可随目标关系语义动态调整,实现了关系特异性的证据自适应分配,输出的实体表示同时具备全局结构完整性与目标关系辨识性,提升了知识图谱推理的精度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122655992A_ABST
    Figure CN122655992A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of knowledge graph and artificial intelligence, and relates to a knowledge graph reasoning method and system based on double-branch feature extraction and relation-guided fusion. When extracting global context features and neighborhood structure features, two parallel feature learning branches are used to learn the cross-distance dependency relationship between entities and the neighborhood structure evidence under the same query condition. The defect that a single mode cannot simultaneously fully capture global and local structure information is solved, and the feature over-smoothing problem is effectively alleviated. The global context features and the neighborhood structure features are cross-fused by taking the query relationship representation as a constraint, adaptive fusion weights are generated in each dimension of the candidate entity, the contributions of the local and global branches to the representation can be dynamically adjusted according to the target relationship semantics, the evidence adaptive allocation of the relationship specificity is realized, and the output entity representation has global structure integrity and target relationship recognition. The accuracy of knowledge graph reasoning is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of knowledge graph and artificial intelligence technology, and relates to a knowledge graph reasoning method and system based on dual-branch feature extraction and relation-guided fusion. Background Technology

[0002] Knowledge graphs, as a structured form of knowledge representation, use (head entity, relation, tail entity) triples as their basic units and have become a crucial infrastructure for tasks such as intelligent question answering, information retrieval, and recommendation decision-making. However, the knowledge in the real world is infinite, and no graph can exhaustively enumerate all entities and relations; incompleteness is an inherent property of knowledge graphs. The core objective of Knowledge Graph Reasoning (KGR) is precisely to mine potential relationships between entities and fill in missing triple knowledge based on existing observations within the graph.

[0003] Current mainstream knowledge graph reasoning methods can be categorized into embedding-based methods, path-based methods, Transformer-based methods, and Graph Neural Network (GNN)-based methods. GNN-based methods, by leveraging graph neural networks to transform path encoding into subgraph-level message passing processes, can effectively capture local topological structure information; however, they have weak modeling capabilities for global sequence structures and struggle to capture long-range complex relationships spanning multiple intermediate nodes. While Transformer-based methods can model global dependencies, they struggle to learn the three-dimensional spatial topology of the graph, and their computational complexity is quadratically related to the number of nodes in a large-scale knowledge graph. Furthermore, most existing methods neglect the guiding role of relations in reasoning; relation types not only influence the direction of message passing but also determine the semantic transformation method.

[0004] Therefore, how to simultaneously consider the global dependencies and local structural features of knowledge graphs, and effectively utilize the guiding role of query relationships in reasoning to improve the accuracy and generalization ability of knowledge graph reasoning, is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] The purpose of this invention is to address the problem that existing knowledge graph reasoning methods struggle to simultaneously capture global and local structural features and fail to fully utilize the guiding role of query relationships, thus reducing the accuracy of knowledge graph reasoning. This invention provides a knowledge graph reasoning method and system based on dual-branch feature extraction and relationship-guided fusion. To achieve the above objectives, the present invention employs the following technical solution: A knowledge graph reasoning method based on dual-branch feature extraction and relation-guided fusion is characterized by the following steps: Obtain knowledge graph triples, encode the knowledge graph triples, and obtain the initial entity representation and query relationship representation; Contextual features are extracted based on the initial entity representation to obtain global contextual features. The head entity in the initial entity representation is used as the starting point for local propagation. Guided by the query relationship representation, neighborhood structural features are captured in the local subgraph through a message passing mechanism. Using query relationship representation as a constraint, the global context features and neighborhood structure features are adaptively weighted and fused to obtain the fused entity representation. The predicted score for each candidate entity is calculated based on the fused entity representation. The candidate entities are then ranked according to the predicted scores to obtain the knowledge graph reasoning results.

[0006] A further improvement of the present invention is that: The process of obtaining knowledge graph triples, encoding the knowledge graph triples, and obtaining initial entity representations and query relation representations includes: Obtain the entity set and relation set in the given knowledge graph, initialize each entity as the corresponding prior feature vector, map each relation as the corresponding relation embedding vector, and obtain the query relation representation; Construct a head entity indicator vector, and concatenate the head entity indicator vector with the prior feature vector to obtain the initial node representation. All the initial node representations constitute the initial entity representation.

[0007] The process of extracting contextual features based on initial entity representations to obtain global contextual features, and using the initial entity representations within the initial entity representations as a guide, guided by query relationship representations, and capturing neighborhood structure features within local subgraphs through a message passing mechanism, includes: A dual-branch feature extraction module is constructed to perform parallel feature extraction on entity representations. The dual-branch feature extraction module includes a gated linear global attention module and a query-driven subgraph aggregation module. The gated linear global attention module is used to capture global contextual features and long-range dependencies of the knowledge graph; The query-driven subgraph aggregation module is used to capture neighborhood structural features within a local subgraph through a message passing mechanism, guided by the query relationship representation.

[0008] The gated linear global attention module is used to capture global contextual features and long-range dependencies of the knowledge graph, including: The initial representation of the entity is used as the input node representation. ; Represent the input node These are mapped to query features, key features, and value features, respectively. Introducing data-dependent gating weights Soft pruning of the value features yields the gated value representation. ; Employing a kernelized linear attention mechanism, based on query features, key features, and a gated value representation. Construct a global memory aggregate, and compute the attention output for each query position within the global memory aggregate. Based on attention output Global context representation is obtained through residual connections and layer normalization. .

[0009] The query-driven subgraph aggregation module is used to capture neighborhood structure features within a local subgraph through a message passing mechanism, guided by query relationship representation, including: Head entity in the initial entity representation As the starting point of local propagation; The query relation representation is converted into a modulation vector corresponding to each relation type, with the head entity as the basis. Centered on the target node, message passing is performed in multiple rounds within the local subgraph. In each round of iteration, the target node's neighboring nodes are modulated according to the target node and the corresponding modulation vector to obtain modulated state information. The modulated state information is then aggregated to obtain an aggregated message. The state is updated based on the aggregated message and the current state of the target node. After a preset number of iterations, the neighborhood structure features are obtained.

[0010] The process of adaptively weighting and fusing global context features and neighborhood structure features using query relationship representation as a constraint to obtain the fused entity representation includes: Broadcast the query relationship representation along the candidate entity dimension to generate a relationship condition field consistent with the dimensions of global context features and neighborhood structure features. A linear transformation projection is performed on the global context features and neighborhood structure features. The linear transformation projection results are then superimposed on the relational condition field to generate global intermediate features and local intermediate features, respectively. The global intermediate features and local intermediate features are each multiplied by a learnable direction vector to obtain the scalar weight scores corresponding to the local and global branches. The adaptive fusion coefficients of the global and local branches are obtained based on the scalar weight scores corresponding to the local and global branches. The global context features and neighborhood structure features are then weighted and summed according to the adaptive fusion coefficients to obtain the fused entity representation.

[0011] A knowledge graph reasoning system based on dual-branch feature extraction and relation-guided fusion includes: The feature encoding module is used to obtain knowledge graph triples, encode the knowledge graph triples, and obtain the initial entity representation and query relationship representation. The dual-branch feature extraction module is used to extract contextual features based on the initial entity representation, obtain global contextual features, and use the head entity in the initial entity representation as the starting point for local propagation. Guided by the query relationship representation, it captures neighborhood structural features in the local subgraph through a message passing mechanism. The relationship-guided cross-fusion module is used to adaptively weight and fuse global context features and neighborhood structure features with query relationship representation as constraints to obtain the fused entity representation. The decoding module is used to calculate the prediction score of each candidate entity based on the fused entity representation, sort the candidate entities according to the prediction score results, and obtain the knowledge graph reasoning results.

[0012] A computer program product includes a computer program that, when executed by a processor, implements any one of the methods described.

[0013] A terminal device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of any of the methods described above.

[0014] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the methods described herein.

[0015] Compared with the prior art, the present invention has the following beneficial effects: This invention discloses a knowledge graph reasoning method based on dual-branch feature extraction and relation-guided fusion. When extracting global context features and neighborhood structure features, two parallel feature learning branches are used to learn cross-distance dependencies and neighborhood structure evidence between entities under the same query conditions. This solves the problem that a single mode cannot simultaneously and fully capture global and local structural information, effectively alleviating the problem of feature oversmoothing. The global context features and neighborhood structure features are cross-fused using query relation representation as a constraint. Adaptive fusion weights are generated in each dimension of the candidate entity, so that the contribution of local and global branches to the representation can be dynamically adjusted according to the semantics of the target relation. This achieves adaptive allocation of relation-specific evidence, and the output entity representation has both global structural integrity and target relation recognizability, improving the accuracy of knowledge graph reasoning.

[0016] Furthermore, in this invention, the gated linear global attention module performs soft pruning on information through data dependency gating to reduce interference from irrelevant nodes during processing, and uses kernelized mapping to reduce the quadratic complexity of standard attention to linear level, enabling it to efficiently adapt to global long-range dependency modeling of large-scale knowledge graphs.

[0017] Furthermore, in this invention, a query-driven subgraph aggregation module is designed in the local branch, which modulates the features propagated on each edge in a multiplicative manner by the query relation conditions, so that the same neighborhood structure produces different local evidence responses under different relation queries, thereby enhancing the model's ability to capture structural evidence related to the query. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a diagram of the overall structure of the model disclosed in an embodiment of the present invention; Figure 2 This is a structural diagram of the gated linear global attention module disclosed in an embodiment of the present invention; Figure 3 This is a schematic diagram of the query-driven subgraph aggregation process disclosed in an embodiment of the present invention; Figure 4 This is a structural diagram of the relationship-guided cross-fusion module disclosed in an embodiment of the present invention. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0021] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0022] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0023] In the description of the embodiments of the present invention, it should be noted that if terms such as "upper," "lower," "horizontal," or "inner" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product of the invention is in use, they are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention. Furthermore, terms such as "first" and "second" are only used to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0024] Furthermore, the use of the term "horizontal" does not imply that the component must be absolutely horizontal, but rather that it can be slightly tilted. For example, "horizontal" simply means that its direction is more horizontal than "vertical," and does not mean that the structure must be completely horizontal, but can be slightly tilted.

[0025] In the description of the embodiments of the present invention, it should also be noted that, unless otherwise explicitly specified and limited, the terms "set," "install," "connect," and "link" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention according to the specific circumstances.

[0026] The present invention will now be described in further detail with reference to the accompanying drawings: See Figures 1 to 4 This invention discloses a knowledge graph reasoning method based on dual-branch feature extraction and relation-guided fusion. It aims to solve the problems of existing knowledge graph reasoning methods, which are difficult to balance global and local features and do not fully utilize the guiding role of query relations. This embodiment can be applied to e-commerce platforms to discover users' potential interests based on their query habits and provide more personalized recommendations that meet user needs. Alternatively, it can be applied to content platforms to make personalized recommendations for videos, news, or music that users are interested in by using user behavior data and knowledge graphs.

[0027] Includes the following steps: Step 1: Construct a graph neural network encoder to encode the input knowledge graph triples to obtain the initial entity representation and query relationship representation.

[0028] This step aims to map the discrete symbols (entities and relations) in the input knowledge graph into continuous, low-dimensional vector representations, laying the foundation for subsequent bi-branch feature extraction.

[0029] This step first initializes and encodes the input knowledge graph data: Given a knowledge graph ,in For a collection of entities, For a set of relations, Let the set of fact triples be ; let the size of the candidate entities be . The hidden dimension is .

[0030] For batch size Query index pairs Each query The aim is to predict the correct tail entity. To incorporate the query relation into subsequent calculations, the relation index is first... Through a learnable relational embedding matrix Mapped to relational condition vector This vector encodes the semantic information of the query relationship.

[0031] Then, initial node features for each query are constructed. Depending on the application scenario, this invention supports two settings: direct and inductive. In the direct setting, an optional, frozen entity feature embedding matrix is ​​used. As prior knowledge, in the inductive setting, to avoid introducing additional semantic priors beyond the training subgraph, the prior feature matrix is ​​set to zero. Simultaneously, to explicitly inject the positional information of the head entity, a head entity indicator vector is constructed. , so that it is in the head entity The corresponding index is set to 1, and the rest are set to 0. This indicator vector is then copied and expanded along the feature dimension. ,in It is a length of A vector of all 1s.

[0032] The aforementioned prior entity features and head entity indicator features are concatenated along the feature dimension to obtain the combined features. .

[0033] The combined features are input into a multilayer perceptron consisting of two feedforward networks. In the process, nonlinear transformations and dimension mappings are performed to generate the initial node representation matrix. .

[0034] Should The concatenated features are fused and mapped to a unified model. Hidden space. At this point, each query... Each obtained its corresponding initial node representation matrix centered on the head entity. and relational condition vectors Both will serve as inputs to the subsequent dual-branch feature extraction module.

[0035] Step 2: Perform parallel feature extraction using the dual-branch feature extraction module. In this step, a dual-branch feature extraction module is used to process the node representation matrix output by the graph neural network encoder. ,in For batch size, For the total number of entities, This is the hidden layer dimension. This module contains two parallel sub-modules: a gated linear global attention module and a query-driven subgraph aggregation module, which are used to capture the global context features and local neighborhood structure features of the knowledge graph, respectively.

[0036] like Figure 2 As shown, the implementation of the gated linear global attention module is as follows: First, represent the input nodes. The query is obtained through three linear projection matrices. ,key Sum ,in To enhance feature representation capabilities, a multi-head attention mechanism is employed. Divide along the feature dimension Each head has a dimension of [number]. .

[0037] To suppress node information irrelevant to the current query, this module introduces data dependency gating weights. ,in, For gated projection matrix, The sigmoid function is used. The gate weights are multiplied element-wise by the value vector to obtain the gated value representation. This allows for soft pruning of contributions from irrelevant nodes.

[0038] To avoid the standard attention mechanism To reduce computational complexity, this module employs kernelized linear attention. It defines the kernel feature map. This mapping guarantees non-negativity of the output and can be used as a feature representation of the attention weights. For each attention head, two global aggregations are computed independently: Global Memory Matrix and the vector sum of nucleated bonds .

[0039] For any query position (correspond Its attention output is ,in This is a numerical stability constant. The calculation transforms the explicit weighted summation of all nodes in Softmax attention into a form of first aggregating key values ​​and then linearly decoding, with an overall computational complexity of O(n log n). It grows linearly with the number of nodes.

[0040] Finally, the multi-head outputs are merged and propagated through residual connections and layer-normalized stable features: , in, This is the result of multi-head attention merging. For location-aware feedforward networks, Presentation layer normalization. Final output. As a representation of the global context.

[0041] like Figure 3 As shown, the implementation of the query-driven subgraph aggregation module is as follows: This module uses the header entity. As the starting point for local propagation, and to query the relationship The message passing process is injected with a multiplicative modulation method, so that the update of the node representation is simultaneously constrained by the sparse topology of the graph and the query semantics.

[0042] First, regarding the first A query, constructing a header entity indicator vector. This makes it only in the head entity The value is 1 at one position and 0 at the other positions, and this is extended to the feature dimension to obtain... Prior entity features and By concatenating along the feature dimension and mapping through two layers of multilayer perceptrons, the initial node states of the local branches are obtained: .

[0043] During the message passing phase, execution The next iteration (in this embodiment) ). In the first First, the query condition vector will be used. Transformed into modulation vectors corresponding to each relation through linear projection For nodes Its incoming edge aggregation message is:

[0044] in, Let be the set of edges. The edge weight is usually set to 1. This is the Hadamard product. This formula achieves multiplicative modulation of the source node features by the relation conditions, enabling the same neighborhood structure to produce different evidence responses under different query relations.

[0045] Subsequently, the node state is updated using aggregated messages, and residual connections and learnable scaling vectors are introduced. :

[0046] in, For the output transform network, For layer normalization, residual design ensures that the original feature baseline is preserved in deep iterations, effectively mitigating the oversmoothing problem.

[0047] Furthermore, during the training phase, random edge masks can be introduced to prevent the model from relying on shortcut edges that have a direct correspondence with the answer. Define the edge mask. Then the effective edge set is and sum the above Replace with .

[0048] go through After the iteration, the node representation is obtained. This is the query-driven local subgraph aggregation representation. This representation is compared with the global context representation output by the gated linear global attention module. Enter the subsequent relationship guidance cross-fusion module together.

[0049] Step 3: Perform feature fusion using the relationship-guided cross-fusion module. See Figure 4 The relation-guided cross-fusion module, located at the output of the dual-branch feature extraction module, adaptively and controllably fuses the global context representation output by the gated linear global attention module with the local neighborhood representation output by the query-driven subgraph aggregation module during the representation update process within the same query task and the same network layer. Existing fusion strategies often employ fixed scalar or graph-wide shared fusion coefficients, failing to characterize the differentiated dependencies of different relation types on local structural evidence and global context evidence. To address this issue, this module uses relation semantics as a constraint, generating adaptive fusion weights for each dimension of candidate entities. This allows the contribution ratio of global and local branches to the representation of each candidate entity to dynamically adjust based on the target relation semantics and the current output representation of the dual branches, thereby achieving adaptive allocation of relation-specific evidence.

[0050] Specifically, let the batch size be... The number of candidate entities is The hidden dimension is Let the local branch output tensor be denoted as The global branch output tensor is denoted as Both maintain completely consistent tensor shapes under the same network layer and the same query sample, and can be based on indexes. Achieve feature alignment of components. The query embedding of the target relation is denoted as... The embedding is obtained by mapping the relation category index through the embedding layer encoding.

[0051] This module first embeds the relationship query. Broadcast along the candidate entity dimension to generate and , Dimensionally consistent relational conditional fields This design enables all candidate entities under the same query task to share a unified relational semantics, and achieves fine-grained differentiated nonlinear interaction between relational semantics and the bi-branch features of each entity's location.

[0052] Next, the dual-branch output features are projected using a structure-shared linear transformation, and then, after being superimposed with the relational conditional field, intermediate feature representations are generated through a rectified nonlinear activation function. This process can be formally represented as:

[0053]

[0054] in, and It is a learnable linear transformation matrix used to map bi-branch features and relational semantics to the same latent space; It is a non-linear activation function.

[0055] Then, the intermediate features are characterized. and Each with a learnable direction vector Perform a dot product operation and compress to obtain the index. Scalar weight scores for local branches and global branches at different locations:

[0056]

[0057] in, .

[0058] By concatenating the two scalar scores along the branch dimension, we obtain the composite score tensor:

[0059] Subsequently, on the branch dimension Normalization using the Softmax function yields non-negative adaptive fusion coefficients that sum to 1.

[0060] in, and The fusion weights correspond to the local branch and the global branch respectively, and satisfy the following conditions: Applying Softmax normalization constraints to the fusion weights along the branch dimension has two advantages: first, it ensures that the module output is a convex combination of bi-branch representations, suppressing the numerical divergence problem of fusion features; second, it improves the numerical stability of the backpropagation process, providing a guarantee for deep training of the model.

[0061] Finally, based on the fusion coefficients, the original output representations of the two branches are summed element-wise with weights to obtain the fused feature representations:

[0062] in, This represents the Hadamard product (element-by-element multiplication). This is the final output of the cross-fusion module guided by the aforementioned relationship.

[0063] Because the fusion weights are calculated independently for each candidate entity location, the model can achieve fine-grained differentiated feature emphasis at the feature representation level. That is, different modeling weights are assigned to different candidate entities based on local neighborhood structural consistency or full-graph context mode. On this basis, by introducing relational semantic conditions, the feature emphasis mode under different relation types can be adaptively adjusted, thereby accurately adapting to the differentiated dependence characteristics of structural evidence on different relations.

[0064] Step 4: Decoding and Loss Function Optimization After completing the aforementioned cross-fusion of dual-branch feature extraction and relationship guidance, it is necessary to map the fusion representation in the node space to the candidate entity prediction score for the query, and then optimize the model parameters end-to-end using the loss function.

[0065] Specifically, let the fusion output be... ,in, To query the batch size, let the batch size be . , The total number of candidate entities. For feature dimensions. The decoder is responsible for processing each query. Each candidate tail entity position Calculate scalar score To balance expressive power and computational overhead, this invention employs a lightweight decoding structure based on a multilayer perceptron. First, a linear transformation layer is used to perform a dimension-preserving projection on the fused features to obtain an intermediate representation. ,in To output the projection weight matrix, This is the bias term. Then... Input a two-layer feedforward network Generate a scalar score for each candidate entity: The first layer of this feedforward network will Dimension mapping to The second layer is mapped to a 1-dimensional output scalar score using the ReLU activation function.

[0066] Furthermore, the supervision signal during the training phase consists of both positive and negative samples, and is coupled with filtering constraints to avoid treating known true triples as negative examples. For each query... First, determine its actual tail entity. Then sample from the candidate entity set. negative examples During sampling, all known correct triples from the training, validation, and test sets must be filtered out to ensure that negative examples do not contain any existing true facts. Negative sampling scale. Controlled by hyperparameters and related to the total number of entities To ensure computational controllability, an upper bound is chosen in this specific implementation. Take 256.

[0067] Furthermore, this invention employs a binary cross-entropy loss with self-adversarial weights as the optimization objective. For candidate subsets... First, calculate the score vector for each candidate entity. The corresponding label vector Positive examples are assigned a value of 1, and negative examples are assigned a value of 0. To enhance the gradient contribution of difficult negative examples, a score-based adversarial weight is introduced for negative examples: Let the negative example score vector be... Temperature parameters If we set it to 0.5, the weights are given by the Softmax function. The weight of positive examples is fixed at 1. The final weighted binary cross-entropy total loss is:

[0068] This loss function encourages the model to give high scores on positive examples while imposing a greater penalty on difficult negative examples, thereby improving ranking performance.

[0069] Furthermore, this invention employs the Adam optimizer for parameter updates, with an initial learning rate set to 5 × 10⁻⁶. 4 The weight decay factor is 10. 4During training, a linear warm-up strategy is employed, with the learning rate linearly increasing from 0 to the initial learning rate for the first 10% of training steps. Afterward, a cosine annealing scheduler is used to gradually decrease the learning rate. The batch size is set to 32 or 64 bytes depending on the GPU memory capacity. The maximum number of training epochs is 100, and at the end of each epoch, the MRR and Hits@10 metrics are calculated on the validation set. The model parameters with the best performance on the validation set are saved for testing.

[0070] During the testing phase, for each query First, the trained model is used to calculate all candidate entities. Score Then, following a filtering and ranking protocol, all known correct triples (excluding the true tail entity of the current query) from the training, validation, and test sets are removed from the candidate list. Next, the remaining candidate entities are sorted from highest to lowest score to obtain the ranking of the true tail entity. Finally, the average reciprocal rank and hit rate are calculated across the entire test set as evaluation metrics.

[0071] This embodiment also discloses a knowledge graph reasoning system based on dual-branch feature extraction and relation-guided fusion, including: The feature encoding module is used to obtain knowledge graph triples, encode the knowledge graph triples, and obtain the initial entity representation and query relationship representation. The dual-branch feature extraction module is used to extract contextual features based on the initial entity representation, obtain global contextual features, and use the head entity in the initial entity representation as the starting point for local propagation. Guided by the query relationship representation, it captures neighborhood structural features in the local subgraph through a message passing mechanism. The relationship-guided cross-fusion module is used to adaptively weight and fuse global context features and neighborhood structure features with query relationship representation as constraints to obtain the fused entity representation. The decoding module is used to calculate the prediction score of each candidate entity based on the fused entity representation, sort the candidate entities according to the prediction score results, and obtain the knowledge graph reasoning results.

[0072] This embodiment first separates global context modeling and local subgraph message passing into two parallel feature learning branches through a dual-branch feature extraction module. Under the same query conditions, these branches learn cross-distance dependencies and neighborhood structure evidence between entities, respectively. This addresses the limitation of a single model in simultaneously capturing sufficient global and local structural information, effectively mitigating the problem of over-smoothing features. Furthermore, a gated linear kernelized attention mechanism is employed in the global branch. Data dependency gating performs soft pruning to reduce interference from irrelevant nodes, and kernelized mapping reduces the quadratic complexity of standard attention to linear complexity, enabling it to efficiently adapt to global long-range dependency modeling in large-scale knowledge graphs. Further, a query-driven subgraph aggregation module is designed in the local branch. This module multiplicatively modulates the features propagated along each edge based on the query relationship conditions, causing the same neighborhood structure to generate different local evidence responses under different relation queries, enhancing the model's ability to capture query-related structural evidence. Furthermore, a relationship-guided cross-fusion module is introduced. Using query relation semantics as constraints, adaptive fusion weights are generated for each dimension of candidate entities. This allows the contributions of local and global branches to the representation to be dynamically adjusted according to the target relation semantics, achieving adaptive allocation of relation-specific evidence. The output entity representation simultaneously possesses global structural integrity and target relation recognizability. This invention significantly improves the accuracy, generalization ability, and adaptability to complex relational patterns of knowledge graph reasoning through the synergistic effects of bi-branch separation modeling, kernelized linear global attention, query conditional message passing, and relationship-guided fusion. It can be widely applied to knowledge-driven tasks such as intelligent question answering, recommendation systems, and knowledge completion.

[0073] A schematic diagram of a terminal device according to an embodiment of the present invention. The terminal device of this embodiment includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps in the various method embodiments described above. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in the various device embodiments described above.

[0074] The computer program can be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention.

[0075] The terminal device can be a desktop computer, laptop computer, cloud server, or other device with strong computing power. The terminal device may include, but is not limited to, a processor and memory.

[0076] The optimal choice for the processor is a multi-core high-speed central processing unit (CPU).

[0077] The memory can be used to store the computer program and / or module. The processor implements various functions of the terminal device by running or executing the computer program and / or module stored in the memory and calling the data stored in the memory.

[0078] If the modules / units integrated into the terminal device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.

[0079] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A knowledge graph reasoning method based on dual-branch feature extraction and relation-guided fusion, characterized in that, Includes the following steps: Obtain knowledge graph triples, encode the knowledge graph triples, and obtain the initial entity representation and query relationship representation; Contextual features are extracted based on the initial entity representation to obtain global contextual features. The head entity in the initial entity representation is used as the starting point for local propagation. Guided by the query relationship representation, neighborhood structural features are captured in the local subgraph through a message passing mechanism. Using query relationship representation as a constraint, the global context features and neighborhood structure features are adaptively weighted and fused to obtain the fused entity representation. The predicted score for each candidate entity is calculated based on the fused entity representation. The candidate entities are then ranked according to the predicted scores to obtain the knowledge graph reasoning results.

2. The knowledge graph reasoning method based on dual-branch feature extraction and relation-guided fusion according to claim 1, characterized in that, The process of obtaining knowledge graph triples, encoding the knowledge graph triples, and obtaining initial entity representations and query relation representations includes: Obtain the entity set and relation set in the given knowledge graph, initialize each entity as the corresponding prior feature vector, map each relation as the corresponding relation embedding vector, and obtain the query relation representation; Construct a head entity indicator vector, and concatenate the head entity indicator vector with the prior feature vector to obtain the initial node representation. All the initial node representations constitute the initial entity representation.

3. The knowledge graph reasoning method based on dual-branch feature extraction and relation-guided fusion according to claim 1, characterized in that, The process of extracting contextual features based on initial entity representations to obtain global contextual features, and using the initial entity representations within the initial entity representations as a guide, guided by query relationship representations, and capturing neighborhood structure features within local subgraphs through a message passing mechanism, includes: A dual-branch feature extraction module is constructed to perform parallel feature extraction on entity representations. The dual-branch feature extraction module includes a gated linear global attention module and a query-driven subgraph aggregation module. The gated linear global attention module is used to capture global contextual features and long-range dependencies of the knowledge graph; The query-driven subgraph aggregation module is used to capture neighborhood structural features within a local subgraph through a message passing mechanism, guided by the query relationship representation.

4. The knowledge graph reasoning method based on dual-branch feature extraction and relation-guided fusion according to claim 3, characterized in that, The gated linear global attention module is used to capture global contextual features and long-range dependencies of the knowledge graph, including: The initial representation of the entity is used as the input node representation. ; Represent the input node These are mapped to query features, key features, and value features, respectively. Introducing data-dependent gating weights Soft pruning of the value features yields the gated value representation. ; Employing a kernelized linear attention mechanism, based on query features, key features, and a gated value representation. Construct a global memory aggregate, and compute the attention output for each query position within the global memory aggregate. Based on attention output Global context representation is obtained through residual connections and layer normalization. .

5. The knowledge graph reasoning method based on dual-branch feature extraction and relation-guided fusion according to claim 3, characterized in that, The query-driven subgraph aggregation module is used to capture neighborhood structure features within a local subgraph through a message passing mechanism, guided by query relationship representation, including: Head entity in the initial entity representation As the starting point of local propagation; The query relation representation is converted into a modulation vector corresponding to each relation type, with the head entity as the basis. Centered on the target node, message passing is performed in multiple rounds within the local subgraph. In each round of iteration, the target node's neighboring nodes are modulated according to the target node and the corresponding modulation vector to obtain modulated state information. The modulated state information is then aggregated to obtain an aggregated message. The state is updated based on the aggregated message and the current state of the target node. After a preset number of iterations, the neighborhood structure features are obtained.

6. The knowledge graph reasoning method based on dual-branch feature extraction and relation-guided fusion according to claim 1, characterized in that, The process of adaptively weighting and fusing global context features and neighborhood structure features using query relationship representation as a constraint to obtain the fused entity representation includes: Broadcast the query relationship representation along the candidate entity dimension to generate a relationship condition field consistent with the dimensions of global context features and neighborhood structure features. A linear transformation projection is performed on the global context features and neighborhood structure features. The linear transformation projection results are then superimposed on the relational condition field to generate global intermediate features and local intermediate features, respectively. The global intermediate features and local intermediate features are each multiplied by a learnable direction vector to obtain the scalar weight scores corresponding to the local and global branches. The adaptive fusion coefficients of the global and local branches are obtained based on the scalar weight scores corresponding to the local and global branches. The global context features and neighborhood structure features are then weighted and summed according to the adaptive fusion coefficients to obtain the fused entity representation.

7. A knowledge graph reasoning system based on dual-branch feature extraction and relation-guided fusion, characterized in that, include: The feature encoding module is used to obtain knowledge graph triples, encode the knowledge graph triples, and obtain the initial entity representation and query relationship representation. The dual-branch feature extraction module is used to extract contextual features based on the initial entity representation, obtain global contextual features, and use the head entity in the initial entity representation as the starting point for local propagation. Guided by the query relationship representation, it captures neighborhood structural features in the local subgraph through a message passing mechanism. The relationship-guided cross-fusion module is used to adaptively weight and fuse global context features and neighborhood structure features with query relationship representation as constraints to obtain the fused entity representation. The decoding module is used to calculate the prediction score of each candidate entity based on the fused entity representation, sort the candidate entities according to the prediction score results, and obtain the knowledge graph reasoning results.

8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-6.

9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1-6.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1-6.