A knowledge reasoning method for new entities in a time-oriented knowledge graph
By constructing neighbor-structure-aware negative samples and fusing multiple encoders, the accuracy and efficiency issues of learning new entity representations in temporal knowledge graphs are addressed, enabling efficient new entity reasoning and graph completion, and improving the performance of intelligent question answering and fast retrieval.
Patent Information
- Application Number
- CN202210932724.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-04
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2042-08-04
AI Technical Summary
Existing temporal knowledge graph representation learning methods ignore the case of newly added entities, resulting in high computational costs and insufficient accuracy for inference and prediction models, and failing to effectively capture deep structural and semantic information.
By constructing negative samples based on neighbor structure awareness, and integrating encoders such as R-GCN, LSTM, and attention mechanisms, we learn neighbor information from multiple perspectives, generate more relevant negative samples, and use these encoders to obtain vector representations of new entities. Finally, we use the decoder for inference and prediction.
It improves the accuracy and efficiency of new entity reasoning, expands the reasoning capabilities of time knowledge graphs, and supports applications such as intelligent question answering and fast retrieval.
Smart Images

Figure CN115344708B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of time knowledge graph and natural language processing. BACKGROUND
[0002] In recent years, with the gradual maturity of the related technology of static knowledge graph, the research on time knowledge graph is increasing, and the representation learning and reasoning technology of time knowledge graph is the most important for completing and applying the graph. In order to obtain the vector representation of the information in the time knowledge graph, the existing model is mostly based on the static knowledge graph representation learning method, and the four-tuple is split into triple according to time for learning, the information source is relatively single, and the new entity information which does not exist in the graph is ignored, and the vector representation of the new entity needs a large calculation cost. SUMMARY
[0003] The reasoning method of new entity knowledge relates to important tasks such as time knowledge graph completion and application, and is suitable for natural language related fields such as news corpus. The current time knowledge graph representation learning method mostly ignores the situation of new entities added over time, and the single-angle learning for data cannot capture deeper structural and semantic information, resulting in that the reasoning prediction model cannot efficiently and accurately obtain the vector representation of the new entity with low calculation cost.
[0004] In view of the above problems of new entity reasoning representation learning of time knowledge graph, the present application provides an effective new entity knowledge reasoning method, which starts from the neighbor entities widely existing in the time knowledge graph, reasonably uses the neighbor information existing in the graph to complete the fast reasoning prediction of the new entity representation, and improves the accuracy of the reasoning representation model through the structure and semantic information of the neighbor, so that the reasoning model can accurately obtain the vector representation of the new entity with small calculation cost, and provides a more efficient and stable reasoning representation learning method for the completion, question answering and other application tasks of the time knowledge graph. Firstly, a negative sample sampling method based on neighbor structure perception is proposed, the negative sample data with stronger entity correlation is obtained through the neighbor structure information, secondly, three different structure encoders based on R-GCN, LSTM and attention mechanism are introduced from three angles of neighbor semantics, relationship time sequence and mutual influence degree between different entities, and then the entity vector representations obtained by the three encoders are weighted and fused to obtain the final entity representation. Finally, the trained reasoning model is used to reason and predict the missing four-tuple data, so as to realize the reasoning prediction and graph completion of the new entity of the time knowledge graph, and provide basic technical support for the intelligent question answering, rapid retrieval and other applications of the graph.
[0005] In order to achieve the above purpose, the technical scheme provided by the present application is:
[0006] A knowledge reasoning method for new entities in a time knowledge graph, characterized in that the method comprises
[0007] Step 1, processing data and constructing negative samples;
[0008] Step 2, encoding the data in step 1 by fusing three kinds of structure encoders;
[0009] Step 3, training the model in combination with a decoder;
[0010] Step 4, using the reasoning model trained in step 3 to realize reasoning prediction for new entities.
[0011] Beneficial effects
[0012] The present application is aimed at the problem that the existing representation learning model for time knowledge graph cannot process newly added entities, and a time knowledge graph new entity reasoning model based on neighbor information is designed, neighbor information is learned from different angles such as neighbor semantics, time sequence and influence between entities by fusing three kinds of different structure encoders, and thus the representation of new entities is directly calculated and reasoned out without separately assigning vectors to each entity and fitting, and the reasoning capability of the time knowledge graph is further expanded.
[0013] In addition, the present application also proposes a negative sample generation method based on neighbor structure perception, which discards the previous method of randomly generating negative samples, generates negative samples of different ranges from neighbor entities of different hops, improves the relevance between entities in the negative samples, and thus makes the reasoning representation learning model have better learning capability. This has great significance for realizing intelligent question answering, auxiliary decision making, efficient retrieval and other application requirements in various fields based on time knowledge graph in the knowledge empowerment era. BRIEF DESCRIPTION OF DRAWINGS
[0014] The accompanying drawings are part of the specification and constitute a part of the specification, and together with the following specific embodiments, they are used to explain the present disclosure, but do not constitute a limitation on the present application. In the drawings:
[0015] Figure 1 It is a flowchart of the new entity knowledge reasoning process for the time knowledge graph;
[0016] Figure 2 It is a negative sample sampling example diagram in step one;
[0017] Figure 3 It is a flowchart of realizing reasoning prediction for new entities in step four;
[0018] Figure 4 It is an example diagram of reasoning prediction for new entities. DETAILED DESCRIPTION
[0019] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the specific implementation of the present application will be described clearly and completely below with reference to the drawings. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the present application, and are not used to limit the present application.
[0020] The specific implementation process of the present application is shown in Figure 1 , which includes the following four aspects:
[0021] Step 1, processing data and constructing negative samples;
[0022] Step 2, fusing three kinds of structure encoders to encode the data of step 1;
[0023] Step 3, training the model in combination with the decoder;
[0024] Step 4, using the model trained in step 3 to realize inference prediction for new entities.
[0025] Each step is described in detail as follows.
[0026] First step: processing data and constructing negative samples;
[0027] 1.1: processing data
[0028] Taking the entity i in the news corpus as an example, for the related four tuples (i, r1, j1, τ1), (i, r2, j2, τ2), …, (i, rk, jk, τk) of the entity in the time knowledge graph, j is the neighbor entity of entity i, r is the relationship between entities, τ is the time label corresponding to the entity relationship, and k ∈ (1, …, n). Because the encoder takes the neighbor entity and the relationship pair of the entity as input, by omitting the known entity i, the above four tuple data is processed into a triple that can meet the input requirements of the encoder, i.e. (r1, j1, τ1), (r2, j2, τ2), …, (rk, jk, τk). n n n k k k n n n ). As in the news corpus, the basketball star LeBron James as a player entity type, has been with the Cleveland Cavaliers, Miami Heat and Los Angeles Lakers team entity type has the relationship of member of, that is (LeBron James, member of, Cleveland Cavaliers, 2003-2010 & 2014-2018), (LeBron James, member of, Miami Heat, 2010-2014) and (LeBron James, member of, Los Angeles Lakers, 2018-). Then, the processed positive sample set X is output to step 1.2 and step 2;
[0029] 1.2: Constructing negative samples
[0030] In order to avoid randomly generating negative samples, the present application proposes a neighbor structure-aware negative sample generation method by means of the neighbor relationship of entities, and different range of negative samples is generated by dividing neighbor entities of different hops. For example, for a certain positive sample triple (r1, j1, τ1) of entity i, if there is a triple (r k1 ,k1,τ k1 ) related to entity j1, then k1 is a two-hop neighbor entity of entity i, and by replacing entity j1 in the positive sample, a two-hop range negative sample (r1, k1, τ1) can be obtained; if there is a triple (r l1 ,m1,τ l1 ) related to entity k1, then m1 is a three-hop neighbor entity of entity i, and by replacing entity j1 in the positive sample, a three-hop range negative sample (r1, m1, τ1) can be obtained. In this way, a negative sample set X' with stronger relevance than the random generation method is obtained. Then, the negative sample set data is output to step 2.
[0031] Specifically, as shown in Figure 2 , the positive samples related to entity 1 are (R2, 3, τ2) and (R3, 4, τ3), and the two-hop positive samples related to entity 3 and entity 4 are (R5, 5, τ5) and (R4, 8, τ4) respectively, then the corresponding two-hop negative samples are (R2, 5, τ2) and (R3, 8, τ3); the positive sample related to entity 8 is (R8, 9, τ8), then the corresponding three-hop negative sample is (R3, 9, τ3). That is, Figure 2 the negative sample set of entity 1 in
[0032] Second step: fuse the three structures of the encoder to encode the data of step 1;
[0033] 2.1: R-GCN-based encoder
[0034] In order to effectively learn the neighbor semantic information in the triple data, the application uses the R-GCN encoder structure, and uses neighbor information to obtain the vector representation of the current entity by means of parameter sharing and matrix decomposition. In order to adapt to the new entity existing in the time knowledge graph in the application, the parameters of the self-loop edge are removed in the R-GCN encoder, which will be described in detail as follows:
[0035] The neighbor structure information in the triple data obtained in step 1 is learned by R-GCN, and R-GCN [1] is a variant of GCN on a multi-relation graph, which can use parameter sharing or matrix decomposition to extract the features of the entity from the neighbor information of the entity with relatively few parameters. R-GCN is composed of a relatively deep network through layer-by-layer stacking, and the vector representation of the entity i obtained by each layer of R-GCN is related to the vector representation obtained by the last layer of R-GCN. The vector representation of entity i in the l+1 layer is:
[0036]
[0037] wherein σ(·) is an activation function, and ReLU function is usually used, is a set of relations in the knowledge graph, is a set of neighbor entities of entity i in the knowledge graph under relation r. i,r is a standardization parameter, which can be set to is the parameter matrix of relation r. And is the parameter of the self-loop edge. Here, the self-loop edge is added to each entity to prevent the calculation of the representation of the entity from only using neighbor information in the interlayer propagation process, and finally completely losing the initial information of the current entity. But in order to solve the problem of new entities, the information of the current entity needs to be completely discarded, and only the neighbor information is used to encode the current entity, so in the application, the self-loop edge is cancelled, and the vector representation of entity i is
[0038]
[0039] The encoder here selects a single-layer R-GCN, and the output of R-GCN is used as the vector representation of entity i output to step 2.4.
[0040] 2.2: LSTM-based encoder
[0041] For the time series information widely existing in the time knowledge graph, the time correlation information in the triple data is learned based on the LSTM encoder structure. In order to better learn the time correlation information, the triple data is first sorted according to the time sequence, then the corresponding linear transformation is carried out, and then the LSTM encoder is used for coding, and the specific process is as follows:
[0042] 2.2.1: Considering that time labels widely exist in the time knowledge graph, the neighbor entities and the relationship pairs in the triple data obtained in step 1 are sorted according to the time sequence to obtain an ordered sequence (r1,j1,τ1),(r2,j2,τ2),…,(r n ,j n ,τ n ),τ1≤τ2≤…≤τ n ;
[0043] 2.2.2: Linear transformation is carried out on the ordered sequence obtained in step 2.2.1:
[0044]
[0045] Wherein is the related parameter of the relationship r n , is the initial vector of the entity j n , and d is the dimension of the vector. Through simple linear transformation, the information of the entity j n and the relationship r n is fused into the vector x n . Therefore, for the entity i, the vector sequence can be obtained:
[0046] x 1:n =[x1,x2,…,x n ]
[0047] 2.2.3: The vector sequence x 1:n obtained in step 2.2.2 is input into LSTM [2] , an LSTM unit accepts an input vector x t ∈x 1:n and the hidden state of the previous LSTM as input. Through the forgetting gate f t ∈[0,1] d decide which information of the previous unit state to discard, 0 means discard all information, and 1 means retain all information:
[0048] f t =σ(W f x t +U f h t-1+b f )
[0049] where σ(·) denotes the sigmoid function, is the weight matrix of the forget gate, is the bias;
[0050] 2.2.4: Update the cell state. First, decide which information to update by the input gate i t ∈ [0, 1] d
[0051] i t = σ(W i x t + U i h t-1 + b i )
[0052] Then, use a tanh layer to generate the new candidate vector
[0053]
[0054] Next, update the LSTM block's state from c t-1 to c t :
[0055]
[0056] Here, is the weight matrix of the gate, is the bias of the gate, and ⊙ denotes element-wise multiplication.
[0057] 2.2.5: Obtain the encoded representation of the entity. Determine what information to output by the output gate:
[0058] o t = σ(W o x t + U o h t-1 + b o )
[0059] h t = o t ⊙ tanh c t
[0060] Similarly, denotes the weight matrix, and b o denotes the bias.
[0061] Through the above process, the input sequence x 1:n is converted into n hidden states h1, h2, …, h n Since each hidden state is calculated from the previous hidden state combined with the current input vector, the last hidden state h n has covered the information of the entire input sequence x 1:n , so the output h n is taken as the representation of entity i and output to step 2.4.
[0062] 2.3 Encoder based on attention mechanism
[0063] In order to fully exploit the mutual influence between neighboring entities, the encoder based on attention mechanism in this patent first performs a self-attention mechanism, and then performs an attention mechanism. In the attention mechanism process, the vector sequence obtained by the self-attention mechanism is summed by mean, thereby obtaining a rough representation of the corresponding entity, and it is taken as a query vector for learning. The specific process is as follows:
[0064] 2.3.1: Considering that different neighboring entities have different importance to the current entity, the attention mechanism [3] is introduced to highlight the learning of key information, while the self-attention mechanism is used to exploit the mutual influence between neighboring entities. In step 2.2.2, the output data of step 1 is linearly transformed to obtain an input sequence x 1:n = [x1, x2, …, x n ] that integrates neighbor entity and relationship information.
[0065] 2.3.2: For the input sequence x 1:n , a self-attention mechanism is performed. For each input vector, the self-attention mechanism will calculate the attention degree of the vector to other vectors in the input sequence.
[0066] 2.3.2.1: Multiply each input vector with three weight matrices to obtain three vectors: key vector k i , query vector q i and value v i vector, that is
[0067]
[0068]
[0069]
[0070] 2.3.2.2: The self-attention mechanism takes the query vector q i of the current input x i and the key vector k j of other input vectors x jMultiplying them together, we get a score s, i.e.
[0071]
[0072] 2.3.2.3: In order to prevent large deviations in scores when applying softmax, normalize the scores:
[0073]
[0074] Thus we get a vector s' of scores i,1:n = [s' i,1 , s' i,2 ,..., s' i,n ];
[0075] 2.3.2.4: Apply the softmax function to s' i,1:n , i.e. get the attention degree of the current input x i to other inputs:
[0076] a i,1:n = softmax(s' i,1:n )
[0077] 2.3.2.5: Multiply the value vector v j of each input vector x j with the corresponding weight a i,j , and sum all the resulting vectors, i.e.:
[0078]
[0079] where z i already contains the influence of all other inputs on the current input, take z i as the output of the current layer for input x i . Thus, for an input sequence x 1:n , the output vector sequence z 1:n = [z1, z2,..., z n ] of the self-attention layer.
[0080] 2.3.3: For the vector sequence z 1:n = [z1, z2,..., z n ], perform an attention mechanism to get the vector representation of the current entity.
[0081] Take the mean sum of the vector sequence z 1:n to get a rough representation of the current entity, and take it as the query vector q of the attention mechanism of the current layer, i.e.:
[0082]
[0083] Thus, the weight of each input vector is:
[0084] α j = softmax(qz j )
[0085] Finally, the weighted sum of all input vectors gives the vector representation of the current entity i, and is output to step 2.4:
[0086]
[0087] 2.4 Fusing the three encoders
[0088] The representations obtained from steps 2.1, 2.2 and 2.3 are jointly combined to obtain the final representation of the entity.
[0089] For entity i, the final representation at relation r and time τ is:
[0090]
[0091]
[0092] where σ is the sigmoid function, and parameters h = 1, 2, 3 are the weights of the entity’s representation based on structural information. Correspondingly, the final representation of entity j is denoted as
[0093] Step 3: Train the model with the decoder in step 2;
[0094] 3.1 Decoder
[0095] For a quadruple (i, r, j, τ), the decoder will calculate the score of the quadruple using the scoring function of HyTE [4] , i.e.,
[0096]
[0097]
[0098]
[0099]
[0100] where, e r are the vector representations of the head entity, tail entity and relation, respectively, and τ ‖w
[0101] Since the representation of the entity has been calculated by the encoder in step 2, the decoder only needs to learn the vector representation of the relation and the normal vector of the time hyperplane Yes;
[0102] 3.2 Calculate the loss value.
[0103] For the positive sample X and the negative sample X' obtained in step 1, the loss value loss = max(0, f(X) - f(X') + γ), where f is the scoring function f τ (i, r, j), is the first or second norm of the vector, and γ > 0 is the distance between the positive and negative samples. The loss value loss is then provided to step 3.3;
[0104] 3.3: Backpropagation phase to optimize model parameters.
[0105] According to the loss value obtained in step 3.2, use gradient descent or Adam algorithm to adjust the model parameters to minimize the loss value of the whole model;
[0106] 3.4: Iterative training model
[0107] If the condition for stopping iteration is met after one iteration (the loss value is less than the set threshold or the number of iterations reaches the maximum number), the training is ended and the trained model is obtained, which is provided to step 4, otherwise continue step 1.2.
[0108] Step 4: Use the model trained in step 3 to realize inference prediction for new entities. As Figure 3 shown;
[0109] 4.1: In the model obtained in step 3.4, all entities (or relationships) in the knowledge graph are respectively substituted into the quadruple, and the value of the scoring function f after each substitution of the entity (or relationship) is calculated according to step 3.2, and the scores of all entities (or relationships) are provided to step 4.2.
[0110] 4.2: Sort according to the score and select one or more entities (or relationships) with the highest score as the prediction value. As Figure 4 is an example of inference prediction of new entities, by using the inference model to learn the existing quadruple information in the knowledge graph, the vector representation of each neighbor entity is obtained, and then the entity information with the strongest correlation to the missing quadruple relationship and tail entity is obtained by calculating the score, that is, it can be inferred that the player who has served in the Cavaliers, Heat, Cavaliers, Lakers, etc. is LeBron James.
[0111] References
[0112] [1] Schlichtkrull M, Kipf T N, Bloem P, et al. Modeling relational data with graph convolutional networks [C] / / European semantic web conference. Springer, Cham, 2018: 593-607.
[0113] [2] Huang Z, Xu W, Yu K. Bidirectional LSTM-CRF models for sequence tagging [J]. arXiv preprint arXiv:1508.01991, 2015.
[0114] [3] Vaswani A, Shazeer N, Parmar N, et al. Attention is all you need [C] / / Advances in neural information processing systems. 2017: 5998-6008.
[0115] [4] Dasgupta S S, Ray S N, Talukdar P. Hyte: Hyperplane-based temporally aware knowledge graph embedding [C] / / Proceedings of the 2018 conference on empirical methods in natural language processing. 2018: 2001-2011.
[0116] Innovative points
[0117] A knowledge reasoning method for new entities in a time knowledge graph is proposed, which is different from the method of obtaining the representation of new entities from single information in the prior art. The method proposed in the application starts from the neighbor structure and semantic information in the time graph, and proposes a negative sample generation method based on neighbor structure perception. Different range of negative samples are generated by dividing neighbor entities of different jump levels, so as to improve the quality of training data. In addition, the application uses three encoder structures of R-GCN, LSTM and attention mechanism to fuse the information of neighbor semantics, time sequence and mutual influence degree between different neighbors in the time knowledge graph, so that the reasoning representation model can not only quickly learn the representation of new entities through neighbor entities, but also can improve the accuracy of the representation result to a certain extent.
[0118] The new entity knowledge reasoning method has good performance in reasoning prediction and completing a time knowledge graph task, and improves the accuracy and efficiency of new entity reasoning prediction.
Claims
1. A knowledge reasoning method for new entities in a time-oriented knowledge graph, characterized in that, Comprise: Step 1, processing data, building negative samples; Step 2, fusion three kinds of structure's encoder to step 1 data carries out coding;Specifically includes: 2.1: based on R-GCN's encoder In order to effectively learn the neighbor semantic information in the triple data, with the help of R-GCN encoder structure, through the method of parameter sharing and matrix decomposition, the vector representation of the current entity is obtained by using the neighbor information;In order to adapt to the new entity existing in the time knowledge graph, the parameters of the self spin edge are removed in the R-GCN encoder, which is specifically explained as follows: The neighbor structure information in the triple data obtained in step 1 is learned by R-GCN, which is a variant of GCN on a multi-relation graph, and the features of the entities are extracted from the neighbor information of the entities by using a parameter sharing or matrix decomposition method with relatively few parameters; R-GCN is stacked layer by layer to form a deep network, and the vector representation of an entity calculated by each layer of R-GCN is related to the vector representation obtained by the previous layer of R-GCN; the vector representation of entity i in the l+1 layer is : where σ(·) is an activation function, usually using ReLU function, is the set of relations in the knowledge graph, is the set of neighbor entities of entity i in the knowledge graph under relation r; c i,r is a standardization parameter, usually set to is the parameter matrix of relation r; and is the parameter of the spin edge; the spin edge is added to each entity to prevent the calculation of the entity representation during inter-layer propagation from only using neighbor information, ultimately completely losing the initial information of the current entity; to solve the new entity problem, the spin edge is cancelled, and the corresponding vector representation of entity i is The encoder here chooses a single-layer R-GCN and takes the output of R-GCN as the vector representation of entity i Output to step 2.4; 2.2: based on LSTM's encoder For the time sequence information widely existing in the time knowledge graph, based on the LSTM encoder structure to learn the time correlation information in the triple data;In order to better learn the time correlation information, first, the triple data is sorted according to the time sequence, and then the corresponding linear transformation is carried out, and then the LSTM encoder is used for coding; 2.3 based on attention mechanism's encoder In order to fully learn the mutual influence between neighbor entities, the encoder based on attention mechanism first executes a self attention mechanism, and then executes an attention mechanism; 2.4 fusion three kinds of encoder The representation obtained by step 2.1, 2.2 and 2.3 is combined to obtain the final representation of the entity; For entity i, the final representation under the relationship r and time τ is: where σ is a sigmoid function, and parameters are weights for the entity's representation based on structural information; correspondingly, the final representation of entity j is denoted as Step 3, combine the decoder to train the model; Step 4, using the reasoning model trained in step 3, realize the reasoning prediction for new entity.
2. The knowledge reasoning method for new entities in a time-oriented knowledge graph according to claim 1, characterized in that, Step 1: processing data, building negative samples; 1.1: processing data For entity i, for the relevant quadruplets (i,r1,j1,τ1), (i,r2,j2,τ2), ..., (i,r n ,j n ,τ n ), j k Let r be a neighboring entity of entity i. k For relationships between entities, τ k Let k be the time label corresponding to the entity relation, k∈(1,…,n); the encoder takes the neighbor entities and relation pairs of the entity as input, and by omitting the known entity i, processes the above quadruple data into triples that can meet the encoder input requirements, namely (r1,j1,τ1),(r2,j2,τ2),…,(r n ,j n ,τ n Then, the processed positive sample set X is output to steps 1.2 and 2. 1.2: build negative samples To avoid randomly generating negative samples, a neighbor structure-aware negative sample generation method is proposed, leveraging the neighbor relationships of entities. This method generates negative samples of different ranges by dividing neighbor entities into different skip levels. In summary: for a positive sample triple (r1, j1, τ1) of entity i, if there exists a triple (r1, j1, τ1) related to entity j1... k1 ,k1,τ k1 If k1 is a two-hop neighbor of entity i, then by replacing entity j1 in the positive sample, a negative sample (r1, k1, τ1) with a two-hop range is obtained; if there exists a triple (r1, k1, τ1) related to entity k1... l1 ,m1,τ l1 If m1 is a three-hop neighbor entity of entity i, then by replacing entity j1 in the positive sample, a negative sample (r1, m1, τ1) with a three-hop range is obtained. By doing so, a negative sample set X′ with stronger relevance than that generated by the random generation method is obtained. Then, the negative sample set data is output to step 2.
3. The knowledge reasoning method for new entities in a time-oriented knowledge graph according to claim 1, characterized in that, Step 2.2, the specific process is described as follows: 2.2.1: Considering the widespread presence of time tags in time knowledge graphs, the neighbor entities and relation pairs in the triplet data obtained in step 1 are first sorted according to time order to obtain an ordered sequence (r1,j1,τ1), (r2,j2,τ2), ..., (r n ,j n ,τ n ), τ1≤τ2≤…≤τ n ; 2.2.2: linear transformation is carried out on the ordered sequence obtained in step 2.2.1: wherein is a related parameter of the relation r n , is an initial vector of the entity j n , d is the dimension of the vector; by linear transformation, the information of the entity j n and the relation r n is fused into the vector x n ; for the entity i, the vector sequence is obtained: x 1:n = [x1, x2,..., x n ] 2.2.3: The vector sequence x obtained from step 2.2.2 is 1:n Input LSTM, an LSTM cell takes an input vector x t ∈ x 1:n and the previous LSTM's hidden state as input; through the forget gate f t ∈ [0, 1] d decides which information of the previous cell state to discard, 0 means discard all information, 1 means keep all information: f t = σ(W f x t + U f h t-1 + b f ) where σ(·) denotes a sigmoid function, is a weight matrix for the forget gate, is a bias; 2.2.4: Update the cell state; first, by the input gate i t ∈ [0, 1] d Decide which information to update: i t = σ(W i x t + U i h t-1 + b i ) Then, a tanh layer is used to generate new candidate vectors Next the state of the LSTM block is updated from c t-1 to c t : Here, is the weight matrix for the gate, is the bias for the gate, and denotes element-wise multiplication. 2.2.5: obtain the encoding representation of the entity;The output gate determines what information is output: o t = σ(W o x t + U o h t-1 + b o ) h t = o t ⊙ tanh c t The same applies to the following description and the claims. denotes a weight matrix, b o denotes a bias; By the above process, the input sequence x 1:n is converted into n hidden states h1, h2,..., hn n ; since each hidden state is computed from the previous hidden state combined with the current input vector, the last hidden state hn n has encompassed the information of the entire input sequence x 1:n , so the output hn n is taken as the representation of the entity i and output to step 2.
4.
4. The knowledge reasoning method for new entities in a time-oriented knowledge graph according to claim 1, characterized in that, Step 2.3: In the attention mechanism process, the vector sequence obtained by the self attention mechanism is summed by mean value, so as to obtain the rough representation of the corresponding entity, and it is used as the query vector for learning, and the specific process is described as follows: 2.3.1: Considering that different neighbor entities have different importance to the current entity, the attention mechanism is introduced to highlight the learning of key information, and the self-attention mechanism is used to mine the mutual influence between neighbor entities; the linear transformation of step 2.2.2 is performed on the output data of step 1 to obtain the input sequence x that integrates the neighbor entity and relationship information 1:n = [x1, x2, …, x n ]; 2.3.2: For the input sequence x 1:n , perform one self-attention mechanism; for each input vector, the self-attention mechanism will compute how much attention this vector pays to other vectors of the input sequence; 2.3.2.1: Multiply each input vector with three weight matrices to obtain three vectors: key vector k i , query vector q i and value v i vector, i.e. 2.3.2.2: The self-attention mechanism multiplies the query vector q i of the current input x i with the key vector k j of the other input vectors x j to obtain a score s, i.e.: 2.3.2.3: normalize the score: from which a vector s' of scores is obtained i,1:n = [s' i,1 , s' i,2 ,..., s' i,n ]; 2.3.2.4: s' for s i,1:n Applying the softmax function, we get the current input x i Degree of attention to other inputs: a i,1:n = softmax(s′ i,1:n ) 2.3.2.5: Multiply the value vector v of each input vector x j with the corresponding weight α and sum all the resulting vectors, i.e.:v = ∑ α x j i,j 2.3.2.6: Compute the output value y of the neuron as the dot product of the value vector v and the weight vector w, i.e. where z i Having included the effect of all other inputs on the current input, z i is the input x i The output at the current layer; thus, for the input sequence x 1:n , the self-attention layer output vector sequence z 1:n = [z1, z2,..., z n ] ; 2.3.3: For the vector sequence z 1:n = [z1, z2,..., z n ], perform one attention mechanism to get the vector representation of the current entity; The vector sequence z 1:n The mean sum is obtained to get the rough representation of the current entity, and is used as the query vector q of the attention mechanism of the current layer, that is: Therefore, the weight of each input vector is: a j = softmax(qz j ) The final weighted sum of all input vectors yields the vector representation of the current entity i, which is output to step 2.4: Output to step 2.4:
5. The knowledge reasoning method for new entities in a time-oriented knowledge graph according to claim 1, characterized in that, Step 3: combine the decoder to train the model; 3.1 decoder For a four tuple (i, r, j, τ), the decoder will use the score function of HyTE to calculate the score of the four tuple, that is: wherein, e r are vectors of head entities, tail entities and relations, respectively, and τ ‖2=1; As the representation of the entities has been computed by the encoder in step 2, the decoder learns the vectorial representation of the relations and the normal vector of the time hyperplane 3.2 calculate the loss value; For the positive sample X and the negative sample X' obtained in step 1, the loss value loss = max(0, f(X) - f(X') + γ), where f is the scoring function f τ (i, r, j), is the first or second norm of the vector, and γ > 0 is the margin between positive and negative samples; the loss value loss is then provided to step 3.3; 3.3: optimization model parameters in back propagation stage; According to the loss value obtained in step 3.2, the model parameters are adjusted by using gradient descent method or Adam algorithm, so as to minimize the loss value of the whole model; 3.4: iterative training model If the stopping iteration condition is reached after one iteration, the training is ended, the trained model is obtained, and is provided to step 4, otherwise step 1.2 is continued; The stopping iteration condition is that the loss value is less than the set threshold or the iteration number reaches the maximum number.
6. The knowledge reasoning method for new entities in a time-oriented knowledge graph according to claim 5, characterized in that, Define step 4.1, step 4.2: The step 4.1: in the model obtained in the step 3.4, all entities or relations in the knowledge graph are respectively substituted into the quadruple in the step 3.1, and the value of the scoring function f after each substitution of the entity or relation is calculated according to the step 3.2, and the scores of all entities or relations are provided to the step 4.2; The step 4.2: according to the scoring, one or more entities or relations with the highest score are selected as the prediction value; The above steps 4.1 and 4.2 constitute the step 4.
Citation Information
Patent Citations
Relationship extraction model based on natural language reasoning
CN112966527A
Knowledge social recommendation method, system and equipment based on graph neural network
CN113158071A