Entity relationship prediction method and device for time sequence knowledge graph
By using the pre-trained TFKE neural network model to predict the timing knowledge graph, the problem of missing entity relationships in the timing knowledge graph is solved, and the prediction efficiency is significantly improved.
Patent Information
- Application Number
- CN202411715701.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-18
AI Technical Summary
With the expansion of the timing knowledge graph, the problem of missing entity relationships is becoming more and more serious, and it is difficult for the existing technology to effectively infer missing entity relationships.
The pre-trained TFKE neural network model is used to predict the missing content of the quad to be predicted in the timing knowledge graph, and the vector representations of the head entity, tail entity, head entity, head entity and time are obtained through training to complete the prediction of entities and relationships.
Effectively predicting lost entities and relationships in the timing knowledge graph, improving the entity relationship prediction efficiency of the timing knowledge graph.
Smart Images

Figure CN119647567A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a method and device for predicting entity relationships in a temporal knowledge graph. Background Art
[0002] With the continuous advancement of science and technology, the demand for data processing and information analysis is growing. Traditional data processing methods often cannot meet this demand, especially when processing large amounts of complex and changing data, a more efficient and accurate method is needed.
[0003] The temporal knowledge graph is a new type of data structure that organizes, stores and retrieves information such as entities, attributes and relationships through a certain mathematical model. It can not only describe the relationship between entities, but also complete the description of knowledge.
[0004] As the temporal knowledge graph continues to expand, the problem of missing entity relationships is becoming more and more serious. How to effectively infer the missing entity relationships has become an urgent problem that needs to be solved. Summary of the invention
[0005] In view of this, the present application provides a method and device for predicting entity relationships in a temporal knowledge graph, aiming to effectively predict knowledge and efficiently infer lost entity relationships, thereby improving the prediction efficiency of entity relationships in a temporal knowledge graph.
[0006] In a first aspect, the present application provides a method for predicting entity relationships in a temporal knowledge graph, the method comprising:
[0007] Obtain the quadruple to be predicted from the time series knowledge graph;
[0008] The pre-trained TFKE neural network model is used to predict the missing content of the quadruple to be predicted, and a plurality of predicted quadruple are obtained; the missing content of the quadruple to be predicted includes missing head entity, missing tail entity, or missing head-tail entity relationship; the TFKE neural network model is trained to obtain vector representations of head entity, tail entity, head-tail entity relationship and time, and can complete entity prediction and relationship prediction in vector space;
[0009] Using the TFKE neural network model, calculating each prediction quadruple in the multiple prediction quadruple to obtain a score for each prediction quadruple;
[0010] The predicted quadruple whose score exceeds the score threshold is added to the temporal knowledge graph for completion.
[0011] Optionally, the training process of the TFKE neural network model includes:
[0012] Acquire a time series knowledge sample library, the time series knowledge sample library includes a plurality of sample quadruple groups, and use the plurality of sample quadruple groups as a training sample set; the sample quadruple groups include a head entity, a tail entity, a head-tail entity relationship, and a time feature;
[0013] The TFKE neural network model is trained using the training sample set, and the model parameters of the TFKE neural network model are optimized based on a pre-constructed loss function until the model convergence condition is reached, thereby obtaining the TFKE neural network model.
[0014] Optionally, after obtaining the TFKE neural network model, the method further includes:
[0015] Obtain a validation data set for the TFKE neural network model;
[0016] The accuracy of the TFKE neural network model is verified using the verification data set.
[0017] Optionally, after obtaining the TFKE neural network model, the method further includes:
[0018] Obtaining an updated data set for the TFKE neural network model;
[0019] The TFKE neural network model is trained using the updated data set to obtain an updated TFKE neural network model.
[0020] Optionally, the scoring process of the TFKE neural network model includes:
[0021] Acquire a target quadruple, and initialize the target quadruple using a random initialization method to obtain an initialized target quadruple, wherein the initialized target quadruple includes a head entity vector, a tail entity vector, a head-tail entity relationship vector, and a time feature vector;
[0022] By using a feedforward neural network, the time feature vector is integrated into the head entity vector and the tail entity vector to obtain a fused time series feature;
[0023] Calculate a vector representation of a new entity according to the fused temporal features and the initialized target quadruple;
[0024] According to the vector representation of the new entity, the head entity vector and the tail entity vector are vector-transformed to obtain a target quadruple of time feature fusion;
[0025] Splicing the time feature vector and the target quadruple fused with the time feature to obtain a spliced target quadruple;
[0026] Inputting the spliced target quadruple into a convolutional neural network, and obtaining multiple feature maps through a convolution operation;
[0027] Performing a full connection operation on the multiple feature maps to obtain a fully connected feature map;
[0028] The fully connected feature map is input into a preset scoring function, and the prediction score of the target quadruple is obtained using the scoring function.
[0029] In a second aspect, the present application provides an entity relationship prediction device for a temporal knowledge graph, the device comprising:
[0030] An acquisition module, used to acquire the quadruple to be predicted of the time series knowledge graph;
[0031] A prediction module is used to predict the missing content of the to-be-predicted quadruple using a pre-trained TFKE neural network model to obtain a plurality of predicted quadruple; the missing content of the to-be-predicted quadruple includes missing head entity, missing tail entity, or missing head-tail entity relationship; the TFKE neural network model obtains vector representations of head entity, tail entity, head-tail entity relationship and time through training, and can complete entity prediction and relationship prediction in vector space;
[0032] A calculation module, used to calculate each prediction quadruple in the multiple prediction quadruple by using the TFKE neural network model to obtain a score of each prediction quadruple;
[0033] A completion module is used to add the prediction quadruple whose score exceeds the score threshold to the time series knowledge graph for completion.
[0034] Optionally, the training process of the TFKE neural network model includes:
[0035] Acquire a time series knowledge sample library, the time series knowledge sample library includes a plurality of sample quadruple groups, and use the plurality of sample quadruple groups as a training sample set; the sample quadruple groups include a head entity, a tail entity, a head-tail entity relationship, and a time feature;
[0036] The TFKE neural network model is trained using the training sample set, and the model parameters of the TFKE neural network model are optimized based on a pre-constructed loss function until the model convergence condition is reached, thereby obtaining the TFKE neural network model.
[0037] Optionally, after obtaining the TFKE neural network model, the device further includes a verification module;
[0038] The verification module is used to obtain a verification data set of the TFKE neural network model;
[0039] The accuracy of the TFKE neural network model is verified using the verification data set.
[0040] Optionally, after obtaining the TFKE neural network model, the device further includes an updating module;
[0041] The updating module is used to obtain an updated data set of the TFKE neural network model;
[0042] The TFKE neural network model is trained using the updated data set to obtain an updated TFKE neural network model.
[0043] Optionally, the device further comprises a scoring module;
[0044] The scoring module is used to obtain a target quadruple, initialize the target quadruple using a random initialization method, and obtain an initialized target quadruple, wherein the initialized target quadruple includes a head entity vector, a tail entity vector, a head-tail entity relationship vector, and a time feature vector;
[0045] By using a feedforward neural network, the time feature vector is integrated into the head entity vector and the tail entity vector to obtain a fused time series feature;
[0046] Calculate a vector representation of a new entity according to the fused temporal features and the initialized target quadruple;
[0047] According to the vector representation of the new entity, the head entity vector and the tail entity vector are vector-transformed to obtain a target quadruple of time feature fusion;
[0048] Splicing the time feature vector and the target quadruple fused with the time feature to obtain a spliced target quadruple;
[0049] Inputting the spliced target quadruple into a convolutional neural network, and obtaining multiple feature maps through a convolution operation;
[0050] Performing a full connection operation on the multiple feature maps to obtain a fully connected feature map;
[0051] The fully connected feature map is input into a preset scoring function, and the prediction score of the target quadruple is obtained using the scoring function.
[0052] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising:
[0053] A memory for storing one or more programs;
[0054] Processor; when the one or more programs are executed by the processor, the entity relationship prediction method of the temporal knowledge graph described in any one of the first aspects above is implemented.
[0055] In a fourth aspect, an embodiment of the present application provides a computer storage medium, in which a program is stored. When the program is executed by a processor, the entity relationship prediction method of the temporal knowledge graph described in any one of the first aspects is implemented.
[0056] The above technical solution has the following beneficial effects:
[0057] The present application provides an entity relationship prediction method and device for a time series knowledge graph. When executing the method, firstly, a quadruple to be predicted of the time series knowledge graph is obtained; then, a pre-trained TFKE neural network model is used to predict the missing content of the quadruple to be predicted to obtain multiple predicted quadruple; the missing content of the quadruple to be predicted includes missing head entity, missing tail entity, or missing head-tail entity relationship; then, the TFKE neural network model is used to calculate each predicted quadruple in the multiple predicted quadruple to obtain the score of each predicted quadruple; finally, the predicted quadruple whose score exceeds the score threshold of each predicted quadruple is added to the time series knowledge graph for completion. The TFKE neural network model that can complete entity prediction and relationship prediction in the vector space by training to obtain the vector representation of the head entity, tail entity, head-tail entity relationship and time can effectively predict the missing entities and relationships in the time series knowledge graph, thereby improving the prediction efficiency of the entity relationship of the time series knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions in this embodiment or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0059] Figure 1 An example diagram of the model composition relationship provided in the embodiment of the present application;
[0060] Figure 2 A schematic diagram of the structure of a threshold value generating device for an anti-money laundering rule model provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] The technical scheme in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only a part of the embodiment of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0062] In order to facilitate further understanding of the technical solution provided by this application, the background technology involved in this application will be explained below.
[0063] The temporal knowledge graph is a new type of data structure that organizes, stores and retrieves information such as entities, attributes and relationships through a certain mathematical model. It can not only describe the relationship between entities, but also complete the description of knowledge.
[0064] As the temporal knowledge graph continues to expand, the knowledge representation method of graph storage is inefficient, and the problem of knowledge missing is becoming more and more serious. How to effectively represent knowledge and efficiently reason about the missing knowledge has become an urgent problem that needs to be solved.
[0065] Existing knowledge representation methods often only model entities and relationships, do not fully consider temporal knowledge graphs, and ignore the impact of temporal characteristics on entities and relationships; and when existing reasoning technology faces large-scale knowledge graphs, the knowledge representation method stored in the graph is inefficient and lacks timeliness.
[0066] In order to overcome the above technical problems, the embodiment of the present application provides an entity relationship prediction method and device for a time series knowledge graph. When executing the method, first obtain the to-be-predicted quadruple of the time series knowledge graph; then use the pre-trained TFKE neural network model to predict the missing content of the to-be-predicted quadruple to obtain multiple predicted quadruple; the missing content of the to-be-predicted quadruple includes missing head entity, missing tail entity, or missing head-tail entity relationship; then use the TFKE neural network model to calculate each predicted quadruple in the multiple predicted quadruple to obtain the score of each predicted quadruple; finally, add the predicted quadruple whose score exceeds the score threshold to the time series knowledge graph for completion. The TFKE neural network model that can complete entity prediction and relationship prediction in the vector space by training to obtain the vector representation of the head entity, tail entity, head-tail entity relationship and time can effectively predict the missing entities and relationships in the time series knowledge graph, thereby improving the prediction efficiency of the entity relationship of the time series knowledge graph.
[0067] The technical terms of the embodiments of the present application are introduced as follows:
[0068] Knowledge graph: a new type of data structure that organizes, stores and retrieves information such as entities, attributes and relationships through a certain mathematical model.
[0069] Temporal knowledge graph: Integrate temporal features into the traditional static knowledge graph to form a dynamic temporal knowledge graph with time features, represented by a quadruple.
[0070] Knowledge representation: Represent knowledge into vectors through machine learning methods.
[0071] TFKE: The model proposed in this application is used to predict missing entities and relations in temporal knowledge graphs.
[0072] The method of the embodiment of the present invention can be executed by an entity relationship prediction device of a temporal knowledge graph, which can be implemented by software and / or hardware and can generally be integrated into a server or terminal device.
[0073] See also Figure 1 , Figure 1 A flow chart of an entity relationship prediction method for a temporal knowledge graph provided in an embodiment of the present application.
[0074] The method may include:
[0075] Step S101: Obtain the quadruple to be predicted in the time series knowledge graph.
[0076] Specifically, the quadruple of the temporal knowledge graph is (h, r, t, o), where h represents the head entity, t represents the tail entity, r represents the relationship between the head and tail entities, and o represents the time feature.
[0077] The to-be-predicted quadruple is a quadruple with missing content, such as (h, r, ?, o) or (?, r, t, o).
[0078] Step S102: using the pre-trained TFKE neural network model, predict the missing content of the quadruple to be predicted to obtain multiple predicted quadruple; the missing content of the quadruple to be predicted includes missing head entity, missing tail entity, or missing head-tail entity relationship; the TFKE neural network model obtains the vector representation of the head entity, tail entity, head-tail entity relationship and time through training, and can complete entity prediction and relationship prediction in the vector space.
[0079] Specifically, after obtaining the quadruple to be predicted of the time series knowledge graph, the pre-trained TFKE neural network model is used to predict the missing content of the quadruple to be predicted to obtain multiple predicted quadruple.
[0080] As described in step S101, the missing content of the quadruple to be predicted includes missing head entity, missing tail entity, or missing head and tail entity relationship.
[0081] In a possible implementation, the training process of the TFKE neural network model includes:
[0082] Acquire a time series knowledge sample library, the time series knowledge sample library includes a plurality of sample quadruple groups, and use the plurality of sample quadruple groups as a training sample set; the sample quadruple groups include a head entity, a tail entity, a head-tail entity relationship, and a time feature;
[0083] The TFKE neural network model is trained using the training sample set, and the model parameters of the TFKE neural network model are optimized based on a pre-constructed loss function until the model convergence condition is reached, thereby obtaining the TFKE neural network model.
[0084] Specifically, multiple sample quadruples of the time series knowledge sample library are used as training sample sets, and the TFKE neural network model is trained using the training data set. The model parameters of the TFKE neural network model are optimized based on a pre-constructed loss function until the model convergence conditions are met, and the TFKE neural network model is obtained.
[0085] It should be noted that the model convergence condition can be set according to actual conditions. For example, when the change in model parameters between two iterations is less than or equal to a change threshold, it is considered that the model convergence condition is met.
[0086] The pre-built loss function is:
[0087]
[0088] Among them, S represents the positive example quadruple, S' represents the negative example quadruple, and the negative example quadruple is generated by randomly replacing the head and tail entities. w and α are regularization parameters, exp() is the natural exponential function, f(h",r,t",o) is the score function, and (h",r,t",o) is the target quadruple after splicing.
[0089] In order to test the accuracy of the TFKE neural network model, in a possible implementation, after obtaining the TFKE neural network model, the method further includes:
[0090] Obtain a validation data set for the TFKE neural network model;
[0091] The accuracy of the TFKE neural network model is verified using the verification data set.
[0092] Specifically, after the TFKE neural network model is generated, the TFKE neural network model is tested using a test data set to determine the accuracy of the TFKE neural network model.
[0093] For example: Use the test data set to evaluate the trained model, and use the validation data to evaluate the model's performance, including accuracy, speed, and stability. The model needs to be able to show the same accuracy and generalization ability on the test data as on the training data set.
[0094] In order to further improve the accuracy of the TFKE neural network model, in a possible implementation, the method may further include:
[0095] After obtaining the TFKE neural network model, the method further includes:
[0096] Obtaining an updated data set for the TFKE neural network model;
[0097] The TFKE neural network model is trained using the updated data set to obtain an updated TFKE neural network model.
[0098] Specifically, the embodiment of the present application can obtain an updated data set of the TFKE neural network model, use the updated data set to train the TFKE neural network model, and obtain an updated TFKE neural network model.
[0099] It can be understood that the embodiment of the present application iteratively updates the TFKE neural network model so that the TFKE neural network model can learn more information, thereby further improving the accuracy of the TFKE neural network model.
[0100] Step S103: using the TFKE neural network model, calculating each prediction quadruple in the multiple prediction quadruple to obtain a score for each prediction quadruple.
[0101] Specifically, after obtaining a plurality of prediction quadruple groups, the TFKE neural network model is used to calculate each prediction quadruple group in the plurality of prediction quadruple groups to obtain a score for each prediction quadruple group.
[0102] In one possible implementation, the scoring process of the TFKE neural network model includes:
[0103] Acquire a target quadruple, and initialize the target quadruple using a random initialization method to obtain an initialized target quadruple, wherein the initialized target quadruple includes a head entity vector, a tail entity vector, a head-tail entity relationship vector, and a time feature vector;
[0104] By using a feedforward neural network, the time feature vector is integrated into the head entity vector and the tail entity vector to obtain a fused time series feature;
[0105] Calculate a vector representation of a new entity according to the fused temporal features and the initialized target quadruple;
[0106] According to the vector representation of the new entity, the head entity vector and the tail entity vector are vector-transformed to obtain a target quadruple of time feature fusion;
[0107] Splicing the time feature vector and the target quadruple fused with the time feature to obtain a spliced target quadruple;
[0108] Inputting the spliced target quadruple into a convolutional neural network, and obtaining multiple feature maps through a convolution operation;
[0109] Performing a full connection operation on the multiple feature maps to obtain a fully connected feature map;
[0110] The fully connected feature map is input into a preset scoring function, and the prediction score of the target quadruple is obtained using the scoring function.
[0111] Specifically, the target quadruple is first initialized using a random initialization method to obtain an initialized target quadruple, wherein the initialized target quadruple includes a head entity vector, a tail entity vector, a head-tail entity relationship vector, and a time feature vector.
[0112] Then, a feedforward neural network is used to integrate the temporal feature o into the vector representation of the head and tail entities (h, t) to obtain the fused temporal feature.
[0113] Add the fused time series features to the initialized target quadruple to calculate the vector representation of the new entity:
[0114] The process of integrating temporal features is shown in formula (1).
[0115] e'=e+σ(W[e*o||e*r]+b) (1)
[0116] Where e' is the vector representation of the new entity, e is the vector representation of the entity to be learned, e∈{h, t}, r is the vector representation of the head-tail relationship, o is the vector representation of the time feature, W is the parameter matrix obtained through learning, b is the bias, || represents vector concatenation, σ is the Sigmoid activation function, and * represents vector multiplication.
[0117] The head entity vector and the tail entity vector of the initialized quadruple are transformed using formula (1) to obtain the target quadruple of temporal feature fusion as shown in formula (2).
[0118] [h,r,t,o]→[h',r,t',o] (2)
[0119] Furthermore, for the quadruple [h', r, t', o] that has completed the time information fusion, the time vector is continued to be used to strengthen the interaction between the entity relationship and the time information: the time feature vector is concatenated with the target quadruple fused with the time feature to obtain the concatenated target quadruple. The transformation process is shown in formula (3);
[0120] [h',r,t',o]→[h”||o,r||o,t”||o,h'+r-t'||o] (3)
[0121] Where h”=t'-r'-o, t”=h'+r'+o, and n is the embedding dimension. The positive example quadruple has the translation feature of h”+r+o≈t”+o, while the negative example has the opposite.
[0122] The spliced target quadruple is input into the convolutional neural network, and multiple feature maps are obtained through convolution operation.
[0123] Furthermore, a full connection operation is performed on multiple feature maps to obtain a fully connected feature map.
[0124] Finally, the fully connected feature map is input into a preset scoring function, and the prediction score of the target quadruple is obtained using the scoring function.
[0125] The scoring function is:
[0126]
[0127] Among them, h', t' are entity representations that incorporate temporal features, · represents the convolution operation, represents the fully connected operation. W is a shared parameter. It is a collection of multiple filters; concat represents connecting multiple feature maps.
[0128] It should be noted that the embodiment of the present application combines the time series features with the convolutional neural network. On the one hand, it retains the use of the feedforward neural network to capture the time series features, and on the other hand, it uses the convolutional neural network to improve the learning ability of the model. Moreover, by interacting with the time series features, relationship features and head and tail entities to enhance the time series and relationship features of the head and tail entities, the TFKE neural network model can effectively predict the missing entities and relationships in the time series knowledge graph, thereby improving the prediction efficiency of the entity relationship of the time series knowledge graph.
[0129] Step S104: adding the predicted quadruple whose score exceeds the score threshold to the temporal knowledge graph for completion.
[0130] Specifically, after obtaining the score of each predicted quadruple, the predicted quadruple whose score exceeds the score threshold is further added to the temporal knowledge graph for completion.
[0131] It is understandable that the score threshold can be set according to actual needs and is not limited here.
[0132] It can be seen from the above technical solution that the present application first obtains the quadruplets to be predicted of the time series knowledge graph; then uses the pre-trained TFKE neural network model to predict the missing content of the quadruplets to be predicted, and obtains multiple predicted quadruplets; the missing content of the quadruplets to be predicted includes missing head entities, missing tail entities, or missing head-tail entity relationships; then uses the TFKE neural network model to calculate each predicted quadruplet in the multiple predicted quadruplets to obtain the score of each predicted quadruplet; finally, the predicted quadruplets whose scores of each predicted quadruplet exceed the score threshold are added to the time series knowledge graph for completion. The TFKE neural network model that can complete entity prediction and relationship prediction in the vector space by training to obtain the vector representation of the head entity, tail entity, head-tail entity relationship, and time can effectively predict the missing entities and relationships in the time series knowledge graph, thereby improving the prediction efficiency of the entity relationship of the time series knowledge graph.
[0133] Next, the construction steps of the TFKE neural network model are introduced in detail.
[0134] TFKE construction includes three steps: temporal feature fusion, head-tail entity fusion, and entity relationship feature extraction.
[0135] Firstly, the target quadruple is initialized by using a random initialization method to obtain an initialized target quadruple, wherein the initialized target quadruple includes a head entity vector, a tail entity vector, a head-tail entity relationship vector and a time feature vector.
[0136] Then, a feedforward neural network is used to integrate the temporal feature o into the vector representation of the head and tail entities (h, t) to obtain the fused temporal feature.
[0137] Add the fused time series features to the initialized target quadruple to calculate the vector representation of the new entity:
[0138] The process of integrating temporal features is shown in formula (5).
[0139] e'=e+σ(W[e*o||e*r]+b) (5)
[0140] Where e' is the vector representation of the new entity, e is the vector representation of the entity to be learned, e∈{h, t}, r is the vector representation of the head-tail relationship, o is the vector representation of the time feature, W is the parameter matrix obtained through learning, b is the bias, || represents vector concatenation, σ is the Sigmoid activation function, and * represents vector multiplication.
[0141] The head entity vector and the tail entity vector of the initialized quadruple are transformed using formula (5) to obtain the target quadruple of temporal feature fusion as shown in formula (6).
[0142] [h,r,t,o]→[h',r,t',o] (6)
[0143] Furthermore, for the quadruple [h', r, t', o] that has completed the time information fusion, the time vector is continued to be used to strengthen the interaction between the entity relationship and the time information: the time feature vector is concatenated with the target quadruple fused with the time feature to obtain the concatenated target quadruple. The transformation process is shown in formula (7);
[0144] [h',r,t',o]→[h”||o,r||o,t”||o,h'+r-t'||o] (7)
[0145] Where h”=t'-r'-o, t”=h'+r'+o, and n is the embedding dimension. The positive example quadruple has the translation feature of h”+r+o≈t”+o, while the negative example has the opposite.
[0146] Furthermore, the translation features are extracted using a convolutional neural network as follows:
[0147] Using ω∈R 1×2n As the filter of the convolutional layer, the sliding step is set to 1 to capture local features. The calculation method of local features is shown in formula (8):
[0148]
[0149] Where Vi represents the i-th local feature, g is the activation function, represents the filter, represents the convolution operation, and E i,: represents the i-th column of the input matrix E; b is the bias; the i-th local feature is the filter Convolve with the i-th column of the input matrix A.
[0150] Furthermore, the TFKE neural network model uses a scoring function and an optimization objective to complete the training, specifically:
[0151] Use multiple filters to capture local features from different angles, concatenate the feature maps, and use the fully connected layer to get the score of the quadruple. The scoring function is shown in formula (9):
[0152]
[0153] Among them, h', t' are entity representations that incorporate temporal features, · represents the convolution operation, represents the fully connected operation. W is a shared parameter. It is a collection of multiple filters; concat represents connecting multiple feature maps.
[0154] The optimization objective uses the Log loss function as shown in formula (10):
[0155]
[0156] Where S represents the positive example quadruple, S' represents the negative example quadruple, and the negative example quadruple is generated by randomly replacing the head and tail entities. w and α are regularization parameters, exp() is the natural exponential function, f(h",r,t",o) is the score function, and (h",r,t",o) is the target quadruple after concatenation.
[0157] Furthermore, entity prediction is specifically to predict the missing entity given an incomplete quadruple (h, r, ?, o) or (?, r, t, o) to obtain a predicted quadruple;
[0158] Calculate the score of each predicted quadruple according to the TFKE neural network model;
[0159] A prediction quadruple score threshold θ is set, the value range of θ is 0-1, to determine whether the prediction quadruple is reasonable, and add the reasonable prediction quadruple to the original knowledge graph to complete the completion.
[0160] Furthermore, the relationship prediction is as follows:
[0161] Given an incomplete quadruple (h, ?, t, o), predict its missing relations;
[0162] Use the TFKE neural network model to calculate the score of each predicted quadruple;
[0163] Given a predicted quadruple score threshold θ, the value range of θ is 0-1, judge whether the predicted quadruple is reasonable, and add the reasonable predicted quadruple to the original knowledge graph to complete the completion.
[0164] It should be noted that the embodiment of the present application uses a convolutional neural network to obtain a four-tuple feature map to construct a TFKE model, completes training on a temporal knowledge graph to obtain vector representations of entities, relationships, and time, and thus completes entity and relationship predictions in the vector space.
[0165] For the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the order of the actions described, because according to the present invention, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0166] The above are some specific implementations of the entity relationship prediction of the time series knowledge graph provided in the embodiment of the present application. Based on this, the present application also provides a corresponding device. The entity relationship prediction device of the time series knowledge graph provided in the embodiment of the present application will be introduced from the perspective of functional modularization.
[0167] See also Figure 2 , is a schematic diagram of a structure of an entity relationship prediction device for a temporal knowledge graph provided in an embodiment of the present application, the device comprising:
[0168] An acquisition module 201 is used to acquire a quadruple to be predicted of a time series knowledge graph;
[0169] The prediction module 202 is used to predict the missing content of the to-be-predicted quadruple using a pre-trained TFKE neural network model to obtain a plurality of predicted quadruple; the missing content of the to-be-predicted quadruple includes missing head entity, missing tail entity, or missing head-tail entity relationship; the TFKE neural network model obtains vector representations of head entity, tail entity, head-tail entity relationship and time through training, and can complete entity prediction and relationship prediction in vector space;
[0170] A calculation module 203 is used to calculate each prediction quadruple in the multiple prediction quadruple by using the TFKE neural network model to obtain a score of each prediction quadruple;
[0171] The completion module 204 is used to add the prediction quadruple whose score exceeds the score threshold to the temporal knowledge graph for completion.
[0172] Optionally, the training process of the TFKE neural network model includes:
[0173] Acquire a time series knowledge sample library, the time series knowledge sample library includes a plurality of sample quadruple groups, and use the plurality of sample quadruple groups as a training sample set; the sample quadruple groups include a head entity, a tail entity, a head-tail entity relationship, and a time feature;
[0174] The TFKE neural network model is trained using the training sample set, and the model parameters of the TFKE neural network model are optimized based on a pre-constructed loss function until the model convergence condition is reached, thereby obtaining the TFKE neural network model.
[0175] Optionally, after obtaining the TFKE neural network model, the device further includes a verification module;
[0176] The verification module is used to obtain a verification data set of the TFKE neural network model;
[0177] The accuracy of the TFKE neural network model is verified using the verification data set.
[0178] Optionally, after obtaining the TFKE neural network model, the device further includes an updating module;
[0179] The updating module is used to obtain an updated data set of the TFKE neural network model;
[0180] The TFKE neural network model is trained using the updated data set to obtain an updated TFKE neural network model.
[0181] Optionally, the device further comprises a scoring module;
[0182] The scoring module is used to obtain a target quadruple, initialize the target quadruple using a random initialization method, and obtain an initialized target quadruple, wherein the initialized target quadruple includes a head entity vector, a tail entity vector, a head-tail entity relationship vector, and a time feature vector;
[0183] By using a feedforward neural network, the time feature vector is integrated into the head entity vector and the tail entity vector to obtain a fused time series feature;
[0184] Calculate a vector representation of a new entity according to the fused temporal features and the initialized target quadruple;
[0185] According to the vector representation of the new entity, the head entity vector and the tail entity vector are vector-transformed to obtain a target quadruple of time feature fusion;
[0186] Splicing the time feature vector and the target quadruple fused with the time feature to obtain a spliced target quadruple;
[0187] Inputting the spliced target quadruple into a convolutional neural network, and obtaining multiple feature maps through a convolution operation;
[0188] Performing a full connection operation on the multiple feature maps to obtain a fully connected feature map;
[0189] The fully connected feature map is input into a preset scoring function, and the prediction score of the target quadruple is obtained using the scoring function.
[0190] It can be seen from the above technical scheme that the embodiment of the present application first obtains the quadruplets to be predicted of the time series knowledge graph; then, the pre-trained TFKE neural network model is used to predict the missing content of the quadruplets to be predicted, and obtain multiple predicted quadruplets; the missing content of the quadruplets to be predicted includes missing head entities, missing tail entities, or missing head-tail entity relationships; then, the TFKE neural network model is used to calculate each predicted quadruplet in the multiple predicted quadruplets to obtain the score of each predicted quadruplet; finally, the predicted quadruplets whose scores of each predicted quadruplet exceed the score threshold are added to the time series knowledge graph for completion. The TFKE neural network model that can complete entity prediction and relationship prediction in the vector space by training to obtain the vector representation of the head entity, tail entity, head-tail entity relationship, and time can effectively predict the missing entities and relationships in the time series knowledge graph, thereby improving the prediction efficiency of the entity relationship of the time series knowledge graph.
[0191] An embodiment of the present application further provides an electronic device, comprising: a memory for storing one or more programs;
[0192] Processor; when the one or more programs are executed by the processor, the entity relationship prediction method of the temporal knowledge graph described in the above embodiment is implemented.
[0193] An embodiment of the present application also provides a computer storage medium, in which a program is stored. When the program is executed by a processor, the entity relationship prediction method of the temporal knowledge graph described in the above embodiment is implemented.
[0194] The "first" and "second" in the names such as "first" and "second" (if any) mentioned in the embodiments of the present application are only used as name identifiers and do not represent the first or second in order.
[0195] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0196] Those skilled in the art can understand that the flowchart shown in the figure is only an example in which the embodiments of the present application can be implemented, and the scope of application of the embodiments of the present application is not limited by any aspect of the flowchart.
[0197] In the several embodiments provided in the present application, it should be understood that the disclosed methods, devices and equipment can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0198] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, the functional units in the various embodiments of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0199] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.
[0200] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for predicting entity relationships in a temporal knowledge graph, characterized in that: The method comprises: Obtain the quadruple to be predicted from the time series knowledge graph; The pre-trained TFKE neural network model is used to predict the missing content of the quadruple to be predicted, and a plurality of predicted quadruple are obtained; the missing content of the quadruple to be predicted includes missing head entity, missing tail entity, or missing head-tail entity relationship; the TFKE neural network model is trained to obtain vector representations of head entity, tail entity, head-tail entity relationship and time, and can complete entity prediction and relationship prediction in vector space; Using the TFKE neural network model, calculating each prediction quadruple in the multiple prediction quadruple to obtain a score for each prediction quadruple; The predicted quadruple whose score exceeds the score threshold is added to the temporal knowledge graph for completion.
2. The method according to claim 1, characterized in that The training process of the TFKE neural network model includes: Acquire a time series knowledge sample library, the time series knowledge sample library includes a plurality of sample quadruple groups, and use the plurality of sample quadruple groups as a training sample set; the sample quadruple groups include a head entity, a tail entity, a head-tail entity relationship, and a time feature; The TFKE neural network model is trained using the training sample set, and the model parameters of the TFKE neural network model are optimized based on a pre-constructed loss function until the model convergence condition is reached, thereby obtaining the TFKE neural network model.
3. The method according to claim 2, characterized in that After obtaining the TFKE neural network model, the method further includes: Obtain a validation data set for the TFKE neural network model; The accuracy of the TFKE neural network model is verified using the verification data set.
4. The method according to claim 2, characterized in that: After obtaining the TFKE neural network model, the method further includes: Obtaining an updated data set for the TFKE neural network model; The TFKE neural network model is trained using the updated data set to obtain an updated TFKE neural network model.
5. The method according to claim 1, characterized in that The scoring process of the TFKE neural network model includes: Acquire a target quadruple, and initialize the target quadruple using a random initialization method to obtain an initialized target quadruple, wherein the initialized target quadruple includes a head entity vector, a tail entity vector, a head-tail entity relationship vector, and a time feature vector; By using a feedforward neural network, the time feature vector is integrated into the head entity vector and the tail entity vector to obtain a fused time series feature; Calculating a vector representation of a new entity according to the fused temporal features and the initialized target quadruple; According to the vector representation of the new entity, the head entity vector and the tail entity vector are vector-transformed to obtain a target quadruple of time feature fusion; Splicing the time feature vector and the target quadruple fused with the time feature to obtain a spliced target quadruple; Inputting the spliced target quadruple into a convolutional neural network, and obtaining multiple feature maps through a convolution operation; Performing a full connection operation on the multiple feature maps to obtain a fully connected feature map; The fully connected feature map is input into a preset scoring function, and the prediction score of the target quadruple is obtained using the scoring function.
6. An entity relationship prediction device for a temporal knowledge graph, characterized in that: The device comprises: An acquisition module, used to acquire the quadruple to be predicted of the time series knowledge graph; A prediction module is used to predict the missing content of the to-be-predicted quadruple using a pre-trained TFKE neural network model to obtain a plurality of predicted quadruple; the missing content of the to-be-predicted quadruple includes missing head entity, missing tail entity, or missing head-tail entity relationship; the TFKE neural network model obtains vector representations of head entity, tail entity, head-tail entity relationship and time through training, and can complete entity prediction and relationship prediction in vector space; A calculation module, used to calculate each prediction quadruple in the multiple prediction quadruple by using the TFKE neural network model to obtain a score of each prediction quadruple; A completion module is used to add the prediction quadruple whose score exceeds the score threshold to the time series knowledge graph for completion.
7. The device according to claim 6, characterized in that The training process of the TFKE neural network model includes: Acquire a time series knowledge sample library, the time series knowledge sample library includes a plurality of sample quadruple groups, and use the plurality of sample quadruple groups as a training sample set; the sample quadruple groups include a head entity, a tail entity, a head-tail entity relationship, and a time feature; The TFKE neural network model is trained using the training sample set, and the model parameters of the TFKE neural network model are optimized based on a pre-constructed loss function until the model convergence condition is reached, thereby obtaining the TFKE neural network model.
8. The device according to claim 7, characterized in that After obtaining the TFKE neural network model, the device further includes a verification module; The verification module is used to obtain a verification data set of the TFKE neural network model; The accuracy of the TFKE neural network model is verified using the verification data set.
9. The device according to claim 7, characterized in that After obtaining the TFKE neural network model, the device further includes an updating module; The updating module is used to obtain an updated data set of the TFKE neural network model; The TFKE neural network model is trained using the updated data set to obtain an updated TFKE neural network model.
10. The device according to claim 6, characterized in that The device also includes a scoring module; The scoring module is used to obtain a target quadruple, initialize the target quadruple using a random initialization method, and obtain an initialized target quadruple, wherein the initialized target quadruple includes a head entity vector, a tail entity vector, a head-tail entity relationship vector, and a time feature vector; By using a feedforward neural network, the time feature vector is integrated into the head entity vector and the tail entity vector to obtain a fused time series feature; Calculating a vector representation of a new entity according to the fused temporal features and the initialized target quadruple; According to the vector representation of the new entity, the head entity vector and the tail entity vector are vector-transformed to obtain a target quadruple of time feature fusion; Splicing the time feature vector and the target quadruple fused with the time feature to obtain a spliced target quadruple; Inputting the spliced target quadruple into a convolutional neural network, and obtaining multiple feature maps through a convolution operation; Performing a full connection operation on the multiple feature maps to obtain a fully connected feature map; The fully connected feature map is input into a preset scoring function, and the prediction score of the target quadruple is obtained using the scoring function.
Citation Information
Cited By
Training method and device of electricity consumption information prediction model and electricity consumption information prediction method
CN120409854A
Training method and device of electricity consumption information prediction model and electricity consumption information prediction method
CN120409854B