Small sample knowledge graph completion method based on neighborhood composite attention
By introducing a method based on neighborhood compound attention in the small sample knowledge graph completion model, exploring and fusion of independent and collaborative neighbor information, the problem of the impact of existing models on the interaction and noise of different neighbor features of the same entity is solved, and the problem of the impact of existing models on the interaction and noise of different neighbors in the same entity is realized. High-quality small sample relationship embedding and knowledge graph completion performance improvement.
Patent Information
- Application Number
- CN202411333184.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2044-09-24
AI Technical Summary
The existing small sample knowledge graph completion model fails to fully explore the feature interactions between different neighbors of the same entity, and ignores the impact of neighborhood noise on small sample relationship learning, resulting in insufficient accuracy in judging the degree of contribution to neighbors and the ability to embed relationship expression. decline.
CoNA-FKGC, a small sample knowledge graph completion model based on neighborhood composite attention, explore neighborhood information through independent and coordinated angles, reduce noise impact, and learn high-quality small sample relationship embedding. Specific steps include calculating independent and collaborative neighborhood encoder outputs, fusion domain features, aggregating entities using Bi-LSTM networks, and balancing relationship representations through attention mechanisms.
It effectively improves the performance of the knowledge graph completion task, learns high-quality small sample relationship embedding, reduces the impact of noise on model performance, and improves the prediction ability of small sample relationships.
Smart Images

Figure CN119166831A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence and relates to a small sample knowledge graph completion method based on neighborhood composite attention. Background Art
[0002] As the basis of knowledge graph completion tasks, knowledge graph representation learning aims to automatically capture the semantic and structural features between entities and relations in knowledge graphs by learning a representation model. The fundamental advantage of knowledge graphs is their ability to store and represent structured data, which gives them the characteristics of clear expressions, flexible data connection methods, and efficient query and retrieval efficiency. These advantages make knowledge graphs show important application potential in various fields.
[0003] Knowledge graph completion refers to the process of predicting or completing missing facts in an existing knowledge graph through deep learning and other methods. The facts here include entity, relationship or attribute information. The knowledge graph completion task mainly includes two aspects: entity completion and relationship completion.
[0004] Small-sample knowledge graph completion methods are used to handle completion tasks in scenarios where the number of samples is scarce and the knowledge graph is dynamically updated. According to the learning strategy, they can be divided into metric learning-based methods and meta-learning-based methods. Metric learning focuses on learning a similarity function to complete a specific task. Specifically, metric learning-based small-sample knowledge graph completion methods complete the completion task by calculating the similarity between the support set and the query set. For example, GMapching averages the single-hop neighbor information of aggregated entity pairs and learns a differentiable metric to measure the similarity between the support set and the query sample. Meta-learning-based methods use meta-knowledge to quickly infer new small-sample relations in the knowledge graph. For example, MetaR, as a meta-relation framework, can learn invisible meta-relation representations from support set entity pairs in a short time by transferring meta-knowledge of specific relations.
[0005] However, existing small-shot knowledge graph completion models fail to fully explore the feature interactions between different neighbors of the same entity, and also ignore the impact of neighborhood noise on the small-shot relationship learning stage. In addition, although previous methods consider the dynamic expression of neighbor relationships in specific relationship task scenarios, they do not comprehensively consider the interaction between neighbor entities and dynamic expressions, resulting in inaccurate judgment of the degree of neighbor contribution. Summary of the invention
[0006] Existing small-sample knowledge graph completion methods do not sufficiently explore entity neighborhood information and ignore the feature interactions between different neighbors of the same entity, while the interactions between neighbors can help the model better learn small-sample relationships. In addition, after aggregating the neighborhood information of the central entity, previous models did not properly handle the noise impact that may be brought by the aggregated neighborhood information, resulting in a decrease in the expressive power of small-sample relationship embedding.
[0007] In response to the problems existing in the existing methods, this paper proposes a small-sample knowledge graph completion model CoNA-FKGC based on neighborhood composite attention, which explores valuable information in the neighborhood from both independent and collaborative perspectives, while reducing the impact of neighborhood noise on model performance to a certain extent, so as to learn high-quality small-sample relationship embedding.
[0008] The technical solution of the present invention is:
[0009] A small sample knowledge graph completion method based on neighborhood composite attention includes the following steps:
[0010] Step 100, neighborhood coding;
[0011] Step 101, calculating the independent neighborhood encoder output;
[0012] Treat different neighbors differently through the attention mechanism, and calculate the central entity u and the neighbor entity v in the knowledge graph in the form of dot product. i In the neighbor relationship r i Correlation coefficient in the corresponding space The calculation process is as follows:
[0013] e′ u,r =W r ·e u
[0014]
[0015]
[0016] Among them, e u represents the initial embedding of the central entity u obtained in advance by the pre-trained model, W r represents the projection matrix corresponding to the neighbor relationship r, e′ u,r represents the embedding representation of the central entity u projected into the space where the neighbor relationship r is located, and represents matrix multiplication. i represents the i-th neighbor relationship connected to the central entity u, (u,v i ,r i ) is represented as a neighbor triplet, Represents the neighbor entity v iThe correlation coefficient with the central entity u, represents the embedding of the central entity u in the corresponding relationship space of the connected i-th neighbor entity, Represents the i-th neighbor entity v of the central entity u i Embedded in the space of its connected relations, represents the set of all neighbors of the central entity u, (v k ,r k ) represents the kth neighbor in the set, v k represents the kth neighbor entity, r k represents the kth neighbor relationship connected to the central entity u. T represents the transpose of the matrix.
[0017] The cross-combination calculation method is used to describe the cross-influence between neighbor relationships and entities, and the cross-influence is multiplied and accumulated with the attention coefficient as the output N of the independent neighborhood encoder. ind , the overall calculation process is as follows: Among them, r represents the embedded representation of the neighbor relationship, e v represents the embedding of the neighbor entity v, s v,r Represents the cross-combination features of the relationship between the neighbor entity v of the central entity and its corresponding entity, Represents the cross-combination feature of the relationship between the i-th neighbor entity of the central entity and its corresponding entity.
[0018] Step 102, calculating the collaborative neighborhood encoder output;
[0019] Introduce a multi-head self-attention mechanism to focus on different aspects or features of the input sequence and aggregate the output s′ of the multi-head attention block i To generate the output N of the collaborative neighborhood encoder co The calculation process is as follows: N co =Σβ i s′ i Where N represents the number of neighbors of the central entity u, s i ′ and s′ k Respectively represent the output results of the i-th and k-th neighbor entities after integrating other neighbor information. i It represents the correlation coefficient between the i-th neighbor entity and the central entity u after integrating other neighbor information.
[0020] Step 103, integrating domain features;
[0021] The output N of the two-part neighborhood encoder ind and N co Aggregate to obtain the fused domain features N final , through h = σ (W 1 e u+W 2 N final ) updates the central entity representation. Among them, h represents the entity representation after integrating the neighborhood information, σ represents the activation function, and W 1 Represents the initial embedding e of the central entity u u The linear transformation matrix, W 2 Represents the neighborhood feature N after fusion final The linear transformation matrix of , both of which are obtained through training;
[0022] Step 200, small sample relationship learning;
[0023] The updated head and tail entity representations are obtained through step 103 and further concatenated to obtain the embedding representation of the entity pair. The calculation process is as follows: j =[h j ||t j ], and then use the Bi-LSTM network to aggregate k entity pairs. The overall calculation process is as follows:
[0024]
[0025] Among them, h j With t j They represent the embedding representation of the jth head and tail entity after fusing the neighborhood information. j represents the embedding representation of the jth head-tail entity pair, p j Represents the output result of the j-th head-tail entity pair passing through the LSTM network at the current time step, where → and ← are forward and reverse respectively.
[0026] Then the generalized representation of the small sample relationship is generated by summing: n =∑ k g j , where j = 1, 2, 3, ..., k, the embedding representations of the head and tail entities are further concatenated, m′ j =[e h,j ||e t,j ]. Among them, e h,j With e t,j Represent the original embedding of the jth head and tail entity in the support set, m′ j Represents the original embedding representation of the jth entity pair. Then the attention mechanism is used to aggregate the information of k entity pairs. The calculation process is as follows:
[0027]
[0028] Among them, σ represents the activation function, ω x represents the attention coefficient of the xth sample, r p represents a small sample relationship representation generated using only the original information of the entity pair, u1 represents the weight matrix obtained through training. Finally, the method aggregates two small sample relationship representations, where the hyperparameter λ is used to balance the ratio. The calculation process is as follows: final =(1-λ)r n +λr p Among them, r final represents the final few-shot relation representation.
[0029] Step 300, training the model formed in steps 100 and 200;
[0030] Step 301, constructing a data set;
[0031] For each small sample relationship task generated in step 200, a support set, a query set and a candidate set are constructed for it by random sampling. The support set is used to provide a small number of training samples, the query set is used to test the model's ability to predict new facts, and the candidate set provides a set of possible answers for each query item in the query set.
[0032] Step 302, calculating the matching degree;
[0033] The embedding of each entity pair in the query set is concatenated with the small sample relationship and looped into the LSTM network. The matching process is as follows:
[0034]
[0035] in, Represents the embedding representation of the query set entity pairs. t With c t Represent the hidden state and unit state of the LSTM network at step t, respectively, and p t-1 With c t-1 Represent the hidden state and unit state of the LSTM network at step t-1, p′ t represents the intermediate representation of the hidden state at the tth time step, p′ T represents the intermediate representation of the hidden state at the last time step, Represents the matching score of the final few-sample relation and query entity pair.
[0036] Step 303, training target;
[0037] The objective is trained using a ranking-based loss function. The ranking-based loss function is defined as:
[0038]
[0039] Among them, r few represents the current small sample relationship, Represents a query set, represents a negative query set, (h q ,t q ) represents an entity pair, Represents the negative sample entity pairs of the query set, represents the matching score of the query entity pair, represents the matching score of the negative query entity pair, and ζ is used to control the gap between the positive and negative sample scores.
[0040] Step 304, updating model parameters;
[0041] Gradient descent updates the model parameters e u , W r , W 1 , W 2 And the weight parameters of the LSTM network to complete the training.
[0042] Step 400, knowledge graph completion;
[0043] The model trained in step 300 and the hyperparameters λ and ξ are used to predict the link task, and the prediction results of the model are saved.
[0044] Beneficial effects of the present invention: The present invention introduces an attention mechanism to divide neighborhood coding into two processes: independent coding and collaborative coding, so as to aggregate neighborhood information in a fine-grained manner. At the same time, a denoising small sample relation learner is used to reduce the impact of neighborhood noise on model performance. With limited training samples, high-quality small sample relation embedding can be learned, effectively improving the performance of knowledge graph completion tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 This is a flowchart for implementing the small sample knowledge graph completion method based on the neighborhood composite attention mechanism provided by the present invention.
[0046] Figure 2 is a flowchart for implementing step 100;
[0047] Figure 3 is a flowchart for implementing step 300. DETAILED DESCRIPTION
[0048] The specific implementation of the present invention is further described below in conjunction with the accompanying drawings and technical solutions.
[0049] like Figure 1 As shown, the present invention implements a small sample knowledge graph completion method based on a neighborhood composite attention mechanism, comprising the following steps:
[0050] Step 100, neighborhood encoding. The proposed independent neighborhood encoder is used to aggregate each neighbor of the central entity separately. In addition, the neighborhood encoder also introduces a neighborhood feature fuser to enhance the feature representation of the entity. At the same time, the proposed collaborative neighborhood encoder is used to capture the relevant information of the interaction between different neighbors of the same entity. Finally, the fusion enables the model to capture information in different semantic spaces and different locations, and learn a richer and more comprehensive feature representation.
[0051] like Figure 2 As shown, step 100 includes steps 101 to 103, which are specifically as follows:
[0052] Step 101, calculate the independent neighborhood encoder output.
[0053] First, the correlation coefficient is calculated. Different neighbors are treated differently through the attention mechanism, and the correlation coefficient between the central entity and the neighboring entity in the connected relationship space is calculated in the form of dot product. The correlation coefficient represents the degree of semantic association between the neighboring entity and the central entity. It is used for subsequent neighborhood information aggregation. The calculation process is as follows:
[0054] e′ u,r =W r ·e u
[0055]
[0056] Among them, e u represents the initial embedding of the central entity u obtained in advance by the pre-trained model, W r represents the projection matrix corresponding to the relation r, e′ u,r represents the embedding representation of the central entity u projected into the space where the relation r is located, and represents matrix multiplication. i represents the i-th neighbor relationship connected to the central entity u, (u,v i ,r i ) is represented as a neighbor triplet, Represents the neighbor entity v i The correlation coefficient with the central entity u, represents the embedding of the central entity u in the connected i-th relation space, represents the i-th neighbor v of the central entity u i Embedded in the space of its connected relations, represents the set of all neighbors of the central entity u, (v k ,r k ) represents the kth neighbor in the set, v k represents the kth neighbor entity, r krepresents the kth neighbor relationship connected to the central entity u. T represents the transpose of the matrix.
[0057] Then, a cross-combination calculation method is used to describe the cross-influence between neighbor relationships and entities, and it is multiplied and accumulated with the attention coefficient as the output N of the independent neighborhood encoder. ind , the overall calculation process is as follows:
[0058] s v,r =W r e v +W r (e v ·r)
[0059]
[0060] Among them, r represents the embedded representation of the neighbor relationship, e v represents the embedding of entity v, s v,r Represents the cross-combination features of the relationship between the neighbors v of the central entity and its corresponding Represents the cross-combination feature of the relationship between the i-th neighbor of the central entity and its corresponding one.
[0061] Step 102, calculate the output of the collaborative neighborhood encoder. This step introduces multiple attention heads, each of which can focus on different aspects or different features of the input sequence, so that the model can capture information in different semantic spaces and different positions and learn a richer and more comprehensive feature representation.
[0062] First, the cross information is used as the input element of the multi-head attention block, and all neighbors are modeled as a sequence c 0 :
[0063] c 0 =[s 1 ;s 2 ;…,;s N ]
[0064] Where N represents the maximum number of neighbors of the central entity. The model then inputs this sequence into a multi-head attention block, which fuses each other's information based on the similarity between neighbors. The output of the multi-head attention block is as follows:
[0065] s′ 1 ,s′ 2 ,…,s′ N =MSA(c 0 )
[0066] Among them, s′ i Represents the output result of the ith neighbor after integrating the information of other neighbors. Use dot product to calculate s′ i The relevance to the central entity and aggregate all s′i To generate the output N of the collaborative neighborhood encoder co The calculation process is as follows:
[0067]
[0068] N co =∑β i s′ i
[0069] Among them, s i ′ and s′ k Respectively represent the output results of the i-th and k-th neighbors after integrating the information of other neighbors. i It represents the correlation coefficient between the i-th neighbor entity and the central entity u after integrating other neighbor information.
[0070] Step 103: Fusion of domain features. After obtaining the output N of the two partial neighborhood encoders ind and N co After that, this step simply aggregates these two pieces of information, and the calculation process is as follows:
[0071] N final =N ind +N co
[0072] Among them, N final Represents the final neighborhood information. The central entity and the final neighborhood representation are sent to the fully connected layer for fusion, and then the activation function is used to obtain the updated central entity representation. The process is as follows:
[0073] h=σ(W 1 e u +W 2 N final )
[0074] Among them, h represents the entity representation after integrating neighborhood information, σ represents the activation function, and W 1 and W 2 Represents the matrix obtained through training.
[0075] Step 200, small sample relationship learning. The denoising small sample relationship learner is used to integrate the features of the support set sample pairs to obtain a generalized representation of the small sample relationship. This step aggregates the sample pair information that incorporates the neighborhood information and aggregates the original information of the entity pair to obtain the small sample relationship and reduce the impact of neighborhood noise.
[0076] The updated head and tail entity representations are obtained through step 103 and further concatenated to obtain the embedding representation of the entity pair. The calculation process is as follows: j =[h j ||tj ], and then use the Bi-LSTM network to aggregate k entity pairs. The overall calculation process is as follows:
[0077]
[0078] Among them, h j With t j They represent the embedding representation of the jth head and tail entity after integrating the neighborhood information; m j represents the embedding representation of the jth head-tail entity pair, p j Represents the output result of the j-th head-tail entity pair passing through the LSTM network at the current time step, where → and ← are forward and reverse respectively.
[0079] Then, the enhanced representation of the head and tail entities is obtained through the neighborhood encoder, and the embedded representation of the head and tail entities is further concatenated. The calculation process is as follows:
[0080] m′ j =[e h,j ||e t,j ]
[0081] Among them, e h,j With e t,j Represent the original embedding of the jth head and tail entity in the support set, m′ j Represents the original embedding representation of the jth entity pair. After obtaining the embedding representation of the entity pair without integrating the neighborhood information, the model uses the attention mechanism to aggregate the information of k entity pairs. The calculation process is as follows:
[0082]
[0083] Among them, σ represents the activation function, ω x represents the attention coefficient of the xth sample, r p represents a small sample relationship representation generated using only the original information of the entity pair, u 1 Represents the weight matrix obtained through training. Finally, the method aggregates two small sample relationship representations, where the hyperparameter λ is used to balance the ratio. The calculation process is as follows:
[0084] r final =(1-λ)r n +λr p
[0085] Among them, r final represents the final few-shot relation representation.
[0086] Step 300: Model training. Figure 3 As shown, step 300 includes steps 301 to 304:
[0087] Step 301, constructing a data set;
[0088] For each small sample relationship task, a support set, query set and candidate set are constructed by random sampling. The support set is used to provide a small number of training samples, the query set is used to test the model's ability to predict new facts, and the candidate set provides a set of possible answers for each query item in the query set.
[0089] Step 302, calculate the degree of matching. The LSTM network is used to model the interaction between the small sample relationship and the query set, and the degree of matching between the input query and the small sample relationship is measured. First, the embedding of each entity pair in the query set is obtained through the proposed composite neighborhood encoder. Then, it is concatenated with the small sample relationship as the recurrent input of the LSTM network. The complete matching process is shown below:
[0090]
[0091] in, Represents the embedding representation of the query set entity pairs. t With c t Represent the hidden state and unit state of the LSTM network at step t, respectively, and p t-1 With c t-1 Represent the hidden state and unit state of the LSTM network at step t-1, p′ t represents the intermediate representation of the hidden state at the tth time step, p′ T represents the intermediate representation of the hidden state at the last time step, Represents the matching score of the final few-sample relation and query entity pair.
[0092] Step 303, training target. The model randomly extracts K positive triplets to construct the support set S r , and select B positive triples to construct the query set Q r , where B represents the batch size. Then, a candidate set of tail entities is constructed according to the type of tail entity. By using the negative sampling strategy, r Randomly select some entity pairs (h q ,t q ) and replace their tail entities with random entities in the candidate set to generate negative query sets The ranking-based loss function is defined as:
[0093]
[0094] where r few represents the current small sample relationship, Represents a query set, represents a negative query set, (h q,t q ) represents an entity pair, Represents the negative sample entity pairs of the query set, represents the matching score of the query entity pair, represents the matching score of the negative query entity pair, and ξ is used to control the gap between the positive and negative sample scores.
[0095] Step 304: Update model parameters. Gradient descent is used to update model parameters to complete training.
[0096] Step 400, knowledge graph completion. In this stage, the model trained in the previous stage and the hyperparameter λ are used to predict various downstream tasks and save the prediction results of the model.
[0097] In combination with the scheme of the present invention, the experimental analysis is carried out as follows:
[0098] Table 1 Link prediction results of single sample and five samples on NELL-One dataset
[0099]
[0100] Table 2 Link prediction results of single sample and five samples on Wiki-One dataset
[0101]
[0102] As can be seen from Tables 1 and 2, among all the small sample knowledge graph completion models, the CoNA-FKGC model proposed in this invention shows the best experimental results on the NELL-One dataset, and also achieves the best overall performance on the Wiki-One dataset. Specifically, taking MRR as an example, in the single sample completion scenario of the NELL-One dataset, this method improves by 15.5% compared with the GMatching model, 9% compared with the MetaR model under the In-Train setting, 11.5% compared with TransAM, and 3.3% compared with the GANA model that achieves the second best results. In the five-sample completion scenario of the NELL-One dataset, it improves by 9.7% compared with FAAN and 3.2% compared with the GANA model. In the single sample setting on the Wiki-One dataset, CoNA-FKGC improves by 2.6% on MRR compared with the second best model, significantly improves by 3.5% on Hits@10 and Hits@5, and improves by 3.5% on Hits@1. The above results show that the model proposed in this paper can achieve excellent performance under different sample number settings and has the ability to adapt to data sets of different sizes, thus proving the dynamic adaptability of the model.
Claims
1. A small sample knowledge graph completion method based on neighborhood composite attention, characterized in that: The steps include: Step 100, neighborhood coding; Step 101, calculating the independent neighborhood encoder output; Treat different neighbors differently through the attention mechanism, and calculate the central entity u and the neighbor entity v in the knowledge graph in the form of dot product. i In the neighbor relationship r i Correlation coefficient in the corresponding space The calculation process is as follows: have been' u,r =W r ·have been u Among them, e u represents the initial embedding of the central entity u obtained in advance by the pre-trained model, W r represents the projection matrix corresponding to the neighbor relationship r, e′ u,r represents the embedding representation of the central entity u projected into the space where the neighbor relationship r is located, · represents matrix multiplication; r i represents the i-th neighbor relationship connected to the central entity u, (u,v i ,r i ) is represented as a neighbor triplet, Represents the neighbor entity v i The correlation coefficient with the central entity u, represents the embedding of the central entity u in the connected i-th relation space, Represents the i-th neighbor entity v of the central entity u i Embedded in the space of its connected relations, represents the set of all neighbors of the central entity u, (v k ,r k ) represents the kth neighbor in the set, v k represents the kth neighbor entity, r k represents the kth neighbor relationship connected to the central entity u; T represents the transpose of the matrix; The cross-combination calculation method is used to describe the cross-influence between neighbor relationships and entities, and the cross-influence is multiplied and accumulated with the attention coefficient as the output N of the independent neighborhood encoder. ind , the overall calculation process is as follows: v,r =W r e v +W r (e v ·r), Among them, r represents the embedded representation of the neighbor relationship, e v represents the embedding of the neighbor entity v, s v,r Represents the cross-combination features of the relationship between the neighbor entity v of the central entity and its corresponding entity, Represents the cross-combination feature of the relationship between the i-th neighbor entity of the central entity and its corresponding entity; Step 102, calculating the collaborative neighborhood encoder output; Introduce a multi-head self-attention mechanism to focus on different aspects or features of the input sequence and aggregate the output s′ of the multi-head attention block i To generate the output N of the collaborative neighborhood encoder co ; The calculation process is as follows: N co =Σβ i s′ i ; where s′ i and s′ k Respectively represent the output results of the i-th and k-th neighbor entities after integrating other neighbor information; β i Represents the correlation coefficient between the i-th neighbor entity and the central entity u after integrating other neighbor information; Step 103, integrating domain features; The output N of the two-part neighborhood encoder ind and N co Aggregate to obtain the fused domain features N final , by h = σ(W1e u +W2N final ) updates the central entity representation; where h represents the entity representation after integrating neighborhood information, σ represents the activation function, and W1 represents the initial embedding e of the central entity u u The linear transformation matrix, W2 represents the fused neighborhood feature N final The linear transformation matrix of , both of which are obtained through training; Step 200, small sample relationship learning; The updated head and tail entity representations are obtained through step 103 and further concatenated to obtain the embedding representation of the entity pair. The calculation process is as follows: j =[h j ||t j ], and then use the Bi-LSTM network to aggregate k entity pairs. The overall calculation process is as follows: Among them, h j With t j They represent the embedding representation of the jth head and tail entity after integrating the neighborhood information; m j represents the embedding representation of the jth head-tail entity pair, p j It represents the output result of the j-th head-tail entity pair passing through the LSTM network at the current time step, where → and ← are forward and reverse respectively; Then the generalized representation of the small sample relationship is generated by summing: n =∑ k g j , where j = 1, 2, 3, ..., k, the embedding representations of the head and tail entities are further concatenated, m′ j =[e h,j ||e t,j ]; where e h,j With e t,j Represent the original embedding of the jth head and tail entity in the support set, m′ j Represents the original embedding representation of the jth entity pair; then the attention mechanism is used to aggregate the information of k entity pairs. The calculation process is as follows: Among them, σ represents the activation function, ω x represents the attention coefficient of the xth sample, r p represents the small sample relationship representation generated using only the original information of the entity pair, and u1 represents the weight matrix obtained through training; finally, the method aggregates two small sample relationship representations, where the hyperparameter λ is used to balance the ratio. The calculation process is as follows: final =(1-λ)r n +λr p ; Among them, r final represents the final small sample relationship representation; Step 300, training the model formed in steps 100 and 200; Step 301, constructing a data set; For each small sample relationship task generated in step 200, a support set, a query set and a candidate set are constructed for it by random sampling; wherein the support set is used to provide a small number of training samples, the query set is used to test the model's ability to predict new facts, and the candidate set provides a set of possible answers for each query item in the query set; Step 302, calculating the matching degree; The embedding of each entity pair in the query set is concatenated with the small sample relationship and looped into the LSTM network; the matching process is as follows: in, represents the embedding representation of the query set entity pair; p t With c t Represent the hidden state and unit state of the LSTM network at step t, respectively, and p t-1 With c t-1 Represent the hidden state and unit state of the LSTM network at step t-1, p′ t represents the intermediate representation of the hidden state at the tth time step, p′ T represents the intermediate representation of the hidden state at the last time step, Represents the matching score of the final small sample relation and the query entity pair; Step 303, training target; The objective is trained using a ranking-based loss function; the ranking-based loss function is defined as: Among them, r few represents the current small sample relationship, Represents a query set, represents a negative query set, (h q ,t q ) represents an entity pair, Represents the negative sample entity pairs of the query set, represents the matching score of the query entity pair, represents the matching score of the negative query entity pair, and ξ is used to control the gap between the positive and negative sample scores; Step 304, updating model parameters; Gradient descent updates the model parameters e u , W r , W1, W2 and the weight parameters of the LSTM network to complete the training; Step 400, knowledge graph completion; The model trained in step 300 and the hyperparameters λ and ξ are used to predict the link task, and the prediction results of the model are saved.
Citation Information
Patent Citations
Information retrieval optimization method and system based on small sample knowledge graph completion
CN116955650A
Knowledge graph reasoning model, system, and reasoning method based on bayesian few-shot learning
US20230351153A1
Multi-source knowledge graph fusion-oriented entity alignment method and apparatus, and system
WO2023273182A1
