Temporal knowledge graph prediction method based on historical correlation and local frequency context

By combining historically relevant and local frequency context encoders with context-enhanced decoders, the problems of information loss and homogeneity prediction in existing technologies are solved, and more accurate temporal knowledge graph prediction is achieved.

CN121503603APending Publication Date: 2026-02-10HUAZHONG UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511331186.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-17
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

Existing representation-based temporal knowledge graph prediction methods fail to effectively utilize the specific temporal context of candidates, resulting in information loss or homogeneous predictions.

Method used

By employing a dual-attention mechanism—a history-related context encoder and a local frequency context encoder—and combining them with a context-enhanced decoder, we can capture the history-related paths and local frequency features of candidate options, thereby generating more accurate prediction results.

Benefits of technology

By modeling the historical relevance and local frequency context of the candidates, more accurate temporal knowledge graph predictions were achieved, improving the variability and accuracy of the predictions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121503603A_ABST
    Figure CN121503603A_ABST
Patent Text Reader

Abstract

The invention discloses a temporal knowledge graph prediction method based on historical correlation and local frequency context. The method comprises the following steps: 1) capturing historical correlation path information of candidate items to be predicted from a historical knowledge graph; 2) capturing local frequency characteristics by using a local frequency context encoder; and 3) fusing the historical path and the local frequency information, calculating a final score of each candidate entity, and taking the highest score as a final prediction result. Modeling is carried out on a specific tense context of the candidate item from two aspects: a historical related context and a local frequency context, so that more accurate prediction can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to knowledge graph technology, and more particularly to a temporal knowledge graph prediction method based on historical relevance and local frequency context. Background Technology

[0002] Existing representation-based temporal knowledge graph prediction (TKGF) methods indiscriminately utilize all relevant historical facts to construct temporal contexts for predicting candidate entities. They ignore candidate-specific temporal contexts, which may lead to severe information loss or homogeneous predictions.

[0003] To address this issue, a novel TKGF representation learning model is proposed, which models the candidate-specific tense context from two aspects: historical relevance context and local frequency context. Specifically, we design a historical relevance context encoder with a dual attention mechanism to encode the historical relevance path of the candidate, and employ a local frequency context encoder to capture local frequency features in repeated facts. Then, we apply a context-enhanced decoder to combine previously generated information to achieve more accurate predictions. Experiments on six benchmark datasets validate the effectiveness of the proposed model, and further analysis reveals that CRAFT can effectively achieve differential prediction by utilizing tense context information. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a temporal knowledge graph prediction method based on historical relevance and local frequency context, which addresses the shortcomings of the existing technology.

[0005] The technical solution adopted by this invention to solve its technical problem is: a temporal knowledge graph prediction method based on historical relevance and local frequency context, comprising the following steps: 1) Capture historical path information of the candidates to be predicted from the historical knowledge graph; 1.1) Data preprocessing: Generate historical related paths and candidate entities; For each query Find possible candidate entities and generate historically relevant paths for these candidates; the historically relevant paths are the association trajectories between the candidate entities and the query entity s in the historical knowledge graph; in, For the timestamp of the query, Represents an entity; 1.2) Evolutionary characterization encoding; For timestamps Query The length of the front is Historical knowledge graph sequence For length of Encode the historical knowledge graph sequence to obtain Evolutionary representation of time; 1.3) Temporal rule encoding; The obtained evolutionary representations are used to encode temporal rules; 1.4) Integrate historical related paths and generate aggregated path representations; A dual attention mechanism is employed to integrate historically relevant paths and generate aggregated path representations; specifically as follows: For each rule-reachable candidate and its applicable rule set The paths are sorted in descending order based on their scores from the corresponding historical paths, and the top n paths are aggregated. in, To be applicable to candidate entities The set of rules; From the time rules of encoding Extract the rule representations corresponding to these n paths to obtain the path matrix of candidate o. ; in, Timestamp The time rule representation matrix corresponding to the following relation r; For each relevant path, semantic alignment attention and time-aware attention are used to capture important temporal context information; Semantic alignment attention aims to enhance contextual features relevant to query candidate entities, which we achieve by capturing the association between paths and candidate entities. Due to the differences between path and entity representations, we employ a linear layer to transform the path representation into a shared space. Contextual information is time-sensitive. Therefore, time-aware attention is used to simulate the temporal validity of context. After obtaining the two attention representations, multi-head attention (which enables the model to focus on important contextual features) is used to generate the final candidate specific aggregation path representation. :

[0006] in, and These are learnable parameters; [;] indicates a vector concatenation operation; 2) Capture local frequency features using a local frequency context encoder; For query Due to the temporal validity of the facts, the occurrence of events in the local sequence is calculated with a window size of w. Frequency of query candidates Furthermore, we restrict the subject entities and relations of the facts to be the same as those in the query. We obtain a query-specific historical local frequency representation by accumulating aggregations on timestamps. :

[0007] in, This indicates the historical frequency of querying q at timestamp i, and Norm represents the normalization operation. 3) Integrate historical path and local frequency information to calculate the final score for each candidate entity, and use the highest score as the final prediction result.

[0008] According to the above scheme, step 1.1) is as follows: First, historical relevant paths of candidates are generated by mining and applying temporal logic rules. The temporal logic rules are defined as follows:

[0009] in, Indicates the rule header, Represents the rule body; and These represent entity and timestamp variables, respectively. Indicates a relationship; For a given query relation First, the corresponding rule set is obtained through rule mining. This rule set will be used for temporal rule encoding; Subsequently, for each temporal rule By grounding the rule body, reachable target entities are searched to obtain a set of rule-reachable candidate entities. ; Each candidate Corresponding to a set of applicable rules The grounding results of these groups of applicable rules constitute the historical relevant paths of the entity.

[0010] According to the above scheme, step 1.3) is as follows: Given a query To obtain the corresponding relation rule set For each rule Extract the relationship chain from the rule body , where l represents the length of the relation chain; For all time rules, based on the embedding matrix The evolutionary representation of the relationships is obtained by extracting the vector of each relationship chain to obtain the relationship chain tensor. ,in, Represents the maximum length of the relation chain; matrix for Time-relationship evolution representation; The relation chain tensor is encoded using a gated recurrent unit (GRU) to obtain a regular representation matrix. :

[0011] in, Z represents the zero matrix.

[0012] According to the above scheme, in step 1.4), a linear layer is used to convert the path representation into a shared space, and the semantic alignment attention is calculated as follows:

[0013] in, and These are learnable parameters. Indicates candidate o at timestamp The representation in; Subsequently, the path representation Weighting is performed to obtain a semantically aligned aggregate representation. :

[0014] in, The corresponding weights.

[0015] According to the above scheme, in step 1.4), time-aware attention is used to simulate the temporal validity of the context.

[0016] For each candidate o, take the timestamp of the first edge of the first n historically related paths to obtain a timestamp vector. The temporal validity of facts decays over time. An exponential distribution is used to simulate this decay, and then the path representation is weighted to obtain a time-aware aggregate representation. Time-perception attention and time-aware aggregation The calculation is as follows:

[0017]

[0018] in, This is the timestamp of the first edge. The decay rate parameter, Time-aware attention weights.

[0019] According to the above scheme, in step 3), the fraction is calculated as follows: ConvTransE is used to obtain the decoding score. The association score only captures the relevance between the query condition and the candidates. Based on this, the local frequency score considers local historical frequency information, masking candidates that have not appeared in the local history. The calculation methods for the two scores are as follows:

[0020]

[0021] Where ConvTransE represents a convolution-based knowledge graph embedding model, and ⊙ represents element-wise multiplication; For related scores, For local frequency fractions, For timestamps The entity embedding matrix below; For timestamps The relational embedding vector below; Furthermore, we compute the aggregation path score by utilizing the aggregation path representation of specific candidates. :

[0022] For candidates that cannot be reached by any rules, we will [take appropriate action]. Set it to the zero vector, and finally obtain the aggregated path score vector. We then weighted the scores to calculate the final scores for the candidates. :

[0023] in, ; This represents the softmax activation function. These are the weighting coefficients corresponding to each score; and .

[0024] The beneficial effects of this invention are: This invention models the temporal context of candidates from two aspects: historical relevant context and local frequency context, which can achieve more accurate prediction. Attached Figure Description

[0025] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the accompanying drawings: Figure 1 This is a flowchart of a method according to an embodiment of the present invention. Detailed Implementation

[0026] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0027] like Figure 1 As shown, a temporal knowledge graph prediction method based on historical relevance and local frequency context includes the following steps: 1) Extract and encode query-related path information from historical knowledge graphs, and capture contextual information in the historically relevant paths of the candidate options to be predicted. 1.1) Data preprocessing: Generate historical related paths and candidate entities; For each query That is ("in time") The system identifies potential candidate entities (who the target entity is associated with through relation r) and generates historically relevant paths for these candidates. These historically relevant paths are the association trajectories between the candidate entities and the query entity s in the historical knowledge graph. First, historical relevant paths of candidates are generated by mining and applying temporal logic rules. The temporal logic rules are defined as shown in Equation 1: (1) in, Indicates the rule header, Represents the rule body; and These represent entity and timestamp variables, respectively. Indicates a relationship; For a given query relation First, the corresponding rule set is obtained through rule mining. This rule set will be used for temporal rule encoding; (e.g., "If s is associated with e1 through r1 in T1, and e1 is associated with o through r2 in T2, then s is associated with o through r in T3"). Subsequently, for each temporal rule By grounding the rule body, reachable target entities are searched to obtain a set of rule-reachable candidate entities. ; Each candidate Corresponding to a set of applicable rules The grounding results of these applicable rules constitute the historical relevant paths of an entity.

[0028] In addition, we calculate a score for each pair of related paths and candidates to facilitate path aggregation.

[0029] 1.2) Evolutionary characterization encoding; For timestamps Query The length of the front is Historical knowledge graph sequence For length of Encode the historical knowledge graph sequence to obtain Evolutionary representation of time; TKG entities and relationships change over time and must be queried within the specified time frame. The historical knowledge graph of entities and relationships is used to generate dynamic evolutionary representations. The initial representations of entities and relations are respectively represented as follows: and , where d represents the dimension of the embedding; The historical knowledge graph (KG) evolves in chronological order, utilizing recurrent graph convolutional networks (RGCNs) to capture intra-graph structural dependencies and employing a temporal gated recurrent (TGR) module to capture inter-graph temporal order patterns. (2) (3) (4) (5) Among them, timestamp . and They were set to R and H respectively.

[0030] 1.3) Temporal rule encoding; The obtained evolutionary representations are used to encode temporal rules; Given a query To obtain the corresponding relation rule set For each rule Extract the relationship chain from the rule body , where l represents the length of the relation chain; For all time rules, based on the embedding matrix The evolutionary representation of the relationships is obtained by extracting the vector of each relationship chain to obtain the relationship chain tensor. ,in, Represents the maximum length of the relation chain; matrix for The evolution of time-relationships is represented as follows: Chains that are too short are padded to facilitate batch processing.

[0031] The relation chain tensor is encoded using a gated recurrent unit (GRU) to obtain a regular representation matrix. : (6) in, Z represents the zero matrix.

[0032] It is worth noting that we use the output of the loop unit corresponding to the rule length as the representation of the rule.

[0033] 1.4) Integrate historical related paths and generate aggregated path representations; A dual attention mechanism is employed to integrate historically relevant paths and generate aggregated path representations; for each rule reachable candidate... and its applicable rule set The paths are sorted in descending order based on their scores from the corresponding historical paths, and the top n paths are aggregated. From the time rules of encoding Extract the rule representations corresponding to these n paths to obtain the path matrix of candidate o. ; For each relevant path, semantic alignment attention and time-aware attention are used to capture important temporal contextual information.

[0034] Semantic alignment attention aims to enhance contextual features relevant to query candidate entities, which we achieve by capturing the association between paths and candidate entities. Due to the differences between path and entity representations, we employ a linear layer to transform the path representation into a shared space. The semantic alignment attention is computed as follows: (7) in, and These are learnable parameters. Indicates candidate o at timestamp The path representation is then weighted to obtain a semantically aligned aggregate representation: (8) Contextual information is time-sensitive. Therefore, time-aware attention is used to simulate the temporal validity of context.

[0035] For each candidate o, take the timestamp of the first edge of the first n historically related paths to obtain a timestamp vector. Intuitively, the temporal validity of facts decays over time, and we use an exponential distribution to model this decay. Similarly, we weight the path representation to obtain a time-aware aggregate representation. The time-aware attention and time-aware aggregate representation are computed as follows: (9) (10) After obtaining the two attention representations, we employ multi-head attention (enabling the model to focus on important contextual features) and generate the final candidate specific aggregation path representation: (11) in and These are learnable parameters. [;] indicates a vector concatenation operation.

[0036] 2) Capture local frequency features using a local frequency context encoder; For query Due to the temporal validity of the facts, the occurrence of events in the local sequence is calculated with a window size of w. Frequency of query candidates Furthermore, we restrict the subject entities and relations of the facts to be the same as those in the query. We obtain a query-specific historical local frequency representation by accumulating aggregations on timestamps. : (12) in, This indicates the historical frequency of querying q at timestamp i, and Norm represents the normalization operation.

[0037] 3) Integrate historical path and local frequency information to calculate the final score for each candidate entity, and use the highest score as the final prediction result.

[0038] ConvTransE is used to obtain the decoding score. The association score only captures the relevance between the query condition and the candidates. Based on this, the local frequency score considers local historical frequency information, masking candidates that have not appeared in the local history. The calculation methods for the two scores are as follows: (13) (14) Here, ⊙ denotes element-wise multiplication. Furthermore, we calculate the aggregation path score by utilizing the aggregation path representation of specific candidates: (15) For candidates that cannot be reached by any rules, we will [take appropriate action]. Set it to the zero vector, and finally obtain the aggregated path score vector. We then weighted the scores to calculate the final scores for the candidates: (16) in, ; and ; This represents the softmax activation function.

[0039] It should be understood that those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

Claims

1. A temporal knowledge graph prediction method based on historical relevance and local frequency context, characterized in that, Includes the following steps: 1) Capture historical path information of the candidates to be predicted from the historical knowledge graph; 1.1) Data preprocessing: Generate historical related paths and candidate entities; For each query Find possible candidate entities and generate historically relevant paths for these candidates; the historically relevant paths are the association trajectories between the candidate entities and the query entity s in the historical knowledge graph; in, For the timestamp of the query, Represents an entity; 1.2) Evolutionary characterization encoding; For timestamps Query The length of the front is Historical knowledge graph sequence For length of Encode the historical knowledge graph sequence to obtain Evolutionary representation of time; 1.3) Temporal rule encoding; The obtained evolutionary representations are used to encode temporal rules; 1.4) Integrate historical related paths and generate aggregated path representations; A dual attention mechanism is employed to integrate historically relevant paths and generate aggregated path representations; specifically as follows: For each rule-reachable candidate and its applicable rule set The paths are sorted in descending order based on their scores from the corresponding historical paths, and the top n paths are aggregated. in, To be applicable to candidate entities The set of rules; From the time rules of encoding Extract the rule representations corresponding to these n paths to obtain the path matrix of candidate o. ; in, Timestamp The time rule representation matrix corresponding to the following relation r; For each relevant path, semantic alignment attention and time-aware attention are used to capture important temporal context information; Semantic alignment attention aims to enhance contextual features relevant to query candidate entities, which we achieve by capturing the association between paths and candidate entities. Due to the differences between path and entity representations, we employ a linear layer to transform the path representation into a shared space. Using time-aware attention to simulate the temporal validity of context; After obtaining the two attention representations, multi-head attention is used to generate the final candidate specific aggregation path representation; 2) Capture local frequency features using a local frequency context encoder; For query Due to the temporal validity of the facts, the occurrence of events in the local sequence is calculated with a window size of w. Frequency of query candidates A query-specific historical local frequency representation is obtained by accumulating and aggregating on timestamps. : in, This indicates the historical frequency of querying q at timestamp i, and Norm represents the normalization operation. 3) Integrate historical path and local frequency information to calculate the final score for each candidate entity, and use the highest score as the final prediction result.

2. The temporal knowledge graph prediction method based on historical relevance and local frequency context according to claim 1, characterized in that, Step 1.1) is as follows: First, historical relevant paths of candidates are generated by mining and applying temporal logic rules. The temporal logic rules are defined as follows: in, Indicates the rule header, Represents the rule body; and These represent entity and timestamp variables, respectively. Indicates a relationship; For a given query relation First, the corresponding rule set is obtained through rule mining. This rule set will be used for temporal rule encoding; Subsequently, for each temporal rule By grounding the rule body, reachable target entities are searched to obtain a set of rule-reachable candidate entities. ; Each candidate Corresponding to a set of applicable rules The grounding results of these groups of applicable rules constitute the historical relevant paths of the entity.

3. The temporal knowledge graph prediction method based on historical relevance and local frequency context according to claim 1, characterized in that, Step 1.3) is as follows: Given a query To obtain the corresponding relation rule set For each rule Extract the relationship chain from the rule body , where l represents the length of the relation chain; For all time rules, based on the embedding matrix The evolutionary representation of the relationships is obtained by extracting the vector of each relationship chain to obtain the relationship chain tensor. ,in, Represents the maximum length of the relation chain; matrix for Time-relationship evolution representation; The relation chain tensor is encoded using gated recurrent units to obtain the rule representation matrix. : in, Z represents the zero matrix.

4. The temporal knowledge graph prediction method based on historical relevance and local frequency context according to claim 1, characterized in that... In step 1.4), a linear layer is used to convert the path representation into a shared space, and the semantic alignment attention is calculated as follows: in, and These are learnable parameters. Indicates candidate o at timestamp The representation in; Subsequently, the path representation Weighting is performed to obtain a semantically aligned aggregate representation. : in, The corresponding weights.

5. The temporal knowledge graph prediction method based on historical relevance and local frequency context according to claim 1, characterized in that... In step 1.4), time-aware attention is used to simulate the temporal validity of the context. For each candidate o, take the timestamp of the first edge of the first n historically related paths to obtain a timestamp vector. The temporal validity of facts decays over time. An exponential distribution is used to simulate this decay, and then the path representation is weighted to obtain a time-aware aggregate representation. Time-perception attention and time-aware aggregation The calculation is as follows: in, This is the timestamp of the first edge. The decay rate parameter, Time-aware attention weights.

6. The temporal knowledge graph prediction method based on historical relevance and local frequency context according to claim 1, characterized in that... In step 3), the fraction is calculated as follows: ConvTransE is used to obtain the decoding score. The association score only captures the relevance between the query condition and the candidates. Based on this, the local frequency score considers local historical frequency information, masking candidates that have not appeared in the local history. The calculation methods for the two scores are as follows: Where ConvTransE represents a convolution-based knowledge graph embedding model, and ⊙ represents element-wise multiplication; For related scores, For local frequency fractions, For timestamps The entity embedding matrix below; For timestamps The relational embedding vector below; Aggregate path scores are calculated by utilizing the aggregate path representations of specific candidates. : For candidates that cannot be reached by any rules, we will [take appropriate action]. Set it to the zero vector, and finally obtain the aggregated path score vector. ; The scores are weighted to calculate the final score for each candidate. : in, ; This represents the softmax activation function. These are the weighting coefficients corresponding to each score; and .

7. An electronic device, characterized in that, include: One or more processors; as well as Storage device for storing one or more programs. Wherein, when the one or more programs are executed by the one or more processors, the one or more processors perform the method according to any one of claims 1 to 6.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 6.