A rule-based uncertainty knowledge graph reasoning method
Through the uncertainty knowledge graph reasoning method based on rule mining, the rule probability distribution is generated and combined with the pre-trained language model to predict the confidence, which solves the problem of completing the uncertainty knowledge graph and realizes efficient and reliable reasoning and confidence prediction.
Patent Information
- Application Number
- CN202510270081.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-07
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-03-07
AI Technical Summary
Existing rule mining methods are performed in deterministic knowledge graph scenarios and cannot be effectively applied to the completion problem of uncertain knowledge graphs. They also lack modeling and explainability of knowledge uncertainty.
This paper adopts an uncertain knowledge graph reasoning method based on rule mining, generates rule probability distribution through the Vanilla Transformer architecture, designs a differentiable reasoning framework in combination with TensorLog, and uses a pre-trained language model to predict the confidence of triples to achieve end-to-end training.
It improves the reasoning efficiency and interpretability of uncertainty knowledge graphs, can generate reliable logical rules and confidence predictions, and significantly improves the accuracy of link predictions and confidence predictions.
Smart Images

Figure CN120104809B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to a rule mining-based uncertain knowledge graph reasoning method, and belongs to the technical field of knowledge graphs. BACKGROUND
[0002] A knowledge graph is a structured knowledge base that stores real-world facts in the form of a graph, where each fact is represented as a triple (h, r, t), with h and t being the head and tail entities, respectively, and r being the relation connecting them. Knowledge graphs composed of these fact triples, such as YAGO, Wikidata, and Zhishi.me, have been widely applied to various downstream tasks, such as question-answering systems and decision support. However, the aforementioned knowledge graphs do not consider the inherent uncertainty of knowledge. The uncertainty of knowledge mainly comes from two situations: one is the nature of knowledge itself, many knowledge facts are not absolutely certain. For example, in the biomedical field, there is a certain probability of interaction between different proteins, rather than a fixed and certain relationship; the second is data noise and errors in automated construction, many knowledge graphs are constructed from unstructured text through automated methods such as information extraction, pattern matching or machine learning, which may introduce noisy data or incorrect reasoning, resulting in lower confidence of some knowledge. In order to model the uncertainty in the knowledge graph, an uncertain knowledge graph is proposed. Like ProBase, ConceptNet and NELL, in addition to describing facts with triples, each triple is additionally assigned a confidence to describe the uncertainty of knowledge, such as <(university, synonym, institute), 0.86>. There are mainly two ways to obtain the confidence of the uncertain knowledge graph: automatic annotation algorithm calculates the confidence through machine learning or rule reasoning model, such as statistical information or neural network model to estimate the reliability of triples; human crowdsourcing annotation uses expert annotation or crowdsourcing platform to collect human confidence evaluation to improve the reliability of data.
[0003] Although the size of a knowledge graph can be very large, it often faces the problem of incompleteness. During the construction process, the knowledge graph cannot cover all facts. To solve this problem, many studies focus on the reasoning problem of knowledge graphs, which can be divided into two categories: embedding-based methods and rule-based methods. Embedding-based methods (such as TransE, RotatE, and CompleEx) map entities and relationships to a low-dimensional dense vector space, and use vector operations to simulate the relationship between entities in triples. With the development of pre-trained language models, some embedding methods based on pre-trained language models (such as KG-BERT and BERTRL) have also been proposed. Embedding-based methods are efficient in knowledge graph reasoning because they use vector-based calculations, but lack interpretability. Therefore, rule-based methods are more popular due to their interpretability. This type of method (such as AMIE) performs rule mining by iterating through the knowledge graph, and uses these rules for reasoning. However, existing rule mining methods are all in the context of deterministic knowledge graphs, ignoring the uncertainty of knowledge, so they cannot be directly applied to the completion problem of uncertain knowledge graphs.
[0004] To solve this problem, the present invention proposes an uncertain knowledge graph reasoning method based on rule mining, which consists of a rule mining module and a confidence prediction module. The rule mining module uses an advanced Vanilla Transformer architecture, treats rule mining as a sequence-to-sequence generation task, generates rules to infer new triples, and designs a differentiable reasoning framework using TensorLog to model uncertainty and perform end-to-end training. The confidence prediction module uses a pre-trained language model to predict the confidence score of a given triple by combining the structural information of the graph and the semantic information of the language model. In summary, the present invention has made significant breakthroughs in interpretability, reasoning ability, and uncertainty modeling, providing an efficient and reliable solution for uncertain knowledge graph reasoning. SUMMARY
[0005] Technical problem: The present invention provides an uncertain knowledge graph reasoning method based on rule mining, which can not only automatically mine logical rules in uncertain knowledge graphs, but also predict missing triples with interpretability, and can predict the confidence score of a given triple by combining the structural information of the knowledge graph and the semantic information of the pre-trained language model.
[0006] Technical solution:
[0007] The uncertain knowledge graph reasoning method based on rule mining of the present invention is executed by the following steps:
[0008] 1) The head entity and relation of all triples in the uncertain knowledge graph training data are input into the rule generator as query triples, and the probability distribution of the relation path is generated step by step.
[0009] 2) The rule reasoner infers the missing tail entity of the query triple according to the probability distribution of the relation path, calculates the loss with the real label, and trains until convergence.
[0010] 3) The inference result and the probability distribution of the relation path are input into the rule parser to obtain the logical rule.
[0011] 4) The completed triple is input into the confidence prediction module to calculate the confidence, and the uncertain knowledge graph reasoning task is completed.
[0012] In the uncertain knowledge graph reasoning method based on rule mining, in the step 1), the rule generator generates the probability distribution of the relation path in the following way:
[0013] 1-a) For each triple in the uncertain knowledge graph training data, the head entity h and the relation r are extracted as query triples, which are formally defined as (h, r,?), and the tail entity t is taken as the real label in the subsequent step. The rule generator adopts the Vanilla Transformer architecture, first defines a vocabulary, and each entity and relation has a corresponding embedding vector. Before inputting the rule generator, the text format of the head entity and the relation is used to retrieve the vocabulary to obtain the vector representation h and r respectively, and the input sequence S = h, r is obtained after splicing and integrating. The semantic encoding unit calculates the encoding result S' = h', r' through the multi-head self-attention layer and the feedforward neural network layer.
[0014] 1-b) The rule generation unit first receives the encoding result S', which is taken as the context, and then uses the special starting symbol <bos>As the starting input, the probability distribution of each relation in the rule body is generated autoregressively after performing multi-head self-attention layers, cross-attention calculations, and other operations. The complete process is calculated by the following way:
[0015] R t+1 = Softmax(MLP(CrossAttention(S', S t )))
[0016] where S t denotes the input of the rule generation unit at the t-th step, R t+1 denotes the relation probability distribution at the t+1-th step, and CrossAttention denotes the cross-attention operation. MLP denotes a multi-layer perceptron with a fully connected layer that maps the dimension of the output attention vector to the number of relations. The Softmax activation function converts the input vector into a probability distribution.
[0017] The above process is repeated T times, thereby obtaining a rule body with a length of T. In order to enable the model to generate rules of free length, the method additionally adds <slf>The relationship is used to fill the rule body to the maximum length.
[0018] In the rule-based uncertainty knowledge graph reasoning method of the present application, in step 2), the rule reasoner predicts the missing tail entity in the following way:
[0019] In TensorLog, an entity is represented by a one-hot vector e i ∈{0,1} |v| , and |ε| is the number of entities in the uncertainty knowledge graph. A relationship is represented by an adjacency matrix M r ∈{0,1} |ε|×|ε| , and M r [i,j] = 1 indicates that there is a triple (e i , r, e j ) in the knowledge graph. The reasoning process can be obtained by multiplying the entity vector and the relationship matrix:
[0020]
[0021] where e h is the head entity vector, e t is the tail entity vector, and M r is the matrix of each relationship. In order to model the uncertainty information, the present application redefines the relationship matrix. M r [i,j] = s indicates that there is a triple (e i , r, e j ) in the uncertainty knowledge graph, and has a confidence s. The head entity and the relationship matrix in the rule body are calculated in the following way:
[0022]
[0023] where Y represents the probability distribution of the reasoning result. α ij represents the probability value of the jth relationship generated by the ith step of the rule generator, e h represents the head entity vector, T represents the length of the rule body, and |R| represents the total number of relationships in the uncertainty knowledge graph.
[0024] In the training process, the present method uses the following loss function to measure the gap between the predicted tail entity and the true label:
[0025] loss = -log(max(γ, Y target ))
[0026] where Y target The probability value representing the real tail entity, gamma is a very small constant, max is used to take the larger value of the two, and the -log(·) operation is used to calculate the negative log likelihood. By optimizing this loss function, the rule reasoner will assign higher weights to more reliable relationship paths, thereby maximizing the accuracy of tail entity prediction.
[0027] In the rule mining-based uncertain knowledge graph reasoning method of the application, in the step 3), the rule parser decodes the complete reasoning path from the tail entity in reverse, that is, the last relationship in the rule body is decoded first, then the previous relationship is parsed, until the head entity h in the query triple is decoded, and the complete reasoning path is extracted. Replace the entity in the reasoning path with a specific variable name to obtain the reasoning rule for the query triple.
[0028] In the rule mining-based uncertain knowledge graph reasoning method of the application, in the step 4), the confidence prediction module predicts the triple confidence in the following manner:
[0029] 4-a) The confidence prediction module receives the results of steps 2) and 3) as input, first designs a task-specific prompt word "You are a linguistic normalization assistant specialized in standardizing entity and relation names. Given a set of non-standard entity or relation names, your task is to convert them into clear and properly formatted phrases in standard English. 1) Convert concatenated words into natural phrases. 2) Expand abbreviations when necessary. 3) Convert camel case or snake case into readable phrases. 4) Ensure proper grammatical structure and spacing.", and uses a large language model to convert non-standard, abbreviated or inconsistent entity and relation names into clear and natural language expressions, ensuring consistency and readability of input. Then, design a template "[CLS]Question: h' r' what? Is the correct answer: t'? [SEP]Context: grounding rule [SEP].", convert the input into a query statement in natural language form, which is used for subsequent confidence prediction.
[0030] 4-b) Use the pre-trained language model BERT to encode the query statement to get the embedding sequence: E1, E2,..., E n Then, through the CLS aggregation strategy, directly use the hidden representation of the special symbol "[CLS]" position in the BERT model as the input feature for confidence prediction.
[0031] 4-c) Input the generated feature representation into a feedforward neural network to calculate the confidence score of the triple in the following way:
[0032] FNN(x) = W1(ReLU(W2x + b2)) + b1
[0033] where x denotes the feature representation after aggregation, W1 and W2 denote two weight matrices, b1 and b2 denote bias terms, and ReLU(·) = max(0, ·) denotes a linear rectifier function. The output of the feedforward neural network is the predicted triple confidence score.
[0034] So far, the uncertainty knowledge graph reasoning task is completed, and the present application not only can predict the missing tail entity of the triple, but also gives the triple a reliable confidence.
[0035] An electronic device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the rule mining-based uncertainty knowledge graph reasoning method when executing the program.
[0036] A computer-readable storage medium has computer instructions stored thereon, and the computer instructions are executed by a processor to implement the rule mining-based uncertainty knowledge graph reasoning method.
[0037] Advantages: Compared with the prior art, the present application has the following advantages:
[0038] 1. Enhanced modeling ability for uncertainty: Existing embedding-based methods (such as TransE, RotatE) mainly focus on mapping entities and relations to low-dimensional vector spaces, but lack support for knowledge uncertainty and explainability, making it difficult to evaluate the credibility of reasoning results. The present application effectively models the uncertainty of knowledge by introducing rule mining and confidence prediction, making the reasoning results more interpretable and reliable.
[0039] 2. Solve the limitations of rule-based methods in uncertain scenarios: Traditional rule-based methods (such as AMIE) are usually conducted in a deterministic environment, ignoring the inherent uncertainty in knowledge graphs. The present application converts the rule mining task into a sequence-to-sequence generation task, designs a differentiable reasoning framework with TensorLog, and trains the model end-to-end. It makes rule mining not only applicable to deterministic knowledge graphs, but also effective in uncertain knowledge graphs.
[0040] 3. Solve the problem of high complexity of traditional rule mining methods: Traditional rule mining methods mainly rely on depth-first search algorithms, using the relevance between triples to search for paths. Due to the large search space and high algorithm complexity, it is difficult to apply to large knowledge graphs. The present application directly generates the probability distribution of implicit rules according to the semantic information of the head entity and the relationship in the triple for reasoning, avoiding the huge search space of relationship path search, greatly improving the efficiency of rule mining. And this method converts rule mining into a sequence-to-sequence task, which can generate rules of variable length.
[0041] 4. Innovatively combine rule-based reasoning and pre-trained language models: Existing methods (such as KG-BERT) have tried to combine pre-trained language models and embedding methods, but still do not fully consider uncertainty modeling. The present invention combines pre-trained language model BERT on the basis of rule-based reasoning, jointly models the structural information of the knowledge graph and the semantic information of the pre-trained language model, so that the reasoning result is more in line with common sense, and the credibility of knowledge completion is improved.
[0042] 5. The actual evaluation results are significantly better than existing methods: The present invention has carried out experimental evaluation on the uncertainty knowledge graph dataset CN15K and NL27K. In the link prediction task, the MRR index of the present invention on the CN15K dataset is 0.204, which is 61.9% higher than the traditional representation learning model, 6.25% higher than the traditional rule mining model, and 43.7% higher than the uncertainty knowledge graph representation learning model. For the NL27K dataset, it is 81.5% higher than the traditional representation learning model, and 71.7% higher than the uncertainty knowledge graph representation learning model; in the confidence prediction task, the MAE (mean absolute error) indexes of the present invention on CN15K and NL27K are 0.11 and 0.055 respectively, which are much better than existing methods. In summary, the rule mining-based uncertainty knowledge graph reasoning method of the present invention shows effectiveness and superiority in practical scenarios. At the same time, the proposed reasoning method not only performs well on experimental data, but also can be applied to large-scale uncertainty knowledge graphs in the real world, such as biomedical, social networks, intelligent question answering, etc. BRIEF DESCRIPTION OF DRAWINGS
[0043] Figure 1 is a schematic diagram of the framework of the present invention,
[0044] Figure 2 is a schematic diagram of the rule mining module of the present invention,
[0045] Figure 3 is a schematic diagram of the confidence prediction module of the present invention. DETAILED DESCRIPTION
[0046] The implementation process of the present invention will be described in detail below in combination with the embodiments and the accompanying drawings.
[0047] Embodiment: The present invention designs a rule mining-based uncertainty knowledge graph reasoning method to solve the completion problem of uncertainty knowledge graph, which mainly includes the following steps:
[0048] 1) The rule generator generates an implicit rule probability distribution,
[0049] The rule generator is based on a Vanilla Transformer architecture and is composed of a semantic encoding unit and a rule generation unit. The semantic encoding unit is stacked with N Transformer blocks to encode the input sequence to obtain an encoding information matrix. Specifically, first, the head entity h and the relation r in the query triple (h, r,?) are converted from text format to vector representation h and r, and the input sequence S = h, r is obtained by splicing and integrating. The encoding result S' = h', r' is calculated for subsequent processes. The rule generation unit is also stacked with N Transformer blocks, which calculate attention weights in combination with the information matrix obtained by semantic encoding, and use the attention weights to calculate the final rule score. <bos>As initial input, the distribution of relations in the rule body is autoregressively generated. The S t representation of the input sequence of the rule generation unit at time step t, the process can be represented as:
[0050] R t+1 = Softmax(MLP(CrossAttention(S', S t )))
[0051] where R t+1 represents the relation probability distribution at step t+1, CrossAttention represents the cross-attention layer. MLP represents a multi-layer perceptron with a fully connected layer that maps the dimension of the output attention vector to the number of relations. The Softmax activation function converts the input vector to a probability distribution.
[0052] To make the model more flexible to generate rules, the invention expands all relations with corresponding inverse relations, such as expanding (X, r, Y) to (Y, inv_r, X). In addition, to enable the model to generate rules of free length, an additional <slf>The relations are used to fill the rules to the maximum length, for any entity e E, there is (e, <slf>e) is true. Wherein, <slf>denotes a self-referential relation, while inv r denotes the inverse relation of r, and finally the replacement operation.
[0053] 2) The rule reasoner calculates the missing tail entity,
[0054] The rule generator can generate the probability distribution of relations in the rule body, however, the probability distribution cannot be directly used as rules and reasoning. This method aims to solve the problem of how to use the relation distribution in the rule body for interpretable uncertain rule reasoning and get the reasoning result. Taking the relation probability distribution generated by the rule generator as input, an uncertain rule reasoner based on TensorLog is designed.
[0055] Specifically, a differentiable reasoning framework is designed based on TensorLog, which represents rule-based reasoning of knowledge graphs as differentiable vector and matrix multiplication operations. Entities are represented as corresponding one-hot encoded vectors e i ∈{0,1} |ε| , and relations are represented as adjacency matrices M r ∈{0,1} |ε|×|ε| If M r [i,j] = 1, it means that there is a relation r between the i-th entity e i and the j-th entity e j in the knowledge graph. Therefore, the single-step rule-based reasoning using relation r for the head entity h can be represented as t = h·M r , where t and h are both one-hot encoded vectors, and t is the result of reasoning. For the above process, the generalization to reasoning using the rule R(X,Y)←P(X,Z)∧Q(Z,Y) can be formally represented as:
[0056] Y = e X ·M P ·M Q
[0057] where e X represents the vector of entity X in the rule, M P and M Q represent the matrix representation of relations P and Q, respectively. Y is the vector representation of the reasoning result, and the i-th item is an integer whose value represents the number of paths that can be obtained by instantiating all variables in the rule body with entity instances to obtain the i-th entity as the result in the knowledge graph. Here, the path refers to a path in the knowledge graph obtained by instantiating all variables in the rule body with entity instances. During the rule mining process, each rule will have a weight representing the quality of the rule. Therefore, for a query triple with n rules, assuming that the probability weight of each rule is α i , the reasoning result can be represented as the weighted sum of the reasoning results of different rules:
[0058]
[0059] e x The entity obtained by intermediate process reasoning, r represents a relationship in the rule body. However, the above formula needs to use the explicit rule body relationship matrix M r to perform reasoning, and instead of the rule body relationship probability distribution, in order to use the rule generator to decode the obtained probability distribution to perform reasoning and avoid a huge rule search space, the above formula can be converted into the following form:
[0060]
[0061] Where T is the rule body length, and α′ ij represents the probability of the jth relationship in the ith relationship probability distribution output by the rule generation unit, that is, the probability of the jth relationship in the ith step, and thus the reasoning result can be further expressed in the form of expectation calculation:
[0062] Y = e x ∏E M~Generator (M)
[0063] In order to model the uncertainty information, the method redefines M r [i,j] = s indicates that the triple (e i , r, e j ) has a confidence s. The head entity and the relationship matrix in the rule body are calculated in the following manner:
[0064]
[0065] Where Y represents the probability distribution of the reasoning result. α ij represents the probability value of the jth relationship generated by the ith step of the rule generator, e h represents the head entity vector, T represents the length of the rule body, and |R| represents the total number of relationships in the uncertain knowledge graph.
[0066] It should be noted that each item in the reasoning result Y at this time represents the weight of the corresponding entity as the reasoning result, which contains the confidence information in the reasoning path. If there are more paths to reason out the entity, and the confidence of the triple in the path is high, the weight of the reasoning result obtained is also high, and it is more reliable. When there are fewer reasoning paths, or there are triples with low confidence in the path, the weight of the reasoning result will be lowered, indicating that the reasoning result is not reliable.
[0067] The method uses the following loss function to measure the gap between the predicted tail entity and the true label:
[0068] loss = -log(max(γ, Y target ))
[0069] where Y target represents the probability value of the true tail entity, γ is a small constant, max is used to take the larger value of the two, and the -log(·) operation is used to calculate the negative log-likelihood. By optimizing this loss function, the rule reasoner will assign higher weights to more reliable relationship paths, thus maximizing the accuracy of tail entity prediction.
[0070] 3) The rule parser calculates the logical rule
[0071] The present application designs a brand-new rule parsing algorithm, which can sample high-quality rule bodies from the rule distribution, i.e., the relationship sequence r1∧r2∧...∧r T , as the rule mining result. The key to sampling high-quality rule bodies is to select those entities and relationships that can maximize the probability of the true tail entity. Starting from the tail entity, the reasoning result of the entity weight vector can be represented as:
[0072]
[0073] where, represents the reasoning result obtained using the rule body before T steps, and the final reasoning result is represented by |R| vectors of |ε| dimensions and. The tail entity weight of each step of reasoning can be obtained by calculating the sum of the corresponding positions. The relationship with the maximum value in the corresponding vector will be selected as the Tth relationship. When the Tth relationship is selected, the reasoning result of the entity weight vector can be represented as:
[0074]
[0075] where r T represents the Tth relationship in the rule body, represents the weight coefficient of the Tth relationship. Further decompose it into [w1,w2,...,w |ε| ]·[m1,m2,...,m |ε| ]. Where w i is a real number, and |ε| is the number of entities in the uncertain knowledge graph, therefore, the entity weight vector can be represented as Repeat the above process until the head entity h in the query triple is parsed, and the complete reasoning path can be obtained. By replacing the entities in the reasoning path with variables, the reasoning rule for the query triple can be obtained.
[0076] 4) Triplet confidence calculation
[0077] The confidence prediction module receives the results of steps 2) and 3) as input, first converts the input into a sentence conforming to the natural language form using a large language model. Specifically, to solve the problem of non-standard entity and relationship names in the knowledge graph, a task-specific prompt is designed: "You are a linguistic normalization assistant specialized in standardizing entity and relation names. Given a set of non-standard entity or relation names, your task is to convert them into clear and properly formatted phrases in standard English. 1) Convert concatenated words into natural phrases. 2) Expand abbreviations when necessary. 3) Convert camel case or snake case into readable phrases. 4) Ensure proper grammatical structure and spacing." Then concatenate the text content in the query triple and the logical rule to the prompt, and use the large language model to generate entity and relationship names (h', r', t') conforming to natural language expression.
[0078] For the preprocessed query triple (h', r', t') and its corresponding logical rule (h', r', t') <- (h', r', x') ^ (x', inv_r', t'), the method designs a template "[CLS]Question: h' r' what? Is the correct answer: t'? [SEP]Context: grounding rule [SEP]." Only need to replace the entity, relationship and rule in the template, can get the query sentence conforming to the natural language form. Then use the pre-trained language model BERT to encode the query sentence, get the embedding sequence: E1, E2,..., E n The method adopts a CLS strategy to aggregate the features of the embedded sequence to generate a comprehensive feature representation, which not only considers the structural information of the triplets, but also embeds the semantic information of the language model therein.
[0079] For the feature representation of the input sequence "[CLS]" position, the method designs a feedforward neural network, and the generated feature representation is input into the feedforward neural network, and the confidence score of the triplet is calculated in the following manner:
[0080] FNN(x)=W1(ReLU(W2x+b2))+b1
[0081] Wherein, x represents the aggregated feature representation, W1∈R 4d×1 and W2∈R d×4d represent two weight matrices, b1 and b2 represent bias terms, and ReLU(·)=max(0,·) represents a linear rectifier function. FNN represents a feedforward neural network layer, and the output of the feedforward neural network is the predicted triplet confidence.
[0082] So far, the uncertainty knowledge graph reasoning task is completed, and the present application not only can predict the tail entity of the missing triplet, but also gives the triplet a reliable confidence. Using the method, the link prediction index and the confidence prediction index on the uncertainty knowledge graph dataset CN15K and NL27K are significantly better than the existing methods.
[0083] The above shows and describes the basic principles, main features and advantages of the present application. Those skilled in the art should understand that the present application is not limited to the above specific embodiments, and the above specific embodiments and descriptions in the specification are only to further illustrate the principles of the present application, and various changes and improvements can be made without departing from the spirit and scope of the present application, and these changes and improvements all fall within the scope of the claimed present application. The scope of protection of the present application is defined by the claims and their equivalents.< / slf> < / slf> < / slf> < / bos> < / slf> < / bos>
Claims
1. A method for uncertainty knowledge graph reasoning based on rule mining, characterized by: The method comprises the following steps: 1) Input the head entities and relations of all triples in the uncertainty knowledge graph training data as query triples into the rule generator, and gradually generate the probability distribution of the relationship path. 2) The rule reasoner infers the missing tail entity of the query triple based on the probability distribution of the relationship path, calculates the loss with the true label, and trains until convergence. 3) Input the inference results and the probability distribution of the relationship path into the rule parser to parse and obtain the logical rules. 4) Input the completed triples into the confidence prediction module to calculate the confidence and complete the uncertainty knowledge graph reasoning task; In step 1), the rule mining task is transformed into a sequence-to-sequence generation task, so that the Vanilla Transformer architecture is applied to query triples. and relationships Composition, formally defined as , before entering the rule generator, the head entities and relations are first converted from text format to vector representation and , after splicing and integration, the input sequence is obtained , Transformer first performs query semantic encoding to obtain the encoding result , and then use it as context, and use the special start symbol , autoregressively generates the distribution of relations in the rule body, which is calculated as follows: in Indicates that the rule generation unit is Step input, Indicates in The probability distribution of the relationship between the steps, Represents a multi-layer perceptron that maps the dimension of the output attention vector to the number of relations in the uncertain knowledge graph, using The activation function transforms the input vector into a probability distribution. Repeat the above decoding process times, thus obtaining a length of In order to generate rules more flexibly, for each triple in the knowledge graph Added a reverse triple ; To generate variable length regular sequences, use special symbols Pad the decoded sequence to a fixed length, represents a relationship pointing to itself, and Representing relationships The reverse relationship, and finally replace them; In step 2), for the relationship distribution of each step in the rule body generated in step 1), the rule reasoner designs a differentiable reasoning framework based on TensorLog, represents rule reasoning as differentiable vector and matrix multiplication operations, and represents entities as one-hot encoding. , the relationship is expressed as an adjacency matrix ,in Represents a triple With confidence s, Represents the number of entities in the uncertainty knowledge graph, and calculates the relationship between the head entity and the rule body as follows: in, Indicates the probability distribution of the target tail entity is calculated, Indicates the rule generator The first step generated The probability value of a relationship, Represents the head entity vector, represents the length of the rule body, and Represents the total number of relations in the uncertainty knowledge graph, The following loss function is used to measure the difference between the predicted tail entity and the true label: in represents the probability value of the true tail entity, is a very small constant, Used to take the larger value of the two. The operation is used to calculate the negative log-likelihood. By optimizing this loss function, the rule reasoner will assign higher weights to more reliable relationship paths, thereby maximizing the accuracy of tail entity prediction.
2. The uncertainty knowledge graph reasoning method based on rule mining according to claim 1 is characterized in that: In step 3), based on the tail entity predicted in step 2), the rule parser decodes the complete reasoning path from the tail entity in reverse until the head entity in the query triple is decoded. , extract the complete reasoning path, and replace the entities in the reasoning path with specific variable names to obtain the inference rules for the query triples.
3. The uncertainty knowledge graph reasoning method based on rule mining according to claim 2 is characterized in that: In step 4), for the tail entity and logic rule predicted in steps 2) and 3), the confidence prediction module will complete the triple and logic rules as input, the confidence of the triple is calculated as follows: i) First, we design a task-specific prompt: "You are a linguistic normalization assistant specialized in standardizing entity and relation names. Given a set of non-standard entity or relation names, your task is to convert them into clear and properly formatted phrases in standard English. \n\n 1) Convert concatenated words into natural phrases. \n\n 2) Expand abbreviations when necessary. \n\n 3) Convert camel case or snake case into readable phrases. \n\n 4) Ensure proper grammatical structure and spacing." Then, we append the query triples and the text content in the logic rules to the prompt. Using a large language model, we convert non-standard, abbreviated, or inconsistently formatted entity and relation names into clear and fluent natural language expressions, denoted as , ii) Query triples preprocessed in step i) , and its corresponding logical rules , design the template "[CLS]Question: h' r' what? Is the correct answer: t'? [SEP] Context: grounding rule [SEP].", and simply replace the entities, relations, and rules in the template to obtain a query statement that conforms to the natural language form. Then use the pre-trained language model BERT to encode the query statement and obtain the embedding sequence: The CLS strategy is used to aggregate the features of the embedded sequence and generate a comprehensive feature representation, thereby utilizing the semantic information of the triples and language model. The CLS strategy directly uses the special symbols in the BERT model. The hidden representation of the position is used as input feature for confidence prediction. iii) Regarding " ” Position feature representation, design a feedforward neural network to calculate the confidence score of the triple in the following way: in, represents the aggregated feature vector, and Represents two weight matrices, and represents the bias term, represents the linear rectification function.
4. An electronic device comprising 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 an uncertainty knowledge graph reasoning method based on rule mining as described in any one of claims 1 to 3 above.
5. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer instruction is executed by the processor, an uncertainty knowledge graph reasoning method based on rule mining as described in any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Knowledge graph completion method based on path and graph context
CN115795042A
Neural symbol combined knowledge graph reasoning method
CN118469012A