Uncertain knowledge graph reasoning method based on rule mining
By introducing rule mining and confidence prediction modules into the uncertain knowledge graph, Vanilla Transformer and TensorLog are used for reasoning, the problem that the existing technology cannot be effectively applied to the uncertain knowledge graph is solved, and efficient, interpretable and reliable knowledge graph reasoning is achieved.
Patent Information
- Application Number
- CN202510270081.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-07
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2045-03-07
AI Technical Summary
The existing rule mining methods are carried out in the deterministic knowledge graph scenario and cannot be directly applied to the completion problem of uncertain knowledge graphs, and lack modeling and interpretability support for knowledge uncertainty.
A method of uncertainty knowledge graph inference based on rule mining is proposed. The rules are composed of the rule mining module and the confidence prediction module. The Vanilla Transformer architecture is used to generate rules, and the microinference framework is designed to be end-to-end trained through TensorLog, and the confidence of triples is predicted in combination with the pre-trained language model.
It realizes automatic mining of logical rules in the uncertainty knowledge graph, completes the prediction of missing triples, and gives the triples a reliable confidence score, enhancing the modeling ability of uncertainty and interpretability and reliability of inference results.
Smart Images

Figure CN120104809A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an uncertainty knowledge graph reasoning method based on rule mining, and belongs to the technical field of knowledge graphs. Background Art
[0002] Knowledge graphs are structured knowledge bases that store real-world facts in the form of graphs. Each fact is represented as a triple (h, r, t), where h and t are the head entity and the tail entity, respectively, and r is the relationship connecting them. Knowledge graphs composed of these fact triplets, such as YAGO, Wikidata, and Zhishi.me, have been widely used in various downstream tasks, such as question-answering systems and decision support. However, the above knowledge graphs do not consider the inherent uncertainty of knowledge. The uncertainty of knowledge mainly comes from two situations: one is the nature of the 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 definite relationship; the other is data noise and errors in automated construction. Many knowledge graphs are constructed from unstructured texts through automated methods (such as information extraction, pattern matching, or machine learning). This method may introduce noisy data or erroneous reasoning, resulting in low confidence in some knowledge. In order to model uncertainty in knowledge graphs, uncertainty knowledge graphs are proposed. For example, ProBase, ConceptNet, and NELL, in addition to using triples to describe facts, also assign an additional confidence level to each triple to describe the uncertainty of knowledge, such as <(university, synonym, institute), 0.86>. There are two main ways to obtain the confidence level of uncertainty knowledge graphs: automatic annotation algorithms calculate confidence levels through machine learning or rule-based reasoning models, such as estimating the reliability of triples based on statistical information or neural network models; manual crowdsourcing annotation uses expert annotation or crowdsourcing platforms to collect human confidence assessments to improve data reliability.
[0003] Although knowledge graphs can be very large in size, they usually face the problem of incompleteness. During the construction process, knowledge graphs cannot cover all facts. To solve this problem, many studies have focused on the reasoning problem of knowledge graphs, and these methods can be divided into two categories: embedding-based methods and rule-based methods. Embedding-based methods (such as TransE, RotatE, and CompleEx) simulate the relationship between entities in triples by mapping entities and relations into low-dimensional dense vector spaces and using vector operations. 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 because of their interpretability. This type of method (such as AMIE) mines rules by iterating the knowledge graph and uses these rules for reasoning. However, existing rule mining methods are all performed in the context of deterministic knowledge graphs, ignoring the uncertainty of knowledge, and therefore cannot be directly applied to the completion problem of uncertain knowledge graphs.
[0004] To solve this problem, the present invention proposes an uncertainty 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 the advanced Vanilla Transformer architecture, regards rule mining as a sequence-to-sequence generation task, generates rules to infer new triples, and designs a differentiable reasoning framework through TensorLog to model uncertainty and perform end-to-end training. The confidence prediction module uses a pre-trained language model to combine the structural information of the graph and the semantic information of the language model to predict the confidence score of a given triple. In summary, the present invention has made significant breakthroughs in interpretability, reasoning ability and uncertainty modeling, and provides an efficient and reliable solution for the reasoning of uncertainty knowledge graphs. Summary of the invention
[0005] Technical problem: The present invention provides an uncertainty knowledge graph reasoning method based on rule mining, which can not only automatically mine the logical rules in the uncertainty knowledge graph and complete the prediction of missing triples under the premise of interpretability, but also combine the structural information of the knowledge graph and the semantic information of the pre-trained language model to predict the confidence score of a given triple.
[0006] Technical solution:
[0007] The uncertainty knowledge graph reasoning method based on rule mining of the present invention is performed by the following steps:
[0008] 1) The head entities and relations of all triples in the uncertainty knowledge graph training data are used as query triples to input the rule generator, and the probability distribution of the relationship path is gradually generated.
[0009] 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.
[0010] 3) Input the inference results and the probability distribution of the relationship path into the rule parser and parse to obtain the logical rules.
[0011] 4) Input the completed triples into the confidence prediction module, calculate the confidence, and complete the uncertainty knowledge graph reasoning task.
[0012] In the uncertainty knowledge graph reasoning method based on rule mining of the present invention, in the step 1), the rule generator gradually generates the probability distribution of the relationship path in the following manner:
[0013] 1-a) For each triple in the uncertainty knowledge graph training data, the head entity h and the relationship r are extracted as the query triple, formally defined as (h, r,?), and the tail entity t is used as the true label for the subsequent steps. The rule generator adopts the Vanilla Transformer architecture. First, a vocabulary is defined. Each entity and relationship has a corresponding embedding vector. Before entering the rule generator, the text format of the head entity and the relationship is used to search the vocabulary to obtain the vector representation h and r respectively. After concatenation and integration, the input sequence S = h, r is obtained. The semantic encoding unit passes through the multi-head self-attention layer and the feedforward neural network layer, and the encoding result S′ = h′, r′ is calculated.
[0014] 1-b) The rule generation unit first receives the encoding result S', uses it as context, and then uses the special start symbol <bos>As the starting input, after performing multi-head self-attention layers, cross-attention calculations, etc., the probability distribution of each relationship in the rule body is generated autoregressively. The complete process is calculated in the following way:
[0015] R t+1 =Softmax(MLP(CrossAttention(S′,S t )))
[0016] Where S t represents the input of the rule generation unit at step t, R t+1 represents the probability distribution of relations at step t+1, CrossAttention represents the cross attention operation. 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 into a probability distribution.
[0017] Repeat the above process T times to obtain a rule body of length T. In order to enable the model to generate rules of free length, this method adds <slf>Relations are used to fill the rule body to a maximum length.
[0018] In the uncertainty knowledge graph reasoning method based on rule mining of the present invention, in step 2), the rule reasoner predicts the missing tail entity in the following manner:
[0019] In TensorLog, entities are represented by one-hot vectors e i ∈{0,1} |v| , |ε| is the number of entities in the uncertainty knowledge graph. The relationship is represented by the adjacency matrix M r ∈{0,1} |ε|×|ε| Indicates that M r [i,j]=1 indicates that there is a triple in the knowledge graph (e i ,r,e j ). The reasoning process can be obtained by multiplying the entity vector and the relationship matrix:
[0020]
[0021] where e h Represents the head entity vector, e t represents the tail entity vector, M r The matrix representing each relationship. In order to model uncertainty information, the present invention redefines the relationship matrix. r [i,j]=s means that there is a triple (e i ,r,e j ), and has a confidence level s. The relationship matrix between the head entity and the rule body is calculated as follows:
[0022]
[0023] Among them, Y represents the probability distribution of the inference result. ij represents the probability value of the jth relationship generated by the rule generator in step i, e h represents the head entity vector, T represents the length of the rule body, and |R| represents the total number of relations in the uncertainty knowledge graph.
[0024] During the training process, this 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 represents the probability value of the true tail entity, γ 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 uncertainty knowledge graph reasoning method based on rule mining of the present invention, in step 3), the rule parser reversely decodes the complete reasoning path from the tail entity, that is, first decodes the last relationship in the rule body, and then parses the previous relationship until the head entity h in the query triple is decoded, and the complete reasoning path is extracted. The entities in the reasoning path are replaced with specific variable names to obtain the reasoning rules for the query triple.
[0028] In the uncertainty knowledge graph reasoning method based on rule mining of the present invention, in 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 step 2) and step 3) as input. First, it designs task-specific prompt words "You are a linguistic normalization assistant specialized instandardizing entity and relation names. Given a set of non-standard entity or relation names, your task is to convert theminto 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\n3) Convert camel case or snake case into readable phrases.\n\n 4) Ensure proper grammatical structure and spacing." and uses a large language model to convert non-standard, abbreviations or inconsistently formatted entity and relation names into clear and fluent natural language expressions to ensure the consistency and readability of the input. Subsequently, a template "[CLS]Question:h'r'what?Is the correct answer:t'?[SEP]Context:grounding rule[SEP]." is designed to convert the input into a query statement in natural language form for subsequent confidence prediction.
[0030] 4-b) Use the pre-trained language model BERT to encode the query sentence and obtain the embedded sequence: E 1 ,E 2 ,...,E n , and then through the CLS aggregation strategy, the hidden representation of the special symbol "[CLS]" in the BERT model is directly used as the input feature for confidence prediction.
[0031] 4-c) Input the generated feature representation into the feedforward neural network and calculate the confidence score of the triplet as follows:
[0032] FNN(x)=W 1 (ReLU(W 2 x+b 2 ))+b 1
[0033] Among them, x represents the feature representation after aggregation, W 1 and W 2 Represents two weight matrices, b 1 and b 2 represents the bias term, and ReLU(·)=max(0,·) represents the linear rectification function. The output of the feedforward neural network is the predicted triple confidence.
[0034] At this point, the uncertainty knowledge graph reasoning task is completed. The present invention can not only predict the tail entity of the missing triple, but also give the triple a reliable confidence.
[0035] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the method for reasoning an uncertain knowledge graph based on rule mining is implemented.
[0036] A computer-readable storage medium stores computer instructions, which, when executed by a processor, implement the uncertainty knowledge graph reasoning method based on rule mining.
[0037] Beneficial effects: Compared with the prior art, the present invention has the following advantages:
[0038] 1. Enhance the modeling ability of uncertainty: Existing embedding-based methods (such as TransE and RotatE) mainly focus on mapping entities and relationships into low-dimensional vector spaces, but lack support for knowledge uncertainty and interpretability, making it difficult to evaluate the credibility of reasoning results. This paper effectively models knowledge uncertainty by introducing rule mining and confidence prediction, making 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 performed in a deterministic environment, ignoring the inherent uncertainty in the knowledge graph. This paper transforms the rule mining task into a sequence-to-sequence generation task, combines TensorLog to design a differentiable reasoning framework, and trains the model end-to-end. And 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 and use the correlation between triples to perform path search. Due to the large search space and high algorithm complexity, it is difficult to apply to large knowledge graphs. The present invention directly generates the probability distribution of implicit rules for reasoning based on the semantic information of the head entity and relationship in the triple, avoiding the huge search space for relationship path search and greatly improving the efficiency of rule mining. In addition, this method converts rule mining into a sequence-to-sequence task and can generate rules of variable length.
[0041] 4. Innovative fusion of rule reasoning and pre-trained language model: Existing methods (such as KG-BERT) have tried to combine pre-trained language models and embedding methods, but have not fully considered uncertainty modeling. Based on rule reasoning, this invention combines the pre-trained language model BERT to jointly model the structural information of the knowledge graph with the semantic information of the pre-trained language model, making the reasoning results more in line with common sense and improving the credibility of knowledge completion.
[0042] 5. The actual evaluation results are significantly better than the existing methods: The present invention has been experimentally evaluated on the uncertainty knowledge graph datasets CN15K and NL27K. In the link prediction task, the MRR index of this method in the CN15K dataset reached 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, the effect 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) indicators of this method in CN15K and NL27K are 0.11 and 0.055 respectively, which greatly exceeds the existing methods. In general, the uncertainty knowledge graph reasoning method based on rule mining of the present invention has demonstrated effectiveness and superiority in actual scenarios. At the same time, the proposed reasoning method not only performs well in experimental data, but can also be applied to large-scale uncertainty knowledge graphs in the real world, such as biomedicine, social networks, intelligent question and answer, and other fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a schematic diagram of the framework of the present invention,
[0044] Figure 2 is a schematic diagram of a rule mining module of the present invention,
[0045] Figure 3 It is a schematic diagram of the confidence prediction module of the present invention. DETAILED DESCRIPTION
[0046] The implementation process of the present invention is described in detail below in conjunction with the embodiments and the accompanying drawings.
[0047] Embodiment: The present invention designs an uncertainty knowledge graph reasoning method based on rule mining to solve the problem of completing the uncertainty knowledge graph, which mainly includes the following steps:
[0048] 1) The rule generator generates implicit rule probability distribution,
[0049] The rule generator is based on the Vanilla Transformer architecture and consists of a semantic encoding unit and a rule generation unit. The semantic encoding unit is composed of N stacked Transformer blocks, which are used to encode the input sequence to obtain an encoded information matrix. Specifically, the head entity h and the relationship r in the query triple (h, r, ?) are first converted from text format to vector representations h and r, and the input sequence S = h, r is obtained after concatenation and integration. The encoding result S′ = h′, r′ is calculated and used in subsequent processes. The rule generation unit is also composed of N stacked Transformer blocks. The attention weights are calculated based on the information matrix obtained by semantic encoding, and the attention weights are used. <bos>As the initial input, the distribution of relations in the rule body is generated autoregressively. t represents the input sequence of the rule generation unit at time step t, then the process can be expressed as:
[0050] R t+1 =Softmax(MLP(CrossAttention(S′,S t )))
[0051] Where R t+1 represents the probability distribution of relations 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 into a probability distribution.
[0052] In order to allow the model to generate rules more flexibly, the present invention expands the corresponding inverse relations for all relations, such as expanding the triple (X, r, Y) to (Y, inv_r, X). In addition, in order for the model to generate rules of free length, additional <slf>The relation is used to fill the rule body to the maximum length. For any entity e∈E, there is (e, <slf>,e) is established. Among them, <slf>Indicates a relationship pointing to itself, while inv r Represents the reverse relation of relation r, and finally performs a replacement operation on them.
[0053] 2) The rule reasoner calculates the missing tail entity,
[0054] The rule generator can generate the probability distribution of the relations in the rule body. However, the probability distribution cannot be directly used as a rule and reasoning. This method aims to solve the problem of how to use the relation distribution in the rule body to perform interpretable uncertain rule reasoning and obtain reasoning results. Taking the relation probability distribution generated by the rule generator as input, an uncertain rule reasoner based on TensorLog is designed.
[0055] Specifically, we design a differentiable reasoning framework based on TensorLog, and represent the rule reasoning of the knowledge graph as differentiable vector and matrix multiplication operations. The entity is represented as the corresponding one-hot encoding vector e i ∈{0,1} |ε| , the relationship is represented as the adjacency matrix M r ∈{0,1} |ε|×|ε| , if M r [i,j] = 1, which means that the i-th entity e in the knowledge graph i and the jth entity e j There is a relationship r between them. So the single-step rule reasoning for the head entity h using the relationship r can be expressed as t = h·M r , where t and h are both one-hot encoding vectors, and t is the result of reasoning. The above process is extended to reasoning using the rule R(X,Y)←P(X,Z)∧Q(Z,Y), which can be formally expressed as:
[0056] Y=e X ·M P ·M Q
[0057] Among them, e X The vector representing entity X in the rule, M P and M Q They represent the matrices of relations P and Q respectively. Y is the vector representation of the inference result. In this case, the i-th item is an integer, and its value represents the number of paths that can obtain the i-th entity as the result through the current rule reasoning. The path here refers to a path in the knowledge graph obtained by instantiating all the variables in the rule body with entities. In the rule mining process, each rule will have a weight to represent the quality of the rule. Therefore, for a query triple of n rules, assuming that the probability weight of each rule is α i , the reasoning result can be expressed as the weighted sum of the reasoning results of different rules:
[0058]
[0059] e x represents the entity inferred by the intermediate process, and r represents a relationship in the rule body. However, the above formula requires the use of a clear rule body relationship matrix M r In order to use the probability distribution obtained by decoding the rule generator to reason and avoid the huge rule search space, the above formula can be converted to the following form:
[0060]
[0061] Where T is the length of the rule body, α′ ij It represents the jth item in the probability distribution of the i-th relation in the rule body output by the rule generation unit, that is, the probability of the j-th relation in the i-th step, so the reasoning result can be further expressed in the form of expected calculation:
[0062] Y=e x ∏E M~Generator (M)
[0063] In order to model uncertainty information, this method redefines M r [i,j]=s represents a triple (e i ,r,e j ) has a confidence level s. The relationship matrix between the head entity and the rule body is calculated as follows:
[0064]
[0065] Among them, Y represents the probability distribution of the inference result. ij represents the probability value of the jth relationship generated by the rule generator in step i, e h represents the head entity vector, T represents the length of the rule body, and |R| represents the total number of relations in the uncertainty knowledge graph.
[0066] It should be noted that each item in the inference result Y at this time represents the weight of the corresponding entity as the inference result, which contains the confidence information in the inference path. If there are many paths to infer the entity and the confidence of the triples in the path is high, the weight of the inference result is also high and more reliable; when there are fewer inference paths or there are triples with low confidence in the path, it will lower the weight of the inference result, indicating that the inference result is unreliable.
[0067] This 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 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.
[0070] 3) The rule parser calculates the logical rules
[0071] The present invention designs a new rule parsing algorithm, which can sample high-quality rule bodies from rule distribution, namely, relation sequences r 1 ∧r 2 ∧...∧r T , as the rule mining result. The key to sampling high-quality rule bodies is to select entities and relations that can maximize the probability of true tail entities. Starting from the tail entity, the inference result of the entity weight vector can be expressed as:
[0072]
[0073] in, represents the inference result obtained using the rule body T steps ago, and the final inference result is represented by the sum of |R| |ε|-dimensional vectors. 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 tail entity in the corresponding vector will be selected as the Tth relationship. When the Tth relationship is selected, the inference result of the entity weight vector can be expressed as:
[0074]
[0075] where r T represents the Tth relation in the rule body, represents the weight coefficient of the T-th step relationship. It is further decomposed into [w 1 ,w 2 ,...,w |ε| ]·[m 1 ,m 2 ,...,m |ε| ]. i is a real number, |ε| is the number of entities in the uncertain knowledge graph, so the entity weight vector can be expressed as Repeat the above process until the head entity h in the query triple is parsed, and the complete reasoning path can be obtained. Replace the entities in the reasoning path with variables to obtain the reasoning rules for the query triple.
[0076] 4) Triple confidence calculation
[0077] The confidence prediction module receives the results of step 2) and step 3) as input, and first uses the large language model to convert the input into a sentence that conforms to the natural language form. Specifically, in response to the problem of non-standard entity and relation names in the knowledge graph, a task-specific prompt word 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 theminto 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.", and then the query triples and the text content in the logical rules are concatenated to the prompt word, and the entity and relation names (h′, r′, t′) that conform to the natural language expression are generated with the help of the large language model.
[0078] For the preprocessed query triple (h′, r′, t′) and its corresponding logical rule (h′, r′, t′)←(h′, r′, x′)∧(x′, inv_r′, t′), this method designs the template "[CLS]Question: h'r'what? Is the correct answer: t'? [SEP]Context: grounding rule[SEP].", and only needs to 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 embedded sequence: E 1 ,E 2 ,...,E n This method uses the CLS strategy to aggregate the features of the embedded sequence and generate a comprehensive feature representation. This feature representation not only considers the structural information of the triples, but also embeds the semantic information of the language model. Among them, the CLS strategy directly uses the hidden representation of the special symbol "[CLS]" in the BERT model as the input feature for confidence prediction.
[0079] For the feature representation of the position "[CLS]" in the input sequence, this method designs a feedforward neural network, inputs the generated feature representation into the feedforward neural network, and calculates the confidence score of the triple in the following way:
[0080] FNN(x)=W 1 (ReLU(W 2 x+b 2 ))+b 1
[0081] Among them, x represents the feature representation after aggregation, W 1 ∈R 4d×1 and W 2 ∈R d×4d Represents two weight matrices, b 1 and b 2 represents the bias term, ReLU(·)=max(0,·) represents the linear rectification function. FNN represents a feedforward neural network layer, and the output of the feedforward neural network is the predicted triple confidence.
[0082] At this point, the uncertainty knowledge graph reasoning task is completed. The present invention can not only predict the tail entity of the missing triple, but also give the triple a reliable confidence. Using this method, the link prediction index and confidence prediction index on the uncertainty knowledge graph datasets 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 invention. Those skilled in the art should understand that the present invention is not limited to the above specific embodiments. The above specific embodiments and the description in the specification are only for further illustrating the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of the present invention to be protected 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 in that: 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, calculate the confidence, and complete the uncertainty knowledge graph reasoning task.
2. The uncertainty knowledge graph reasoning method based on rule mining as claimed in claim 1 is characterized in that: In step 1), the rule mining task is converted into a sequence-to-sequence generation task, so as to apply the Vanilla Transformer architecture. The query triple is composed of a head entity h and a relation r, and is defined in the form of (h, r, ?). Before entering the rule generator, the head entity and relation are first converted from text format to vector representations h and r, and the input sequence S = h, r is obtained after concatenation and integration. The Transformer first performs query semantic encoding to obtain the encoding result S′ = h′, r′, and then uses it as context and uses a special start symbol <bos> , autoregressively generates the distribution of relations in the rule body, which is calculated as follows:< / bos> R t+1 =Softmax(MLP(CrossAttention(S′,S t ))) Where S t represents the input of the rule generation unit at step t, R t+1 represents the probability distribution of the relationship at step t+1, MLP represents a multi-layer perceptron, maps the dimension of the output attention vector to the number of relations in the uncertain knowledge graph, and uses the Softmax activation function to convert the input vector into a probability distribution. Repeat the above decoding process T times to obtain a rule body of length T. In order to generate rules more flexibly, an inverse triple (Y, inv) is added to each triple (X, r, Y) in the knowledge graph. r ,X); In order to generate variable length regular sequences, special symbols are used <slf>Pad the decoded sequence to a fixed length, <slf>Indicates a relationship pointing to itself, while inv r Represents the reverse relation of relation r, and finally performs a replacement operation on them.< / slf> < / slf> 3. The uncertainty knowledge graph reasoning method based on rule mining as claimed in claim 2 is characterized in that: 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 e i ∈{0,1} |ε| , the relationship is expressed as the adjacency matrix M r ∈{0,1} |ε|×|ε| , where M r [i,j]=s represents a triple (e i ,r,e j ) has a confidence level s, |ε| represents the number of entities in the uncertainty knowledge graph, and the relationship between the head entity and the rule body is calculated as follows: Among them, Y represents the probability distribution of the target tail entity, α ij represents the probability value of the jth relationship generated by the rule generator in step i, e h represents the head entity vector, T represents the length of the rule body, and |R| represents the total number of relations in the uncertainty knowledge graph. The following loss function is used to measure the gap between the predicted tail entity and the true label: loss=-log(max(γ,Y target )) where Y target represents the probability value of the true tail entity, γ 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 logarithmic 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.
4. The uncertainty knowledge graph reasoning method based on rule mining as claimed in claim 3 is characterized in that: In step 3), based on the tail entity predicted in step 2), the rule parser reversely decodes the complete reasoning path starting from the tail entity until the head entity h in the query triple is decoded, extracts the complete reasoning path, and replaces the entities in the reasoning path with specific variable names to obtain the reasoning rules for the query triple.
5. The uncertainty knowledge graph reasoning method based on rule mining as claimed in claim 4 is characterized in that: In step 4), for the tail entity and logical rule predicted in step 2) and step 3), the confidence prediction module takes the completed triple (h, r, t) and the logical rule as input and calculates the confidence of the triple in the following manner: i) First, we design task-specific prompt words: "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 the minto 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 concatenate the query triples and the text content in the logic rules to the prompt words, and use the large language model to convert non-standard, abbreviated or inconsistently formatted entity and relation names into clear and fluent natural language expressions, denoted as (h′, r′, t′). ii) For the query triple (h′, r′, t′) preprocessed in step i), and its corresponding logical rule (h′, r′, t′)←(h′, r′, x′)∧(x′, inv_r′, t′), design the template "[CLS]Question: h'r'what? Is the correct answer: t'? [SEP]Context: grounding rule[SEP].". Only by replacing the entities, relations and rules in the template can the query statement in natural language be obtained, and then the pre-trained language model BERT is used to encode the query statement to obtain the embedding sequence: E1, E2, ..., E n , 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 triple and language model. Among them, the CLS strategy directly uses the hidden representation of the special symbol "[CLS]" position in the BERT model as the input feature for confidence prediction. iii) For the feature representation of the "[CLS]" position, a feed-forward neural network is designed to calculate the confidence score of the triple in the following way: FNN(x)=W1(ReLU(W2x+b2))+n1 Among them, x represents the aggregated feature vector, W1 and W2 represent two weight matrices, b1 and b2 represent bias terms, and ReLU(·)=max(0,·) represents the linear rectification function.
6. 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 uncertain knowledge graph reasoning method based on rule mining as described in any one of claims 1 to 5 above.
7. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer instruction is executed by the processor, an uncertain knowledge graph reasoning method based on rule mining as described in any one of claims 1-5 is implemented.
Citation Information
Patent Citations
Knowledge graph completion method and device, storage medium and electronic equipment
CN112836064A
Knowledge graph triple reliability evaluation method, system and device and medium
CN115238582A
Knowledge graph completion method based on path and graph context
CN115795042A
Knowledge graph completion method and system based on triple global information interaction
CN117035080A
Neural symbol combined knowledge graph reasoning method
CN118469012A
Cited By
Quantum circuit enhanced knowledge graph reasoning method
CN122390039A
A quantum circuit enhanced knowledge graph reasoning method
CN122390039B