Knowledge graph completion method and system in few-sample scene

By constructing a few-sample relation dataset and utilizing the TransE model, hierarchical neighbor aggregator, and affine attention mechanism, the problem of underutilization of structural information and random neighbor noise in knowledge graphs is solved, achieving efficient and accurate knowledge graph completion in few-sample scenarios.

CN121543680APending Publication Date: 2026-02-17CIVIL AVIATION LOGISTICS TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511610150.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-05
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

Existing technologies fail to fully utilize the structural information of knowledge graphs in scenarios with few samples. Randomly aggregating neighbor information leads to noise interference, and it is difficult to capture the subtle differences and complexities of relationships, affecting the accuracy of knowledge graph completion.

Method used

By constructing a few-sample relation dataset, the TransE model is used to train and optimize entity embedding and relation embedding. Deep semantic information of the direct and indirect neighbors of the head entity and candidate tail entity is extracted. A hierarchical neighbor aggregator and affine attention mechanism are used to generate entity pair representations, and the optimal candidate tail entity is selected for completion.

Benefits of technology

Without increasing computational complexity, it enhances the accuracy and comprehensiveness of entity representation, reduces noise interference, accurately captures complex details of relationships, and improves the accuracy of knowledge graph completion prediction in scenarios with few samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121543680A_ABST
    Figure CN121543680A_ABST
Patent Text Reader

Abstract

The invention provides a knowledge graph completion method and system in a few-sample scene, and the method comprises the following steps: constructing and training a few-sample relation data set, and obtaining optimized entity and relation embedding; extracting a candidate tail entity from the support set, and extracting direct and indirect neighbors of the head entity and the candidate tail entity; optimizing entity and relation embedding is called, deep semantic information is extracted from direct and indirect neighbors, and head entity enhanced embedding and candidate tail entity enhanced embedding are obtained; generating and processing entity pair representations to obtain relation element representations, and updating the relation of the query set based on the relation element representations to obtain relation updating representations; and calculating and screening an optimal candidate tail entity based on head entity enhanced embedding, candidate tail entity enhanced embedding and relation updating representation, and supplementing the optimal candidate tail entity into a query set. The method solves the problems that in the prior art, knowledge graph structure information and random aggregation neighbor information are not fully utilized, noise is introduced, and nuisance and complexity of a few-sample relation are difficult to capture.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method and system for knowledge graph completion in scenarios with few samples. Background Technology

[0002] Knowledge graphs (KGs) encapsulate rich multi-relation data in the form of directed graphs. Facts are represented as triples (h, r, t), where h represents the head entity, r represents the relation, and t represents the tail entity. Large-scale knowledge graphs, as a structured semantic knowledge base, have various functions and applications, primarily including information retrieval. [1] Question and Answer System [2] and recommendation engines [3] In addition to these key functions, knowledge graphs are also a treasure trove of data and fundamental knowledge, greatly enhancing text classification. [4] and fact-checking [5] Performance of tasks such as [unspecified tasks].

[0003] In real-world scenarios, knowledge graphs (KGs) often face the challenge of incompleteness. [6] This inherent limitation has spurred extensive research in the field of Knowledge Graph Completion (KGC). Researchers are actively developing sophisticated methods to reason about and supplement missing entities, relations, or attribute values ​​in knowledge graphs. As a mainstream method for knowledge graph completion, Knowledge Graph Embedding (KGE) and its variants transform entities and relations in knowledge graphs into compact, low-dimensional vector representations, thereby enabling efficient computation and reasoning in vector spaces. [7] While knowledge graph embedding techniques have demonstrated remarkable effectiveness in addressing the challenges of knowledge graph completion, they typically require a large number of triples for each relation to be trained. This reliance on a large number of training triples to reach their full potential underscores the need for sufficient data to optimize the embedding model and ensure its predictive accuracy.

[0004] However, relations in real-world knowledge graphs (KGs) typically exhibit a long-tail distribution, with many relations containing a limited number of triples. For example, approximately 10% of relations in Wikidata contain 10 or fewer triples. [8]Therefore, for knowledge graph completion tasks involving long-tail relations, the performance of models based on knowledge graph embeddings drops significantly. To address this challenge, more and more scholars have begun to study the few-shot knowledge graph completion (FKGC) task. Its goal is to predict and complete entirely new information triples for a given relation with very few training samples. Specifically, given a target relation r and its K associated reference entity pairs, the research aims to infer the tail entity t by predicting the query set (h, r, ?).

[0005] However, existing FKGC methods have some shortcomings, such as failing to fully utilize the structural information in knowledge graphs and ignoring the fine-grained information of interactions between entity pairs. Specifically, there are three main points: (1) First, most models only enhance the semantic representation of entities through their direct neighbors, failing to fully utilize the structural information in knowledge graphs (KGs). Even though the role of indirect neighbors is not as significant as that of direct neighbors, they still contribute to the semantic representation of entities. For example, the two-hop neighbor information in the neighbor structure of the head entity and the tail entity can also be utilized, but too many two-hop neighbors may increase computational complexity; (2) Second, enhancing entity embedding requires aggregating neighbor information. If all selected neighbors are randomly selected, noise information will inevitably be introduced; (3) Finally, if there are few training instances of a certain relation, the relation representation learned from these limited entity pairs may not be sufficient and it is difficult to capture all the subtle differences and complexities of the relation.

[0006] References: [1] R. Reinanda, E. Meij, and M. de Rijke, “Knowledge graphs: Aninformation retrieval perspective,” Found. Trends Inf. Retr., vol. 14, no. 4, pp. 289–444, 2020. [2] R. Omar, I. Dhall, P. Kalnis, and E. Mansour, “A universal question answering platform for knowledge graphs,” Proc. ACM Manage. Data, vol. 1, no. 1, pp. 1-25, May 2023. [3] Q. Guo, F. Zhuang, C. Qin, H. Zhu, X. Xie, H. Xiong, and Q. He,“A survey on knowledge graph-based recommender systems,”IEEE Trans. Knowl.Data Eng., vol. 34, no. 8, pp. 3549–3568, Aug. 2022. [4] M. Ramezani, M.-R. Feizi-Derakhshi, and M.-A. Balafar, “Text-based automatic personality prediction using KGrAt-net: A knowledge graphattention network classifier,”Sci. Rep., vol. 12, no. 1, p. 21453, Dec. 2022. [5] J. Kim and K.-S. Choi, “Unsupervised fact checking by counter-weighted positive and negative evidential paths in a knowledge graph,” inProc. 28th Int. Conf. Comput. Linguistics, Jul. 2020, pp. 1677–1686. [6] S. Ji, S. Pan, E. Cambria, P. Marttinen, and P. S. Yu, “A surveyon knowledge graphs: Representation, acquisition, and applications,”IEEETrans. Neural Netw. Learn. Syst., vol. 33, no. 2, pp. 494–514, Feb. 2022. [7] Y. Dai, S. Wang, NN Xiong, and W. Guo, “A survey on knowledgegraph embedding: Approaches, applications and benchmarks,” Electronics, vol.9, no. 5, p. 750, May 2020. [8] M. Chen, W. Zhang, W. Zhang, Q. Chen, and H. Chen, “Metarelational learning for few-shot link prediction in knowledge graphs,” inProc. Conf. Empirical Methods Natural Lang. Process. 9th Int. Joint Conf.Natural Lang. Process. (EMNLP-IJCNLP), Oct. 2019, pp. 4217–4226. Summary of the Invention To address the shortcomings of existing technologies, this invention provides a knowledge graph completion method and system for scenarios with few samples. It solves the problems of insufficient utilization of knowledge graph structural information, noise introduced by random aggregation of neighbor information, and difficulty in capturing all the subtle differences and complexities of relationships with few samples in existing technologies.

[0007] According to an embodiment of the present invention, a knowledge graph completion method for few-sample scenarios is provided, the completion method comprising the following steps: A few-sample relation dataset is constructed, and the TransE model is used to train the dataset to obtain optimized entity embedding and optimized relation embedding. The dataset is derived from a knowledge graph and includes a support set and a query set. Both the support set and the query set store detailed information about entities and their relations in the form of head entity-relation-tail entity triples. Based on the head entities and relationships of the query set, candidate tail entities that are related to the head entities are extracted from the support set to form a candidate tail entity set. Then, several direct neighbors of the head entities and the candidate tail entities, as well as several indirect neighbors corresponding to each direct neighbor, are extracted from the support set. By invoking the optimized entity embedding and optimized relation embedding, deep semantic information is extracted from the direct neighbors and indirect neighbors of the head entity and the candidate tail entity, resulting in head entity enhanced embedding and candidate tail entity enhanced embedding containing the information of the direct neighbors and indirect neighbors; Entity pair representations are generated based on the head entity augmentation embedding and the candidate tail entity augmentation embedding, and the entity pair representations are processed to obtain relation meta-representations. The relations of the query set are then updated based on the relation meta-representations to obtain relation update representations. Based on the head entity augmentation embedding, the candidate tail entity augmentation embedding, and the relation update representation, the rationality of each candidate tail entity is calculated, the optimal candidate tail entity is selected, and then the optimal candidate tail entity is added to the query set to complete the missing tail entities in the query set.

[0008] According to another embodiment of the present invention, a knowledge graph completion system for few-sample scenarios is also provided, the completion system comprising: A storage device for storing information in a constructed few-sample relation dataset, the dataset comprising a support set and a query set, both of which store detailed information about entities and their relations in the form of head entity-relation-tail entity triples; The knowledge graph completion device is used to call the support set and query set stored in the storage device, and to complete the missing tail entities in the query set using the knowledge graph completion method for a few-sample scenario described above.

[0009] Compared with the prior art, the present invention has the following beneficial effects: By extracting the direct and indirect neighbors of head entities and candidate tail entities from the support set in the query set, and extracting deep semantic information from these direct and indirect neighbors, we obtain enhanced head entity embeddings and enhanced candidate tail entity embeddings containing information about direct and indirect neighbors. This enhances the semantic richness of entity embeddings, ensuring more accurate selection of candidate tail entities. This solves the problem of insufficient utilization of knowledge graph structural information in existing technologies. Without significantly increasing computational complexity, it fully mines the deep structural information of the knowledge graph, improving the accuracy and comprehensiveness of entity representation. At the same time, when extracting deep semantic information from direct and indirect neighbors, it is necessary to call the optimized entity embeddings and optimized relation embeddings trained by the TransE model. This ensures that the selected direct and indirect neighbors are entity representations related to a small number of sample relations, rather than being randomly selected. This solves the problem of noise introduced by random aggregation of neighbor information in existing technologies, reducing the introduction of noise.

[0010] By employing head entity augmentation embedding and candidate tail entity augmentation embedding to generate entity pair representations, and processing these entity pair representations to obtain relation meta-representations, we can focus on both the relative importance of different entity pairs and the importance of different dimensional features of entity pairs. This enhances the internal and external interactions of entity pairs and solves the problem of existing technologies failing to capture all the subtle differences and complexities of few-sample relations. In few-sample scenarios, it can more accurately capture the complex details and semantics of relations while avoiding excessive increase in model complexity, thus balancing representation quality and efficiency.

[0011] By updating the relations of the query set using relational meta-representation, a relational update representation is obtained. The optimal candidate tail entity is then selected based on the head entity augmentation embedding, the candidate tail entity augmentation embedding, and the relational update representation to be added to the query set. This enables the direct transfer of few-sample relational knowledge learned during the training phase to the completion phase, ensuring accurate completion even in scenarios with "very few training samples" and significantly improving the prediction accuracy of knowledge graph completion in few-sample scenarios. Attached Figure Description

[0012] Figure 1 This is a flowchart illustrating the steps of a knowledge graph completion method in a few-sample scenario according to an embodiment of the present invention.

[0013] Figure 2 This diagram illustrates the specific steps involved in training the dataset according to an embodiment of the present invention.

[0014] Figure 3 This is a schematic diagram illustrating the specific process of training a dataset according to an embodiment of the present invention.

[0015] Figure 4 This is a detailed framework diagram of the affine attention mechanism in an embodiment of the present invention.

[0016] Figure 5 The diagram illustrates the specific steps involved in calculating the rationality of each candidate tail entity and selecting the optimal candidate tail entity according to an embodiment of the present invention.

[0017] Figure 6 This is a control principle diagram of a knowledge graph completion system in a few-sample scenario according to another embodiment of the present invention.

[0018] Figure 7 This is a detailed control principle diagram of a knowledge graph completion device according to another embodiment of the present invention.

[0019] In the above figures: 1. Storage device; 2. Knowledge graph completion device; 21. Hierarchical neighbor aggregator; 22. Relation generator; 23. Relation updater; 211. Neighbor filter; 212. Graph attention network; 221. Hierarchical neighbor aggregator; 222. Bidirectional long short-term memory network; 231. Relation learner; 232. Relation updater; 233. Embedded learner. Detailed Implementation

[0020] The technical solutions of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0021] Definition 1 (Knowledge Graph): A knowledge graph consists of G={E, R, T}, where E and R represent the entity set and relation set, respectively, and T={(h, r, t)∈E×R×E} represents the set of triples (h, r, t).

[0022] Definition 2 (Few-shot Relational Dataset): A few-shot relational dataset G* stores detailed information about actual entities and their relations in the form of (entity-relation-entity) triples, including frequently occurring relations. Therefore, the few-shot relational dataset provides rich contextual information for various knowledge-based reasoning and information completion tasks.

[0023] Definition 3 (Few-order relation neighbors): For a relation r in a triple (h, r, t), a neighbor is defined as (h, t, N). h , N t ), where N h and N t These are the neighbor sets of entities h and t, respectively, both derived from a few-sample relation dataset. Entities h and t can be connected to different entities through different neighbor relations. Taking the head entity h as an example, it is connected through relation r. i Entity e directly connected to the head entity h i It is a 1-hop neighbor (direct neighbor) of the head entity, denoted as . and e i Directly connected entity e ij It is a 2-hop neighbor (indirect neighbor) of the head entity, represented as .

[0024] Definition 4 (FKGC Task): The goal of Few-Shot Knowledge Graph Completion (FKGC) is to complete a knowledge graph with a specific relation r and a reference set. (where |S r |=K, and the value of K is small, meaning the number of reference entity pairs is small, for the query set Q r The missing tail entities in the query set are predicted. The purpose is to predict the query set. Q rThe missing tail entity of entity t in each query set. Q r In the expression = (h, r, ?), there usually exists a candidate set containing all possible tail entities. C t , C t The task of this type is to select appropriate tail entities t from the candidate set to complete the triples of the query set. To address the training challenges posed by data scarcity, a meta-learning strategy is adopted, in which each task... T r Both are related to a specific relation r and are derived from the reference set. S r (Support set) and query set Q r The corresponding set ( T r ={ S r , Q r These tasks must be divided into a meta-training set. Tr train Heyuan Test Set Tr test The meta-training set and the meta-test set are denoted as and Each task has its own support set and query set, which are mutually exclusive.

[0025] like Figures 1-5 As shown in the figure, this embodiment of the invention proposes a knowledge graph completion method in a few-sample scenario. The completion method includes the following steps: S1. Construct a few-sample relation dataset, and train the dataset using the TransE model to obtain optimized entity embedding and optimized relation embedding. The dataset is derived from a knowledge graph and includes a support set and a query set. Both the support set and the query set store detailed information about entities and their relations in the form of head entity-relation-tail entity triples.

[0026] The training of the dataset specifically includes: S11. Derive the direct and indirect neighbors of each entity in the support set, and then extract deep semantic information from the direct and indirect neighbors to obtain entity representations related to few-sample relations. The support set includes pre-trained initial entity embeddings and initial relation embeddings.

[0027] Specifically, obtaining the entity representation related to the few-sample relationship includes: Based on the support set, several direct neighbors of each entity and several indirect neighbors corresponding to each direct neighbor are derived, and then the indirect neighbors that are highly correlated with each direct neighbor are selected. The direct neighbors are aggregated with the corresponding filtered indirect neighbors to obtain an entity representation for each entity. The entity representation is an entity-enhanced embedding that includes information about the direct neighbors and the indirect neighbors.

[0028] Specifically, in the process of obtaining entity representations related to minority-sample relationships, a hierarchical neighbor aggregator 21 (including a neighbor filter 211 and a graph attention network 212) is designed to encode each entity in the support set, and learn entity representations related to minority-sample relationships through the neighbor filter 211 and the graph attention network 212, so as to achieve [the desired outcome]. k Controllable aggregation of neighbor information within the jump range.

[0029] For simplicity, we will encode 1-hop and 2-hop neighbors ( k Taking the scenario of =2) as an example, the process of neighbor information aggregation is explained, focusing on entities that support centralized aggregation. e It indicates that it can be obtained from a multi-hop neighbor set. The derivation shows that, among which and Entities e The system considers direct and indirect neighbors, i.e., 1-hop neighbors and 2-hop neighbors. To comprehensively aggregate entity information, 2-hop neighbors are taken into account: information is first collected from a broad set of 2-hop neighbors, and then this data is refined from the outside in. However, expanding the scope of entity neighbors inevitably increases noise. This problem is addressed by selecting neighbors not randomly, but based on their relevance to specific relationships. Filtering 1-hop neighbors would significantly increase the computational complexity of the model; while 2-hop neighbors contribute relatively little to entity embedding, so neighbor filter 211 is used to select more refined and higher-quality neighbors, which can enhance the expressive effect of entity embedding. Therefore, neighbor filter 211 is first used to refine 2-hop neighbors, and then more effective 2-hop neighbors are selected, thereby improving the effectiveness of the aggregation process. This allows for the selection of more effective 2-hop neighbors and the measurement of direct relationships between entities. r i (i.e., 1-hop neighbor relationship) and indirect relationship r ij The correlation between (i.e., 2-hop neighbor relationships) is assessed using a dot product-based correlation scoring function:

[0030] in, r i , rij They respectively represent the connection of the first i The j-th one-hop neighborhood relation embedding and its j-th two-hop neighborhood relation embedding are learned in a low-dimensional space by the pre-trained model TransE, which can capture the essence of relations in the knowledge graph.

[0031] Using the similarity scoring function sim( r i , r ij The similarity between 1-hop and 2-hop neighborhood relationships of entities can be calculated, allowing 2-hop neighbors with high similarity to be included in the aggregation process. Hyperparameters are then introduced. n and m Let represent the number of 1-hop neighbors and the number of 2-hop neighbors, respectively. Based on similarity scores, 2-hop neighbors are sorted in descending order, and the top 10 are selected. m Including 2-hop neighbors in the target range is necessary; however, neighbor filtering may increase the computational complexity of the model. Therefore, while ensuring model efficiency, it is crucial to minimize the number of direct and indirect neighbors. n , m .

[0032] Before screening m After including 2-hop neighbors in the target range, the filtered 2-hop neighbors are aggregated into a 1-hop neighbor representation:

[0033] in, t ij Represents entity number i The first jump neighbor's first j Embedding of 2-hop neighbor entities; n ij express( r ij , t ij This is the neighbor's statement; W 1 is a linear transformation matrix; the symbol ⊕ indicates a concatenation operation.

[0034] Then, through the attention mechanism of the graph attention network 212, a representation that aggregates the information of two-hop neighbors can be obtained:

[0035] in, V 1 represents a weight vector; ReLU(·) is an activation function used to capture non-linear relationships and optimize learnable vectors. V 1. Results of linear transformation n ij The product is subjected to a nonlinear transformation; η ijIt is the first i The first jump neighbor's first j The absolute attention value of each 2-hop neighbor can be obtained by using the softmax function to get the relative attention value of each 2-hop neighbor. α ij By weighting the 2-hop neighbor entity embeddings with attention values, we can obtain partial 1-hop neighbor entity representations. f j ( e i ).

[0036] One-hop neighbor embedding is achieved by embedding neighbor nodes. f j ( e i The summation and integration of the entity's own embeddings yields an entity embedding representation that simultaneously includes information about its two-hop neighbors, namely:

[0037] Next, the semantic information of direct and indirect neighbors is enhanced. By using the 1-hop neighbor entity representation that aggregates the information of 2-hop neighbors, an entity embedding that aggregates the information of both levels of neighbors is finally obtained:

[0038] in, n i Is the entity's number i One hop neighbor ( r i , e i The representation of ); W 2 is a linear transformation matrix.

[0039] Then, through the attention mechanism, a representation that aggregates the information of one-hop neighbors can be obtained:

[0040] in, V 2 represents a weight vector, which is the entity's... i The absolute attention value of each 1-hop neighbor can be obtained by applying the softmax(·) function, which yields the relative attention value for each 1-hop neighbor. α i Then, a weighted sum is performed on the embedding of the 1-hop neighbor entity, thus obtaining the 1-hop neighbor entity representation containing 2-hop neighbor information. f i ( e ).

[0041] To obtain entities eFor deeper semantic understanding, the embedding representations of 1-hop neighbors need to be integrated to obtain a 1-hop neighbor aggregated embedding representation that includes information about 2-hop neighbors. ,Right now:

[0042] in, e This represents the dimension of entity embedding. Based on past experience, it is considered that the entity... e The importance of neighbor embedding is not the same, therefore, introducing V A weight matrix is ​​used, where "+" indicates vector summation. At this point, the information of 1-hop and 2-hop neighbors is injected into the entity embedding, and entities with semantically enhanced representations are successfully obtained.

[0043] Assuming the existence of a triple (h, r, t), substituting it into all the above formulas, both the head entity h and the tail entity t can be represented by entity representations that contain information about their corresponding direct and indirect neighbors, respectively. Therefore, the head entity representation and tail entity representation of each triple (h, r, t) in the support set, including information on its corresponding direct and indirect neighbors, can be obtained according to the above formula. .

[0044] S12. Receive the entity representation, generate the corresponding entity pair representation, and process the entity pair representation to obtain the relation meta-representation.

[0045] Specifically, obtaining the relational element representation includes: Receive the entity representation of each entity, and aggregate the entity representations of two highly correlated entities based on the initial relation embedding to generate corresponding entity pair representations; A bidirectional long short-term memory model with affine attention mechanism is introduced to integrate the entity pair representations to obtain the relation meta-representation corresponding to the entity pair representations.

[0046] Specifically, based on the above analysis, we can obtain the triplet ( h , r , t Entity embedding representation in ) Currently, the cutting-edge model GANA (G. Niu, Y. Li, C. Tang, R. Geng, J. Dai, Q. Liu, H. Wang, J. Sun, F. Huang, and L. Si, “Relational learning with gated and attentive neighbor aggregator for few-shot knowledge graph completion,” in Proc. 44th Int. ACMSIGIR Conf. Res. Develop. Inf. Retr., Jul. 2021, pp. 213–222.) sequentially feeds each neighbor representation in the support set into a bidirectional long short-term memory network, and then introduces an attention mechanism. These models then dynamically assign different weights to different neighbor representations in the support set, effectively capturing the overall semantics of the relation. Given that relations in most knowledge graphs (KGs) are long-tailed, if a relation has only a few training instances and only simulates the interactions between a very small number of reference entity pairs, it may be difficult to capture the subtle differences and complexities within that relation. The TransAM model (Y. Liang, S. Zhao, B. Cheng, and H. Yang, “TransAM: Transformer appending matcher for few-shot knowledge graph completion,” Neurocomputing, vol. 537, pp. 61–72, Jun. 2023.) utilizes the Transformer encoder to further capture the intrinsic interactions between entities and cross-instance interactions, but this significantly increases the modeling complexity and may lead to excessively large model capacity.

[0047] To address this issue, a relation generator 22 with an affine attention mechanism is proposed (including a hierarchical neighbor aggregator 221 and a bidirectional long short-term memory network 222), aiming to extract relation meta-information from more complex interactions between reference triples, given a target relation r and its corresponding support set S. r There exist K triples These triples are composed of K The first reference triplet in the nth reference triplet i A triplet entity pair and This is represented by a hierarchical neighbor aggregator 221:

[0048] in, d i r It is the first i The embedding representations of entity pairs are then introduced via a relation generator 22, employing a bidirectional long short-term memory (Bi-LSTM) model with affine attention to integrate the entity pair representations supporting the set and obtain a general representation of the target relation. Mathematically, this can be described as follows:

[0049] Among them, LSTM ( () is a long short-term memory unit used to update the hidden state; and These are the forward and reverse hidden state vectors, respectively; d i r Represents entity pairs used as input vectors; It is a composite hidden state; W 3 is a linear transformation matrix.

[0050] A task relation may involve multiple different entity pairs, and capturing the complex details and subtleties of the relation can be difficult when dealing with a small number of training instances and limited simulated interactions between entity pairs. Furthermore, in mastering the relational semantics of entities, each hidden state must be weighed to encode interaction information. The importance of each dimension is crucial because not all dimensions of the triples contribute equally to the representation of few-sample relations in the support set, especially when K When =1, therefore, an affine attention mechanism is introduced:

[0051] in, σ It is the activation function tanh( ); V 4 is the weight vector; b It is the bias term vector; ⊙ is the Hadamard product operator; attention score vector. l i Is it using softmax ( The attention weight vector is calculated using the function. δ i This vector is normalized to ensure the attention score vector is normalized. l i Each dimension within the vector can receive an attention value, thus enabling internal interactions between vectors. Through support centralization KThe weighted summation of all neighbors of a triplet is used to obtain a general representation of a few-sample relation.

[0052] The biggest difference between affine attention mechanisms and graph attention networks lies in the fact that it is based on the Hadamard product and normalization of attention score vectors along the feature dimension. This is mainly reflected in the use of the Hadamard product instead of the dot product in the calculation of attention scores and the weighted summation of feature representations, such as... Figure 4 As shown, the affine attention mechanism not only focuses on the relative importance between different entity pairs, but also on the relative importance of entity pairs in different dimensions of features, effectively enhancing the interaction between internal and external entity pairs.

[0053] S13. Receive the relational representation, calculate the loss function of the support set based on the relational representation, update the relational representation, migrate the updated relational representation to the query set, and calculate the loss function of the query set.

[0054] The calculation of the loss function for the query set specifically includes: The entity pairs are received and their corresponding relational representations are represented. The loss function of the support set is calculated based on the relational representations. The gradient of the relation element representation is calculated based on the loss function of the support set, and the relation element representation is updated according to stochastic gradient descent; The updated relational representation is migrated to the query set, and the loss function of the query set is calculated.

[0055] Specifically, upon receiving the relational representation Then, using gradient-based meta-updates of relation meta-updaters 23 (including relation learners 231, 232, and embedding learners 233), the relation meta-updates generated from the support set are updated. A rapid update is performed and transferred to the calculation of the score function of the query set to predict query triples. Therefore, the relation learner 231 uses the score function of the TransE model on the support set... S r The entity pairs in the data are scored as follows:

[0056] Among them, || | |L1 / L2 The difference between two vectors can be measured using the L1 norm or L2 norm.

[0057] Next, calculate the total loss of the support set:

[0058] in, It is a negative triple relative to a positive triple, which is obtained by randomly replacing the positive triple in the support set. The tail entity obtained indicates that there is no definite relationship between the head entity and the tail entity; γ It is a hyperparameter used to distinguish between positive and negative triples.

[0059] Loss function based on support set L ( S r The relation representation is calculated using relation updater 232. Use gradients to optimize parameters:

[0060] The relation is then updated using stochastic gradient descent:

[0061] in, λ The learning rate is represented by the learned learner 233, which is used to represent the updated relation. The scoring function used to calculate the query set:

[0062] Based on the formula for the query set scoring function, the loss function for the query set is calculated as follows:

[0063] Similar to the calculation of the support set loss function, It is a negative triple of the query set, and It is the score of the negative triples in the query set, in order to minimize the loss on the query set. Only by minimizing the support set loss and the query set loss can the model learn to transfer knowledge from "limited reference triples" to "new query tasks" and ensure the accuracy of subsequent predictions.

[0064] S14. Based on the loss function of the support set and the loss function of the query set, update and optimize the initial entity embedding and the initial relation embedding.

[0065] Specifically, the training steps for the TransE model are as follows: (1) Initialization: Input training task set Tr train Small sample relation dataset G * Pre-trained entity embeddings e The model's initialization parameters Θ and the small sample size K ; (2) Loop training: Enter a loop and continue to perform the following operations until the training is completed: (a) Sampling task relationship: from the training task set Tr train Randomly sample a task relation in the middle. This step is to optimize the model from different relation perspectives in each training session and simulate different knowledge graph completion task scenarios. (b) Constructing the dataset: for the support set S r collect K A positive entity pair, which is also a query set. Q r Collect additional positive entity pairs and create negative entity pairs for the support set and query set respectively, and tag them. and Positive entity pairs are combinations of entities with known relationships, while negative entity pairs are combinations without relationships. This method allows the model to learn to distinguish between real and false relationships, thereby enhancing the model's judgment ability. (c) Generating entity representations: Using a hierarchical neighbor aggregator 221, combined with mechanisms such as neighbor filtering and graph attention network 212, the 1-hop and 2-hop neighbor information of entities is filtered, aggregated, and weighted to generate entity representations containing direct and indirect neighbor information. This step can fully explore the semantic information of entity neighbors, and improve the richness and accuracy of entity representation; (d) Generate relation representations: Input the generated entity pair representations into a Bi-LSTM network with affine attention mechanism to compute relation representations. Affine attention mechanisms can better capture the complex interaction information between entity pairs, making the representation of relationships more accurate; (e) Calculate the support set loss: Calculate the support set loss using the scoring function and hinge loss function of the TransE model. L ( S r The loss value is used to measure the difference between the model's predictions on the support set and the actual situation, providing a basis for subsequent parameter updates. (f) Update relation metadata: Utilize a gradient-based meta-update method to compute the support set loss on the relation representation. Grad( The relation metadata is updated using stochastic gradient descent to obtain the updated relation representation. This step allows the model to quickly adjust its relational representation based on the support set, making it more adaptable to task requirements; (g) Calculate the query set loss: represented by the updated relation. Calculate the scoring function of the query set, and then calculate the loss of the query set.L ( Q r The query set loss reflects the model's predictive ability on unknown data and is also an important optimization objective in model training. (h) Update model parameters: Based on the calculated support set loss and query set loss, update the full-link parameters of the model (the parameters to be updated include: the linear transformation matrix in the hierarchical neighbor aggregator 21). W 1, W 2) Weight vector ( V 1, V 2, V 3); Bi-LSTM hidden layer parameters and affine attention weights in relation generator 22 V 4, b The model is updated by adjusting the weights and biases of the model through algorithms such as backpropagation, so that the model is optimized in the direction of minimizing the loss of the support set loss + the query set loss, thereby improving the model performance (ensuring the model's generalization ability on "few sample relations", that is, it can fit the semantic rules of the reference set and accurately predict the missing entities in the query set).

[0066] (3) Output results: After the loop ends, the optimized model parameters are returned. These parameters represent the optimal configuration of the model after training on the few-shot knowledge graph completion task, which can be used for subsequent prediction tasks to ensure the accuracy of subsequent predictions.

[0067] S2. Based on the head entities and relationships of the query set, extract candidate tail entities that are related to the head entities from the support set to form a candidate tail entity set. Then, extract several direct neighbors of the head entities and the candidate tail entities, as well as several indirect neighbors corresponding to each direct neighbor, from the support set.

[0068] Specifically, after parameter optimization, for the target query (h, r, ?) in the query set, based on the head entity h and relation r of the query set, candidate tail entities that are related to the head entity are extracted from the support set (including all possible tail entities, excluding duplicate entities that already exist in the few-sample relation dataset), forming a candidate tail entity set. C t Then extract the head entity h and the candidate tail entity set from the support set. C t All direct neighbors of all candidate tail entities t and all indirect neighbors of each direct neighbor.

[0069] S3. Invoke the optimized entity embedding and optimized relation embedding to extract deep semantic information from the direct neighbors and indirect neighbors of the head entity and the candidate tail entity, and obtain the head entity enhanced embedding and candidate tail entity enhanced embedding containing the information of the direct neighbors and indirect neighbors.

[0070] Specifically, the process involves optimizing entity embedding and optimizing relation embedding, filtering indirect neighbors related to the target relation r (using a neighbor filter 211 to remove noise and retaining the top m highly similar indirect neighbors), and then using a graph attention network 212 to hierarchically aggregate the information of direct neighbors and the filtered indirect neighbors, ultimately generating a head entity augmented embedding containing both direct and indirect neighbor information. and candidate tail entity augmentation embedding .

[0071] S4. Generate entity pair representations based on the head entity augmentation embedding and the candidate tail entity augmentation embedding, process the entity pair representations to obtain relation meta-representations, and then update the relations of the query set based on the relation meta-representations to obtain relation update representations.

[0072] Specifically, based on the head entity enhancement embedding and candidate tail entity augmentation embedding Entity pair representations are generated, and these representations are aggregated by a hierarchical neighbor aggregator 221. Then, a bidirectional long short-term memory (Bi-LSTM) model with affine attention mechanism is introduced through a bidirectional long short-term memory network 222 to integrate the entity pair representations supporting the set and obtain a general representation of the target relation, namely the relation meta-representation. Then, the relation meta-representation is calculated by relation updater 232. The gradient is calculated, and the relation element representation is updated according to stochastic gradient descent to obtain the updated relation representation. .

[0073] S5. Based on the head entity enhancement embedding, the candidate tail entity enhancement embedding, and the relation update representation, calculate the rationality of each candidate tail entity, select the optimal candidate tail entity, and then add the optimal candidate tail entity to the query set to complete the missing tail entities in the query set.

[0074] The calculation of the rationality of each candidate tail entity and the selection of the optimal candidate tail entity specifically includes: S51. Based on the head entity augmentation embedding, candidate tail entity augmentation embedding and relation update representation, the score of each candidate tail entity in the candidate tail entity set is calculated using the scoring function of the TransE model; S52. Sort the scores of each candidate tail entity in ascending order and compare the scores of each candidate tail entity with a preset reasonableness threshold. S53. If the score of the candidate tail entity exceeds the reasonableness threshold, the candidate tail entity is excluded; if the score of the candidate tail entity does not exceed the reasonableness threshold, the candidate tail entity is retained. S54. Select the candidate tail entity with the lowest score among the retained candidate tail entities as the optimal candidate tail entity.

[0075] Specifically, based on the obtained head entity augmentation embedding Candidate tail entity augmentation embedding Relationship update representation The candidate tail entity set is calculated using the scoring function of the TransE model. C t The score for each candidate tail entity t, and the specific formula for calculating the score function is as follows:

[0076] Among them, || | |L1 / L2 This represents the difference (distance) between two vectors. The lower the score, the more reasonable it is for the candidate tail entity to be considered a tail entity.

[0077] Based on the scores of the candidate tail entities, all candidate tail entities in the candidate tail entity set are sorted in ascending order (candidate tail entities with lower scores are given priority). After sorting, a reasonableness threshold is set (which can be determined through the optimal validation results during the training phase, similar to the hyperparameter in the support set loss). The score of each candidate tail entity is compared with the preset reasonableness threshold. If the score of the candidate tail entity exceeds (>) the reasonableness threshold, it is determined that the current query has no effective completion effect (the completeness of the candidate tail entity set or model parameters need to be checked), and the candidate tail entity is excluded. If the score of the candidate tail entity does not exceed (≤) the reasonableness threshold, the candidate tail entity is retained. Then, the candidate tail entity with the lowest score is selected from all the retained candidate tail entities as the optimal candidate tail entity.

[0078] S6. After adding the best candidate tail entity to the query set, verify the redundancy and logicality of the head entity, relation, and tail entity in the query set.

[0079] The verification of the redundancy and logical consistency of the head entities, relations, and tail entities in the query set specifically includes: After adding the best candidate tail entity to the query set, check whether the query set exists in the knowledge graph. If it exists, remove the query set; otherwise, proceed to the next verification step. The query set is verified based on the high-frequency relationship logic of the knowledge graph. If it does not conform to common sense, the query set is removed; if it does, the verification is successful.

[0080] Specifically, after adding the best candidate tail entity to the query set, it checks whether the query set exists in the knowledge graph. If it exists, the query set is removed; if it does not exist, the next verification step is performed. Then, the query set is verified to conform to common sense by combining the high-frequency relationship logic of the knowledge graph (such as the transitivity of the "parent-child" relationship and the uniqueness of the "nationality" relationship). For example, if the nationality of the head entity is "China", then the score of the candidate tail entity "United States" should be higher than the threshold and should be excluded. If it does not conform, the query set is removed; if it does conform, the verification is successful.

[0081] S7. After successful verification, the query set is added to the knowledge graph, and the entity set, relation set, and triple set of the knowledge graph are updated to complete the knowledge graph completion in the few-sample scenario.

[0082] Specifically, after successful validation, the validated query set is added to the knowledge graph, and the entity set E, relation set R, and triple set T of the knowledge graph are updated to complete the knowledge graph in the few-shot scenario. Throughout the knowledge graph completion process, the model parameters are adapted to the few-shot relations by minimizing the support set loss and query set loss. Subsequently, through a process of "enhanced representation generation - candidate scoring - result filtering," the "reference set knowledge" learned by the model is transformed into "new triple completion results," ultimately improving the completeness of the knowledge graph. The entire process revolves around three core designs: "fully utilizing structural information (multi-hop neighbors)," "accurately capturing relational semantics (affine attention)," and "efficiently transferring knowledge (meta-learning)," solving the problems of high noise, weak semantics, and poor transfer in existing methods under few-shot scenarios.

[0083] The detailed working process of this embodiment is as follows: First, a few-sample relation dataset is constructed. The TransE model is then used to train the few-sample relation dataset, resulting in optimized entity embeddings and optimized relation embeddings. Based on the head entities and relations of the query set (h,r,?), candidate tail entities related to the head entities are extracted from the support set to form a candidate tail entity set. Next, several direct neighbors of the head entities and candidate tail entities, as well as several indirect neighbors corresponding to each direct neighbor, are extracted from the support set. Then, the trained and optimized entity embeddings and optimized relation embeddings are called. A hierarchical neighbor aggregator 21 is used to extract deep semantic information from the direct and indirect neighbors of the head entities and candidate tail entities, resulting in enhanced head entity embeddings and enhanced candidate tail entity embeddings containing direct and indirect neighbor information. Finally, based on the enhanced head entity embeddings and... Candidate tail entity augmentation embedding involves generating entity pair representations through relation generator 22, processing these representations to obtain relation meta-representations, and then updating the relations in the query set based on these meta-representations to obtain relation update representations. Subsequently, based on head entity augmentation embedding, candidate tail entity augmentation embedding, and relation update representations, relation meta-updater 23 calculates the rationality of each candidate tail entity and selects the optimal candidate tail entity. This optimal candidate tail entity is then added to the query set to complete the missing tail entities. Finally, the redundancy and logicality of the head entities, relations, and tail entities in the query set are verified. After successful verification, the query set is added to the knowledge graph, and the entity set, relation set, and triple set of the knowledge graph are updated to complete the knowledge graph completion in the few-sample scenario.

[0084] In the knowledge graph completion process, a hierarchical neighbor aggregator 21 is used to achieve controllable aggregation of direct and indirect neighbor information, thereby enhancing the semantic richness of entity embedding and ensuring more accurate selection of candidate tail entities. This solves the problem of insufficient utilization of knowledge graph structural information in existing technologies. Without significantly increasing computational complexity, it fully mines the deep structural information of the knowledge graph, improving the accuracy and comprehensiveness of entity representation. Furthermore, the selected direct and indirect neighbors are entity representations related to few-sample relations, rather than being randomly selected, thus solving the problem of noise introduction caused by random aggregation of neighbor information in existing technologies and reducing noise introduction. An affine attention mechanism (i.e., attention score based on Hadamard product for feature dimensions) is introduced through the relation generator 22. By focusing on the importance of different entity pairs, the semantic matching degree of few-sample relations is improved, avoiding the need for completion. The study addresses the issue of "relational semantic bias" by focusing on the importance of entities to features across different dimensions and enhancing the interaction between entities internally and externally. This solves the problem of existing technologies struggling to capture all the subtle differences and complexities of relationships with few samples. In few-sample scenarios, it can more accurately capture the complex details and semantics of relationships while avoiding excessive model complexity, balancing representation quality and efficiency. The study calculates the loss function of the support set using a relation meta-updater, updates the relation representation using stochastic gradient descent, and transfers the updated relation meta-knowledge to the query set. Through a meta-learning strategy, the few-sample relation knowledge learned during training is directly transferred to the completion stage, ensuring accurate completion even in scenarios with "extremely few training samples." Furthermore, it achieves efficient knowledge transfer from limited reference triples to new query triples, significantly improving the prediction accuracy of knowledge graph completion in few-sample scenarios.

[0085] like Figure 6 and Figure 7 As shown, another embodiment of the present invention proposes a knowledge graph completion system for scenarios with few samples, the completion system comprising: Storage device 1 is used to store information in a constructed few-sample relation dataset, the dataset containing a support set and a query set, both of which store detailed information about entities and their relations in the form of head entity-relation-tail entity triples; The knowledge graph completion device 2 is used to call the support set and query set stored in the storage device 1, and use the knowledge graph completion method for a few-sample scenario described above to complete the missing tail entities in the query set.

[0086] Furthermore, the knowledge graph completion device 2 includes: Hierarchical neighbor aggregator 21 is used to extract deep semantic information from the direct and indirect neighbors of each entity in the support set to obtain entity representations related to few-sample relations, wherein the entity representations are entity-enhanced embeddings containing information about direct and indirect neighbors; Relation generator 22, equipped with an affine attention mechanism, is used to receive entity representations sent by the hierarchical neighbor aggregator 21, generate corresponding entity pair representations, and process the generated entity pair representations to obtain relation meta-representations. The relational meta updater 23 is used to receive the relational meta representation sent by the relation generator 22, and calculate the loss function of the support set based on the relational meta representation; and to update the received relational meta representation, then migrate the updated relational meta representation to the query set, calculate the loss function of the query set, so as to predict the content of the tail entity to be completed.

[0087] Specifically, the hierarchical neighbor aggregator 21 includes a neighbor filter 211 and a graph attention network 212. The neighbor filter 211 is used to filter the indirect neighbors of an entity and filter out the indirect neighbors related to the target relationship. The graph attention network 212 is used to aggregate the direct neighbors of an entity and the filtered indirect neighbor information, and finally generate an entity-enhanced embedding containing direct neighbor and indirect neighbor information.

[0088] The relation generator 22 includes a hierarchical neighbor aggregator 221 and a bidirectional long short-term memory network 222. The hierarchical neighbor aggregator 221 is used to receive the entity augmentation embedding sent by the graph attention network 212, generate the corresponding entity pair representation, and aggregate the generated entity pair representation. The bidirectional long short-term memory network 222 is used to introduce a bidirectional long short-term memory (Bi-LSTM) model with an affine attention mechanism to integrate and support the entity pair representation in the set and obtain a general representation of the target relation, namely the relation meta-representation.

[0089] The relation meta-updater 23 includes a relation learner 231, a relation updater 232, and an embedding learner 233. The relation learner 231 is used to apply the scoring function of the TransE model to the support set. S r The entity pairs in the set are scored, and the total loss of the support set is calculated based on the scores. The relation updater 232 is used to calculate the gradient of the relation representation based on the total loss of the support set and update the relation meta-representation based on stochastic gradient descent. The embedding learner 233 is used to transfer the updated relation meta-representation to the query set and calculate the loss function of the query set to predict the content of the tail entity to be completed.

[0090] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A method for knowledge graph completion in a few-shot scenario, the method comprising: The completion method comprises the following steps: The method comprises the following steps: A few-sample relationship data set is constructed, and the data set is trained by using a TransE model to obtain optimized entity embedding and optimized relationship embedding, the data set is derived from a knowledge graph, the data set comprises a support set and a query set, and the support set and the query set store detailed information of entities and their relationships in the form of a head entity-relation-tail entity triple; Based on the head entity and the relationship of the query set, candidate tail entities related to the head entity are extracted from the support set to form a candidate tail entity set, and a plurality of direct neighbors of the head entity and the candidate tail entities and a plurality of indirect neighbors corresponding to each direct neighbor are extracted from the support set; The optimized entity embedding and the optimized relationship embedding are called to extract deep semantic information from the direct neighbors and the indirect neighbors of the head entity and the candidate tail entities, and head entity enhanced embedding and candidate tail entity enhanced embedding containing the direct neighbor information and the indirect neighbor information are obtained; Based on the head entity enhanced embedding and the candidate tail entity enhanced embedding, entity pair representation is generated, the entity pair representation is processed to obtain relationship meta representation, and the relationship of the query set is updated based on the relationship meta representation to obtain relationship updated representation; 2. The knowledge graph completion method in a few-shot scenario according to claim 1, characterized in that, Based on the head entity enhanced embedding, the candidate tail entity enhanced embedding and the relationship updated representation, the rationality of each candidate tail entity is calculated, and the optimal candidate tail entity is screened out, and the optimal candidate tail entity is supplemented into the query set to complete the missing tail entity of the query set. The training of the data set comprises the following steps: The direct neighbors and the indirect neighbors of each entity in the support set are derived, and deep semantic information is extracted from the direct neighbors and the indirect neighbors to obtain entity representation related to the few-sample relationship, the support set comprises pre-trained initial entity embedding and initial relationship embedding; The entity representation is received, corresponding entity pair representation is generated, and the entity pair representation is processed to obtain relationship meta representation; The relationship meta representation is received, and a loss function of the support set is calculated based on the relationship meta representation, the relationship meta representation is updated, the updated relationship meta representation is migrated to the query set, and a loss function of the query set is calculated; 3. The knowledge graph completion method in a few-shot scenario according to claim 2, characterized in that, Based on the loss function of the support set and the loss function of the query set, the initial entity embedding and the initial relationship embedding are updated and optimized. The entity representation related to the few-sample relationship comprises the following steps: Based on each entity in the support set, a plurality of direct neighbors of each entity and a plurality of indirect neighbors corresponding to each direct neighbor are derived, and the indirect neighbors having high correlation with each direct neighbor are screened out; 4. The knowledge graph completion method in a few-shot scenario according to claim 2, characterized in that, The direct neighbors and the corresponding indirect neighbors screened out are aggregated to obtain entity representation of each entity, and the entity representation is an entity enhanced embedding containing the direct neighbor information and the indirect neighbor information. The relationship meta representation comprises the following steps: receiving entity representations of each entity, aggregating the entity representations of two entities with high correlation based on initial relation embeddings to generate corresponding entity pair representations; introducing a bidirectional long short-term memory model with an affine attention mechanism to integrate the entity pair representations to obtain corresponding relation meta representations of the entity pair representations.

5. The knowledge graph completion method in a few-shot scenario according to claim 2, characterized in that, The loss function of the query set is calculated, specifically including: receiving the relation meta representations corresponding to the entity pair representations, and calculating the loss function of the support set based on the relation meta representations; calculating the gradient of the relation meta representation based on the loss function of the support set, and updating the relation meta representation according to the stochastic gradient descent; migrate the updated relation meta representation to the query set, and calculate the loss function of the query set.

6. The knowledge graph completion method in a few-shot scenario according to claim 1, characterized in that, The rationality of each candidate tail entity is calculated, and the optimal candidate tail entity is selected, specifically including: Based on the head entity enhanced embedding, the candidate tail entity enhanced embedding and the relation update representation, the score function of the TransE model is used to calculate the score of each candidate tail entity in the candidate tail entity set; arranging the scores of each candidate tail entity in ascending order, and comparing the scores of each candidate tail entity with a preset rationality threshold; if the score of the candidate tail entity exceeds the rationality threshold, the candidate tail entity is excluded; if the score of the candidate tail entity does not exceed the rationality threshold, the candidate tail entity is retained; selecting the candidate tail entity with the lowest score among the retained candidate tail entities as the optimal candidate tail entity.

7. The method of claim 1, wherein, The completion method further includes the following steps: After the optimal candidate tail entity is supplemented into the query set, the repeatability and logic of the head entity, relation and tail entity in the query set are verified; After verification, the query set is added to the knowledge graph, and the entity set, relation set and triple set of the knowledge graph are updated, completing the knowledge graph completion in the few-shot scenario.

8. The method of claim 7, wherein, The repeatability and logic of the head entity, relation and tail entity in the query set are verified, specifically including: After the optimal candidate tail entity is supplemented into the query set, it is checked whether the query set exists in the knowledge graph, if it exists, the query set is excluded, if it does not exist, the next step is verified; based on the high-frequency relation logic of the knowledge graph, it is verified whether the query set conforms to common sense, if it does not conform, the query set is excluded, if it conforms, the verification is passed.

9. A knowledge graph completion system under few-shot scenario, characterized in that, The completion system includes: a storage device for storing information in a constructed few-shot relation dataset, the dataset containing a support set and a query set, the support set and the query set storing detailed information of entities and their relations in the form of head entity-relation-tail entity triples; a knowledge graph completion device for calling the support set and the query set stored by the storage device, and using any one of the knowledge graph completion methods in claims 1-8 to complete the missing tail entity in the query set.

10. The knowledge graph completion system in a few-shot scenario according to claim 9, characterized in that, The knowledge graph completion device includes: a hierarchical neighbor aggregator configured to extract deep semantic information from direct neighbors and indirect neighbors of each entity in the support set, to obtain an entity representation related to a few-shot relation, the entity representation being an entity-enhanced embedding containing direct neighbor and indirect neighbor information; a relation generator with an affine attention mechanism configured to receive the entity representation sent by the hierarchical neighbor aggregator, to generate a corresponding entity pair representation, and to process the generated entity pair representation to obtain a relation meta representation; a relation meta updater configured to receive the relation meta representation sent by the relation generator, to calculate a loss function of the support set based on the relation meta representation, to update the received relation meta representation, to migrate the updated relation meta representation to the query set, to calculate a loss function of the query set, to predict the content of the tail entity to be completed, and to calculate and screen out an optimal candidate tail entity based on the entity-enhanced embedding and the relation meta representation, and to fill the optimal candidate tail entity into the query set.