Event prediction method and device based on dynamic knowledge graph
By constructing and splicing dynamic knowledge graphs of historical events, and using feature encoding and prediction submodules to generate feature representations of the current cycle, the problem that the static knowledge graph inference model cannot be applied to dynamic knowledge graphs is solved, and accurate dynamic prediction of events is achieved.
Patent Information
- Application Number
- CN202210576172.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-24
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2042-05-24
AI Technical Summary
The static knowledge graph inference model in the prior art cannot be applied to dynamic knowledge graphs and cannot accurately predict events.
By obtaining historical events, constructing a dynamic knowledge graph, using the coding submodule and feature prediction submodule to feature encoding and prediction of entities and relationships in the graph, and generating feature representations of the current cycle to achieve dynamic prediction of events.
Accurate dynamic prediction of events in dynamic knowledge graphs is achieved, long-term and short-term time dependencies in the graph sequence are captured, and the accuracy and reliability of predictions are improved.
Smart Images

Figure CN115062779B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an event prediction method and device based on a dynamic knowledge graph. Background Art
[0002] Traditional knowledge graphs (KGs) represent various entities and relationships in the real world as multi-relational data in a structured way, and are applied to various downstream tasks such as information retrieval, dialogue systems, reading comprehension, medical health, etc. However, due to the limitations of manpower and material resources, the relationship information in the knowledge graph is usually incomplete, so a knowledge graph reasoning model is needed to complete and reason about the existing knowledge graph.
[0003] In the existing technology, most of the knowledge graph reasoning methods assume that the knowledge graph is static, that is, only entities and the relationships between entities are used to reason and construct the knowledge graph. In practice, many knowledge graphs constructed from event data are often dynamic, that is, the semantics of entities or relationships will evolve over time.
[0004] However, the knowledge graph reasoning methods in the prior art ignore time information, that is, ignore the nature of the evolution of entity and relationship representations over time, resulting in the existing static graph reasoning models being unable to apply to dynamic knowledge graph prediction scenarios and unable to accurately reason and predict events.
[0005] In summary, the need to accurately and dynamically predict events based on dynamic knowledge graphs is an important issue that needs to be urgently addressed in the industry. Summary of the invention
[0006] The present invention provides an event prediction method and device based on a dynamic knowledge graph, so as to solve the defect that the existing static graph reasoning model in the prior art cannot be applied to the prediction scenario of the dynamic knowledge graph and cannot accurately reason and predict events, so as to realize accurate dynamic prediction of events.
[0007] The present invention provides an event prediction method based on a dynamic knowledge graph, comprising:
[0008] Obtain target historical events within a first historical period, and construct a first knowledge graph corresponding to each moment according to all target historical events at each moment within the first historical period;
[0009] Splicing the first knowledge graphs corresponding to all moments in the first historical period to generate a second knowledge graph;
[0010] Inputting the second knowledge graph into the first prediction module of the prediction model to obtain feature representations of the entities and the relationships between the entities in the second knowledge graph in the current period;
[0011] Inputting the feature representation of each entity and each relationship in the second knowledge graph in the current period into the second prediction module of the prediction model to obtain the predicted event of the current period;
[0012] The prediction model is obtained by training based on sample historical events in the second historical period and real events in the next historical period of the second historical period.
[0013] According to an event prediction method based on a dynamic knowledge graph provided by the present invention, the first prediction module includes an encoding submodule and a feature prediction submodule;
[0014] The step of inputting the second knowledge graph into the first prediction module of the prediction model to obtain feature representations of the entities and the relationships between the entities in the second knowledge graph in the current period includes:
[0015] Inputting the second knowledge graph into the encoding submodule to obtain feature encoding results of each entity in the second knowledge graph at each time in the first historical period;
[0016] The feature encoding results of each entity and each relationship in the second knowledge graph at each moment in the first historical period are input into the feature prediction submodule to obtain the feature representation of each entity and each relationship in the second knowledge graph in the current period.
[0017] According to an event prediction method based on a dynamic knowledge graph provided by the present invention, the encoding submodule includes a first encoding unit and a second encoding unit;
[0018] The step of inputting the second knowledge graph into the encoding submodule to obtain the feature encoding results of each entity in the second knowledge graph at each time point in the first historical period includes:
[0019] Input the second knowledge graph into the first encoding unit, and perform feature encoding on each entity in each first knowledge graph in the second knowledge graph at the level of each first knowledge graph in the second knowledge graph, to obtain a first feature encoding result for each entity in each first knowledge graph in the second knowledge graph at each time in the first historical period;
[0020] The first feature encoding result of each entity in each first knowledge graph is input into the second encoding unit, and at the level of the second knowledge graph, each entity in the second knowledge graph is feature encoded to obtain the second feature encoding result of each entity in the second knowledge graph at each moment in the first historical period.
[0021] According to an event prediction method based on a dynamic knowledge graph provided by the present invention, the first feature encoding result of each entity in each first knowledge graph is input into the second encoding unit, and at the level of the second knowledge graph, each entity in the second knowledge graph is feature encoded to obtain the second feature encoding result of each entity in the second knowledge graph at each time in the first historical period, including:
[0022] For each entity in the second knowledge graph, perform the following steps:
[0023] Obtaining the time difference and relationship between the current entity and the neighboring entities of the current entity;
[0024] According to the time difference and the relationship, obtaining the degree of dependence of the relationship between the current entity and the neighbor entity on time;
[0025] According to the relationship between the current entity and the neighboring entities and the degree of dependence, the current entity is aggregated and updated to obtain a second feature encoding result of the current entity.
[0026] According to an event prediction method based on a dynamic knowledge graph provided by the present invention, the feature prediction submodule includes a first feature prediction unit, a second feature prediction unit and a fusion unit; the fusion unit includes a first fusion unit and a second fusion unit;
[0027] The feature encoding results of each entity and each relationship in the second knowledge graph at each moment in the first historical period are input into the feature prediction submodule to obtain the feature representation of each entity and each relationship in the second knowledge graph in the current period, including:
[0028] Input the first feature encoding results of each entity in each first knowledge graph and each relationship in the second knowledge graph at each moment in the first historical period into the first feature prediction unit to obtain the first feature representation of each entity and each relationship in the second knowledge graph in the current period;
[0029] Input the second feature encoding results of each entity and each relationship in the second knowledge graph at each moment in the first historical period into the second feature prediction unit to obtain the second feature representation of each entity and each relationship in the second knowledge graph in the current period;
[0030] Inputting the first feature representation and the second feature representation of each entity in the second knowledge graph into the first fusion unit to obtain the feature representation of each entity in the second knowledge graph in the current period;
[0031] The first feature representation and the second feature representation of each relationship in the second knowledge graph are input into the second fusion unit to obtain the feature representation of each relationship in the second knowledge graph in the current period.
[0032] According to an event prediction method based on a dynamic knowledge graph provided by the present invention, the loss function of the first prediction module is generated based on the fusion of the first loss function and the second loss function;
[0033] The first loss function is generated by constructing a deviation between the predicted feature representation of each entity in the fourth knowledge graph generated by splicing the third knowledge graph corresponding to all moments in the second historical period and the actual feature representation;
[0034] The second loss function is generated based on the deviation between the predicted feature representation and the actual feature representation of each relationship in the fourth knowledge graph.
[0035] According to an event prediction method based on a dynamic knowledge graph provided by the present invention, the first prediction module is generated based on a graph neural network and a recurrent neural network.
[0036] The present invention also provides an event prediction device based on a dynamic knowledge graph, comprising:
[0037] A first construction module is used to: obtain target historical events within a first historical period, and construct a first knowledge graph corresponding to each moment according to all target historical events at each moment within the first historical period;
[0038] A second construction module is used to: splice the first knowledge graphs corresponding to all moments in the first historical period to generate a second knowledge graph;
[0039] A feature prediction module, used to: input the second knowledge graph into the first prediction module of the prediction model to obtain feature representations of the entities and the relationships between the entities in the second knowledge graph in the current period;
[0040] An event prediction module, used to: input the feature representation of each entity and each relationship in the second knowledge graph in the current period into the second prediction module of the prediction model to obtain the predicted event of the current period;
[0041] The prediction model is obtained by training based on sample historical events in the second historical period and real events in the next historical period of the second historical period.
[0042] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, an event prediction method based on a dynamic knowledge graph as described above is implemented.
[0043] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the event prediction methods based on a dynamic knowledge graph as described above.
[0044] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned event prediction methods based on dynamic knowledge graphs.
[0045] The event prediction method and device based on dynamic knowledge graph provided by the present invention construct a first knowledge graph corresponding to each time by utilizing the entities and relationships of the target historical events, and splice the sequences composed of all the first knowledge graphs to obtain a global second knowledge graph. By learning the temporal information of the global second knowledge graph, the feature representation of each entity and the relationship between entities in the second knowledge graph in the current period is dynamically predicted to achieve accurate dynamic prediction of events. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0047] Figure 1 This is one of the flow charts of the event prediction method based on the dynamic knowledge graph provided by the present invention;
[0048] Figure 2 This is the second flow chart of the event prediction method based on the dynamic knowledge graph provided by the present invention;
[0049] Figure 3 It is a structural schematic diagram of an event prediction device based on a dynamic knowledge graph provided by the present invention;
[0050] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0052] It should be noted that the execution subject of the method may be an electronic device, a component in an electronic device, an integrated circuit, or a chip. The electronic device may be a mobile electronic device or a non-mobile electronic device. For example, the mobile electronic device may be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, and a smart wearable device, etc., and the non-mobile electronic device may be a server, a network attached storage, and a personal computer, etc., which are not specifically limited in the present invention.
[0053] Combine the following Figure 1 The event prediction method based on dynamic knowledge graph of the present invention is described, and the method comprises the following steps:
[0054] Step 101, obtaining target historical events in a first historical period, and constructing a first knowledge graph corresponding to each moment according to all target historical events at each moment in the first historical period;
[0055] Among them, the first historical cycle is a time period of preset length, which can be set according to actual needs.
[0056] The target historical event is a historical event that occurred in the first historical period and meets preset conditions; for example, a historical event whose popularity is greater than a preset threshold, a historical event whose theme is a preset theme or a target field, etc. are taken as target historical events, and this embodiment does not make specific limitations on this.
[0057] Optionally, the target historical events are first collected from a corpus such as news events or Wikipedia, and then the target historical events are imported into an event database, and data cleaning is performed on the target time in the event database to eliminate abnormal target historical events and / or abnormal entities in the event database.
[0058] Then, through entity extraction, such as named entity recognition algorithm, and entity relationship recognition technology, such as various machine learning models, the entities and the relationships between entities in each target historical event at each moment in the first historical period are extracted; and each entity in all target historical events at each moment is used as a node, and the relationship between each entity in all target historical events at each moment is used as an edge to construct a dynamic knowledge graph related to time, that is, the first knowledge graph corresponding to each moment; wherein each moment corresponds one-to-one to each first knowledge graph.
[0059] The relationship includes but is not limited to a co-occurrence relationship and an association relationship, which are not specifically limited in this embodiment. A co-occurrence relationship is used to indicate whether two entities appear at the same time in the same target historical event; an association relationship is an association relationship between the attribute information of the two entities themselves.
[0060] Step 102, concatenating the first knowledge graphs corresponding to all moments in the first historical period to generate a second knowledge graph;
[0061] Optionally, after obtaining the first knowledge graph corresponding to each moment in the first historical period, the first knowledge graph corresponding to each moment can be converted into a global knowledge graph, that is, a second knowledge graph.
[0062] Optionally, the first knowledge graph corresponding to each moment in the first historical period is used as a subgraph in the second knowledge graph. By splicing the first knowledge graphs corresponding to all moments in the first historical period, the first knowledge graphs corresponding to each moment can be converted into the second knowledge graph.
[0063] Among them, the method of splicing knowledge graphs includes: splicing the same entities appearing in the first knowledge graphs corresponding to different times; or splicing entities with high similarity in the first knowledge graphs corresponding to different times, etc. This embodiment does not specifically limit the method of splicing knowledge graphs.
[0064] Step 103, inputting the second knowledge graph into the first prediction module of the prediction model to obtain the feature representation of each entity and the relationship between each entity in the second knowledge graph in the current period; wherein the prediction model is trained based on sample historical events in the second historical period and real events in the next historical period of the second historical period;
[0065] Among them, the prediction model includes a first prediction module and a second prediction module; the first prediction module is used to predict the feature representation of each entity and each relationship in the second knowledge graph, and the second prediction model is used to predict events.
[0066] The structures of the first prediction module and the second prediction module can be set according to actual needs, such as being constructed and generated based on a hierarchical relationship graph neural network model, a feature extraction module and a prediction sub-module.
[0067] Before executing step 103, the prediction model needs to be trained. The specific training steps include:
[0068] First, sample historical events within the second historical period and real events in the next historical period of the second historical period are collected; it should be noted that there are multiple second historical periods, which can be set according to actual needs.
[0069] According to all sample historical events at each moment in the second historical period, a third knowledge graph corresponding to each moment is constructed and generated, and the third knowledge graphs corresponding to all moments in the second historical period are spliced to generate a fourth knowledge graph;
[0070] The fourth knowledge graph is used as a sample of the prediction model, and the real events of the next historical period of the second historical period are used as labels of the samples to construct a sample data set;
[0071] And divide the sample data set into training set, validation set and test set; for example, sort the fourth knowledge graph sequence in the constructed sample data set by time, and use 80%, 10% and 10% of the data as training set, validation set and test set respectively.
[0072] Then, the fourth knowledge graph in the training set is input into the prediction model, and the parameters of the prediction model are updated according to the predicted events and real events output by the prediction model until the termination conditions of the prediction model training are met, such as the prediction model convergence. At this time, the parameters of the obtained prediction model reach the global optimum, and then a prediction model that can accurately and dynamically predict events based on the global knowledge graph composed of historical events is obtained. And according to the prediction accuracy of the prediction model on the verification set, the prediction model with the best performance on the verification set is selected as the final prediction model.
[0073] In order to verify the accuracy of event prediction in this embodiment, the trained prediction model is tested on the test set, and the prediction precision and accuracy are evaluated, as shown in Table 1.
[0074] As shown in Table 1. The prediction model in this embodiment has good performance indicators on the datasets ICEWS14, ICEWS05-15 and ICEWS18.
[0075] Table 1 Prediction performance of the prediction model in this embodiment on different data sets
[0076]
[0077] Among them, the MRR indicator in Table 1 is used to calculate the average of the reciprocal ranking of the true value in the predicted link entity. MRR measures the order of the predicted ranking. The larger the MRR value, the higher the correct recommendation. The calculation formula is:
[0078]
[0079] Among them, N is the total number of searches, rank i is the position of the most relevant result in the i-th search.
[0080] Hit (Hit Ration, recall offline evaluation) represents the average value of the proportion of true values in the first k predicted entities. The calculation formula is:
[0081]
[0082] Among them, n hit represents the number of true values in the first k predicted entities, n test Indicates the number of test cases.
[0083] After obtaining the second knowledge graph, the second knowledge graph can be used as the input of the trained first prediction module to predict and update the feature representations of the entities and the relationships between them in the second knowledge graph to obtain the feature representations of the relationships between them in the second knowledge graph in the current period.
[0084] Step 104: Input the feature representation of each entity and each relationship in the second knowledge graph in the current period into the second prediction module of the prediction model to obtain the predicted events of the current period.
[0085] The predicted event is a new event predicted based on the target historical event.
[0086] Optionally, after obtaining the feature representation of each entity and each relationship in the second knowledge graph in the current period, the feature representation of each entity and each relationship in the second knowledge graph in the current period can be input into the second prediction module. By learning the features of each entity and each relationship in the current period, the predicted events of the current period can be obtained.
[0087] The event prediction method based on the dynamic knowledge graph provided in this embodiment constructs a first knowledge graph corresponding to each time by utilizing the entities and relationships of the target historical events, and splices the sequences composed of all the first knowledge graphs to obtain a global second knowledge graph. By learning the temporal information of the global second knowledge graph, the feature representation of each entity and the relationship between entities in the second knowledge graph in the current period is dynamically predicted to achieve accurate dynamic prediction of events.
[0088] On the basis of the above embodiments, in this embodiment, the first prediction module includes an encoding submodule and a feature prediction submodule; the second knowledge graph is input into the first prediction module of the prediction model to obtain the feature representation of each entity and the relationship between each entity in the second knowledge graph in the current period, including: inputting the second knowledge graph into the encoding submodule to obtain the feature encoding results of each entity in the second knowledge graph at each moment in the first historical period; inputting the feature encoding results of each entity in the second knowledge graph at each moment in the first historical period and each relationship into the feature prediction submodule to obtain the feature representation of each entity and each relationship in the second knowledge graph in the current period.
[0089] Among them, the encoding submodule can be generated based on other deep learning models such as hierarchical relationship graph neural network; the feature prediction submodule can be generated based on other deep learning models such as recurrent neural network model; the number of encoding submodules and feature prediction submodules can be set according to actual needs, and this embodiment does not make specific limitations on this.
[0090] Optionally, in order to better capture the temporal information of each entity in the second knowledge graph, the second knowledge graph can be first input into the encoding submodule, and the features of each entity in the second knowledge graph can be encoded to obtain the feature encoding results of each entity in the second knowledge graph at each moment in the first historical period.
[0091] The feature encoding method includes: directly encoding the features of each entity in the second knowledge graph at the global graph level of the second knowledge graph according to each entity, the relationship between each entity and time in the second knowledge graph;
[0092] Alternatively, first, at the sub-layer level of the second knowledge graph, that is, the first knowledge graph level, feature encoding is performed on each entity in the first knowledge graph according to each entity in the first knowledge graph and the relationship between each entity; then, at the global layer level of the second knowledge graph, feature encoding is performed on each entity in the second knowledge graph according to the encoding features of each entity in the first knowledge graph, the relationship between each entity and time; this example does not specifically limit the method of feature encoding.
[0093] After obtaining the feature coding results of each entity in the second knowledge graph at each moment in the first historical period, feature prediction can be performed on each entity and each relationship in the second knowledge graph based on the feature coding results of each entity in the second knowledge graph to obtain the feature representation of each entity and each relationship in the second knowledge graph in the current period.
[0094] Among them, the feature prediction method includes: directly predicting the feature representation of each entity and each relationship in the second knowledge graph in the current period based on the feature encoding results of each entity and each relationship in the second knowledge graph at each moment in the first historical period.
[0095] Alternatively, first, at the sub-map level of the second knowledge graph, that is, the first knowledge graph level, based on the feature encoding results of each entity in the first knowledge graph and the relationship between each entity, the feature representation of each entity and each relationship in the first knowledge graph in the current period is predicted, that is, short-term feature prediction; at the same time, at the global map level of the second knowledge graph, based on the feature encoding results of each entity in the second knowledge graph and the relationship between each entity, the feature representation of each entity and each relationship in the second knowledge graph in the current period is predicted, that is, long-term feature prediction; then, the short-term feature prediction and the long-term feature prediction are fused to predict the final feature representation of each entity and each relationship in the second knowledge graph; this example does not specifically limit the feature prediction method.
[0096] After acquiring the second knowledge graph, this embodiment can first perform feature encoding on each node in the second knowledge graph to obtain the timing information of each node; then, feature prediction can be performed based on the feature encoding results of each node in the second knowledge graph, so as to quickly and accurately predict the feature representation of the current period of each node in the second knowledge graph based on the timing information, thereby achieving accurate dynamic prediction of events.
[0097] On the basis of the above embodiments, the encoding submodule in this embodiment includes a first encoding unit and a second encoding unit; the inputting the second knowledge graph into the encoding submodule to obtain the feature encoding results of each entity in the second knowledge graph at each moment in the first historical period includes: inputting the second knowledge graph into the first encoding unit, and at the level of each first knowledge graph in the second knowledge graph, feature encoding is performed on each entity in each first knowledge graph in the second knowledge graph to obtain the first feature encoding results of each entity in each first knowledge graph in the second knowledge graph at each moment in the first historical period; inputting the first feature encoding results of each entity in each first knowledge graph into the second encoding unit, and at the level of the second knowledge graph, feature encoding is performed on each entity in the second knowledge graph to obtain the second feature encoding results of each entity in the second knowledge graph at each moment in the first historical period.
[0098] The encoding submodule can be generated by a hierarchical graph neural network. The structure of the encoding submodule, such as the number of layers, initialization hyperparameters, etc., can be set according to actual needs.
[0099] Optionally, the constructed second knowledge graph is input into the encoding submodule, and the hierarchical relationship graph neural network can perform two-level feature encoding on the second knowledge graph; wherein:
[0100] The first encoding unit is used to aggregate and update each entity in the first knowledge graph at the level of the first knowledge graph according to the relationship between each entity in the first knowledge graph to obtain a first feature encoding result for each entity in the first knowledge graph.
[0101] The calculation formula for the first encoding unit to perform feature encoding on each entity is:
[0102]
[0103] in, is the feature encoding result of entity s output by the l+1th layer encoding network in the first encoding unit, and f(·) is the encoding function of the first encoding unit; and is the weight of the l-th layer coding network in the first coding unit; t i Represents entity e in the first knowledge graph s Time of occurrence; Represents entity e s In t i The number of neighbor entities in the first knowledge graph at time instant; Represents entity e s In t i Neighbor entities in the first knowledge graph at the moment, is the feature encoding result of the neighbor entity o output by the l-th layer encoding network in the first encoding unit, x r and are the static representation of relation r and the entity e output by the l-th layer encoding network in the first encoding unit, respectively. s The feature encoding result.
[0104] The second encoding unit is used to aggregate and update each entity in the second knowledge graph at the level of the second knowledge graph according to each entity in the second knowledge graph, the relationship between each entity and the corresponding time information to obtain a second feature encoding result for each entity in the second knowledge graph.
[0105] After obtaining the first feature encoding result and the second feature encoding result, the second feature encoding result can be directly used as the final feature encoding result to predict the feature representation of each entity and each relationship in the second knowledge graph, or the first feature encoding result and the second feature encoding result can be combined as the final feature encoding result to predict the feature representation of each entity and each relationship in the second knowledge graph; this embodiment does not specifically limit this.
[0106] This embodiment obtains the first feature encoding result of each node in the first knowledge graph in the second knowledge graph in a hierarchical manner, first at the sub-map level (first knowledge graph level); then, at the global map level (second knowledge graph level), obtains the second feature encoding result of each node in the second knowledge graph; the timing information and association relationship information of each node in the second knowledge graph can be extracted more comprehensively, thereby making the event prediction result more accurate.
[0107] On the basis of the above embodiments, the first feature encoding result of each entity in each first knowledge graph is input into the second encoding unit in this embodiment, and each entity in the second knowledge graph is feature encoded at the level of the second knowledge graph to obtain the second feature encoding result of each entity in the second knowledge graph at each moment in the first historical period, including: performing the following steps for each entity in the second knowledge graph: obtaining the time difference and relationship between the current entity and the neighboring entity of the current entity; obtaining the degree of dependence of the relationship between the current entity and the neighboring entity on time based on the time difference and the relationship; performing aggregation update on the current entity based on the relationship between the current entity and the neighboring entity and the degree of dependence to obtain the second feature encoding result of the current entity.
[0108] Optionally, for each entity in the second knowledge graph, the second encoding unit is used to perform the following feature encoding steps:
[0109] First, consider the degree of dependence of time on the adjacency relationship between the current entity and the neighboring entity in the second knowledge graph; specifically, obtain the degree of dependence between the current entity and the neighboring entity based on the time difference and relationship between the current entity and the neighboring entity. The specific calculation formula is:
[0110]
[0111]
[0112] in, is the relationship embedding between entity i and neighbor entity j in the second knowledge graph, i.e., the degree of dependency, t i and t j is the time corresponding to entity i and entity j; φ(t) is the time encoding function, x r is the static representation of the relation r, d represents the feature dimension of the static representation, and w and p are learnable vector parameters.
[0113] Then, the attention mechanism in the graph neural network in the second encoding unit is used to calculate the attention calculation coefficient between the current entity and the neighboring entity according to the relationship and degree of dependence between the current entity and the neighboring entity. The specific formula is:
[0114]
[0115] in, is the attention calculation coefficient between the current entity s and the neighbor entity o, is the weight coefficient, a T is the learnable weight vector parameter, is the node in the second knowledge graph At the output of the encoder layer l, is the node in the second knowledge graph At the output of the encoder layer l, is the relationship embedding between entity i and neighbor entity j in the second knowledge graph, is a node in the second knowledge graph At the output of the encoder layer l, is the relationship embedding between entity i and neighbor entity k in the second knowledge graph, is a node in the second knowledge graph, is a node in the second knowledge graph neighbor nodes.
[0116] Then, according to the attention calculation coefficient between the current entity and the neighboring entities, the neighboring entities of each entity are aggregated and the second feature encoding result of the current entity is updated; the specific formula is:
[0117]
[0118] in, is the second feature encoding result of the current entity s, is the attention calculation coefficient between the current entity s and the neighbor entity o, and is the weight coefficient, t i is the time when the entity interaction occurs, is a node in the second knowledge graph At the output of the encoder layer l; is the relationship embedding between entity i and its neighbor entity k in the second knowledge graph; is a node in the second knowledge graph The output of the encoder layer l.
[0119] In recent years, with the development of computer technology and the explosive growth of massive data, deep learning and big data technology have become the mainstream of dynamic knowledge graph prediction. Based on the above consensus, this embodiment develops and establishes algorithms and models for dynamic knowledge graph prediction, converts the time-related first knowledge graph sequence into a global second knowledge graph, and uses the graph neural network model in the encoding submodule to perform multi-level feature encoding on the entities in the second knowledge graph, so as to better capture the time series information, improve the prediction accuracy of the dynamic knowledge graph, and provide more effective reference information for event prediction scenarios.
[0120] On the basis of the above embodiments, the feature prediction submodule in this embodiment includes a first feature prediction unit, a second feature prediction unit and a fusion unit; the fusion unit includes a first fusion unit and a second fusion unit; the feature encoding results of each entity in the second knowledge graph at each moment in the first historical period and each relationship are input into the feature prediction submodule to obtain the feature representation of each entity and each relationship in the second knowledge graph in the current period, including: inputting the first feature encoding results of each entity in the second knowledge graph at each moment in the first historical period and each relationship into the first feature prediction unit to obtain the feature representation of each entity in the second knowledge graph and the first feature representation of each relationship in the current period; input the second feature encoding results of each entity and each relationship in the second knowledge graph at each moment within the first historical period into the second feature prediction unit to obtain the second feature representation of each entity and each relationship in the second knowledge graph in the current period; input the first feature representation and the second feature representation of each entity in the second knowledge graph into the first fusion unit to obtain the feature representation of each entity in the second knowledge graph in the current period; input the first feature representation and the second feature representation of each relationship in the second knowledge graph into the second fusion unit to obtain the feature representation of each relationship in the second knowledge graph in the current period.
[0121] like Figure 2 As shown, the feature prediction submodule includes a first feature prediction unit, a second feature prediction unit and a fusion unit.
[0122] The structure of each unit in the feature prediction submodule can be constructed and generated according to actual needs. For example, the first feature prediction unit and the fusion unit can be constructed and generated based on other deep learning models such as GRU (Gated Recurrent Unit) network, and the second feature prediction unit can be constructed and generated based on other neural network models such as MLP (Multilayer Perceptron).
[0123] After using the encoding submodule to perform feature encoding on each node in the second knowledge graph, the feature prediction submodule can be used to extract the long-term and short-term feature representations of entities and relationships in the second knowledge graph at each moment in the current cycle from the output results of the encoding submodule.
[0124] Among them, for the short-term feature representation, that is, the first feature representation extraction, it can be achieved through the following steps:
[0125] The first feature encoding result and relationship of each entity in the first knowledge graph, i.e., the sub-graph level, are used as the input information of the first feature prediction unit. The first feature prediction unit encodes and predicts the first feature encoding result and relationship of each entity in the first knowledge graph level to obtain the short-term feature representation of each entity and each relationship in the second knowledge graph in the current period, i.e., the first feature representation. Among them, the first feature representation of each entity in the current period is:
[0126]
[0127] in, is the first feature representation of entity s in the second knowledge graph at period t+1; is the first feature representation of entity s in the second knowledge graph at period t, h s,t It is the first feature encoding result of entity s in the first knowledge graph in period t.
[0128] Among them, the first feature of each relationship in the current cycle is expressed as:
[0129]
[0130] in, is the first feature representation of relation r in the second knowledge graph at period t+1; is the first feature representation of entity r in the second knowledge graph at period t, h r,t It is the feature representation of relation r in period t in the first knowledge graph, that is, the relation representation.
[0131] Among them, the relationship representation h at each moment r,t The calculation method is as follows:
[0132]
[0133] Among them, Meanpooling(·) is the average pooling operation; is the entity s in the first knowledge graph i The first feature encoding result at the moment, || is the vector concatenation symbol, x r is the static representation of relation r, e s For entity s, is the set of associated entities of relation r at each moment in period t.
[0134] Among them, for the long-term feature representation, that is, the second feature representation extraction, it can be achieved through the following steps:
[0135] The second feature encoding result and relationship of each entity at the second knowledge graph, i.e., the global graph level, are used as input information of the second feature prediction unit. The second feature prediction unit encodes and predicts the second feature encoding result and relationship of each entity at the second knowledge graph level to obtain the long-term feature representation of each entity and each relationship in the second knowledge graph in the current period, i.e., the second feature representation.
[0136] Among them, the entity input at the global graph level can be used as the long-term representation of each entity at different times, that is, the second feature representation of each entity in the current period:
[0137]
[0138] in, is the long-term representation of entity s in period t+1, i.e., the second feature representation. W6 and b are the weight coefficient and bias in the second feature prediction unit, respectively. Z s,t is the second feature encoding result of entity s in the second knowledge graph in period t;
[0139] Among them, the static representation of the available relationship can be used as the long-term representation of each relationship at different times, that is, the second feature representation of each relationship in the current period:
[0140]
[0141] in, is the second characteristic representation of each relation r in the t+1 period, x r is the static representation of each relation r.
[0142] Optionally, after obtaining the first feature representation and the second feature representation of each entity and each relationship in the second knowledge graph in the current period, a fusion unit can be used to fuse the first feature representation and the second feature representation of the entity, and the first feature representation and the second feature representation of the relationship, respectively, to obtain the final feature representation of the entity and the relationship.
[0143] Among them, the fusion unit can be constructed and generated based on the gated unit; the calculation formula for the final feature representation is:
[0144]
[0145]
[0146] Among them, e s,t+1is the final feature representation of entity s in period t+1, g e , are the gating vectors of entities and relations respectively; ⊙ is the element-wise multiplication operation, is the long-term representation of entity s in period t+1, is the short-term representation of entity s in period t+1; e r,t+1 is the final feature representation of relation r in period t+1, is the long-term representation of relation r in period t+1, is the short-term representation of relation r in period t+1.
[0147] This embodiment first converts the serialized first knowledge graph into a global second knowledge graph, and then uses the hierarchical relationship graph neural network in the encoding submodule to perform feature encoding on the second knowledge graph. After obtaining the feature encoding results of each entity at different levels, the long-term feature representation and short-term feature representation of the predicted entity and relationship are encoded from the feature encoding results at different levels by the first feature prediction unit and the second feature prediction unit respectively. Finally, the fusion unit is used to fuse the long-term and short-term representations of the entity and relationship, so as to make the dynamic prediction of the feature representation of each entity and the feature representation of each relationship more accurate, so as to realize accurate dynamic prediction of events.
[0148] In summary, compared with the existing static graph reasoning models that are unable to model the time dependencies in graph sequences, the prediction model in this example can not only adaptively establish long-term time dependencies in graph sequences, but also adaptively establish short-term time dependencies in graph sequences; and by combining the long-term time dependencies and short-term time dependencies in the graph sequences, the inference and prediction of the feature representations of each entity and each relationship are more accurate, making the event prediction results more reliable and accurate.
[0149] Based on the above embodiments, the loss function of the first prediction module in this implementation is generated based on the fusion of the first loss function and the second loss function; wherein, the first loss function is generated based on the predicted feature representation of each entity in the fourth knowledge graph generated by splicing the third knowledge graph corresponding to all moments in the second historical period, and the deviation between the real feature representation; the second loss function is generated based on the deviation between the predicted feature representation of each relationship in the fourth knowledge graph and the real feature representation.
[0150] Optionally, during the prediction model training process, the prediction model needs to be trained by combining the loss function of the first prediction module and the loss function of the second prediction module;
[0151] Among them, the loss function of the second prediction model is constructed and generated based on the deviation between the predicted event corresponding to the sample historical time and the real event.
[0152] The loss function of the first prediction module is generated based on the fusion of the first loss function and the second loss function.
[0153] Optionally, the loss function acquisition step of the first prediction module includes:
[0154] First, the fourth knowledge graph generated by splicing the third knowledge graphs corresponding to all moments in the second historical period is used as the input information of the prediction model to predict the feature representation of each entity and each relationship in the fourth knowledge graph in the next historical period;
[0155] Then, the deviation between the predicted feature representation and the actual feature representation of each entity in the fourth knowledge graph in the next historical period is constructed to generate the first loss function. The specific formula is:
[0156]
[0157] in, is the first loss function, i.e., the entity prediction loss function; T is the total number of all moments in the second historical period; e s s is the entity; r is the relationship; e is the o is entity o; G t+1 is the knowledge graph of period t+1; is the conditional probability, is a knowledge graph with a period less than t+1.
[0158] The deviation between the predicted feature representation and the actual feature representation of each relationship in the fourth knowledge graph in the next historical period is used to construct the second loss function. The specific formula is:
[0159]
[0160] in, is the second loss function, is the conditional probability.
[0161] Finally, in order to balance the first loss function and the second loss function, the first loss function and the second loss function are fused, and the parameters of the target detection model and the classification model are optimized according to the fusion result;
[0162] The fusion method includes, but is not limited to, directly adding the first loss function and the second loss function or weighted adding them, which is not specifically limited in this implementation.
[0163] For example, the specific formula for generating the loss function of the first prediction module by fusing the first loss function and the second loss function is:
[0164]
[0165] in, is the loss function of the first prediction module, λ1 and λ2 are weight coefficients, and ‖Θ‖2 is the regularization term.
[0166] Since the calculation operations involved in the prediction model are all differentiable, the prediction model can use the standard gradient descent method or other optimized gradient descent methods to update the parameters.
[0167] This embodiment trains the prediction model as a whole by combining the first loss function generated by the entity prediction construction and the second loss function generated by the relationship prediction construction, so that the comprehensive performance of the trained prediction model is better.
[0168] Based on the above embodiments, the first prediction module in this implementation is generated based on a graph neural network and a recurrent neural network.
[0169] like Figure 2 The encoding submodule and the feature prediction submodule in the first prediction module;
[0170] Among them, the first encoding unit and the second encoding unit of the encoding submodule can be generated based on the graph neural network; the type of the graph neural network can be other types such as a hierarchical graph neural network, which is not specifically limited in this embodiment.
[0171] One or more combinations of the first feature prediction unit, the second feature prediction unit and the fusion unit of the feature prediction submodule can be constructed and generated using a recurrent neural network, and the types of the recurrent neural networks used can be the same or different, which is not specifically limited in this embodiment.
[0172] For example, the first feature prediction unit and the second fusion unit both use a GRU network.
[0173] This embodiment performs dynamic knowledge graph prediction problems based on a graph neural network with hierarchical relationships and a recurrent network that can extract up-down relationships, thereby achieving accurate dynamic prediction of events.
[0174] The event prediction device based on the dynamic knowledge graph provided by the present invention is described below. The event prediction device based on the dynamic knowledge graph described below and the event prediction method based on the dynamic knowledge graph described above can be referenced to each other.
[0175] like Figure 3As shown, this embodiment provides an event prediction device based on a dynamic knowledge graph, the device comprising:
[0176] The first construction module 301 is used to: obtain target historical events within a first historical period, and construct a first knowledge graph corresponding to each moment according to all target historical events at each moment within the first historical period;
[0177] Optionally, the target historical event is first collected from a corpus such as news events or Wikipedia.
[0178] Then, through entity extraction, the entities and the relationships between entities in each target historical event at each moment in the first historical period are extracted; and using each entity in all target historical events at each moment as a node, and the relationship between entities in all target historical events at each moment as an edge, a time-related dynamic knowledge graph is constructed and generated, that is, the first knowledge graph corresponding to each moment.
[0179] The second construction module 302 is used to: splice the first knowledge graphs corresponding to all moments in the first historical period to generate a second knowledge graph;
[0180] Optionally, after obtaining the first knowledge graph corresponding to each moment in the first historical period, the first knowledge graph corresponding to each moment can be converted into a global knowledge graph, that is, a second knowledge graph.
[0181] The feature prediction module 303 is used to: input the second knowledge graph into the first prediction module of the prediction model to obtain the feature representation of each entity and the relationship between each entity in the second knowledge graph in the current period;
[0182] After obtaining the second knowledge graph, the second knowledge graph can be used as the input of the trained first prediction module to predict and update the feature representations of the entities and the relationships between them in the second knowledge graph to obtain the feature representations of the relationships between them in the second knowledge graph in the current period.
[0183] The event prediction module 304 is used to: input the feature representation of each entity and each relationship in the second knowledge graph in the current period into the second prediction module of the prediction model to obtain the predicted event of the current period; wherein the prediction model is trained based on sample historical events in the second historical period and real events in the next historical period of the second historical period.
[0184] Optionally, after obtaining the feature representation of each entity and each relationship in the second knowledge graph in the current period, the feature representation of each entity and each relationship in the second knowledge graph in the current period can be input into the second prediction module. By learning the features of each entity and each relationship in the current period, the predicted events of the current period can be obtained.
[0185] The event prediction method based on the dynamic knowledge graph provided in this embodiment constructs a first knowledge graph corresponding to each time by utilizing the entities and relationships of the target historical events, and splices the sequences composed of all the first knowledge graphs to obtain a global second knowledge graph. By learning the temporal information of the global second knowledge graph, the feature representation of each entity and the relationship between entities in the second knowledge graph in the current period is dynamically predicted to achieve accurate dynamic prediction of events.
[0186] Based on the above embodiments, the first prediction module in this embodiment includes an encoding submodule and a feature prediction submodule; the feature prediction module is used to: input the second knowledge graph into the encoding submodule to obtain the feature encoding results of each entity in the second knowledge graph at each moment in the first historical period; input the feature encoding results of each entity and each relationship in the second knowledge graph at each moment in the first historical period into the feature prediction submodule to obtain the feature representation of each entity and each relationship in the second knowledge graph in the current period.
[0187] On the basis of the above embodiments, the encoding submodule in this embodiment includes a first encoding unit and a second encoding unit; the feature prediction module is also used to: input the second knowledge graph into the first encoding unit, and feature encode each entity in each first knowledge graph in the second knowledge graph at the level of each first knowledge graph in the second knowledge graph to obtain the first feature encoding result of each entity in each first knowledge graph in the second knowledge graph at each moment in the first historical period; input the first feature encoding result of each entity in each first knowledge graph into the second encoding unit, and feature encode each entity in the second knowledge graph at the level of the second knowledge graph to obtain the second feature encoding result of each entity in the second knowledge graph at each moment in the first historical period.
[0188] On the basis of the above embodiments, the feature prediction module in this embodiment is also used to: perform the following steps for each entity in the second knowledge graph: obtain the time difference and relationship between the current entity and the neighbor entity of the current entity; obtain the degree of dependence of the relationship between the current entity and the neighbor entity on time based on the time difference and the relationship; perform aggregation update on the current entity based on the relationship between the current entity and the neighbor entity and the degree of dependence to obtain the second feature encoding result of the current entity.
[0189] On the basis of the above embodiments, the feature prediction submodule in this embodiment includes a first feature prediction unit, a second feature prediction unit and a fusion unit; the fusion unit includes a first fusion unit and a second fusion unit;
[0190] The feature prediction module is also used to: input the first feature encoding results of each entity in the second knowledge graph at each moment in the first historical period and each relationship into the first feature prediction unit to obtain the first feature representation of each entity and each relationship in the second knowledge graph in the current period; input the second feature encoding results of each entity in the second knowledge graph at each moment in the first historical period and each relationship into the second feature prediction unit to obtain the second feature representation of each entity and each relationship in the second knowledge graph in the current period; input the first feature representation and the second feature representation of each entity in the second knowledge graph into the first fusion unit to obtain the feature representation of each entity in the second knowledge graph in the current period; input the first feature representation and the second feature representation of each relationship in the second knowledge graph into the second fusion unit to obtain the feature representation of each relationship in the second knowledge graph in the current period.
[0191] On the basis of the above embodiments, the loss function of the first prediction module in this embodiment is generated based on the fusion of the first loss function and the second loss function; wherein, the first loss function is generated based on the predicted feature representation of each entity in the fourth knowledge graph generated by splicing the third knowledge graph corresponding to all moments in the second historical period, and the deviation between the real feature representation; the second loss function is generated based on the deviation between the predicted feature representation of each relationship in the fourth knowledge graph and the real feature representation.
[0192] Based on the above embodiments, the first prediction module in this embodiment is generated based on a graph neural network and a recurrent neural network.
[0193] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4As shown, the electronic device may include: a processor (processor) 401, a communication interface (Communications Interface) 402, a memory (memory) 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404. The processor 401 can call the logic instructions in the memory 403 to execute an event prediction method based on a dynamic knowledge graph, which includes: obtaining target historical events within a first historical period, and constructing a first knowledge graph corresponding to each moment according to all target historical events at each moment in the first historical period; splicing the first knowledge graphs corresponding to all moments in the first historical period to generate a second knowledge graph; inputting the second knowledge graph into a first prediction module of a prediction model to obtain feature representations of each entity and the relationship between each entity in the second knowledge graph in the current period; inputting the feature representations of each entity and each relationship in the second knowledge graph in the current period into a second prediction module of the prediction model to obtain predicted events for the current period; wherein the prediction model is trained based on sample historical events in the second historical period and real events in the next historical period of the second historical period.
[0194] In addition, the logic instructions in the above-mentioned memory 403 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0195] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the event prediction method based on the dynamic knowledge graph provided by the above methods, the method including: obtaining the target historical events within a first historical period, and constructing a first knowledge graph corresponding to each moment according to all the target historical events at each moment in the first historical period; splicing the first knowledge graphs corresponding to all moments in the first historical period to generate a second knowledge graph; inputting the second knowledge graph into the first prediction module of the prediction model to obtain the feature representation of each entity and the relationship between each entity in the second knowledge graph in the current period; inputting the feature representation of each entity and each relationship in the second knowledge graph in the current period into the second prediction module of the prediction model to obtain the predicted event of the current period; wherein the prediction model is trained based on sample historical events in the second historical period and real events in the next historical period of the second historical period.
[0196] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the event prediction method based on the dynamic knowledge graph provided by the above-mentioned methods, the method comprising: obtaining target historical events within a first historical period, and constructing a first knowledge graph corresponding to each moment according to all target historical events at each moment in the first historical period; splicing the first knowledge graphs corresponding to all moments in the first historical period to generate a second knowledge graph; inputting the second knowledge graph into a first prediction module of a prediction model to obtain feature representations of each entity and the relationship between each entity in the second knowledge graph in the current period; inputting the feature representations of each entity and each relationship in the second knowledge graph in the current period into a second prediction module of the prediction model to obtain predicted events for the current period; wherein the prediction model is trained based on sample historical events in the second historical period and real events in the next historical period of the second historical period.
[0197] The device embodiments described above are merely illustrative, wherein 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 modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0198] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0199] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An event prediction method based on dynamic knowledge graph, characterized in that: include: Obtain target historical events within a first historical period, and construct a first knowledge graph corresponding to each moment according to all target historical events at each moment within the first historical period; Splicing the first knowledge graphs corresponding to all moments in the first historical period to generate a second knowledge graph; Inputting the second knowledge graph into the first prediction module of the prediction model to obtain feature representations of the entities and the relationships between the entities in the second knowledge graph in the current period; Inputting the feature representation of each entity and each relationship in the second knowledge graph in the current period into the second prediction module of the prediction model to obtain the predicted event of the current period; The prediction model is obtained by training based on sample historical events in the second historical period and real events in the next historical period of the second historical period; The target historical event is a historical event collected from a corpus of news events whose popularity is greater than a preset threshold, or a historical event whose theme is a preset theme or a target field; The first prediction module includes a coding submodule and a feature prediction submodule, the coding submodule is generated based on a hierarchical relationship graph neural network, and the feature prediction submodule is generated based on a recurrent neural network; The step of obtaining the feature representation of each entity and the relationship between each entity in the second knowledge graph in the current cycle includes: Inputting the second knowledge graph into the encoding submodule to obtain feature encoding results of each entity in the second knowledge graph at each time in the first historical period; The feature encoding results of each entity and each relationship in the second knowledge graph at each moment in the first historical period are input into the feature prediction submodule to obtain the feature representation of each entity and each relationship in the second knowledge graph in the current period.
2. The event prediction method based on dynamic knowledge graph according to claim 1 is characterized in that: The encoding submodule includes a first encoding unit and a second encoding unit; The step of inputting the second knowledge graph into the encoding submodule to obtain the feature encoding results of each entity in the second knowledge graph at each time point in the first historical period includes: Input the second knowledge graph into the first encoding unit, and perform feature encoding on each entity in each first knowledge graph in the second knowledge graph at the level of each first knowledge graph in the second knowledge graph, to obtain a first feature encoding result for each entity in each first knowledge graph in the second knowledge graph at each time in the first historical period; The first feature encoding result of each entity in each first knowledge graph is input into the second encoding unit, and at the level of the second knowledge graph, each entity in the second knowledge graph is feature encoded to obtain the second feature encoding result of each entity in the second knowledge graph at each moment in the first historical period.
3. The event prediction method based on dynamic knowledge graph according to claim 2 is characterized in that: The first feature encoding result of each entity in each first knowledge graph is input into the second encoding unit, and feature encoding is performed on each entity in the second knowledge graph at the level of the second knowledge graph to obtain the second feature encoding result of each entity in the second knowledge graph at each time in the first historical period, including: For each entity in the second knowledge graph, perform the following steps: Obtaining the time difference and relationship between the current entity and the neighboring entities of the current entity; According to the time difference and the relationship, obtaining the degree of dependence of the relationship between the current entity and the neighbor entity on time; According to the relationship between the current entity and the neighboring entities and the degree of dependence, the current entity is aggregated and updated to obtain a second feature encoding result of the current entity.
4. The event prediction method based on dynamic knowledge graph according to claim 2 is characterized in that: The feature prediction submodule includes a first feature prediction unit, a second feature prediction unit and a fusion unit; the fusion unit includes a first fusion unit and a second fusion unit; The feature encoding results of each entity and each relationship in the second knowledge graph at each moment in the first historical period are input into the feature prediction submodule to obtain the feature representation of each entity and each relationship in the second knowledge graph in the current period, including: Input the first feature encoding results of each entity in each first knowledge graph and each relationship in the second knowledge graph at each moment in the first historical period into the first feature prediction unit to obtain the first feature representation of each entity and each relationship in the second knowledge graph in the current period; Input the second feature encoding results of each entity and each relationship in the second knowledge graph at each moment in the first historical period into the second feature prediction unit to obtain the second feature representation of each entity and each relationship in the second knowledge graph in the current period; Inputting the first feature representation and the second feature representation of each entity in the second knowledge graph into the first fusion unit to obtain the feature representation of each entity in the second knowledge graph in the current period; The first feature representation and the second feature representation of each relationship in the second knowledge graph are input into the second fusion unit to obtain the feature representation of each relationship in the second knowledge graph in the current period.
5. The event prediction method based on dynamic knowledge graph according to any one of claims 1 to 4, characterized in that: The loss function of the first prediction module is generated based on the fusion of the first loss function and the second loss function; The first loss function is generated by constructing a deviation between the predicted feature representation of each entity in the fourth knowledge graph generated by splicing the third knowledge graph corresponding to all moments in the second historical period and the actual feature representation; The second loss function is generated based on the deviation between the predicted feature representation and the actual feature representation of each relationship in the fourth knowledge graph.
6. An event prediction device based on a dynamic knowledge graph, characterized in that: include: A first construction module is used to: obtain target historical events within a first historical period, and construct a first knowledge graph corresponding to each moment according to all target historical events at each moment within the first historical period; A second construction module is used to: splice the first knowledge graphs corresponding to all moments in the first historical period to generate a second knowledge graph; A feature prediction module, used to: input the second knowledge graph into the first prediction module of the prediction model to obtain feature representations of the entities and the relationships between the entities in the second knowledge graph in the current period; An event prediction module, used to: input the feature representation of each entity and each relationship in the second knowledge graph in the current period into the second prediction module of the prediction model to obtain the predicted event of the current period; The prediction model is obtained by training based on sample historical events in the second historical period and real events in the next historical period of the second historical period; The target historical event is a historical event collected from a corpus of news events whose popularity is greater than a preset threshold, or a historical event whose theme is a preset theme or a target field; The first prediction module includes a coding submodule and a feature prediction submodule, the coding submodule is generated based on a hierarchical relationship graph neural network, and the feature prediction submodule is generated based on a recurrent neural network; The step of obtaining the feature representation of each entity and the relationship between each entity in the second knowledge graph in the current cycle includes: Inputting the second knowledge graph into the encoding submodule to obtain feature encoding results of each entity in the second knowledge graph at each time in the first historical period; The feature encoding results of each entity and each relationship in the second knowledge graph at each moment in the first historical period are input into the feature prediction submodule to obtain the feature representation of each entity and each relationship in the second knowledge graph in the current period.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the event prediction method based on the dynamic knowledge graph as described in any one of claims 1 to 5 is implemented.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the event prediction method based on a dynamic knowledge graph as described in any one of claims 1 to 5 is implemented.