Coarse and fine granularity-aware knowledge graph reasoning method, device and medium

By employing a coarse-grained knowledge graph reasoning method, which generates an information matrix using local and global path queries and performs weighted fusion, the problem of interference between local and global information processing in existing technologies is solved, achieving higher reasoning accuracy and efficiency.

CN122174938APending Publication Date: 2026-06-09SUZHOU INST FOR ADVANCED STUDY USTC

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SUZHOU INST FOR ADVANCED STUDY USTC
Filing Date
2026-02-09
Publication Date
2026-06-09

Smart Images

  • Figure CN122174938A_ABST
    Figure CN122174938A_ABST
Patent Text Reader

Abstract

The application discloses a coarse and fine granularity perceived knowledge graph reasoning method and device and medium. The method comprises the following steps: calculating the first score of each candidate entity by using a coarse-grained reasoning model to divide the candidate entities into a high-score subset and a low-score subset; for each candidate entity: performing local path query and global path query in the input knowledge graph respectively to generate a local information matrix and a global information matrix, determining a local trust weight vector and a global trust weight vector according to the query vector of the reasoning task, weighting and fusing the local information matrix and the global information matrix, and obtaining the second score of the candidate entity according to the sum of the linear interaction compensation result and the weighted result of the local information matrix and the global information matrix; and selecting the optimal candidate entity as the reasoning answer and outputting according to the highest second score in the low-score subset and the highest second score in the high-score subset. The application improves the reasoning accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence and data processing technology, and more specifically, relates to a knowledge graph reasoning method, device and medium with coarse and fine granular perception. Background Technology

[0002] Knowledge graphs, as a core technology for structurally representing real-world entities and their complex relationships, have become a key driving force in modern artificial intelligence and various downstream computing applications. Existing knowledge graphs generally face a serious technical bottleneck—incompleteness—meaning that a large number of real-world entity relationships are not explicitly stored in the graph. To overcome this bottleneck, automatically inferring and completing missing entity information through "knowledge graph reasoning" technology has become a crucial and urgent technical task in this field.

[0003] Existing research indicates that to achieve efficient and accurate knowledge graph reasoning, models must address two major technical challenges: First, they must possess the ability to effectively aggregate and propagate local information from local neighborhoods to capture multi-hop and subgraph patterns between entities. Second, they must simultaneously capture the global structure and long-range dependencies within large-scale graphs to understand complex relationships spanning multiple intermediate nodes. Therefore, any effective knowledge graph reasoning solution must satisfy these dual technical constraints.

[0004] To address the aforementioned dual technical constraints, existing technologies have explored various approaches, primarily including triple-based methods, message-passing-based methods, Transformer-based methods, and hybrid inference models. Triple-based methods often neglect the graph's topology during modeling, severely limiting their performance when handling inference tasks requiring complex structures (e.g., multi-hop paths), thus failing to meet the dual technical constraints. Message-passing-based methods frequently fail to model long-range dependencies and global structural patterns, struggle to capture global relationships between distant entities, and are also limited by other inherent drawbacks of message-passing networks, such as information incompleteness and over-compression issues when processing deep networks. Transformer-based methods typically require converting the graph structure into a sequential representation during knowledge encoding, inevitably leading to the loss of crucial structural information inherent in the knowledge graph.

[0005] Hybrid reasoning models represent the latest advancements in research, attempting to leverage the strengths of both message passing and Transformer paradigms to capture both local and global information simultaneously. However, hybrid reasoning models still face key challenges in effectively integrating and balancing local and global information. The root cause of this technical challenge or deficiency lies in score oversmoothing. Score oversmoothing refers to the phenomenon where, when scoring all candidate entities in a knowledge graph completion task, numerous incorrect answers receive scores similar to correct answers. This oversmoothing phenomenon has serious negative technical consequences: on the one hand, it severely blurs the distinction between correct and incorrect answers, making it difficult for the model to differentiate them; on the other hand, this low discriminative power caused by oversmoothing greatly hinders the effectiveness of reasoning, constituting a key technical bottleneck limiting the performance improvement of existing hybrid models. Summary of the Invention

[0006] The main objective of this invention is to provide a knowledge graph reasoning method, device, and medium with coarse-grained perception, so as to overcome the shortcomings of the prior art.

[0007] To achieve the above-mentioned objectives, the present invention adopts the following technical solution: The first aspect of this invention provides a coarse-grained and fine-grained knowledge graph reasoning method, comprising: S1, calculating a first score for each candidate entity using a coarse-grained reasoning model to divide all candidate entities into a high-score subset and a low-score subset; S2, for each candidate entity, performing S21-S23: S21, performing local path query and global path query in the input knowledge graph to generate a local information matrix and a global information matrix for the candidate entity; S22, determining a local trust weight vector and a global trust weight vector based on the query vector of the reasoning task to perform weighted fusion of the local information matrix and the global information matrix; S23, performing reasoning to obtain a second score for the candidate entity based on the sum of the linear interaction compensation result of the local information matrix and the global information matrix and the weighted result; S3, selecting the optimal candidate entity as the reasoning answer and outputting it based on the highest second score in the low-score subset and the highest second score in the high-score subset.

[0008] Preferably, all candidate entities are divided into a high-score subset and a low-score subset, specifically including: assigning a set number of candidate entities with the highest first score to the high-score subset and assigning the remaining candidate entities to the low-score subset; or, assigning candidate entities with a first score higher than a first set value to the high-score subset and assigning the remaining candidate entities to the low-score subset.

[0009] Preferably, step S21 specifically includes: generating a positional encoding based on the Laplacian feature vector of the input knowledge graph to obtain entity and relation representations; and performing local path queries and global path queries based on the positional encoding to generate the local information matrix and the global information matrix.

[0010] Preferably, step S22 specifically includes: concatenating the query vector of the inference task into the local information matrix and the global information matrix respectively, and inputting them into a confidence evaluation network based on a multilayer perceptron mechanism to predict the log-variance of local information and the log-variance of global information in the current inference context respectively; generating a local trust weight vector and a global trust weight vector based on the inverse variance principle according to the log-variance of local information and the log-variance of global information; and performing weighted fusion of the local information matrix and the global information matrix according to the local trust weight vector and the global trust weight vector.

[0011] Preferably, the local trust weight vector and the global trust weight vector are respectively: ; ; in, Let be the local trust weight vector. Let be the global trust weight vector. The logarithmic variance of the local information. The logarithmic variance of the global information. This is the exponential function operator.

[0012] Preferably, the linear interaction compensation result and the weighted result are respectively: ; ; in, The linear interaction compensation result, For the weighted result, Let be the local trust weight vector. Let be the global trust weight vector. The local information matrix, This refers to the global information matrix; The relation embedding matrix is ​​a feature matrix that represents all relation types in the knowledge graph. This represents the dot product operation. It is the hyperbolic tangent function.

[0013] Preferably, S23 specifically includes: obtaining the second score based on the sum of the linear interaction compensation result and the weighted result using a multi-layer perception mechanism.

[0014] Preferably, S3 specifically includes: if the highest second score in the low score subset is higher than the highest second score in the high score subset, and the difference between the two is greater than a second set value, then the candidate entity corresponding to the highest second score in the low score subset is used as the reasoning answer and output; otherwise, the candidate entity corresponding to the highest second score in the high score subset is used as the reasoning answer and output.

[0015] A second aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the coarse-grained perception knowledge graph reasoning method as described above.

[0016] A third aspect of the present invention provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the coarse-grained perception knowledge graph reasoning method described above.

[0017] Compared with existing technologies, the beneficial effects of this invention are as follows: This invention provides a coarse-grained and fine-grained knowledge graph reasoning method, device, and medium. It designs a dual-path global-local fusion architecture and a coarse-grained and fine-grained reasoning optimization mechanism. The dual-path global-local fusion architecture can prevent local and global information from interfering with each other and retain the discriminative power of the representation. The coarse-grained and fine-grained reasoning optimization mechanism sharpens the score difference between the high and low score subsets. This dual optimization shows a clearer score separation in the candidate entity score distribution, thereby improving reasoning accuracy and reasoning quality. The dual-path architecture separates local information processing and global information processing, allowing the computation of local and global paths to be processed in parallel, improving processing efficiency. By explicitly injecting the query vector into the confidence assessment, on-demand fusion is achieved, effectively filtering noisy paths under specific queries, thereby significantly improving the accuracy in complex reasoning scenarios. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 The flowchart illustrates the knowledge graph reasoning method with coarse-grained perception provided in this embodiment of the invention.

[0020] Figure 2This is a framework diagram of a coarse-fine collaborative reasoning model provided in an embodiment of the present invention.

[0021] Figure 3 This diagram illustrates the performance comparison between our method and related technologies in an open reasoning scenario.

[0022] Figure 4 This diagram illustrates the performance comparison between our method and related technologies in a closed-loop inference scenario.

[0023] Figure 5 This is a comparison of the training time of our method and existing representative models on different knowledge graph datasets.

[0024] Figure 6 This is a block diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0025] In view of the shortcomings of the prior art, the inventors of this invention, through long-term research and extensive practice, have proposed the technical solution of this invention. The following will further explain and illustrate this technical solution, its implementation process, and its principles.

[0026] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and therefore the scope of protection of the invention is not limited to the specific embodiments disclosed below.

[0027] Furthermore, in the description of this invention, it should be understood that the terms "upper," "lower," "inner," "outer," "horizontal," "vertical," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this 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. Therefore, they should not be construed as limitations on this invention.

[0028] In the description of this specification, the references to terms such as "an embodiment," "a particular embodiment," or "the embodiment" indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0029] Figure 1 A flowchart illustrating the coarse-grained and fine-grained knowledge graph reasoning method provided in this embodiment of the invention. (See also...) Figure 1 This method includes the following operations S1-S3, and their corresponding model framework is as follows: Figure 2 As shown.

[0030] Operation S1 calculates the first score of each candidate entity using a coarse-grained inference model, thereby dividing all candidate entities into a high-score subset and a low-score subset.

[0031] Operation S2: For each candidate entity, perform operations S21-S23 respectively to perform fine-grained reasoning to obtain its second score.

[0032] Operation S21 involves performing local path queries and global path queries in the input knowledge graph to generate the local information matrix and global information matrix of the candidate entity.

[0033] Operation S22 determines the local trust weight vector and the global trust weight vector based on the query vector of the inference task, so as to perform weighted fusion of the local information matrix and the global information matrix.

[0034] Operation S23 involves reasoning based on the sum of the linear interaction compensation result and the weighted result between the local information matrix and the global information matrix to obtain the second score of the candidate entity.

[0035] Operation S3: Based on the highest second-highest score in the low-score subset and the highest second-highest score in the high-score subset, select the optimal candidate entity as the reasoning answer and output it.

[0036] The coarse-fine granularity-aware knowledge graph reasoning method provided by this invention applies a coarse-fine granular reasoning optimization strategy in the reasoning stage to address the limitation of one-step discrimination technology. In the fine-granular reasoning stage, it employs a dual-path global-local fusion model as the core architecture, thereby significantly improving reasoning accuracy and resolving the issue of excessive score smoothing in hybrid reasoning models. This method can be used in scenarios involving link prediction (e.g., head entity completion, tail entity completion, or relation completion), or in various downstream computing applications that rely on large-scale knowledge graphs for reasoning and prediction, such as information retrieval, recommender systems, logical reasoning, biomedical research (e.g., drug redirection or disease-gene association prediction), materials science, and social network analysis.

[0037] In operation S1, a coarse-grained inference model is used to calculate the first score of each candidate entity. The coarse-grained inference model is, for example, the HousE inference model or the RED-GNN inference model. A lightweight scoring model (i.e., a coarse-grained inference model) is used to quickly screen all candidate entities.

[0038] Preferably, operation S1 divides all candidate entities into a high-score subset and a low-score subset, specifically in the following two ways. Operation S1 can narrow down the candidate space, preparing for subsequent fine-tuning.

[0039] Method 1: Assign a set number of candidate entities with the highest initial scores to the high-score subset, and assign the remaining candidate entities to the low-score subset. For example, using a Top-k selector, based on the initial scores of each candidate entity, divide all candidate entities into two mutually exclusive subsets: the high-score subset and the low-score subset. Includes the k candidate entities with the highest initial scores, and a subset of low-scoring entities. Includes all remaining candidate entities.

[0040] Method 2: Assign candidate entities with a first score higher than the first set value to the high score subset, and assign the remaining candidate entities to the low score subset.

[0041] Preferably, operation S21 specifically includes the following sub-operations S211-S212.

[0042] In suboperation S211, positional encodings are generated based on the Laplacian feature vectors of the input knowledge graph to obtain entity and relation representations.

[0043] In suboperation S212, local path lookup and global path lookup are performed according to the position code to generate local information matrix and global information matrix.

[0044] Preferably, operation S22 specifically includes the following sub-operations S221-S223.

[0045] In suboperation S221, the query vector of the inference task is concatenated into the local information matrix and the global information matrix respectively, and then input into the confidence evaluation network based on the multilayer perceptron mechanism to predict the log-variance of local information and the log-variance of global information in the current inference context.

[0046] In suboperation S222, local trust weight vectors and global trust weight vectors are generated based on the log-variance of local information and the log-variance of global information, according to the inverse variance principle.

[0047] Preferably, the local trust weight vector and the global trust weight vector are as follows: ; ; in, For local trust weight vectors, This is the global trust weight vector. For local information, log-variance The logarithm of the global information is the variance. This is the exponential function operator.

[0048] In suboperation S223, the local information matrix and the global information matrix are weighted and fused according to the local trust weight vector and the global trust weight vector.

[0049] Preferably, the linear interaction compensation result and the weighted result are as follows: ; ; in, For the linear interaction compensation result, For the weighted result, For local trust weight vectors, This is the global trust weight vector. For local information matrix, This is the global information matrix; The relation embedding matrix is ​​a feature matrix that represents all relation types in the knowledge graph. This represents the dot product operation. It is the hyperbolic tangent function.

[0050] Preferably, operation S23 specifically includes: obtaining a second score based on the sum of the linear interaction compensation result and the weighted result using a multi-layer perception mechanism.

[0051] Operation S2 is the fine-grained reasoning stage, which adopts a dual-path global-local fusion model to extract the local information matrix and global information matrix of candidate entities.

[0052] The dual-path global-local fusion model receives an input knowledge graph. ,in, For entity sets, For a set of relations, This method calculates the Laplacian feature vector of the knowledge graph and generates positional codes based on the Laplacian feature vectors. These positional codes are then used as the initial vector representations of all entities and relations in the knowledge graph.

[0053] Local path processing employs a query-aware message-passing network. The path is determined based on the current inference query (e.g., ...). ), performing message passing and aggregation within the local neighborhood structure of the graph to capture multi-hop paths and subgraph patterns, generating a local information matrix. And output it.

[0054] The global path processing employs a global attention mechanism. This path operates on the same initial representation but computes attention scores globally, aiming to capture long-range dependencies and global structural patterns beyond local neighborhoods, independently generating a global information matrix. And output it.

[0055] This method employs a variance-aware trust fusion mechanism based on query context to fuse global and local information. This mechanism treats the representations output by the local and global paths as two sources of evidence with different cognitive uncertainties, and dynamically determines the degree of trust in each source of information based on the current inference query.

[0056] First, two parallel confidence evaluation networks (typically implemented as multilayer perceptrons) are introduced. These two networks each receive a local information matrix. and global information matrix and the query vector of the current inference task (For example, relation embeddings) are concatenated into the aforementioned matrix. Through this design, the model can predict the log-variance of local and global representations in the current context, respectively (denoted as the log-variance of local information), based on the specific query intent (e.g., whether to query nearest neighbor relationships or long-range inference). Log-variance of global information The log-variance mathematically quantifies the uncertainty of the corresponding path in a specific dimension.

[0057] Secondly, based on the inverse variance principle that smaller variance equates to higher confidence, the Softmax function is applied to the predicted log-variance to generate a normalized channel-level confidence weight vector. and ): ; ; The weights generated here are vectors rather than scalars, meaning the model can finely control whether to trust local information more in some feature dimensions and global information more in other dimensions.

[0058] To further capture the nonlinear conflicts or synergistic effects between local and global information, this method introduces a "bilinear interaction term" based on weighted fusion. The final entity representation matrix Z is calculated using the following formula, which includes "confidence weighting" and "interaction compensation": ; By inputting the fused representation matrix Z into a multilayer perceptron, the final entity score (i.e., the second score) can be predicted.

[0059] In the fine-grained reasoning stage, the aforementioned "dual-path global-local fusion model" is used as the "fine model" to refine the two subsets obtained in the coarse-grained reasoning. and All candidate entities in the ) are re-scored to generate a "refined entity-score table".

[0060] Preferably, operation S3 specifically includes: if the highest second score in the low score subset is higher than the highest second score in the high score subset, and the difference between the two is greater than a second set value, the candidate entity corresponding to the highest second score in the low score subset is used as the reasoning answer and output; otherwise, the candidate entity corresponding to the highest second score in the high score subset is used as the reasoning answer and output.

[0061] Extract high-score subsets from the refined score table. The second highest rating (Corresponding candidate entities) and low-scoring subsets The second highest rating (Corresponding candidate entities) Calculate the score difference between the highest scores of these two subsets. To bridge this gap With a predefined decision threshold (i.e., the second preset value) is compared. The score difference is determined if and only if... Greater than the threshold (Right now Only when ) will the candidate entity be included. Output the final reasoning answer; otherwise, output the candidate entity. As the final reasoning answer, it is output.

[0062] This two-stage optimization strategy, particularly through the design of decision gates, forces the model to sharpen the score gap between two subsets, thereby significantly improving the model's discriminative ability and robustness to oversmoothing.

[0063] Furthermore, our method was compared with several representative existing methods on multiple publicly available knowledge graph benchmark datasets (including FB15k-237, WN18RR, NELL-995, and YAGO3-10). The experimental results are as follows: Figure 3 , Figure 4 and Figure 5 As shown.

[0064] To comprehensively verify the effectiveness and generalization ability of this method, experiments were conducted under both open-ended and closed-ended reasoning settings. Open-ended reasoning refers to situations where the testing phase may include new entities or relationships not present in the training set, used to evaluate the model's generalization and transfer capabilities when faced with unknown entities. Closed-ended reasoning refers to situations where the training and testing phases share the same set of entities, meaning the test entities have already appeared in the training set, used to verify the model's reasoning ability within a closed knowledge graph.

[0065] In the experimental evaluation, two metrics were used to measure the model's inference accuracy and ranking ability: the mean regression ranking (MRR) and the top k hit rate (Hits@k). MRR characterizes the overall quality of the model's ranking of correct answers; a higher MRR indicates more accurate predictions. Hits@k represents the proportion of correct answers appearing in the top k predicted results, reflecting the model's hit rate in Top-k inference scenarios.

[0066] See Figure 3 The experimental results for open-ended reasoning are presented. The results show that our proposed method significantly outperforms message-passing-based models (Adaprop: Learning adaptive propagation for graph neural network based knowledge graph reasoning, published by Yongqi Zhang et al. in Knowledge Discovery and Data Mining, 2023) and Transformer-based models (such as KnowFormer) on key evaluation metrics including MRR, Hits@1, and Hits@10. In particular, our method achieves a maximum improvement of 8.7% on the high discriminative metric Hits@1, demonstrating its effectiveness in "score separation and oversmoothing suppression".

[0067] See Figure 4 The experimental results of this method in a closed reasoning scenario are shown. It can be seen that on the four benchmark datasets FB15k-237, WN18RR, NELL-995, and YAGO3-10, this method demonstrates significant advantages in the main evaluation metrics MRR, Hits@1, and Hits@10. Compared to message-passing based models (such as AdaProp) and Transformer-based models (such as KnowFormer), this method consistently outperforms them in overall performance. Especially in the high discriminative metric Hits@1, this method achieves a maximum improvement of approximately 6.4%, indicating that it possesses stronger entity discrimination capabilities and better feature fusion effects in closed knowledge graph environments, effectively alleviating the representation redundancy and oversmoothing problems of traditional models in multi-relationship scenarios.

[0068] Figure 5The diagram shows a comparison of training time between our proposed method and existing representative models on different knowledge graph datasets. The left graph compares training time on the FB15k-237 dataset, and the right graph compares training time on the YAGO3-10 dataset. The horizontal axis represents different model methods, including AdaProp, SAttLE, KnowFormer, and our proposed method; the vertical axis represents the time required to complete training. Experimental results show that our proposed method has a significantly shorter training time than other methods under the same experimental conditions, achieving approximately 1.8 times speedup during the training phase.

[0069] The coarse-grained and fine-grained perception knowledge graph reasoning method provided by this invention fundamentally solves the defects of existing technologies, especially the problem of score oversmoothing, through the synergistic effect of its unique "dual-path global-local fusion architecture" and "coarse-grained and fine-grained reasoning optimization" mechanism, and brings the following significant beneficial effects.

[0070] (1) Significantly improves reasoning accuracy and fundamentally alleviates the problem of score oversmoothing. This method addresses the root cause of score oversmoothing from both architectural and mechanistic perspectives.

[0071] Architectural advantages: Existing technologies employ a single-stage stacked architecture, leading to mutual interference between local and global information processing and the accumulation of oversmoothing effects. Our method's dual-path fusion architecture prevents mutual interference and preserves the discriminative power of the representation through separate processing.

[0072] Mechanism Advantages: Existing technologies employ one-time reasoning, resulting in limited discriminative ability. Our method's coarse-grained optimization mechanism, through coarse-grained candidate subset partitioning and fine-grained threshold decision-making, sharpens the score difference between the two subsets (high and low scores).

[0073] This dual optimization enables our method to exhibit clearer score separation in the candidate entity score distribution compared to existing techniques (such as HousE). Experimental data show that our method achieves state-of-the-art inference quality (measured by metrics such as MRR and Hits@1) on multiple benchmark datasets (such as FB15k-237 and WN18RR), achieving an inference quality improvement of up to 8.7% compared to state-of-the-art methods (such as KnowFormer).

[0074] (2) Significantly improves computational efficiency and reduces training costs. The dual-path fusion architecture of this method not only improves quality but also brings significant efficiency advantages.

[0075] Existing stacked architectures must execute local and global information processing sequentially. This method's dual-path architecture separates these two processes, allowing local and global path computations to be processed in parallel, improving processing efficiency. The overall time complexity of this method is determined by the slower of the two parallel paths. The complexity of existing stacking methods is the sum of the two (), ).

[0076] Furthermore, existing technologies often employ fixed weights or simple gating mechanisms, which struggle to address the varying structural dependencies of different queries (e.g., some queries depend on local dependencies, while others depend on global dependencies). Our proposed variance-aware trust fusion introduces uncertainty modeling, endowing the model with metacognitive capabilities—that is, knowing which paths are less reliable. By explicitly injecting query vectors into confidence assessment, the model achieves on-demand fusion, effectively filtering noisy paths for specific queries (e.g., automatically suppressing noise in local paths during long-range queries), thereby significantly improving accuracy in complex reasoning scenarios.

[0077] This parallelization design enables our method to achieve a training efficiency speedup of up to 1.8 times. Compared with existing technologies, this method achieves higher inference accuracy while significantly reducing the computational overhead and time cost required for model training.

[0078] The technical solution of the present invention will be further described in detail below with reference to several preferred embodiments and accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. Test methods in the following embodiments that do not specify specific conditions are generally performed under conventional conditions.

[0079] by Figure 2 Using the illustrated framework as an example, the specific implementation of the coarse-grained and fine-grained perception knowledge graph reasoning method provided by this invention will be further explained. (See also...) Figure 2 The method mainly includes steps such as data input, coarse-grained reasoning, fine-grained reasoning, dual-path fusion, and decision output.

[0080] This embodiment uses the "birthplace" reasoning of "Taylor Swift" as an example to illustrate the specific application process of this method in knowledge graph reasoning tasks.

[0081] (1) Input the knowledge graph and task definition.

[0082] like Figure 2As shown on the left, the input knowledge graph contains several entities and relationships, forming a multi-relation network. For example, entity nodes include "Taylor Swift" (v0), "United States" (v1), "Pennsylvania" (v2), "Grammy Awards" (v3), "California" (v4), "New York University" (v5), and "New York" (v6). These entities are connected by semantic relationships, such as "belongs to," "location of," "parallel relationship," and "graduated from." The reasoning task is to predict the "birthplace" entity of "Taylor Swift" based on known facts.

[0083] (2) Coarse-grained reasoning.

[0084] In the coarse-grained reasoning stage, a lightweight coarse model is first invoked to quickly score all candidate entities in the knowledge graph. This model has low computational complexity and can complete the preliminary ranking of all candidate entities in a short time, thereby quickly filtering potential correct answers. For example, coarse-grained scoring is performed on entities such as "Pennsylvania (v2)," "California (v4)," and "New York (v6)," resulting in a preliminary score table: v2=9, v4=7, v6=10. Based on the scoring results, it can be preliminarily determined that "Pennsylvania" and "California" are more likely to be the target entities.

[0085] (3) Fine-grained reasoning.

[0086] In the fine-grained reasoning stage, the input knowledge graph data is first received, and its Laplacian eigenvectors are calculated to generate positional codes for entities and relations. This encoding reflects the global structural positional information of nodes, enabling the model to perceive the topological hierarchy of the graph.

[0087] After feature encoding, the model proceeds along two parallel paths: a global path and a local path. The global path captures long-distance dependency information using a self-attention mechanism, enabling global semantic modeling across entities. The local path employs a message-passing network to aggregate multi-layered features from neighboring nodes, extracting local structural patterns and multi-hop relational semantics. Through these two paths, the model obtains the global information matrix and the local information matrix, respectively.

[0088] Then, in the fusion module, variance-aware fusion based on query context is performed. Specifically, the vector features of the current query relationship (birthplace in this example) are injected into the local representation and the global representation respectively, and the cognitive uncertainty of these two paths in the current context is dynamically evaluated.

[0089] In this example, analysis reveals that the birthplace relationship typically relies on direct neighborhood facts (e.g., someone was born in a certain place) rather than complex long-range inference. Therefore, the model automatically predicts lower variance (i.e., higher confidence) for local paths and higher variance for global paths. Based on this, a set of channel-level trust weights is generated, focusing on local information and giving local features a higher retention rate. Simultaneously, bilinear interaction features between the two are calculated as a supplement. Finally, the weighted high-confidence features are combined with the interaction features to obtain a fused entity representation, which is then mapped to entity scores using a multilayer perceptron.

[0090] (4) Fine-grained arrangement.

[0091] First, based on the coarse-grained scoring results, the top-k entities with the highest scores are selected as the high-scoring candidate set {v6 (New York), v2 (Pennsylvania), v1 (United States)}, and the rest are selected as the low-scoring candidate set. Then, the fine-grained model is used to re-score and rank these candidate entities at a finer level.

[0092] In the fine-grained stage, the model recalculates the ranking scores of each candidate entity based on the fused global-local features. For example, the updated scores are: v2=10, v4=11, v6=9. At this point, "California (v4)" has the highest score, and the system tends to consider this entity as the optimal answer.

[0093] (5) Decision gate output.

[0094] To ensure the stability and reliability of the prediction results, this embodiment sets up a "decision gate" mechanism in the output stage. This mechanism dynamically compares the difference between the highest scores of the high-scoring set and the low-scoring set: if the difference exceeds a preset threshold Δ, the high-scoring entity is output as the final inference result; if the difference is insufficient, a score correction and re-evaluation process is triggered. For example, in this case, the high-scoring entity v2 has a score of 10, and the low-scoring entity v4 has a score of 11. If (11...) If 10)>Δ (assuming Δ=5), then output v4 (California) as the birthplace of "Taylor Swift". Otherwise, output v2 (Pennsylvania) as the birthplace of "Taylor Swift".

[0095] Based on the same inventive concept, corresponding to the methods of any of the above embodiments, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements the coarse-grained perception knowledge graph reasoning method as described in any of the above embodiments.

[0096] Figure 6This embodiment illustrates a more specific hardware structure of an electronic device, which may include a processor 610, a memory 620, an input / output interface 630, a communication interface 640, and a bus 650. The processor 610, memory 620, input / output interface 630, and communication interface 640 are interconnected internally via the bus 650.

[0097] The processor 610 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0098] The memory 620 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 620 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program code is stored in the memory 620 and is called and executed by the processor 610.

[0099] The input / output interface 630 is used to connect input / output modules to enable information input and output. Input / output modules can be configured as components within the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touchscreens, microphones, various sensors, etc., while output devices may include displays, speakers, vibrators, indicator lights, etc.

[0100] The communication interface 640 is used to connect a communication module (not shown in the figure) to enable communication between this device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0101] Bus 650 includes a pathway for transmitting information between various components of the device, such as processor 610, memory 620, input / output interface 630, and communication interface 640.

[0102] It should be noted that although the above-described device only shows the processor 610, memory 620, input / output interface 630, communication interface 640, and bus 650, in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the embodiments of this specification, and not necessarily all the components shown in the figures.

[0103] The electronic devices described in the above embodiments are used to implement the coarse-grained perception knowledge graph reasoning method described in any of the foregoing embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0104] Based on the same inventive concept, corresponding to the methods of any of the above embodiments, the present invention also provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the coarse-grained perception knowledge graph reasoning method as described in any of the above embodiments.

[0105] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.

[0106] The computer instructions stored in the storage medium of the above embodiments are used to cause the computer to execute the coarse-grained perception knowledge graph reasoning method as described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0107] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of the invention (including the claims) is limited to these examples; within the framework of the invention, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of the embodiments of the invention as described above, which are not provided in the details for the sake of brevity.

[0108] Additionally, to simplify the description and discussion, and to avoid obscuring the embodiments of the invention, the well-known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided drawings. Furthermore, the apparatus may be shown in block diagram form to avoid obscuring the embodiments of the invention, and this also takes into account the fact that the details of implementation of these block diagram apparatuses are highly dependent on the platform on which the embodiments of the invention will be implemented (i.e., these details should be fully understood by those skilled in the art). While specific details (e.g., circuits) have been set forth to describe exemplary embodiments of the invention, it will be apparent to those skilled in the art that the embodiments of the invention may be implemented without these specific details or with variations thereof. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0109] Although the invention has been described in conjunction with specific embodiments thereof, many substitutions, modifications, and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may be used with the embodiments discussed.

[0110] It should be understood that the above embodiments are merely illustrative of the technical concept and features of the present invention, and are intended to enable those skilled in the art to understand the content of the present invention and implement it accordingly. They should not be construed as limiting the scope of protection of the present invention. All equivalent changes or modifications made in accordance with the spirit and essence of the present invention should be covered within the scope of protection of the present invention.

Claims

1. A knowledge graph reasoning method with coarse-grained perception, characterized in that, include: S1, use a coarse-grained reasoning model to calculate the first score of each candidate entity, so as to divide all candidate entities into a high-score subset and a low-score subset; S2, for each candidate entity, execute S21-S23: S21, Perform local path queries and global path queries in the input knowledge graph to generate the local information matrix and global information matrix of the candidate entity; S22, determine the local trust weight vector and the global trust weight vector based on the query vector of the reasoning task, so as to perform weighted fusion of the local information matrix and the global information matrix; S23, based on the sum of the linear interaction compensation result of the local information matrix and the global information matrix and the weighted result, reasoning is performed to obtain the second score of the candidate entity; S3. Based on the highest second score in the low-score subset and the highest second score in the high-score subset, select the optimal candidate entity as the reasoning answer and output it.

2. The knowledge graph reasoning method based on coarse-grained perception according to claim 1, characterized in that, All candidate entities are divided into a high-score subset and a low-score subset, specifically including: The candidate entities with the highest first score are assigned to the high-score subset, and the remaining candidate entities are assigned to the low-score subset. Alternatively, candidate entities with a first score higher than a first set value can be assigned to the high-score subset, and the remaining candidate entities can be assigned to the low-score subset.

3. The knowledge graph reasoning method based on coarse-grained and fine-grained perception according to claim 1, characterized in that, S21 specifically includes: Positional codes are generated based on the Laplacian feature vectors of the input knowledge graph to obtain entity and relation representations; Based on the location code, local path queries and global path queries are performed respectively to generate the local information matrix and the global information matrix.

4. The knowledge graph reasoning method based on coarse-grained perception according to claim 1, characterized in that, S22 specifically includes: The query vector of the reasoning task is concatenated into the local information matrix and the global information matrix respectively, and then input into the confidence evaluation network based on the multilayer perceptron mechanism to predict the log-variance of local information and the log-variance of global information in the current reasoning context respectively. Based on the log-variance of the local information and the log-variance of the global information, a local trust weight vector and a global trust weight vector are generated according to the inverse variance principle. The local information matrix and the global information matrix are weighted and fused based on the local trust weight vector and the global trust weight vector.

5. The knowledge graph reasoning method based on coarse-grained perception according to claim 4, characterized in that, The local trust weight vector and the global trust weight vector are respectively: ; ; in, Let be the local trust weight vector. Let be the global trust weight vector. The logarithmic variance of the local information. The logarithmic variance of the global information. This is the exponential function operator.

6. The knowledge graph reasoning method based on coarse-grained perception according to claim 1, characterized in that, The linear interaction compensation result and the weighted result are respectively: ; ; in, The linear interaction compensation result, For the weighted result, Let be the local trust weight vector. Let be the global trust weight vector. The local information matrix, This refers to the global information matrix; The relation embedding matrix is ​​a feature matrix that represents all relation types in the knowledge graph. This represents the dot product operation. It is the hyperbolic tangent function.

7. The knowledge graph reasoning method based on coarse-grained perception according to claim 1 or 6, characterized in that, S23 specifically includes: obtaining the second score based on the sum of the linear interaction compensation result and the weighted result, using a multi-layer perception mechanism.

8. The knowledge graph reasoning method based on coarse-grained perception according to claim 1, characterized in that, S3 specifically includes: If the highest second score in the low-score subset is higher than the highest second score in the high-score subset, and the difference between the two is greater than a second set value, the candidate entity corresponding to the highest second score in the low-score subset is used as the reasoning answer and output; otherwise, the candidate entity corresponding to the highest second score in the high-score subset is used as the reasoning answer and output.

9. An electronic 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 program, it implements the coarse-grained perception knowledge graph reasoning method as described in any one of claims 1-8.

10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to execute the coarse-grained perception knowledge graph reasoning method as described in any one of claims 1-8.