A multi-element fact-driven time knowledge graph completion method
Patent Information
- Application Number
- CN202411064261.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2044-08-05
AI Technical Summary
[0007]现有的模型如CyGNet建模查询历史中重复发生的事实,RE-NET、GLANet和EvoExplore尝试在每个历史子图中聚合实体的局部或全局邻域事实,然而这些模型都只利用了一类历史事实,即与查询相关的历史事实或实体相关的邻域事实;查询相关的历史事实涉及到与特定查询直接相连的历史事件,这些信息直接反映了查询实体和相应关系的历史背景,而实体相关的邻域事实则包括了知识图谱中各个实体自初始至查询时刻的所有历史记录,这些事实不仅丰富了实体的内涵,还提供了与查询紧密相关的背景信息;由于传统只利用了一类历史事实,导致时间知识图谱补全的效果不佳,进而影响利用时间知识图谱建模得到的模型的模型性能
[0050] A temporal knowledge graph completion model is created by using a query history encoder, an entity history encoder, a query history evolution module, an entity history evolution module, a history fusion module, and a decoder. A loss function is set for the temporal knowledge graph completion model. Then, a large amount of historical knowledge graph data is preprocessed and labeled to construct a dataset. The temporal knowledge graph completion model is trained based on the dataset and the loss function. Finally, temporal knowledge graph completion is performed based on the trained model. The query history encoder is used to aggregate historical facts related to the query entity in the query to obtain the query embedding; the entity history encoder is used to aggregate all entities e in the temporal knowledge graph t. qThe system uses the historical facts of one-hop neighbors in the first n subgraphs to obtain entity embeddings; the query history evolution module evolves the output of the query history encoder according to the time series to obtain the query embedding representation; the entity history evolution module evolves the output of the entity history encoder according to the time series to obtain the entity embedding representation; the history fusion module fuses the outputs of the query history evolution module and the entity history evolution module to obtain the query entity embedding; the decoder decodes the output of the history fusion module to obtain the query-related candidate entity probabilities of the time knowledge graph, and outputs the query prediction result based on the candidate entity probabilities; that is, the time knowledge graph completion model can fuse query-related historical facts and entity-related neighborhood facts, which greatly improves the comprehensiveness of time knowledge graph completion, and thus greatly improves the model performance of the model obtained by modeling using time knowledge graph.
Smart Images

Figure CN119226524B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of knowledge graph technology, and in particular to a method for completing a time-based knowledge graph driven by multiple facts. Background Technology
[0002] Knowledge graphs can be used to store large amounts of human knowledge and facts, storing knowledge and facts in triples (e.g., tuples). s ,r,e o The form is represented as ), where e s 'r' represents the header entity, 'r' represents the relation, and 'e' represents the header entity. o This represents a tail entity, such as (Yao*, nationality, China). Currently, many large-scale knowledge graphs have been built in this field, such as WIKI and YAGO. These knowledge graphs contain massive amounts of information and can provide data support for downstream applications, such as intelligent question-answering robots and recommendation algorithms. However, these knowledge graphs still suffer from various fact gaps, which has spurred the development of knowledge graph completion technology.
[0003] The goal of knowledge graph completion is to automate the completion of factual information in a knowledge graph using machine learning, thereby reducing manual annotation. Knowledge graph completion is divided into static knowledge graph completion and dynamic knowledge graph completion.
[0004] For static knowledge graphs, translation models such as TransE and TransH project entities and relations into a low-dimensional vector space, modeling relations as translation vectors between entities. In this vector space, the translation model calculates the vector coordinates of the tail entity from the vectors of the head entity and the relation, and uses these coordinates for fact completion. The RESCAL model proposed by Bordes et al. is a type of tensor decomposition model, where triples exist in the form of tensors. By decomposing tensors, the potential structure and patterns between entities and relations are learned. However, RESCAL faces the challenge of an excessive number of parameters. To address this issue, researchers subsequently proposed the DistMult model, which simplifies the representation of the relation matrix. ComplEx uses complex numbers to model entity and relation representations, solving the problems of symmetry and asymmetry in entity embedding.
[0005] In practical applications, much information changes over time, and traditional static knowledge graphs cannot accurately reflect this dynamism. For example, a person may have different occupations or geographical locations at different points in time, and such changes are difficult to describe using a static knowledge graph. Therefore, constructing a dynamic knowledge graph with time attributes, i.e., a temporal knowledge graph (TKG), is more practically meaningful. Temporal knowledge graph completion (TKGC) is a completion task for TKGs, which can be specifically divided into inference and extrapolation tasks.
[0006] In temporal knowledge graphs, historical facts are a key factor to consider for completion, especially in extrapolation tasks, where in-depth mining and understanding of historical data becomes particularly important. A temporal knowledge graph is not a single, monolithic structure, but rather divided into multiple smaller graphs, also called subgraphs, based on timestamps. Each subgraph records facts that occurred at the same time, and entities exist in multiple subgraphs. Entities in different subgraphs possess different structural information, i.e., neighborhood information. This difference reveals the temporal changes in entity features. By modeling this dynamic feature, models can achieve more accurate temporal knowledge graph completion.
[0007] Existing models such as CyGNet model recurring facts in query history, while RE-NET, GLANet, and EvoExplore attempt to aggregate local or global neighborhood facts of entities in each historical subgraph. However, these models only utilize one type of historical fact: query-related historical facts or entity-related neighborhood facts. Query-related historical facts involve historical events directly connected to a specific query, reflecting the historical context of the query entity and its corresponding relationships. Entity-related neighborhood facts, on the other hand, include all historical records of each entity in the knowledge graph from its initial state to the query time. These facts not only enrich the entity's connotation but also provide background information closely related to the query. Because traditional models only utilize one type of historical fact, the completion effect of the temporal knowledge graph is poor, which in turn affects the performance of models obtained by using temporal knowledge graphs.
[0008] Therefore, how to provide a time knowledge graph completion method based on multiple facts to improve the comprehensiveness of time knowledge graph completion has become an urgent technical problem to be solved. Summary of the Invention
[0009] The technical problem to be solved by this invention is to provide a time knowledge graph completion method based on multiple facts to improve the comprehensiveness of time knowledge graph completion.
[0010] This invention is implemented as follows: a time-based knowledge graph completion method driven by multiple facts, comprising the following steps:
[0011] Step S1: Create a temporal knowledge graph completion model based on the query history encoder, entity history encoder, query history evolution module, entity history evolution module, history fusion module and decoder, and set the loss function of the temporal knowledge graph completion model;
[0012] Step S2: Obtain a large number of historical knowledge graphs, preprocess and annotate each of the historical knowledge graphs, and then construct a dataset;
[0013] Step S3: Train the time knowledge graph completion model based on the dataset;
[0014] Step S4: Perform time knowledge graph completion operation based on the trained time knowledge graph completion model.
[0015] Furthermore, in step S1, the query history encoder is used to process the query (e q ,r q ,? ,t q In this context, historical facts related to the query entity are aggregated using attention to obtain the query embedding:
[0016]
[0017] Among them, e q Represents the query entity; r q Indicates the query relationship; ? indicates the query embedding to be generated; t q This indicates the q-th query time. Indicates querying entity e q In t i Query embedding at a given time; n represents the number of entities; o i Represents the i-th query entity e q And query relationship r q Neighbor information; N i This indicates that the entity e is obtained from the first i subgraphs of the time knowledge graph and is related to the query entity e. q And query relationship r q Related tail entity embedding; W v W q W k Both represent the parameter matrices used for attention, and d represents the entity embedding dimension; T represents the transpose; softmax() represents the normalized exponential function.
[0018] Furthermore, in step S1, the entity history encoder is used to aggregate all entities e in the time knowledge graph at time t. q The entity embedding is obtained by analyzing the historical facts of one-hop neighbors in the first n subgraphs. The specific process is as follows:
[0019] Split entity e into k blocks:
[0020] e k =eG k ;
[0021] Among them, e k Let e represent the entity in the k-th block; e represents an entity in the temporal knowledge graph, including the query entity; G k Let k be the vector space. Let d represent the entity embedding dimension; n represent the number of entities; t represent the number of entities. q This indicates the q-th query time.
[0022] For each of the e k Perform chunked transmission:
[0023] msg k =W1[r k ||e k ];
[0024] Among them, msg k e k The message being delivered; r k This represents a block embedding indicating a relationship between two entities e; W1 represents the parameter matrix; || represents the concatenation operation;
[0025] Calculate the different messages using graph attention. k The importance coefficients are used to concatenate the neighbor embeddings:
[0026]
[0027] Where, α k The k-th importance coefficient is represented by exp(); the natural exponential function is represented by LeakeyReLU(); the linear rectified function is represented by W2; the parameter matrix is represented by msg. i e i The message being delivered; This represents the neighbor embedding obtained by the neighbor entity o through the l-layer block graph attention embedding; This represents the neighbor embedding obtained by embedding the k-th neighbor entity through the l-1 layer block graph attention.
[0028] Based on the above And e obtains entity embedding:
[0029]
[0030] in, Indicates t i Entity embedding at time; N t (e) indicates the embedding of the tail entity associated with e; This represents the neighbor embedding obtained by the neighbor entity o through the l-1 layer block graph attention embedding.
[0031] Furthermore, in step S1, the query history evolution module is used to evolve the output of the query history encoder according to the time series to obtain the query embedding representation:
[0032]
[0033] The entity history evolution module is used to evolve the output of the entity history encoder according to the time series to obtain the entity embedding representation:
[0034]
[0035] Where GRU() represents the gated loop unit function; Indicates querying entity e q In t i Query embedding at any given moment; Indicates t i The query embedding representation obtained through time-series evolution; Indicates t i-1 The query embedding representation obtained through time-series evolution; Indicates t i Entity embedding at a specific moment; Indicates t i The entity embedding representation obtained through time-series evolution; Indicates t i-1 The entity embedding representation obtained through time-mapping evolution.
[0036] Furthermore, in step S1, the history fusion module is used to fuse the outputs of the query history evolution module and the entity history evolution module to obtain the query entity embedding:
[0037]
[0038] in, Indicates query entity embedding; β represents the adaptive function; sigmoid() represents the activation function; w g The parameter matrix used for attention is represented by ||; the concatenation operation is represented by ||.
[0039] Furthermore, in step S1, the decoder is used to decode the output of the historical fusion module to obtain the probability of candidate entities related to the query, and outputs the prediction result of the query based on the candidate entity probability:
[0040]
[0041] Wherein, p(o'|e q ,r q ,t q ) represents a query to a time-based knowledge graph (e q ,r q ,? ,t q The relevant candidate entity probability; o' represents the candidate entity; e q Represents the query entity; r q Indicates the query relationship; t qIndicates the q-th query time; ? indicates the query embedding to be generated; sigmoid() represents the activation function; ConvTransE() represents the decoding function; This indicates the embedding of the query entity output by the historical fusion module; Indicates t i The entity embedding representation obtained through time-mapping evolution.
[0042] Furthermore, in step S1, the formula for the loss function is:
[0043] Loss = -∑∑log p;
[0044] Where Loss represents the loss value of the loss function; p represents the probability of candidate entities related to the query of the time knowledge graph.
[0045] Furthermore, step S2 specifically includes:
[0046] A large number of historical knowledge graphs are acquired, and each of the historical knowledge graphs is preprocessed, including at least null value handling, data standardization, data merging and missing value handling. The preprocessed historical knowledge graphs are then labeled, and a dataset is constructed based on the labeled historical knowledge graphs.
[0047] Furthermore, step S3 specifically includes:
[0048] The dataset is divided into a training set and a validation set based on a preset ratio. The time knowledge graph completion model is trained using the training set until the loss value of the loss function is less than a preset loss threshold. Then, the time knowledge graph completion model is validated using the validation set to determine whether the completion accuracy is greater than a preset accuracy threshold. If yes, the training ends; otherwise, the training set is expanded and training continues.
[0049] The advantages of this invention are:
[0050] A temporal knowledge graph completion model is created by using a query history encoder, an entity history encoder, a query history evolution module, an entity history evolution module, a history fusion module, and a decoder. A loss function is set for the temporal knowledge graph completion model. Then, a large amount of historical knowledge graph data is preprocessed and labeled to construct a dataset. The temporal knowledge graph completion model is trained based on the dataset and the loss function. Finally, temporal knowledge graph completion is performed based on the trained model. The query history encoder is used to aggregate historical facts related to the query entity in the query to obtain the query embedding; the entity history encoder is used to aggregate all entities e in the temporal knowledge graph t. qThe system uses the historical facts of one-hop neighbors in the first n subgraphs to obtain entity embeddings; the query history evolution module evolves the output of the query history encoder according to the time series to obtain the query embedding representation; the entity history evolution module evolves the output of the entity history encoder according to the time series to obtain the entity embedding representation; the history fusion module fuses the outputs of the query history evolution module and the entity history evolution module to obtain the query entity embedding; the decoder decodes the output of the history fusion module to obtain the query-related candidate entity probabilities of the time knowledge graph, and outputs the query prediction result based on the candidate entity probabilities; that is, the time knowledge graph completion model can fuse query-related historical facts and entity-related neighborhood facts, which greatly improves the comprehensiveness of time knowledge graph completion, and thus greatly improves the model performance of the model obtained by modeling using time knowledge graph. Attached Figure Description
[0051] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0052] Figure 1 This is a flowchart of a time-based knowledge graph completion method driven by multiple facts according to the present invention.
[0053] Figure 2 This is a flowchart illustrating a time-based knowledge graph completion method driven by multiple facts according to the present invention. Detailed Implementation
[0054] The technical solution in this application embodiment has the following general idea: A time knowledge graph completion operation is performed based on a time knowledge graph completion model including a query history encoder, an entity history encoder, a query history evolution module, an entity history evolution module, a history fusion module, and a decoder; the query history encoder is used to perform attention aggregation on historical facts related to the query entity in the query to obtain the query embedding; the entity history encoder is used to aggregate all entities e in time knowledge graph t. q The system uses the historical facts of one-hop neighbors in the first n subgraphs to obtain entity embeddings; the query history evolution module evolves the output of the query history encoder according to the time series to obtain the query embedding representation; the entity history evolution module evolves the output of the entity history encoder according to the time series to obtain the entity embedding representation; the history fusion module fuses the outputs of the query history evolution module and the entity history evolution module to obtain the query entity embedding; the decoder decodes the output of the history fusion module to obtain the probability of candidate entities related to the query in the time knowledge graph, and outputs the prediction result of the query based on the probability of candidate entities; that is, the time knowledge graph completion model can fuse the historical facts related to the query and the neighborhood facts related to the entity to improve the comprehensiveness of the time knowledge graph completion.
[0055] Please refer to Figures 1 to 2 As shown, a preferred embodiment of the present invention, a time-based knowledge graph completion method driven by multiple facts, includes the following steps:
[0056] Step S1: Create a temporal knowledge graph completion model based on the query history encoder, entity history encoder, query history evolution module, entity history evolution module, history fusion module and decoder, and set the loss function of the temporal knowledge graph completion model;
[0057] The query history encoder and entity history encoder are used to perform attention aggregation on historical information of different categories, respectively; the query history evolution module, entity history evolution module and history fusion module are used to evolve entity features in time series and learn the potential semantic information of entities in the entire historical context; the decoder is used to calculate candidate entity scores and give predicted entities, that is, to give the probability of candidate entities related to the query of the time knowledge graph and make predictions based on the candidate entity probabilities.
[0058] Step S2: Obtain a large number of historical knowledge graphs, preprocess and annotate each of the historical knowledge graphs, and then construct a dataset;
[0059] Step S3: Train the time knowledge graph completion model based on the dataset;
[0060] Step S4: Perform time knowledge graph completion operation based on the trained time knowledge graph completion model.
[0061] In step S1, the query history encoder is used to process the query (e) q ,r q ,? ,t q In this context, historical facts related to the query entity are aggregated using attention to obtain the query embedding:
[0062]
[0063] o i =(N i W v softmax((N) i W q ) T (N i W k ));
[0064]
[0065] Among them, e q Represents the query entity; r q Indicates the query relationship; ? indicates the query embedding to be generated; tq This indicates the q-th query time. Indicates querying entity e q In t i Query embedding at a given time; n represents the number of entities; o i Represents the i-th query entity e q And query relationship r q Neighbor information; N i This indicates that the entity e is obtained from the first i subgraphs of the time knowledge graph and is related to the query entity e. q And query relationship r q Related tail entity embedding; W v W q W k Both represent the parameter matrices used for attention, and d represents the entity embedding dimension; T represents the transpose; softmax() represents the normalized exponential function.
[0066] Attention aggregation through the query history encoder helps the temporal knowledge graph completion model learn the relationship with the query entity e. q And query relationship r q Directly relevant historical background information.
[0067] In step S1, the entity history encoder is used to aggregate all entities e in time knowledge graph t. q The entity embedding is obtained by analyzing the historical facts of one-hop neighbors in the first n subgraphs. The specific process is as follows:
[0068] Split entity e into k blocks:
[0069] e k =eG k ;
[0070] Among them, e k Let e represent the entity in the k-th block; e represents an entity in the temporal knowledge graph, including the query entity; G k Let k be the vector space. Let d represent the entity embedding dimension; n represent the number of entities; t represent the number of entities. q This indicates the q-th query time.
[0071] For each of the e k Perform chunked transmission:
[0072] msg k =W1[r k ||e k ];
[0073] Among them, msg k e kThe message being delivered; r k This represents a block embedding indicating a relationship between two entities e; W1 represents the parameter matrix; || represents the concatenation operation;
[0074] In order to aggregate the attribute characteristics of entities in a fine-grained manner, message passing is carried out in a chunked manner;
[0075] Calculate the different messages using graph attention. k The importance coefficients are used to concatenate the neighbor embeddings:
[0076]
[0077] Where, α k The k-th importance coefficient is represented by exp(); the natural exponential function is represented by LeakeyReLU(); the linear rectified function is represented by W2; the parameter matrix is represented by msg. i e i The message being delivered; This represents the neighbor embedding obtained by the neighbor entity o through the l-layer block graph attention embedding; This represents the neighbor embedding obtained by embedding the k-th neighbor entity through the l-1 layer block graph attention.
[0078] Based on the above And e obtains entity embedding:
[0079]
[0080] in, Indicates t i Entity embedding at time; N t (e) indicates the embedding of the tail entity associated with e; This represents the neighbor embedding obtained by the neighbor entity o through the l-1 layer block graph attention embedding.
[0081] Aggregating one-hop neighbor history facts through the entity history encoder helps enrich the embedding information of entity e; the embedding of entity e includes the attribute features of various aspects of an entity. An entity e has various relationships with other entities e, and different relationships focus on different aspects of entity e; taking (Newton, discipline, ?) as an example, the focus should be on the discipline information related to the entity Newton, rather than information such as Newton's family relationships. Existing methods typically perform neighbor aggregation on a unit basis, but entity embeddings are composed of various attribute features, i.e., different aspects of the entity. This invention aggregates the speech information of various aspects of an entity with weights according to specific relationships, amplifying relevant attribute features and weakening irrelevant attribute features. To this end, the entity history encoder performs graph attention aggregation of entities in blocks to achieve fine-grained aggregation.
[0082] In step S1, the query history evolution module is used to evolve the output of the query history encoder according to the time series to obtain the query embedding representation:
[0083]
[0084] The entity history evolution module is used to evolve the output of the entity history encoder according to the time series to obtain the entity embedding representation:
[0085]
[0086] Where GRU() represents the gated loop unit function; Indicates querying entity e q In t i Query embedding at any given moment; Indicates t i The query embedding representation obtained through time-series evolution; Indicates t i-1 The query embedding representation obtained through time-series evolution; Indicates t i Entity embedding at a specific moment; Indicates t i The entity embedding representation obtained through time-series evolution; Indicates t i-1 The entity embedding representation obtained through time-mapping evolution.
[0087] To further utilize the information of entities in different subgraphs, this invention employs GRU() to perform forgetting and remembering on different facts of the same entity in the time series, in order to capture the historical evolution pattern of entities in different subgraphs.
[0088] In step S1, the history fusion module is used to fuse the outputs of the query history evolution module and the entity history evolution module to obtain the query entity embedding:
[0089]
[0090] in, This represents the query entity embedding; β represents the adaptive function used to balance the impact of the two types of historical information, i.e., adaptively adjusting the weights of the two types of historical information; sigmoid() represents the activation function; w g The parameter matrix used for attention is represented by ||; the concatenation operation is represented by ||.
[0091] In step S1, the decoder decodes the output of the historical fusion module to obtain the probability of candidate entities related to the query, and outputs the prediction result of the query based on the candidate entity probability.
[0092]
[0093] Wherein, p(o'|e q ,r q ,t q ) represents a query to a time-based knowledge graph (e q ,r q ,? ,t q The relevant candidate entity probability; o' represents the candidate entity; e q Represents the query entity; r q Indicates the query relationship; t q Indicates the q-th query time; ? indicates the query embedding to be generated; sigmoid() represents the activation function; ConvTransE() represents the decoding function; This indicates the embedding of the query entity output by the historical fusion module; Indicates t i The entity embedding representation obtained through time-mapping evolution.
[0094] This invention uses ConvTransE() as a decoder to calculate the scores of candidate entities. It utilizes convolutional neural networks to enhance the traditional TransE model, enabling it to more effectively capture the complex relationships between entities and their relationships, and providing a more powerful and flexible method for embedding and reasoning in temporal knowledge graphs.
[0095] In step S1, the formula for the loss function is:
[0096] Loss = -∑∑log p;
[0097] Where Loss represents the loss value of the loss function; p represents the probability of candidate entities related to the query of the time knowledge graph.
[0098] For a query (s,r,o,t), when predicting the head / tail, the head / tail entities are masked. The training objective is to maximize the reduction of loss, aiming to give high scores to correct facts and low scores to incorrect facts. The formula is:
[0099]
[0100] Where, ζ t This represents a subgraph of the time knowledge graph at time t.
[0101] Step S2 specifically involves:
[0102] A large number of historical knowledge graphs are acquired, and each of the historical knowledge graphs is preprocessed, including at least null value handling, data standardization, data merging and missing value handling. The preprocessed historical knowledge graphs are then labeled, and a dataset is constructed based on the labeled historical knowledge graphs.
[0103] Step S3 specifically involves:
[0104] The dataset is divided into a training set and a validation set based on a preset ratio. The time knowledge graph completion model is trained using the training set until the loss value of the loss function is less than a preset loss threshold. Then, the time knowledge graph completion model is validated using the validation set to determine whether the completion accuracy is greater than a preset accuracy threshold. If yes, the training ends; otherwise, the training set is expanded and training continues.
[0105] In summary, the advantages of this invention are:
[0106] A temporal knowledge graph completion model is created by using a query history encoder, an entity history encoder, a query history evolution module, an entity history evolution module, a history fusion module, and a decoder. A loss function is set for the temporal knowledge graph completion model. Then, a large amount of historical knowledge graph data is preprocessed and labeled to construct a dataset. The temporal knowledge graph completion model is trained based on the dataset and the loss function. Finally, temporal knowledge graph completion is performed based on the trained model. The query history encoder is used to aggregate historical facts related to the query entity in the query to obtain the query embedding; the entity history encoder is used to aggregate all entities e in the temporal knowledge graph t. q The system uses the historical facts of one-hop neighbors in the first n subgraphs to obtain entity embeddings; the query history evolution module evolves the output of the query history encoder according to the time series to obtain the query embedding representation; the entity history evolution module evolves the output of the entity history encoder according to the time series to obtain the entity embedding representation; the history fusion module fuses the outputs of the query history evolution module and the entity history evolution module to obtain the query entity embedding; the decoder decodes the output of the history fusion module to obtain the query-related candidate entity probabilities of the time knowledge graph, and outputs the query prediction result based on the candidate entity probabilities; that is, the time knowledge graph completion model can fuse query-related historical facts and entity-related neighborhood facts, which greatly improves the comprehensiveness of time knowledge graph completion, and thus greatly improves the model performance of the model obtained by modeling using time knowledge graph.
[0107] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A time-based knowledge graph completion method driven by multiple facts, characterized in that: Includes the following steps: Step S1: Create a temporal knowledge graph completion model based on the query history encoder, entity history encoder, query history evolution module, entity history evolution module, history fusion module and decoder, and set the loss function of the temporal knowledge graph completion model; Step S2: Obtain a large number of historical knowledge graphs, preprocess and annotate each of the historical knowledge graphs, and then construct a dataset; Step S3: Train the time knowledge graph completion model based on the dataset; Step S4: Perform time knowledge graph completion operation based on the trained time knowledge graph completion model; In step S1, the query history encoder is used to process the query. In this process, historical facts related to the queried entity are aggregated using attention to obtain the query embedding: ; ; ; in, Indicates the entity being queried; Indicates the query relationship; ? indicates the query embedding to be generated; Indicates the first One query time; Indicates the query entity exist The query embedding at any given time; n represents the number of entities; Represents the i-th query entity and query relationship Neighbor information; This indicates retrieving and querying entities from the first i subgraphs of the temporal knowledge graph. and query relationship Neighbor information; This indicates retrieving and querying entities from the first i subgraphs of the temporal knowledge graph. and query relationship Related tail entity embedding; Both represent the parameter matrices used for attention, and , Let d represent a real number, d represent the entity embedding dimension, and T represent the transpose. This represents the normalized exponential function; The entity history encoder is used to aggregate all entities e in the time-based knowledge graph. The entity embedding is obtained by analyzing the historical facts of one-hop neighbors in the first n subgraphs. The specific process is as follows: Split entity e into k blocks: ; in, Let e represent the entity in the k-th block; e represents an entity in the time knowledge graph, including the query entity. Let k be the vector space. , Let d represent a real number; n represent the entity embedding dimension; d represents the number of entities. Indicates the first One query time; For each of the above Perform chunked transmission: ; in, express The message being delivered; A block embedding that indicates a relationship between two entities e; Represents the parameter matrix; Indicates a splicing operation; Using graph attention to compute different... The importance coefficients are used to concatenate the neighbor embeddings: ; ; in, The k-th importance coefficient is represented by exp(); exp() represents the natural exponential function. Represents a linear rectified function; Represents the parameter matrix; express The message being delivered; Indicates that the neighboring entity o passes through Neighbor embeddings obtained from layered block graph attention embedding; Indicates that the k-th neighboring entity passed through Neighbor embeddings obtained from layered block graph attention embedding; Based on the above And e obtains entity embedding: ; in, express Entity embedding at a specific moment; This indicates the embedding of the tail entity associated with 'e'; Indicates that the neighboring entity o passes through Neighbor embeddings obtained from layered block graph attention embedding.
2. The time-based knowledge graph completion method based on multiple facts as described in claim 1, characterized in that: In step S1, the query history evolution module is used to evolve the output of the query history encoder according to the time series to obtain the query embedding representation: ; The entity history evolution module is used to evolve the output of the entity history encoder according to the time series to obtain the entity embedding representation: ; in, This represents a gated loop unit function; Indicates the query entity exist Query embedding at any given moment; express The query embedding representation obtained through time-series evolution; express The query embedding representation obtained through time-series evolution; express Entity embedding at a specific moment; express The entity embedding representation obtained through time-series evolution; express The entity embedding representation obtained through time-mapping evolution.
3. The time-based knowledge graph completion method based on multiple facts as described in claim 2, characterized in that: In step S1, the history fusion module is used to fuse the outputs of the query history evolution module and the entity history evolution module to obtain the query entity embedding: ; ; in, Indicates that the query entity is embedded; Represents an adaptive function; Indicates the activation function; This represents the parameter matrix used for attention; This indicates a splicing operation.
4. The time-based knowledge graph completion method based on multiple facts as described in claim 1, characterized in that: In step S1, the decoder decodes the output of the historical fusion module to obtain the probability of candidate entities related to the query, and outputs the prediction result of the query based on the candidate entity probability. ; in, Represents queries related to time knowledge graphs The relevant candidate entity probabilities; Indicates candidate entities; Indicates the entity being queried; Indicates the query relationship; Indicates the first The query time; ? indicates the query embedding to be generated; Indicates the activation function; Indicates the decoding function; This indicates the embedding of the query entity output by the historical fusion module; express The entity embedding representation obtained through time-mapping evolution.
5. The time-based knowledge graph completion method based on multiple facts as described in claim 1, characterized in that: In step S1, the formula for the loss function is: ; in, represents the loss value of the loss function; p represents the probability of candidate entities related to the query in the temporal knowledge graph; Indicates a query; This represents a subgraph of the time knowledge graph at time t.
6. The time-based knowledge graph completion method based on multiple facts as described in claim 1, characterized in that: Step S2 specifically involves: A large number of historical knowledge graphs are acquired, and each of the historical knowledge graphs is preprocessed, including at least null value handling, data standardization, data merging and missing value handling. The preprocessed historical knowledge graphs are then labeled, and a dataset is constructed based on the labeled historical knowledge graphs.
7. The time-based knowledge graph completion method based on multiple facts as described in claim 1, characterized in that: Step S3 specifically involves: The dataset is divided into a training set and a validation set based on a preset ratio. The time knowledge graph completion model is trained using the training set until the loss value of the loss function is less than a preset loss threshold. Then, the time knowledge graph completion model is validated using the validation set to determine whether the completion accuracy is greater than a preset accuracy threshold. If yes, the training ends; otherwise, the training set is expanded and training continues.