Knowledge graph completion method fusing topological structure and semantic information

By integrating the knowledge graph completion method of topological structure and semantic information, using random walk sampling and large language models to generate semantic paths, combined with the cyclic mutual attention module and sliding window encoder, it solves the problem of simple and complicated relationship modeling in the existing technology. It solves the problem of large search space and achieves more accurate and efficient knowledge graph completion.

CN118607622APending Publication Date: 2024-09-06KUNMING UNIV OF SCI & TECH
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410660100.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Existing knowledge graph completion methods are too simple when modeling relationships, rely on zero-order logic, and lack interpretability. Embedding-based methods ignore the semantic information between relationships, and logic rule-based methods face large search spaces and predefined The reliance on heuristic methods leads to a lack of accuracy and complex reasoning capabilities during model training.

Method used

A knowledge graph completion method that integrates topological structure and semantic information, obtains paths through random walk sampling, combines large-scale language models to generate semantic information, uses cyclic mutual attention modules and sliding window encoders to extract logical rules, filter meaningless rules, and generate High-quality logic rules are used for completion.

Benefits of technology

It improves the accuracy and performance of knowledge graph completion, reduces the redundancy of rule generation, and improves the model's complex reasoning ability and interpretability. The experimental results have excellent performance on Family, Kinship, UMLS and other data sets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118607622A
    Figure CN118607622A
Patent Text Reader

Abstract

The invention provides a knowledge graph completion method fusing a topological structure and semantic information, and relates to the field of natural language processing / knowledge graph (KG). According to the method, a large language model (LLM) is combined with a knowledge graph, firstly, a sampling path containing topological structure information is obtained through random walk sampling and input into the LLM, the LLM is used for understanding and obtaining relation semantic information in the knowledge graph, and therefore more accurate and rich path information is generated and used for model training. And finally, filtering all rules enumerated from the knowledge graph, and inputting the filtered rules into the trained model to extract high-quality logic rules for knowledge graph completion. Experiments on a plurality of data sets such as Family, Kinship, UMLS and the like show that the knowledge graph completion method fusing the topological structure and the semantic information, provided by the invention, is effective.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of natural language processing / knowledge graphs, and proposes a knowledge graph completion method that integrates topological structure and semantic information. Background Art

[0002] There is a common problem of missing triples (i.e. missing links) in knowledge graphs. Since the size of missing triples is usually large, it is expensive to manually find these triples. Therefore, researchers have designed the knowledge graph completion (KGC) task. The purpose is to discover new relationships, attributes, or entities, or to infer missing information, so as to complete the missing triples in the knowledge graph. The current mainstream knowledge graph completion methods include embedding-based knowledge graph completion and logical rule learning-based knowledge graph completion.

[0003] A mainstream approach to knowledge graph completion is based on knowledge graph embedding (KGE), which embeds entities and relations into a continuous low-dimensional vector space and uses a scoring function to calculate the score of each triple based on the entity and relation embeddings. The embedding is trained so that facts observed in the knowledge graph have higher scores than unobserved facts. The learning goal here is to maximize the score of positive samples (existing facts) and minimize the score of generated negative samples. Many previous works in this area regard relations as some kind of operation or mapping function between entities. Therefore, the overall previous work research can be divided into models based on translation distance and semantic matching based on the scoring function. The translation distance-based model adopts a distance-based scoring function. Among them, TransE proposed by Bordes et al. defines a relationship as a translation operation between some head entity and tail entity. It is very effective in modeling inverse and composition rules, but it cannot model symmetric relations. TransH proposed by Wang et al. projects the entity embeddings h and t to a relation-specific hyperplane, and Lin et al. further proposed TransR to project to a relation-specific space. RotatE proposed by Sun et al. uses rotation operations in complex spaces to capture symmetry / antisymmetry, inversion, and composition rules. The semantic matching model uses a similarity-based scoring function to measure the rationality of the triple (h, r, t) by matching the latent semantics of h, r, and t. RESCAL proposed by Nickel et al. represents the relation r as a matrix Mr and uses a bilinear function Score (h, r, t). DistMult proposed by Yang et al. uses a bilinear mapping function to model symmetric patterns, but it cannot infer combinatorial patterns. ATTH proposes to embed the knowledge graph into a hyperbolic space with trainable curvature, which can use richer transformations than Euclidean space to separate nodes while capturing logical patterns, and ultimately effectively capture the hierarchical structure in the knowledge graph. Despite this, the relationships modeled in previous work are very simple, and there are problems such as embeddings being learned only based on triples (zero-order logic) contained in a given knowledge graph, being more dependent on the resource information of the knowledge graph itself, and lacking a certain degree of interpretability.

[0004] Another mainstream method for knowledge graph completion is based on logical rule learning. Knowledge graph completion based on logical rule learning is a method of completing by learning and applying logical rules. This method usually uses prior knowledge and existing logical rules to infer new relations, attributes or entities by automatically learning or manually formulating rules. The initial research direction focused on logical rule mining. AMIE proposed by Galárraga et al. focuses on association rule mining. It has three operations, including dangling atoms, instantiated atoms, and closed atoms. Different types of atoms are added to incomplete rules, and predefined evaluation indicators are used to prune incorrect rules. AMIE+ proposed by Galárraga et al. modifies the rule expansion process and improves the evaluation method based on AMIE. Meilicke et al. proposed a framework in Anyburl that can effectively mine rules. Based on randomly sampled paths, some entities are replaced with variables and rules are obtained. Recently, researchers have proposed sampling paths from KG and training models on them to learn logical connections. RLvLR et al. sample rules from subgraphs and propose embedding-based scoring functions to estimate the importance of each rule. However, most traditional methods face the problem of large search space of logical rules or rely on predefined heuristics to guide the search.

[0005] At present, the mainstream knowledge graph completion methods include embedding-based knowledge graph completion and logical rule learning-based knowledge graph completion. Embedding-based knowledge graph completion usually relies on triple representation learning to capture semantics. However, related research still remains at the level of individual relationships and ignores the symbolic nature of knowledge graphs. It lacks interpretability, resulting in poor complex reasoning capabilities. Knowledge graph completion methods based on logical rule learning usually learn logical rules from knowledge graphs and have strong interpretability and generalization. Most of these methods sample paths from KG and train models on them. Ultimately, all rules enumerated from the knowledge graph are input into the trained model to capture the formed high-quality rules. However, the semantic information and logical connections between relationships are ignored in the path sampling stage. This neglect may lead to incompleteness and lack of accuracy in the sampled paths.

[0006] The current knowledge graph completion methods still have the following shortcomings: 1. The relationships modeled by embedding-based knowledge graph completion are very simple, and there are problems such as embeddings are learned only based on triples (zero-order logic) contained in a given knowledge graph, are more dependent on the resource information of the knowledge graph itself, and lack certain interpretability. 2. Knowledge graph completion based on logical rules faces the problem of a large search space for logical rules, or relies on predefined heuristic methods to guide the search. 3. Existing knowledge graph completion methods ignore the semantic information and logical connections between relationships during model training.

[0007] In response to the above problems, the present invention proposes a knowledge graph completion method that integrates topological structure and semantic information. Summary of the invention

[0008] In order to solve the above problems, the present invention proposes a knowledge graph completion method that integrates topological structure and semantic information to make up for the shortcomings of logical rule mining in knowledge graph completion. The present invention can generate more accurate and rich path information and improve model performance; it can reduce the redundancy of rules in the input model by filtering meaningless rules enumerated from the knowledge graph, improve the rule generation efficiency, and successfully mine high-quality logical rules to improve the performance efficiency of knowledge graph completion.

[0009] The present invention first implements the sampling of paths (rules) through a path sampling module that integrates topological structure and semantic information, that is, on the basis of the traditional random walk sampling to obtain the path, the partial path containing topological structure information obtained by random walk sampling is used as a demonstration path, which is input into the large language model (LLM) to make it understand the semantic relationship and generate a new path containing semantic information, and then the paths obtained by the two methods are combined as sampling paths. Next, the path obtained by our sampling is input into the cyclic mutual attention module using the combination characteristics of logical rules to infer the rule head, so as to train the model through the entire logical rule learning process, and finally all possible paths are obtained by enumeration and the unintentional rules composed of repeated relationships are filtered, and then input into the trained model for the final extraction of logical rules, and the logical rules with higher confidence ranking are used as high-quality rules for knowledge graph completion tasks. The experimental results of the present invention on multiple data sets such as Family, Kinship, and UMLS show that the proposed model is effective.

[0010] The technical solution of the present invention is: a knowledge graph completion method integrating topological structure and semantic information, the specific steps of the method are as follows:

[0011] Step 1: Use the random walk sampling method to sample the paths in the input knowledge graph and obtain the sampling paths containing topological structure information;

[0012] Step 2: Use the partial path containing topological structure information obtained in step 1 as the sample path, and convert it into an easy-to-understand logical rule by removing special symbols and entity information in the sample path; Transformed into Mather(X,Z1)∧Father(Z1,Y), and inv_ is used to represent the inverse relationship corresponding to the original relationship, so that the relationship information in the knowledge graph can be considered more comprehensively.

[0013] Step 3: Design a prompt template and put the logic rules converted in step 2 into the prompt, so as to use LLM to generate more sampling rules containing relational semantic information according to semantic information;

[0014] Step 4: Combine the logic rules obtained and transformed by random walk sampling in step 2 and the sampling rules generated by LLM in step 3 as the final sampling rules;

[0015] Step 5: Input the final sampling rules obtained in step 4 into the sliding window encoder one by one, so that each rule body is divided into short combinations ξ i ; and use a fully connected neural network to learn short combinations ξ iThe probability of becoming a meaningful combination, screening out the short combination with the highest probability to form the target short combination;

[0016] Step 6: Input the target short combination into the recurrent mutual attention module to obtain the probability θ that the long rule body can be replaced by each relation in the relation set, thereby completing the model training;

[0017] Step 7: All rules enumerated from the knowledge graph are filtered and input into the trained model to extract high-quality logical rules for knowledge graph completion.

[0018] Furthermore, the step 1 specifically includes:

[0019] First, a certain number of anchor points are designed. These anchor points are distributed in the knowledge graph and evenly distributed according to different relationship types. Next, an entity in the knowledge graph is randomly selected as the source entity k0. With the source entity as the center, a random walk with a maximum path length of n is set. Let k i represents the i-th entity node traversed by the walk. Different from the traditional random walk sampling, each time the next entity k i After sampling, all the i The edge will connect the two nodes k0 and k n The path is represented by P, which means will be able to directly connect k0 and k n The relationship is expressed as r h , and finally obtain a closed sampling path (P, r h )∈ρ1.

[0020] Furthermore, step 3 includes: designing a prompt template, which first stipulates that the basic form of the logic rule is composed of a rule body and a rule header, and allows LLM to learn that the paths in the rule body and the rule header are all from a given set of relationships, and then allows LLM to read the logic rule ρ2 sampled by random walks and naturalized to understand the semantics, and generate a new sampling rule ρ3 based on common sense; in the process of generating rules, LLM may generate some rules that contain similar relationships but do not exist based on its own understanding. Therefore, it is necessary to filter the relationships in the generated rules against the relationship set in the knowledge graph, and filter the relationships that do not exist in the knowledge graph relationship set, so as to obtain more accurate sampling rules that are consistent with the knowledge graph.

[0021] Furthermore, in step 5, the final sampling rules obtained in step 4 are input into the sliding window encoder and the fully connected neural network one by one, so that each rule body are divided into short combinations i , learn short combinations ξi The probability of a meaningful combination is f(ξ i ) and screen out the short combination with the highest probability to form the target short combination, in preparation for the rule body in the logic rule to be merged using the combination characteristics.

[0022] Furthermore, the step 5 specifically includes: for the final sampling rule ρ of the path sampling link, using a sliding window to pass through the rule body in the sampling rule To obtain short combinations, the short combinations in the i-th window The encoded output after inputting into the sliding window encoder is as follows:

[0023] ξ i =[h i ,h i+1 ]=RNN(w i )

[0024] in Represents the rule body in a logical rule, represents the atoms in the regular body, h i ∈R d Represents the short combination w i Relationship in The hidden layer vector of i represents the short combination w after being processed by the sliding window encoder i , then use ξ i To estimate the possibility (co-occurrence) of the short combination relationship in the i-th window, that is, to learn the short combination ξ through a fully connected neural network i The probability of becoming a meaningful combination and screening out the short combination with the highest probability to form the target short combination. The learning process is as follows:

[0025]

[0026] Further, in step 6, the target short combination obtained in step 5 is input into the cyclic mutual attention module, so that the selected target short combination is converted into a single relation and represented as a weighted combination of existing relations. The rule body length is reduced by repeatedly converting the selected target short combination into a single relation and collecting the probability θ that the long rule body can be replaced by each relation (head relation) of the relation set in the last step. Finally, the cross entropy loss function is used to train the model in this process.

[0027] Furthermore, the step 6 specifically includes the following:

[0028] The probability θ that the rule body is replaced by a single relation (head relation) is calculated as follows, let H∈R (|r|+1)×d Represents all head relations (r0,r1,r2,...,r |R|), H0=ξ i ∈R d represents the selected target short combination; next, H is regarded as the key and ξ i Treat it as a query, calculate the vector scaled dot product of the two to get the similarity between them and score them for the attention mechanism:

[0029]

[0030] θ j = p(r j ξ i )

[0031] Where W Q and W K is a learnable parameter, θ∈R |R|+1 represents the learned attention, θ j = p(r j |ξ i ) represents the target short combination ξ i Can be related j Probability of substitution;

[0032] When training the above model, the ultimate goal is to maximize the rule head r corresponding to the sampling path h , that is, the direct connection relationship that can close the path. The final learned attention θ can collect the predicted value of each path P closed by a single head relationship, so the cross entropy loss loss is defined as:

[0033]

[0034] Where ρ represents a closed path (rule) obtained by sampling, which consists of a series of paths p and a closed path rule head r h composition, is a one-hot encoded vector such that only r h The corresponding objective function value is 1, θ p represents the attention learned by path p, and represents the probability that path p cannot be closed by any existing relationship.

[0035] Furthermore, in step 7, for all the rules enumerated from the knowledge graph, the frequency of the relationships in the rule body is counted. If the frequency of a relationship in the rule body exceeds a certain threshold, it is regarded as a common repeated relationship and filtered. Finally, the filtered rules are input into the trained model to extract high-quality logical rules.

[0036] The beneficial effects of the present invention are:

[0037] The present invention considers adding semantic information and logical connections between relationships during model training. The topological structure and semantic information of the knowledge graph are combined, and based on the sampling paths obtained by random walk sampling, a large language model (LLM) is used to expand these sampling paths to obtain richer and more semantically informative paths for model training. The contributions of the model are summarized as follows: (1) A knowledge graph completion method that integrates topological structure and semantic information is proposed; (2) LLM is combined with the knowledge graph, and the role of the topological structure and relational semantic information in the knowledge graph in model training is comprehensively considered, unleashing the power of the large language model to obtain richer and more semantically informative paths; (3) The present invention conducts experiments on multiple datasets such as Family, Kinship, and UMLS, and the experimental results show the effectiveness of the proposed model;

[0038] The present invention proposes a knowledge graph completion method that integrates topological structure and semantic information, which is used to make up for the deficiencies in logical rule mining in knowledge graph completion. The method combines a large language model with a knowledge graph, inputs the sampling path containing topological structure information obtained by random walk sampling into the LLM, and uses the LLM to understand and obtain the relational semantic information in the knowledge graph, thereby generating more accurate and rich path information and improving model performance. It also reduces the redundancy of rules in the input model and improves the efficiency of rule generation by filtering out meaningless rules enumerated from the knowledge graph. The method of the present invention can improve the performance efficiency of knowledge graph completion to a certain extent. The experimental results of the comparison model show that the model proposed in this paper can not only successfully mine high-quality logical rules, but also use the mined high-quality logical rules to deal with relationship extraction problems in the general literary field and other natural language processing tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 A model diagram for implementing the knowledge graph completion method that integrates topological structure and semantic information proposed in the present invention;

[0040] Figure 2 This is a graph showing the sparsity ablation experiment results of the knowledge graph completion method that integrates topological structure and semantic information proposed in the present invention on the Kinship dataset;

[0041] Figure 3 This is a graph showing the Topk ablation experiment results of the number of learning rules for the knowledge graph completion method that integrates topological structure and semantic information proposed in the present invention on the Kinship dataset. DETAILED DESCRIPTION

[0042] Example 1, a knowledge graph completion method integrating topological structure and semantic information, the method proposed in the present invention is experimentally verified on multiple data sets such as Family, Kinship, UMLS, etc., and the specific steps of the method are as follows:

[0043] Step 1: Use the random walk sampling method to sample the paths in the input knowledge graph and obtain the sampling paths containing topological structure information;

[0044] First, a certain number of anchor points are designed. These anchor points are distributed in the knowledge graph and evenly distributed according to different relationship types. The purpose of this is to ensure that different types of relationships can be covered during the random walk. Next, an entity in the knowledge graph is randomly selected as the source entity k0. With the source entity as the center, a random walk with a maximum path length of n is set. Let k i represents the i-th entity node traversed by the walk, then k i It follows the following distribution:

[0045]

[0046] Where |N(e j )| represents entity e j The neighborhood size is different from the traditional random walk sampling. Each time the next entity k i After sampling, all the i The edge will connect the two nodes k0 and k n The path is represented by P, which means will be able to directly connect k0 and k n The relationship is expressed as r h , and finally obtain a closed sampling path (P, r h )∈ρ1.

[0047] Step 2: Use the partial path (rule) ρ1 obtained in step 1 containing topological structure information as the sample path. For each sample rule in ρ1, remove the special symbols and entity information in the sample path to convert it into an easy-to-understand logical rule ρ2. The conversion example is as follows:

[0048]

[0049] And use inv_ to represent the inverse relationship corresponding to the original relationship, so that the relationship information in the knowledge graph can be considered more comprehensively.

[0050] Step 3: Design a prompt template and put the logic rules converted in step 2 into the prompt, so as to use LLM to generate more sampling rules containing relational semantic information according to semantic information;

[0051] Furthermore, step 3 includes: designing a prompt template, which first stipulates that the basic form of the logic rule is composed of a rule body and a rule header, and allows LLM to learn that the paths in the rule body and the rule header are all from a given set of relationships, and then allows LLM to read the logic rule ρ2 sampled by random walks and naturalized to understand the semantics, and generate a new sampling rule ρ3 based on common sense; in the process of generating rules, LLM may generate some rules that contain similar relationships but do not exist based on its own understanding. Therefore, it is necessary to filter the relationships in the generated rules against the relationship set in the knowledge graph, and filter the relationships that do not exist in the knowledge graph relationship set, so as to obtain more accurate sampling rules that are consistent with the knowledge graph.

[0052] Step 4: Combine the logic rules obtained and transformed by random walk sampling in step 2 and the sampling rules generated by LLM in step 3 as the final sampling rules:

[0053] The sampling path ρ1 containing topological structure information obtained by the random walk sampler is converted into an easy-to-understand logical rule ρ2, and then combined with the sampling rule ρ3 containing semantic information generated by LLM to obtain the final sampling rule ρ used for model training. The formula is as follows:

[0054] ρ=ρ2+ρ3 (3)

[0055] Among them, ρ2 represents the converted random walk sampling rule, and ρ3 represents the LLM sampling rule.

[0056] Step 5: Input the final sampling rules obtained in step 4 into the sliding window encoder one by one, so that each rule body is divided into short combinations ξ i ; and use a fully connected neural network to learn short combinations ξ i The probability of becoming a meaningful combination, screening out the short combination with the highest probability to form the target short combination;

[0057] Furthermore, in step 5, the final sampling rules obtained in step 4 are input into the sliding window encoder and the fully connected neural network one by one, so that each rule body are divided into short combinations i , learn short combinations ξ i The probability of a meaningful combination is f(ξ i ) and screen out the short combination with the highest probability to form the target short combination, in preparation for the rule body in the logic rule to be merged using the combination characteristics.

[0058] The step 5 specifically includes: for the final sampling rule ρ of the path sampling link, using a sliding window to pass through the rule body in the sampling rule To obtain short combinations, the short combinations in the i-th window The encoded output after inputting into the sliding window encoder is as follows:

[0059] ξ i =[h i ,h i+1 ]=RNN(w i ) (4)

[0060] in Represents the rule body in a logical rule, represents the atoms in the regular body, h i ∈R d Represents the short combination w i Relationship in The hidden layer vector of i represents the short combination w after being processed by the sliding window encoder i , then use ξ i To estimate the possibility (co-occurrence) of the short combination relationship in the i-th window, that is, to learn the short combination ξ through a fully connected neural network i The probability of becoming a meaningful combination and screening out the short combination with the highest probability to form the target short combination. The learning process is as follows:

[0061]

[0062] Step 6: Input the target short combination into the recurrent mutual attention module to obtain the probability θ that the long rule body can be replaced by each relation in the relation set, thereby completing the model training;

[0063] Further, in step 6, the target short combination obtained in step 5 is input into the cyclic mutual attention module, so that the selected target short combination is converted into a single relation and represented as a weighted combination of existing relations. The rule body length is reduced by repeatedly converting the selected target short combination into a single relation and collecting the probability θ that the long rule body can be replaced by each relation (head relation) of the relation set in the last step. Finally, the cross entropy loss function is used to train the model in this process.

[0064] Furthermore, the step 6 specifically includes the following:

[0065] The probability θ that the rule body is replaced by a single relation (head relation) is calculated as follows, let H∈R (|r|+1)×d Represents all head relations (r0,r1,r2,...,r |R| ), H0=ξ i ∈Rd represents the selected target short combination; next, H is regarded as the key and ξ i Treat it as a query, calculate the vector scaled dot product of the two to get the similarity between them and score them for the attention mechanism:

[0066]

[0067] θ j = p(r j |ξ i ) (7)

[0068] Where W Q and W K is a learnable parameter, θ∈R |R|+1 represents the learned attention, θ j = p(r j |ξ i ) represents the target short combination ξ i Can be related j Probability of substitution;

[0069] When training the above model, the ultimate goal is to maximize the rule head r corresponding to the sampling path h , that is, the direct connection relationship that can close the path. The final learned attention θ can collect the predicted value of each path P closed by a single head relationship, so the cross entropy loss loss is defined as:

[0070]

[0071] Where ρ represents a closed path (rule) obtained by sampling, which consists of a series of paths p and a closed path rule head r h composition, is a one-hot encoded vector such that only r h The corresponding objective function value is 1, θ p represents the attention learned by path p, and represents the probability that path p cannot be closed by any existing relationship.

[0072] Step 7: All rules enumerated from the knowledge graph are filtered and input into the trained model to extract high-quality logical rules for knowledge graph completion.

[0073] First, all the rules in the rule space are enumerated. For any enumerated rule, the rule body is recursively merged through the above model to finally obtain a rule head represented by a single relation. However, it should be noted that due to the large number of all enumerated rules, entering the logical rule learning module one by one to predict the final rule head will significantly increase the time complexity of the calculation. Therefore, we propose a frequency statistical filtering method based on the rule body.

[0074]

[0075] where n i,j Representing relationships In the rule body The number of times it appears in k n k,j Represents the rule body The total number of relations in , so TF i,j It indicates the relationship In the rule body Frequency of occurrence of words.

[0076] Specifically, for rules whose rule bodies consist of repeated relations, we count the frequency of relations in the rule body. If the frequency of a certain relation in the rule body exceeds a certain threshold, we can regard it as a common repeated relation and filter it. Finally, by filtering all the enumerated rules through the above method and then inputting them into the above trained model to predict the rule head of each rule, we obtain the learning attention in the last step of prediction. θ k Representation Rules The confidence score of Finally, the top k rules with the highest confidence are selected as high-quality rules to participate in the link prediction task, thereby completing the knowledge graph completion task.

[0077] The present invention uses public datasets that are commonly used in the field of knowledge graphs, including Family, Kinship, UMLS and other datasets. The Family dataset and the Kinship dataset contain sentences about family relationships, including sentences describing the relationships between characters. The Family dataset has 12 relationship types, and the Kinship dataset has 25 relationship types. In order to make the test field more diverse, UMLS, the Unified Medical Language System dataset, is also used. It is a knowledge graph dataset that brings together many health and biomedical vocabulary and standards, and contains 46 relationship types. This paper randomly extracts 80% of the datasets to train the model, and the rest are used for evaluation.

[0078] Table 1 Dataset statistics

[0079]

[0080] Evaluation indicators are set. The present invention uses MRR and Hit@1, Hit@3, and Hit@10 evaluation indicators to measure model performance:

[0081]

[0082]

[0083] Where S is the set of triples, |S| is the number of triples, and rank i Refers to the link prediction ranking of the i-th triple. The larger the index, the better.

[0084] In order to verify the effectiveness of the model proposed in the present invention, the present invention selects the following representative systems related to the present invention as baseline models from the aspect of link prediction tasks.

[0085] TransE (Bordes et al., 2013) defines a relation as a translation operation between some head entity and tail entity. It is very effective in modeling inverse and composition rules.

[0086] DisMult (Yang et al., 2015) uses a bilinear mapping function to model symmetric patterns.

[0087] ConvE (Dettmers et al., 2018) is a convolutional neural network (CNN) based model that combines the representations of entities and relations and processes them through convolution operations to capture the complex interactions between them. This combination enables the model to better understand the relationships between entities in the knowledge graph.

[0088] RotatE,(Sun et al., 2019) uses rotation operations in complex spaces to capture symmetry / antisymmetry, inversion, and composition rules.

[0089] Neural-LP (Yang et al., 2017) is a model that combines neural networks and logical reasoning. The model aims to combine neural networks and logical programming to process structured data and achieve better performance in reasoning and relation prediction tasks.

[0090] DRUM (Sadeghian et al., 2019) is a model for diverse trajectory prediction, with a special focus on handling complex interaction scenarios and being able to take uncertainty information into account.

[0091] RNNLogic (Qu et al., 2020) separates rule generation and rule weighting, which can enhance each other and reduce the search space.

[0092] NCRL (Sun et al., 2022) exploits the combinatorial properties of logical rules to predict the optimal composition of rule bodies.

[0093] LERP (Han et al., 2023) incorporates the contextual information of entities in the knowledge graph into the probabilistic logic rule learning to learn more expression rules. The experimental results are shown in the following table.

[0094] Table 2 Link prediction experimental results on Family, Kinship, and UMLS datasets. The red part indicates SOTA

[0095]

[0096] The above experimental results show that the method of the present invention has achieved better results than the knowledge graph embedding (KGE) method and the traditional logic rule learning method on multiple datasets such as Family, Kinship, and UMLS. On the Family dataset, our method achieved the best results in the Hit@3 and Hit@10 evaluation indicators and improved them by about 0.4% and 0.1% respectively. On the Kinship dataset, our method also achieved the best results in the MRR, Hit@1, and Hit@3 indicators and improved them by 0.15%, 10.6%, and 2% respectively. In particular, it achieved the current SOTA effect on the UMLS dataset, and improved the four evaluation indicators used by 0.12%, 17.2%, 3.5%, and 0.2% respectively. Compared with traditional knowledge graph embedding (KGE) methods and logical rule learning methods, our method achieved better performance, proving that our method obtains better logical rules. We believe that this performance improvement is due to the fusion of topological structure information and relational semantic information in the knowledge graph during path sampling, thereby improving the quality and accuracy of model training. The above experimental results confirm the correctness of our hypothesis.

[0097] In order to verify the effectiveness of the LMM sampling module / random walk sampling module on the model results, the following ablation experiment was conducted. By removing the random walk path sampling module based on topological structure and the LMM path sampling module based on semantic information, the experimental results are as follows:

[0098] Table 3 Ablation experiment results without ChatGPT sampling module / random walk sampling module

[0099]

[0100] The above ablation experiment results show that in the path sampling stage, using only the random walk path sampling module based on topology structure or the LMM interactive sampling module based on semantic information will cause our method to have a lower performance in the knowledge graph completion task. This strongly proves that using any path sampling method alone will result in an incomplete final sampling path. Only by fusing topology structure and semantic information for path sampling can the integrity and accuracy of the sampling path be guaranteed and the final performance of the model be improved.

[0101] In order to verify the effectiveness of the sparsity of the dataset on the model results, the following ablation experiment was conducted to obtain the performance of different method models on the knowledge graph completion task on the Kinship dataset by changing the sparsity. The experimental results are as follows: Figure 2 As shown;

[0102] The experimental results show that as the sparsity increases, the performance of the five methods including our method is improved, among which our proposed method always has the best performance in knowledge graphs with different sparsity. The experimental results prove the superiority and stability of our method in dealing with knowledge graph completion tasks.

[0103] In order to verify the effectiveness of the number of learning rules Topk on the model results, the following ablation experiment was performed. By changing the value of Topk, the performance of different method models on the knowledge graph completion task on the Kinship dataset was obtained.

[0104] The experimental results are as follows Figure 3 As shown;

[0105] The experimental results show that as the number of logical rules learned increases, the performance of the four methods, including our method, first improves and then gradually stabilizes. Among them, our method still maintains the best performance under different numbers of logical rules learned. This experimental result strongly proves that as the number of logical rules learned increases, our method can better use richer rule information to complete the missing parts in the knowledge graph, and at the same time maintain a stable performance level when facing logical rules of different orders of magnitude, with strong generalization ability and robustness.

Claims

1. A knowledge graph completion method integrating topological structure and semantic information, characterized in that: The method comprises the following steps: Step 1: Use the random walk sampling method to sample the paths in the input knowledge graph and obtain the sampling paths containing topological structure information; Step 2: Use the partial path containing topological structure information obtained in step 1 as a sample path, and convert it into an easy-to-understand logical rule by removing special symbols and entity information in the sample path; Step 3: Design a prompt template and put the logic rules converted in step 2 into the prompt, so as to use LLM to generate more sampling rules containing relational semantic information according to semantic information; Step 4: Combine the logic rules obtained and transformed by random walk sampling in step 2 and the sampling rules generated by LLM in step 3 as the final sampling rules; Step 5: Input the final sampling rules obtained in step 4 into the sliding window encoder one by one, so that each rule body is divided into short combinations ξ i ; and use a fully connected neural network to learn short combinations ξ i The probability of becoming a meaningful combination, screening out the short combination with the highest probability to form the target short combination; Step 6: Input the target short combination into the recurrent mutual attention module to obtain the probability θ that the long rule body can be replaced by each relation in the relation set, thereby completing the model training; Step 7: All rules enumerated from the knowledge graph are filtered and input into the trained model to extract high-quality logical rules for knowledge graph completion.

2. The knowledge graph completion method integrating topological structure and semantic information according to claim 1, characterized in that: The step 1 specifically includes: First, a certain number of anchor points are designed. These anchor points are distributed in the knowledge graph and evenly distributed according to different relationship types. Next, an entity in the knowledge graph is randomly selected as the source entity k0. With the source entity as the center, a random walk with a maximum path length of n is set. Let k i represents the i-th entity node traversed by the walk. Different from the traditional random walk sampling, each time the next entity k i After sampling, all the i The edge will connect the two nodes k0 and k n The path is represented by P, which means will be able to directly connect k0 and k n The relationship is expressed as r h , and finally obtain a closed sampling path (P, r h )∈ρ1.

3. The knowledge graph completion method integrating topological structure and semantic information according to claim 1, characterized in that: The step 3 includes: designing a prompt template, which first stipulates that the basic form of the logical rule is composed of a rule body and a rule header, and allows LLM to learn that the paths in the rule body and the rule header are all from a given relationship set, and then allows LLM to read the logical rule ρ2 sampled by random walks and naturalized to perform semantic understanding, and generate a new sampling rule ρ3 in combination with common sense; in the process of generating rules, it is necessary to filter the relationships in the generated rules against the relationship set in the knowledge graph, and filter the relationships that do not exist in the knowledge graph relationship set to obtain more accurate sampling rules that are consistent with the knowledge graph.

4. The knowledge graph completion method integrating topological structure and semantic information according to claim 1, characterized in that: In step 5, the final sampling rules obtained in step 4 are input into the sliding window encoder and the fully connected neural network one by one, so that each rule body are divided into short combinations i , learn short combinations ξ i The probability of a meaningful combination is f(ξ i ) and screen out the short combination with the highest probability to form the target short combination, in preparation for the rule body in the logic rule to be merged using the combination characteristics.

5. The knowledge graph completion method integrating topological structure and semantic information according to claim 1, characterized in that: The step 5 specifically includes: for the final sampling rule ρ of the path sampling link, using a sliding window to pass through the rule body in the sampling rule To obtain short combinations, the short combinations in the i-th window The encoded output after inputting into the sliding window encoder is as follows: ξ i =[h i ,h i+1 ]=RNN(w i ) in Represents the rule body in a logical rule, represents the atoms in the regular body, h i ∈R d Represents the short combination w i Relationship in The hidden layer vector of i represents the short combination w after being processed by the sliding window encoder i , then use ξ i To estimate the possibility (co-occurrence) of the short combination relationship in the i-th window, that is, to learn the short combination ξ through a fully connected neural network i The probability of becoming a meaningful combination and screening out the short combination with the highest probability to form the target short combination. The learning process is as follows:

6. The knowledge graph completion method integrating topological structure and semantic information according to claim 1, characterized in that: In step 6, the target short combination obtained in step 5 is input into the cyclic mutual attention module, so that the selected target short combination is converted into a single relation and represented as a weighted combination of existing relations. The rule body length is reduced by repeatedly converting the selected target short combination into a single relation and collecting the probability θ that the long rule body can be replaced by each relation (head relation) of the relation set in the last step. Finally, the cross entropy loss function is used to train the model in this process.

7. The knowledge graph completion method integrating topological structure and semantic information according to claim 1, characterized in that: The step 6 specifically includes the following: The probability θ that a rule body is replaced by a single relation (head relation) is calculated as follows, let H∈R( |r|+1)×d Represents all head relations (r0,r1,r2,...,r |R| ) series matrix, H0 = ξ i ∈R d represents the selected target short combination; next, H is regarded as the key and ξ i Treat it as a query, calculate the vector scaled dot product of the two to get the similarity between them and score them for the attention mechanism: i j =p(r j |x i ) Where W Q and W K is a learnable parameter, θ∈R |R|+1 represents the learned attention, θ j = p(r j |ξ i ) represents the target short combination ξ i Can be related j Probability of substitution; When training the above model, the ultimate goal is to maximize the rule head r corresponding to the sampling path h , that is, the direct connection relationship that can close the path. The final learned attention θ can collect the predicted value of each path P closed by a single head relationship, so the cross entropy loss loss is defined as: Where ρ represents a closed path (rule) obtained by sampling, which consists of a series of paths p and a closed path rule head r h composition, is a one-hot encoded vector such that only r h The corresponding objective function value is 1, θ p represents the attention learned by path p, and represents the probability that path p cannot be closed by any existing relationship.

8. The knowledge graph completion method integrating topological structure and semantic information according to claim 1, characterized in that: In step 7, for all the rules enumerated from the knowledge graph, the frequency of the relationships in the rule body is counted. If the frequency of a relationship in the rule body exceeds a certain threshold, it is regarded as a common repeated relationship and filtered. Finally, the filtered rules are input into the trained model to extract high-quality logical rules.

Citation Information

Cited By

  • Few-sample knowledge graph completion model and method

    CN119358661A

  • Uncertain knowledge graph reasoning method based on rule mining

    CN120104809A

  • End-to-end fusion method, device and equipment for atlas and large model, medium and product

    CN120744078A

  • Atlas and large model end-to-end fusion method, device, equipment, medium and product

    CN120744078B