A temporal knowledge graph reasoning method based on a specific query flow graph model

By adding anti -relationships and self -sidelines in the timing knowledge map, and using the graph attention to the mechanism network for reasoning, it solves the problem of weak explanatory explanatory explanatory and unable to predict the longer path in the existing technology. Prediction of time -order knowledge diagram.

CN116304105BActive Publication Date: 2025-01-24NORTHWESTERN POLYTECHNICAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310302582.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-27
Publication Date
2025-01-24
Estimated Expiration
2043-03-27

AI Technical Summary

Technical Problem

The prior art has problems in timing knowledge graph prediction that there is a problem that the explanation is weak, the long path cannot be predicted well, and specific inference paths are provided.

Method used

Adopt the timing knowledge diagram reasoning method based on a specific query stream diagram model. By adding anti -relationships and self -sidelines in the time -order knowledge map, a new knowledge map is constructed, and the relationship between the mechanism network aggregation physical nodes is used. Multiple sampling and aggregation to obtain the score of the query results.

Benefits of technology

It achieves highly interpretable time series knowledge graph prediction, which can predict long paths well and provide specific reasoning paths.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116304105B_ABST
    Figure CN116304105B_ABST
Patent Text Reader

Abstract

The present invention provides a temporal knowledge graph reasoning method based on a specific query flow graph model, which belongs to the technical field of temporal knowledge graph reasoning. The method comprises: constructing a knowledge graph Q, extracting all nodes (e) containing the entity to be searched from the knowledge graph Q, q ,t q ), and construct the subgraph #imgabs0# to sample the subgraph #imgabs1#. After sampling, the entity node information and the entity to be searched e q The time information and relationship information between nodes are aggregated into the neighbor node u; the neighbor node set is set as the node set to be queried, and the sampling and aggregation process is repeated to realize the time series knowledge graph reasoning; the nodes in the last layer are selected, and the node score of each node is calculated. The node with the highest score is the reasoning result. This method is highly interpretable, can well predict longer paths and provide specific reasoning paths.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of temporal knowledge graph reasoning, and specifically relates to a temporal knowledge graph reasoning method based on a specific query flow graph model. Background Art

[0002] In daily life and business management, decisions are often made based on expectations. For example, the financial industry needs to predict future industry trends to make investments, and students need to choose the right major based on market changes.

[0003] The knowledge graph describes the knowledge or facts in the objective world in a structured form. It is essentially a graph-based semantic network consisting of nodes (entities) and directed edges (relationships). In the knowledge graph, each node represents an "entity" that exists in the real world. Each directed edge links a head entity and a tail entity, and carries a label that represents the "relationship" between the two, represented by a relationship triple (head entity, relationship, tail entity). Due to actual industrial needs and the storage of a large number of knowledge facts, the scale of the knowledge graph has grown significantly. Although the knowledge graph contains millions of entities and triples, they are far from complete compared with the existing facts and newly added knowledge in the real world. Therefore, how to complete or even infer new knowledge based on the constructed knowledge graph containing limited entities and relationships, given partial information, has become a hot topic in industry and academia. Knowledge graph link prediction is a technology developed to solve this problem.

[0004] At the same time, knowledge in the real world will evolve and update over time, which is reflected in the knowledge graph as the emergence of new entities and the disappearance of old entities or the establishment and removal of relationships, which greatly increases the difficulty of prediction. Existing work ignores the temporal characteristics of knowledge graphs, resulting in inaccurate and unreasonable embedding representations learned. Therefore, it is necessary to expand the static knowledge graph to a time-series knowledge graph with a time dimension, add timestamp tags, and integrate time-series information into knowledge graph learning and prediction, effectively reflecting the characteristics of entities and relationships changing dynamically over time.

[0005] There are currently three main approaches to predicting time series knowledge graphs: the first uses reinforcement learning to derive reasoning paths related to queries to infer answers, the second focuses on using graph neural networks to recursively capture snapshots of the entire network and update structural relationships, and the third uses a subgraph-based model to capture local information while reducing computational overhead.

[0006] However, the first method based on reinforcement learning can only obtain a single reasoning path due to the characteristics of random walk in reinforcement learning. However, the derivative development of events is often cross-influenced by multiple factors, so a single path cannot model the evolution and development of events well. The second method based on graph neural network mostly uses full graph information for updating, resulting in low computational efficiency and high computational overhead. The third method based on subgraph mostly uses central information graph to evenly expand the local structure, aggregates longer dependency information to query nodes, and predicts answers through information query nodes and explored candidate nodes. This method has weak interpretability and cannot well predict longer paths and provide specific reasoning paths.

[0007] In summary, the existing technology has the problem that the method of temporal knowledge graph prediction based on subgraphs has weak interpretability and cannot well predict longer paths and provide specific reasoning paths. Summary of the invention

[0008] In order to overcome the deficiencies of the above-mentioned prior art, the present invention provides a temporal knowledge graph reasoning method based on a specific query flow graph model.

[0009] In order to achieve the above object, the present invention provides the following technical solutions:

[0010] A temporal knowledge graph reasoning method based on a specific query flow graph model, comprising:

[0011] Quadruple in the temporal knowledge graph <e o ,r,e s , t> add anti-relation quadruple in the dataset <e s , R reverse , e o , t> and the self-linking edge relationship quadruple <e,R self ,e,t>, forming a new temporal knowledge graph quadruple dataset;

[0012] All the quadruple in the new temporal knowledge graph quadruple dataset <e o , R, e s , t> becomes a triplet <(e o ,t0),r,(e s , t s )>, build a new knowledge graph Q;

[0013] The reasoning process of a specific query flow graph model is:

[0014] For the tuple to be predicted <e q , r q , e qq , t q >, extract all nodes containing the entity to be searched in the new knowledge graph Q (e q, t q ), and the extracted triples form a subgraph Pair of subgraphs Sampling is performed to obtain the entity node to be searched (e q , t q )’s neighbor node set V = {(e i , t′)} and the edge set R′={r i},e i ≠e q ; Add an inverse relationship to each entity in the subgraph and update the set R′={r i , R reverse}, the entity node to be searched (e q , t q ) is added to the set V, and a self-linking edge relationship is added to each entity in the subgraph to update R′={r i , R reverse , R self};

[0015] For each neighbor node u in the set V, add the node vector of the aggregation time and entity information to the corresponding relationship vector, and aggregate the relationship between entity nodes through the graph attention mechanism network;

[0016] Set the neighbor node set V to the node set to be queried U = {(e q , t q )}, for the subgraph The query result scores obtained after multiple sampling and aggregation, the entity node with the highest score is used as the inference result;

[0017] Where e is any entity, e o is the head entity, e q is the entity to be searched, e s is the tail entity, e i is the i-th entity, r is the relationship between entities, R reverse is an inverse relationship, R self is a self-linking relationship, R is r, R reverse and R self The general term for i for e i With e q relationship, t is the current time, t0 is the appearance time of the head entity, t s is the appearance time of the tail entity, t q is the time when the entity to be searched appears, t′ is e i The time of appearance.

[0018] Furthermore, the anti-relationship quadruple <e s , R reverse , e o, t> and the self-linking edge relationship quadruple <e,R self ,e,t>, including:

[0019] Construct an entity dictionary and a relationship dictionary;

[0020] Traverse each tuple in the existing temporal knowledge graph four-tuple data set. If the entity node in the tuple has not appeared in the entity dictionary, put the entity node into the entity dictionary; if the relationship in the tuple has not appeared in the relationship dictionary, put the relationship into the relationship dictionary until the traversal is completed;

[0021] Each entity in the entity dictionary is numbered starting from 0, and the number is used as the ID label of the entity; each relationship in the relationship dictionary is numbered starting from 0, and the number is used as the ID label of the relationship;

[0022] Put the anti-relation into the relation dictionary and give it a digital ID label. If it exists in the temporal knowledge graph quadruple dataset, <e o ,R,e s ,t>tuple, then construct the anti-relational quadruple <e s ,R reverse , e o , t>

[0023] Each entity e and each self-linking edge relationship R owned by entity e self Put it into the relationship dictionary to construct a self-linking edge relationship quadruple <e,R self ,e,t>.

[0024] Furthermore, all the quadruple in the new temporal knowledge graph quadruple dataset are <e o ,R,e s , t> becomes a triple <(e o ,t0),r,(e s ,t s )>, including:

[0025] The quad <e o ,r,e s ,t> head entity e o and tail entity e s Respectively with the head entity e o The appearance time and tail entity e s The appearance time is paired to form a new head entity node (e o , t0) and the new tail entity node (e s ,t s );

[0026] Use the relationship r between entities to convert the head entity node (e o, t0) and the tail entity node (e s ,t s ) to realize the quadruple <e o ,R,e s ,t> becomes a triple <(e o ,t0),r,(e s ,t s )>.

[0027] Furthermore, it also includes:

[0028] Using the Word2Vector model, the triple <(e o ,t0),r,(e s ,t s )> all entity nodes and the relationships between entities are vectorized, and the text information is converted into feature vectors with a mapping dimension of d=128.

[0029] Further, the pair of subgraphs Sampling is performed to obtain the entity node to be searched (e q ,t q )’s neighbor node set V = {(e i , t′)} and the edge set R′={r i},include:

[0030] Subgraphs are sorted according to temporal probability Perform multiple sampling to obtain the set of neighbor nodes V = {(e i , t′)} and the edge set R′={r i}; wherein the calculation formula of the time probability is:

[0031]

[0032] In the formula, P is the time probability, α is the hyperparameter, and t q To find the time when the entity node appears, t′ is e i The appearance time of t″ is the time label of any tuple.

[0033] Furthermore, the determination of the node vector of the aggregation time and entity information includes:

[0034] Construct the time word vector, the expression is:

[0035]

[0036] Among them, Φ(t1) is the time word vector, d is the dimension of the time word vector, ω is the learnable period, is the learnable phase value, t1 is the time of the sampled neighbor node relative to the entity node to be searched;

[0037] will be relative to the entity to be searched e q The time word vector of is concatenated into the node word vector of the neighbor node u to obtain a 256-dimensional neighbor node vector;

[0038] The 256-dimensional neighbor node vector is input into the fully connected neural network, and a 128-dimensional neighbor node vector with aggregated time and entity node information is obtained by compression; the 128-dimensional neighbor node vector is constructed as follows:

[0039]

[0040] in, is the 128-dimensional neighbor node vector that aggregates time and entity node information, h u is a 256-dimensional neighbor node vector, and MLP is a fully connected neural network.

[0041] Furthermore, the relationship between the entity nodes aggregated by the graph attention mechanism network is expressed as:

[0042]

[0043]

[0044] in, Neighbor nodes that aggregate time information, entity information, and relationship information. is the parameter of the graph attention mechanism network, l is the current query layer number, is the weight matrix of the model layer l, h r is the embedding of the relationship connected to u, δ is the ReLU activation function, V is the set of neighbor nodes, is the embedding representation of the neighbor node after the l-1 layer update; W is used to associate the current node, and w is used to score the node association degree. is the embedding representation of the query relation after l layers of updates, is the embedding of the relationship connected to u after l layers of update, σ is the sigmoid function, and T is the transpose operator.

[0045] Furthermore, the expression for scoring the query result is:

[0046] f(v,q)=w T h v (q)

[0047] Among them, w is a learnable parameter, f(v,q) represents the score of the correctness of the answer to be predicted for node v. The higher the score, the higher the probability that node v is the correct answer. v (q) is the inference result node vector, and T is the transposition symbol.

[0048] The temporal knowledge graph reasoning method based on a specific query flow graph model provided by the present invention has the following beneficial effects:

[0049] The present invention proposes a specific query flow graph model for knowledge graph link prediction. The model starts from the entity node to be queried and selects the nodes from the subgraph according to the time probability. Extract neighbor nodes of the entity node to be queried, and connect the extracted nodes with relationship vectors. After connection, embed the time relative to the entity node to be queried and the relationship information between each connected node into the extracted node to obtain neighbor nodes with aggregated time information, entity node information, and relationship information; when the time of all nodes in the neighbor node V with aggregated time information, entity node information, and relationship information is the set time relative to the time of the entity node to be queried, stop sampling; at this time, all nodes and the connection relationships between nodes together constitute an inference prediction graph, select the neighbor node set V with aggregated time information, entity node information, and relationship information in the inference prediction graph for the last time, use the learnable parameters to multiply the node vectors in the neighbor node set V, and obtain the node score of each node. The node with the highest score is the answer node corresponding to the entity node to be queried, and the inference process is realized.

[0050] In the present invention, multiple entity nodes are passed from the query node to the answer node, and relationship vectors are connected between the nodes. The relationship between the nodes can be judged through the relationship vector, and the relationship path can reflect how the query node is inferred to the answer node, that is, it can intuitively reflect the specific reasoning path from the query node to the answer node. This method has strong interpretability, can well predict longer paths and provide specific reasoning paths. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the embodiment of the present invention and its design scheme, the following briefly introduces the drawings required for this embodiment. The drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0052] Figure 1 A schematic diagram of a temporal knowledge graph reasoning method based on a specific query flow graph model according to an embodiment of the present invention;

[0053] Figure 2 It is a schematic diagram of the reasoning process of the present invention. DETAILED DESCRIPTION

[0054] In order to enable those skilled in the art to better understand the technical solution of the present invention and implement it, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the scope of protection of the present invention.

[0055] Example:

[0056] The present invention provides a temporal knowledge graph reasoning method based on a specific query flow graph model, specifically as follows Figure 1 As shown, including:

[0057] Quadruple in the temporal knowledge graph <e o ,r,e s , t> add anti-relation quadruple in the dataset <e s , R reverse , e o , t> and the self-linking edge relationship quadruple <e,R self , e, t>, forming a new temporal knowledge graph quadruple data set; all quadruple in the new temporal knowledge graph quadruple data set <e o , R, e s , t> becomes a triple <(e o ,t0),r,(e s , t s )>, build a new knowledge graph Q.

[0058] The reasoning process of a specific query flow graph model is:

[0059] For the tuple to be predicted <e q , r q , e qq , t q >, extract all nodes containing the entity to be searched in the new knowledge graph Q (e q , t q ), and the extracted triples form a subgraph Pair of subgraphs Sampling is performed to obtain the entity node to be searched (e q , t q )’s neighbor node set V = {(e i , t′)} and the edge set R′={r i},e i ≠e q ; Add an inverse relationship to each entity in the subgraph and update the set R′={r i , R reverse}, the entity node to be searched (e q , t q ) is added to the set V, and a self-linking edge relationship is added to each entity in the subgraph to update R′={ri , R reverse , R self}; For each neighbor node u in the set V, add the node vector of the aggregation time and entity information to the corresponding relationship vector, and aggregate the relationship between entity nodes through the graph attention mechanism network; Set the neighbor node set V to the query node set U = {(e q , t q )}, for the subgraph After multiple sampling and aggregation, the query result scores are obtained, and the entity node with the highest score is used as the inference result; where e is any entity, e o is the head entity, e q is the entity to be searched, e s is the tail entity, e i is the i-th entity, r is the relationship between entities, R reverse is an inverse relationship, R self is a self-linking relationship, R is r, R reverse and R self The general term for i for e i With e q relationship, t is the current time, t0 is the appearance time of the head entity, t s is the appearance time of the tail entity, t q is the time when the entity to be searched appears, t′ is e i The time of appearance.

[0060] The following are the specific implementation details of the method of the present invention:

[0061] S1. Data preprocessing, database expansion, adding anti-relationships and self-linking edge relationships.

[0062] The specific process is as follows:

[0063] S101. Construct an entity dictionary and a relationship dictionary.

[0064] S102. Traverse each tuple in the existing temporal knowledge graph four-tuple (head entity, relationship, tail entity, time) data set. If the entity in the tuple (head entity or tail entity) has not appeared in the entity dictionary, put the entity into the entity dictionary. If the relationship in the tuple has not appeared in the relationship dictionary, put the relationship into the relationship dictionary until the traversal is completed.

[0065] S103. Number each entity in the entity dictionary starting from 0, and use the number as the ID tag of the entity; number each relationship in the relationship dictionary starting from 0, and use the number as the ID tag of the relationship;

[0066] S104. In addition, the present invention designs a corresponding inverse relationship R for each relationship.reverse , and put the inverse relationship into the relationship dictionary and give it a digital ID label. <e o , R, e s , t>, then we construct a corresponding <e s , R reverse , e o , t>tuple, the purpose of this is to expand the data.

[0067] S105. At the same time, the present invention designs a self-linking edge relationship R self , each entity e has a self-connected edge relationship with itself, and several corresponding <e,R self ,e,t> tuple, the purpose of this is to introduce attention to itself in S4.

[0068] After preprocessing, we obtain the newly constructed first time series knowledge graph quadruple, which will be used as the input data of the present invention. <e q , r q , e qq , t q > is also passed into the model as input, where e q , r q , t q is the given query information, e qq Represents the unknown entity to be predicted.

[0069] S2. Construct an inference prediction graph based on the augmented dataset:

[0070] S201. All four tuples <e o , R, e s , the head entity node e in t> o and tail entity node e s Paired with their respective appearance times to form a new head entity node (e o , t0) and the new tail entity node (e s ,t s ); form different network nodes, and the relationships in the time series knowledge graph (i.e., the relationships between entity nodes) form the edges of the network. The network structure changes from the four-tuple in the original data set to the three-tuple <(e o ,t0),r,(e s , t s )>Get the updated temporal knowledge graph Q.

[0071] S202. Next, the Word2Vector model is used to vectorize all nodes and edges, converting the text information into feature vectors that can be recognized by a specific query flow graph model, and the mapping dimension is d=128.

[0072] S3. Sub-graph sampling:

[0073] S301. Based on the initial input tuple to be predicted <e q ,r q ,e qq ,t q >, extract all entities e in Q that contain the entity to be searched q The subgraph composed of triples of (The node contains e q The set of triples of .

[0074] S302. According to the time probability (Formula 1), Perform k samplings to obtain the set V of the l-order neighbor node u = {(e i , t′)}(e i ≠e q ) and the edge set R′={r i}.

[0075]

[0076] Among them, P is the time probability, α is the hyperparameter, and t q is a given time, t′ is e i The time of occurrence of t″ is the time label of any tuple. The timestamp in the tuple to be sampled is the same as the given time t q The smaller the gap, the easier it is to be selected.

[0077] S303. For the new subgraph obtained by sampling, Supplement the inverse relation update R′={r i ,r reverse}.

[0078] S304. Add node (e q , t q ) to the set V, and for each entity in the subgraph, add a self-linking edge relationship to update R′={r i ,r ireverse , r iself}.

[0079] S4. Subgraph update:

[0080] S401. Aggregate entity node information, time information and relationship information for each node u of the subgraph, specifically:

[0081] Time embedding. First, construct the time word vector according to formula 2:

[0082]

[0083] Among them, Φ(t1) is the time vector, d is the dimension of the time word vector, ω is the learnable period, is the learnable phase value, and t1 is the time of the sampled neighbor node relative to the entity node to be searched.

[0084] Then, according to Formula 3, the time vector is concatenated to the node word vector to obtain a 256-dimensional vector, which is then compressed through a fully connected network (MLP) to obtain a 128-dimensional node vector that aggregates entity embedding and time embedding. The details of Formula 3 are as follows:

[0085] h u (q) = MLP(h u ||φ(t)) Formula 3

[0086] Among them, among them, is the 128-dimensional neighbor node vector that aggregates time and entity node information, h u is a 256-dimensional neighbor node vector, and MLP is a fully connected neural network.

[0087] S402. Relationship embedding: According to Formula 4, the node vector of aggregated time and entity node information is added to the corresponding relationship vector, and the relationship information is aggregated through the graph attention mechanism network. The details of Formula 4 are as follows:

[0088]

[0089] From formula 5, we get:

[0090]

[0091] in, Neighbor nodes that aggregate time information, entity information, and relationship information. is the parameter of the graph attention mechanism network, l is the current query layer number, is the weight matrix of the model layer l, h r is the embedding of the relationship connected to u, δ is the ReLU activation function, V is the set of neighbor nodes, is the embedding representation of the neighbor node after the l-1 layer update; W is used to associate the current node, and w is used to score the node association degree. is the embedding representation of the query relation after l layers of updates, is the embedding of the relationship connected to u after l layers of update, σ is the sigmoid function, and T is the transpose symbol.

[0092] W is used to associate the current node with the path to be predicted, and w is used to score its relevance. A high relevance score means that the current entity, node and prediction problem are highly correlated, and vice versa.

[0093] S5. Set the obtained neighbor node set V as the node set to be queried U, and repeat steps S3-S4.

[0094] S6. After the first layer of aggregation, the query results are scored according to the following formula:

[0095] f(v,q)=w T h v (q) Formula 6

[0096] Among them, w is a learnable parameter, f(v, q) represents the score of the correctness of the answer to be predicted for node v. The higher the score, the higher the probability that node v is the correct answer. v (q) is the inference result node vector.

[0097] S7. Continuously update the parameters through the multi-classification log-loss loss function:

[0098]

[0099] in, is the score for the correct answer, is the estimated score of all entities predicted as answers.

[0100] The specific query flow graph model of the present invention starts from the entity node to be queried, uses directed time edge sampling to perform reasoning evolution, uses the attention mechanism network to aggregate the node relationship information in the inferred reasoning graph, and infers future facts by evaluating the local reasoning structure; at the same time, before aggregating the node relationship information in the reasoning graph, the entity node to be queried is added to the neighbor node set V, and the self-edge relationship and the reverse relationship are added to the edge set R′; adding the reverse relationship can, on the one hand, expand the training data and have more data training samples, and on the other hand, it can fully learn the positive and reverse relationships between the two entities, so that the model can better understand the interaction logic between the two entities; adding the self-edge relationship can, on the one hand, timely update the information of the entity itself, and on the other hand, realize data expansion; through the reverse relationship and the self-edge relationship, the model can better learn the interaction logic between the nodes.

[0101] Compared with the prior art, the present invention has a stronger ability to capture local structures and can provide explainable evidence for inference results.

[0102] Comparison table of effectiveness of the algorithm of the present invention Table 1

[0103]

[0104] Table 1 is a comparison table of the effectiveness of the algorithms of the present invention. It can be seen that the model of the present invention has the best effect among all the models.

[0105] The following is the algorithm pseudo code of the present invention:

[0106]

[0107] The above embodiments are only preferred specific implementation methods of the present invention, and the protection scope of the present invention is not limited thereto. Any simple changes or equivalent replacements of the technical solutions that can be obviously obtained by any technician familiar with the field within the technical scope disclosed in the present invention belong to the protection scope of the present invention.

Claims

1. A temporal knowledge graph reasoning method based on a specific query flow graph model, characterized in that: include: Quadruple in the temporal knowledge graph <e o ,r,e s ,t>Add anti-relation quadruple in the dataset <e s ,R reverse ,e o ,t> and self-linking edge relationship quadruple <e,R self ,e,t>, forming a new temporal knowledge graph quadruple dataset; All the quadruple in the new temporal knowledge graph quadruple dataset <e o ,R,e s ,t> becomes a triple <(e o ,t0),r,(e s ,t s )>, build a new knowledge graph Q; use the Word2Vector model to analyze the triples <(e o ,t0),r,(e s ,t s )> all entity nodes and the relationships between entities are vectorized, and the text information is converted into feature vectors; The reasoning process of a specific query flow graph model is: For the tuple to be predicted <e q ,r q ,e qq ,t q >, extract all nodes containing the entity to be searched in the new knowledge graph Q (e q ,t q ), and the extracted triples form a subgraph Pair of subgraphs Sampling is performed to obtain the entity node to be searched (e q ,t q )’s neighbor node set V = {(e i ,t′)} and the edge set R′={r i },e i ≠e q ; Add an inverse relationship to each entity in the subgraph and update the set R' = {r i , R reverse }, the entity node to be searched (e q ,t q ) is added to the set V, and a self-linking relationship is added to each entity in the subgraph to update R'={r i ,R reverse ,R self }; For each neighbor node u in the set V, add the node vector of the aggregation time and entity information to the corresponding relationship vector, and aggregate the relationship between entity nodes through the graph attention mechanism network; Set the neighbor node set V to the node set to be queried U = {(e q ,t q )}, for the subgraph The query result scores obtained after multiple sampling and aggregation, the entity node with the highest score is used as the inference result; Where e is any entity, e o is the head entity, e q is the entity to be searched, e s is the tail entity, e i is the i-th entity, r is the relationship between entities, R reverse is an inverse relationship, R self is a self-linking relationship, R is r, R reverse and R self The general term for i for e i With e q relationship, t is the current time, t0 is the appearance time of the head entity, t s is the appearance time of the tail entity, t q is the time when the entity to be searched appears, t′ is e i The time of appearance; Pair of subgraphs Sampling is performed to obtain the entity node to be searched (e q ,t q )’s neighbor node set V = {(e i ,t′)} and the edge set R′={r i },include: Subgraphs are sorted according to temporal probability Perform multiple sampling to obtain the set of neighbor nodes V = {(e i ,t′)} and the edge set R′={r i }; wherein the calculation formula of the time probability is: In the formula, P is the time probability, α is the hyperparameter, and t q To find the time when the entity node appears, t′ is e i The appearance time of t” is the time label of any tuple.

2. According to claim 1, a temporal knowledge graph reasoning method based on a specific query flow graph model is characterized in that: The anti-relationship quad <e s ,R reverse ,e o ,t> and self-linking edge relationship quadruple <e,R self ,e,t>, including: Construct an entity dictionary and a relationship dictionary; Traverse each tuple in the existing temporal knowledge graph four-tuple data set. If the entity node in the tuple has not appeared in the entity dictionary, put the entity node into the entity dictionary; if the relationship in the tuple has not appeared in the relationship dictionary, put the relationship into the relationship dictionary until the traversal is completed; Each entity in the entity dictionary is numbered starting from 0, and the number is used as the ID label of the entity; each relationship in the relationship dictionary is numbered starting from 0, and the number is used as the ID label of the relationship; Put the anti-relation into the relation dictionary and give it a digital ID label. If it exists in the temporal knowledge graph quadruple dataset, <e o ,R,e s ,t>tuple, then construct the anti-relational quadruple <e s ,R reverse ,e o ,t>; Each entity e and each self-linking edge relationship R owned by entity e self Put it into the relationship dictionary to construct a self-linking edge relationship quadruple <e,R self ,e,t>.

3. According to claim 1, a temporal knowledge graph reasoning method based on a specific query flow graph model is characterized in that: All the quadruple in the new temporal knowledge graph quadruple dataset are <e o ,R,e s ,t> becomes a triple <(e o ,t0),r,(e s ,t s )>, including: The quad <e o ,r,e s ,t> head entity e o and tail entity e s Respectively with the head entity e o The appearance time and tail entity e s The appearance time is paired to form a new head entity node (e o ,t0) and the new tail entity node (e s ,t s ); Use the relationship r between entities to convert the head entity node (e o ,t0) and the tail entity node (e s ,t s ) to realize the quadruple <e o ,R,e s ,t> becomes a triple <(e o ,t0),r,(e s ,t s )>.

4. According to claim 1, a temporal knowledge graph reasoning method based on a specific query flow graph model is characterized in that: The determination of the node vector of the aggregation time and entity information includes: Construct a time word vector, the expression is: Among them, Φ(t1) is the time word vector, d is the dimension of the time word vector, ω is the learnable period, is the learnable phase value, t1 is the time of the sampled neighbor node relative to the entity node to be searched; will be relative to the entity to be searched e q The time word vector of is concatenated into the node word vector of the neighbor node u to obtain a 256-dimensional neighbor node vector; The 256-dimensional neighbor node vector is input into the fully connected neural network, and a 128-dimensional neighbor node vector with aggregated time and entity node information is obtained by compression; the 128-dimensional neighbor node vector is constructed as follows: in, is the 128-dimensional neighbor node vector that aggregates time and entity node information, h u is a 256-dimensional neighbor node vector, and MLP is a fully connected neural network.

5. According to claim 1, a temporal knowledge graph reasoning method based on a specific query flow graph model is characterized in that: The relationship between the entity nodes aggregated by the graph attention mechanism network is expressed as: in, Neighbor nodes that aggregate time information, entity information, and relationship information. is the parameter of the graph attention mechanism network, l is the current query layer number, is the weight matrix of the model layer l, h r is the embedding of the relationship connected to u, δ is the ReLU activation function, V is the set of neighbor nodes, is the embedding representation of the neighbor node after the l-1 layer update; W is used to associate the current node, and w is used to score the node association degree. is the embedding representation of the query relation after l layers of updates, is the embedding of the relationship connected to u after l layers of update, σ is the sigmoid function, and T is the transpose operator.

6. According to claim 1, a temporal knowledge graph reasoning method based on a specific query flow graph model is characterized in that: The expression for scoring the query result is: f(v,q)=w T h v (q) Among them, w is a learnable parameter, f(v,q) represents the score of the correctness of the answer to be predicted for node v. The higher the score, the higher the probability that node v is the correct answer. v (q) is the inference result node vector, and T is the transposition symbol.

Citation Information

Patent Citations

  • Knowledge graph reasoning method and device for concerning neighbor entities

    CN110929047A

  • Time sequence knowledge graph completion method and system based on metric learning

    CN115599927A