Knowledge graph completion method, system and equipment based on entity relationship attention and medium
By assigning embedding vectors to entities and relations in the knowledge graph, capturing deep semantic associations using an attention mechanism, generating joint feature vectors and performing probabilistic scoring, the shortcomings of existing methods in capturing the interaction features of entities and relations are addressed, achieving efficient completion and improved accuracy of the knowledge graph.
Patent Information
- Application Number
- CN202510792880.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-11-04
AI Technical Summary
Existing knowledge graph completion methods are insufficient in capturing the interaction features of entities and relationships, resulting in low efficiency when processing complex relationships and difficulty in adapting to the dynamics and accuracy of knowledge graphs.
We employ an entity-relationship attention-based approach. By assigning embedding vectors to entities and relations, we capture deep semantic associations using an attention mechanism, generate joint feature vectors, and then use inner product operations and the Sigmoid function to perform probabilistic scoring to select high-confidence completion results.
It significantly improves the completeness and accuracy of knowledge graphs, especially when dealing with complex relationships, with a 7.9 and 3.4 percentage point increase in hit rate and average reciprocal ranking index, respectively, effectively addressing the shortcomings of traditional methods in terms of interaction feature capture and information selection efficiency.
Smart Images

Figure CN120892574A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence and knowledge engineering, and particularly relates to a knowledge graph completion method and system based on entity relation attention, a device and a medium. BACKGROUND
[0002] With the rapid development of artificial intelligence technology, knowledge graph, as a structured knowledge representation form, has become one of the key technologies to realize cognitive intelligence. By modeling the complex associations between things through graph structure, it can effectively represent and reason the semantic relationships between entities, and has been widely applied in search engines, recommendation systems, intelligent question answering and other fields. For example, in search engines, knowledge graph can provide more accurate search results; in recommendation systems, it can help users discover potential interest points; in intelligent question answering systems, knowledge graph can support more natural language interaction and more accurate answer generation. In recent years, large-scale knowledge graphs such as Freebase, YAGO, WikiData and Dbpedia have become the focus of research. These knowledge graphs integrate multi-source data and provide rich semantic information, but also have the problem of incompleteness. This incompleteness mainly manifests as the missing of triples in the knowledge graph, which limits the performance of the knowledge graph in practical applications and may lead to inaccurate reasoning and decision-making. Therefore, the knowledge graph completion task arises at the historic moment, aiming to improve the knowledge graph by predicting the missing entities or relationships.
[0003] The knowledge graph completion task also faces many challenges. First, the relationship types in the knowledge graph are complex and diverse, including symmetric relationships, asymmetric relationships, many-to-many relationships, etc., which increases the difficulty of the completion task. Second, the number of entities and relationships in the knowledge graph is huge, and there is a lot of semantic redundancy and noise, which requires the completion model to have efficient feature extraction ability and strong semantic understanding ability. Finally, the dynamic nature of the knowledge graph requires the completion model to adapt to the addition of new data and the update of old data, and to maintain the integrity of the knowledge graph in real time.
[0004] In recent years, researchers have proposed various knowledge graph completion models, which can be roughly divided into translation distance models, semantic matching models, and neural network models. Translation distance models map entities and relationships to low-dimensional vector spaces and use the distance between vectors to measure the rationality of facts. However, such models have limitations in handling complex relationships and have limited modeling capabilities for relationships. Semantic matching models measure the rationality of facts by calculating the similarity between the vector representations of entities and relationships, which can better capture semantic information but have high computational complexity. Neural network models introduce deep learning techniques such as convolutional neural networks to more flexibly model the complex interactions between entities and relationships, but often overlook the importance of information selection, resulting in insufficient capture of key features. Although these methods have improved the performance of knowledge graph completion to some extent, existing methods still have limitations in capturing the interaction features between entities and relationships. For example, convolutional neural network-based methods can extract features of entities and relationships, but are inefficient in handling complex relationships and do not adequately model the interaction between entities and relationships. In addition, these methods often overlook the importance of information selection, resulting in low efficiency and difficulty in capturing key features when processing large-scale knowledge graphs.
[0005] To overcome the above problems, researchers have begun to explore new methods and techniques. For example, some research has introduced attention mechanisms into the knowledge graph completion task by assigning weights to different entities and relationships to highlight important information and suppress irrelevant information, thereby improving model performance. Path-based methods consider path information between entities to infer potential relationships, which can better utilize the structural information of knowledge graphs. In summary, knowledge graph completion technology is of great significance in practical applications, but also faces many challenges. How to better model the interaction features between entities and relationships, how to improve the efficiency and accuracy of the model, and how to adapt to the dynamics of knowledge graphs are the focus and difficulty of current research. SUMMARY
[0006] In view of the above existing problems, the present application is proposed.
[0007] Therefore, the present application provides a knowledge graph completion method, system, device and medium based on entity relationship attention, aiming to solve the shortcomings of existing knowledge graph completion methods in capturing the interaction features of entities and relationships, to improve the performance of knowledge graph completion.
[0008] To solve the above technical problems, the present application provides the following technical solutions:
[0009] In a first aspect, the present application provides a knowledge graph completion method based on entity relationship attention, comprising:
[0010] A fixed-length embedding vector is assigned to each entity and relation in a knowledge graph based on a structured knowledge representation, and a first initialization method is used to initialize the embedding vector;
[0011] The embedding vectors of the head entity and the relation are mapped and reshaped into matrix forms, respectively;
[0012] Deep relationships between the head entity and the relation are captured through an attention mechanism to generate a joint feature vector;
[0013] The joint feature vector is calculated with the embedding vector of the tail entity to obtain a scoring result of the triple;
[0014] All candidate triples are sorted and selected according to the scoring result, and the first selection result is added to the knowledge graph as a completion result to complete the knowledge graph.
[0015] As a preferred scheme of the knowledge graph completion method based on entity relation attention, the generation of the joint feature vector includes:
[0016] An attention coefficient between the head entity and the relation is calculated, and the attention coefficient is converted into a probability distribution;
[0017] The vectors in the value matrix are weighted and aggregated based on the normalized probability distribution to obtain the joint feature vector.
[0018] As a preferred scheme of the knowledge graph completion method based on entity relation attention, the generation of the joint feature vector further includes:
[0019] The weighted and aggregated joint feature vector is linearly transformed through a fully connected layer to map it into a joint feature vector consistent with the entity embedding dimension, which is used for subsequent triple scoring.
[0020] As a preferred scheme of the knowledge graph completion method based on entity relation attention, the generation of the joint feature vector includes:
[0021] To evaluate the authenticity of the fact represented by the triple, the joint feature vector and the embedding vector of the tail entity are subjected to an inner product operation to obtain an inner product result;
[0022] The inner product result reflects the similarity between the joint feature vector and the tail entity vector;
[0023] The inner product result is subjected to a nonlinear transformation through an activation function to obtain a scoring result of the triple.
[0024] The beneficial effects of this preferred technical solution are: it can effectively capture the deep semantic associations between entities and relationships, and dynamically focus on key information through an attention mechanism, thereby achieving better performance in knowledge graph completion.
[0025] As a preferred embodiment of the knowledge graph completion method based on entity relation attention described in this invention, all candidate triples are sorted from high to low according to the scoring results, and the top k triples are selected as completion results and added to the knowledge graph to achieve knowledge graph completion, where k is a preset positive integer.
[0026] As a preferred embodiment of the knowledge graph completion method based on entity relationship attention described in this invention, the initialization includes:
[0027] The initial weight distribution is set by the first initialization method, so that the variance of the input and output of each layer of the network remains consistent during forward propagation.
[0028] The beneficial effects of this preferred technical solution are: optimizing the embedding vectors of entities and relations to ensure numerical stability in the early stages of training.
[0029] As a preferred embodiment of the knowledge graph completion method based on entity relation attention described in this invention, the step of mapping and reshaping the embedding vectors of the head entity and relation into matrix form includes:
[0030] The embedding vectors of head entities and relations are mapped and reshaped into matrix form using learnable matrices. Let the embedding vector of the head entity be h, and the embedding vector of the relation be r. The mapping and reshaping process is then expressed as follows:
[0031] Q = reshape(rW) Q ), K = reshape(hW K ),V = reshape(hW V )
[0032] Where h, r∈d represent the head entity and relation, respectively, and W Q W K W V All are learnable matrices, Q,K,V∈d M ×d M This is the mapped and shaped matrix.
[0033] Secondly, this invention provides a knowledge graph completion system based on entity relationship attention, including:
[0034] An initialization module is configured to assign a fixed-length embedding vector to each entity and relation in a knowledge graph based on a structured knowledge representation, and initialize the embedding vector by using a first initialization method;
[0035] A feature mapping and reshaping module is configured to map and reshape the embedding vectors of the head entity and relation into a matrix form, respectively;
[0036] A feature extraction module is configured to capture deep relationships between the head entity and relation by using an attention mechanism, and generate a joint feature vector;
[0037] A knowledge graph completion module is configured to obtain a scoring result of a triple by calculating the joint feature vector and the embedding vector of the tail entity, sort and select all candidate triples according to the scoring result, and add a first selection result as a completion result to the knowledge graph, thereby completing the knowledge graph.
[0038] In a third aspect, the present application provides an electronic device comprising a memory and a processor; the memory is configured to store computer executable instructions, and the processor is configured to implement the steps of the knowledge graph completion method based on entity relationship attention when executing the computer executable instructions.
[0039] In a fourth aspect, the present application provides a computer readable storage medium storing computer executable instructions, which are configured to implement the steps of the knowledge graph completion method based on entity relationship attention when executed by a processor.
[0040] Compared with the prior art, the present application has the following beneficial effects: by introducing the knowledge graph completion method based on entity relationship attention, the completeness and accuracy of the knowledge graph are significantly improved. First, the embedding vectors of entities and relations are optimized by Xavier initialization to ensure the numerical stability in the early stage of training; then, the feature mapping and reshaping technology is used to enrich the semantic expression, and the attention mechanism is used to dynamically capture the deep interaction features between entities and relations to generate a joint vector; finally, the inner product operation and Sigmoid function are combined to probabilistically score and sort the triples, and the completion results with high confidence are selected, which can effectively capture the deep semantic association between entities and relations, and dynamically focus on key information through the attention mechanism, thereby achieving better knowledge graph completion. Experiments show that the method significantly outperforms the prior art on the WN18RR and FB15K-237 data sets, especially in handling complex relations, with the Hit@K and MRR indicators improving by up to 7.9 and 3.4 percentage points, respectively, effectively solving the deficiencies of traditional methods in interaction feature capture and information selection efficiency, and can be applied to various knowledge graph completion tasks to improve the completeness and accuracy of the knowledge graph. BRIEF DESCRIPTION OF DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments description. Obviously, the drawings in the following description only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.
[0042] Figure 1 The overall flow logic diagram of the knowledge graph completion method based on entity relation attention for an embodiment of the present application.
[0043] Figure 2 The model diagram of the knowledge graph completion method based on entity relation attention for an embodiment of the present application. DETAILED DESCRIPTION
[0044] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific embodiments of the present application will be described in detail below with reference to the drawings in the specification. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should be within the scope of protection of the present application.
[0045] Embodiment 1, refer to Figures 1-2 For an embodiment of the present application, a knowledge graph completion method based on entity relation attention is provided, which focuses on deeply mining the deep semantic association between entities and relations, so as to realize efficient prediction of missing triples in the knowledge graph, and further improve the integrity and accuracy of the knowledge graph. As shown in Figure 1 specifically includes the following steps:
[0046] S100: Assigning a fixed-length embedding vector to each entity and relation in the knowledge graph based on structured knowledge representation, and initializing the embedding vector by using a first initialization method;
[0047] S200: Mapping and reshaping the embedding vectors of the head entity and the relation into matrix form respectively;
[0048] S300: Capturing the deep relationship between the head entity and the relation through the attention mechanism to generate a joint feature vector;
[0049] S400: Obtaining the scoring result of the triple by calculating the joint feature vector and the embedding vector of the tail entity;
[0050] S500: Sorting and selecting all candidate triples according to the scoring result, and adding the first selection result to the knowledge graph as the completion result to realize the completion of the knowledge graph.
[0051] It should be noted that, in order to solve the problem of the existing knowledge graph completion method in capturing the interaction features of entities and relations, and to improve the performance of knowledge graph completion, the steps S100-S500 introduce a knowledge graph completion method based on entity relation attention, which significantly improves the integrity and accuracy of the knowledge graph. First, the embedding vectors of entities and relations are optimized through Xavier initialization to ensure the numerical stability at the beginning of training. Then, the feature mapping and reshaping techniques are used to enrich the semantic expression, and the attention mechanism is used to dynamically capture the deep interaction features between entities and relations to generate joint vectors. Finally, the inner product operation and Sigmoid function are combined to probabilistically score and sort the triples, and the high-confidence completion results are selected, which can effectively capture the deep semantic association between entities and relations, and dynamically focus on key information through the attention mechanism, thereby achieving better performance of knowledge graph completion.
[0052] In the embodiment of the present application, the above step S100 comprises:
[0053] In order to represent the knowledge graph, the embodiment assigns a fixed-length embedding vector to each entity and relation, and sets the vector dimension of the entity and the relation to d, wherein the embedding vector is used to capture and represent the corresponding semantic information.
[0054] In order to ensure that the embedding vector can effectively participate in the learning process at the beginning of model training, the embodiment uses the Xavier initialization method to initialize the embedding vector. For the entity embedding vector e i and the relation embedding vector r j , the initialization formula is:
[0055]
[0056] wherein, represents uniform distribution;
[0057] It should be noted that the core idea of Xavier initialization is to set the initial weight distribution reasonably so that the variance of the input and output of each layer of the network remains consistent during forward propagation. This strategy helps to maintain the stable size of the gradient during backpropagation, thereby avoiding the problem of gradient vanishing or gradient explosion that may occur at the beginning of training, and providing a strong guarantee for the efficient training and convergence of the model.
[0058] In an optional embodiment, the first initialization method can also use Kaiming initialization: this method is designed for ReLU activation function, and adjusts the initialization distribution by considering the nonlinear characteristics. According to the input dimension of the network layer, the weight variance is adjusted so that the signal variance remains unchanged during forward propagation, which is especially suitable for deep neural networks and can effectively alleviate the gradient vanishing problem and speed up convergence.
[0059] In another optional embodiment, the first initialization method can also employ normal distribution initialization: the embedding vectors are randomly initialized using a normal distribution with a mean of 0 and a variance-adjustable variance. By controlling the variance size to balance the diversity of the initial parameters, it is suitable for various model structures, but needs to be combined with gradient clipping and other technologies to avoid unstable training.
[0060] It should be noted that the above step S100 assigns fixed-length embedding vectors to entities and relations in the knowledge graph, and optimizes them using the Xavier initialization method to ensure the numerical stability at the initial stage of model training, effectively avoiding the problems of gradient disappearance or gradient explosion, providing an initialization basis for subsequent feature extraction and interaction modeling, thereby improving the convergence speed and training efficiency of the model.
[0061] In the embodiments of the present application, the above step S200 includes:
[0062] To further enrich the semantic expression of head entities and relations, the embedding vectors of head entities and relations are mapped and reshaped into matrix form through a learnable matrix. Let the embedding vector of the head entity be h and the embedding vector of the relation be r, then the mapping and reshaping process is represented by the formula:
[0063] Q = reshape(rW Q ), K = reshape(hW K ), V = reshape(hW V )
[0064] Where h, r ∈ d represent the head entity and the relation respectively, W Q ,W K ,W V are all learnable matrices, and Q, K, V ∈ d M ×d M are the mapped and reshaped matrices.
[0065] It should be noted that the above step S200 maps and reshapes the embedding vectors of the head entity and the relation into matrix form, further enriching the semantic expression. By increasing the dimension information, the features of entities and relations can be more fully expanded and refined, thereby providing a richer semantic basis for subsequent interaction feature extraction.
[0066] In the embodiments of the present application, as shown in Figure 2 the above step S300 includes the following sub-steps C1-C4:
[0067] In C1: calculate the attention coefficient between the head entity and the relation;
[0068] Specifically, the attention coefficient between the head entity and the relation is calculated by querying the matrix Q, the key matrix K and the value matrix V, and the formula is represented as:
[0069]
[0070] It should be noted that the attention score is calculated by performing an inner product operation on the query matrix and the key matrix, and is scaled by dividing by the square root of the dimension of the key matrix to ensure numerical stability.
[0071] In C2, the entity relation attention coefficient is normalized;
[0072] Specifically, the attention coefficient is normalized to a probability distribution by the softmax function, thereby reflecting the importance of each value vector relative to the query vector, and the formula is represented as:
[0073]
[0074] In C3, the vector in the value matrix is weighted and aggregated based on the normalized probability distribution to obtain the joint feature vector: E = AV.
[0075] It should be noted that the joint vector representing the head entity and the relation is aggregated: based on these normalized probability distributions, the model weights and aggregates the vectors in the value matrix V to generate a weighted joint feature vector, which represents the joint semantics of the head entity and the relation.
[0076] In C4, the weighted and aggregated joint feature vector c is linearly transformed by a fully connected layer to map it to a joint feature vector consistent with the entity embedding dimension, which is used for subsequent triple scoring, and the formula is represented as:
[0077] c = EW
[0078] where W is a learned matrix, and c is a joint vector representing the head entity and the relation.
[0079] It should be noted that the above step S300 dynamically captures the deep interaction features between the head entity and the relation through the attention mechanism, generates a joint feature vector, and can adaptively focus on key information and suppress irrelevant noise, thereby more accurately representing the semantic association between entities and relations, and significantly improving the understanding and prediction ability of the model for complex relations.
[0080] In the embodiments of the present application, the above step S400 includes:
[0081] To evaluate the authenticity of the fact represented by the triple (h, r, t), the inner product operation is performed on the joint feature vector and the embedding vector of the tail entity to obtain the inner product result.
[0082] The inner product result reflects the similarity between the joint feature vector and the tail entity vector;
[0083] The inner product result is nonlinearly transformed by an activation function to obtain a scoring result s of the triple:
[0084] s = score(h, r, t) = σ(ct T )
[0085] where σ is a Sigmoid function, and the output range is (0, 1), indicating the probability of existence of the triple;
[0086] It should be noted that, to evaluate the authenticity of the fact represented by a triple, the model performs an inner product operation on the joint feature vector of the head entity and the relation and the embedding vector of the tail entity. Then, the inner product result is nonlinearly transformed by an activation function to map it to a probability value between 0 and 1, indicating the probability of existence of the fact represented by the triple. In this process, the activation function uses the Sigmoid function, which can map any real number value to the interval (0, 1), thereby providing the model with a probabilistic output, so that the model can evaluate the authenticity of the triple in a more natural way.
[0087] It should be noted that the above step S400 calculates the joint feature vector and the embedding vector of the tail entity, and obtains the probabilistic scoring result of the triple through the Sigmoid function, which not only quantifies the authenticity of the triple, but also enhances the expression ability of the model through nonlinear transformation, making the prediction result more reliable and interpretable.
[0088] In the embodiments of the present application, the above step S500 includes:
[0089] All candidate triples are sorted in descending order of the scoring result, and the triples ranked at the top are identified as triples that are more likely to exist;
[0090] The top-k triples are selected as the completion result and added to the knowledge graph to complete the knowledge graph, where k is a predetermined positive integer.
[0091] It should be noted that the above step S500 sorts all candidate triples according to the scoring result, and selects high-confidence results as completion content to add to the knowledge graph, ensuring the accuracy and practicality of the completion result, and efficiently screening out the most likely existing triples, thereby significantly improving the completeness and application value of the knowledge graph.
[0092] Embodiment 2, based on the previous embodiment, the present embodiment provides an application example of the knowledge graph completion method, system, device and medium based on entity relation attention, which verifies and explains the technical effects used in the present method.
[0093] This embodiment demonstrates its outstanding performance and broad application prospects through a series of rigorous and comprehensive experiments. The experiments are carried out on two widely recognized benchmark knowledge graph datasets, WN18RR and FB15K-237, which have become the gold standard for evaluating the performance of knowledge graph completion models due to their unique characteristics and wide applications. Among them, the WN18RR dataset is based on WordNet and focuses on semantic relationships between words such as "synonyms", "antonyms", and "hypernyms". Compared with the original WN18 dataset, WN18RR solves the test set leakage problem through optimization, significantly improving data quality and test effectiveness. The entities are mainly derived from English vocabulary, making it an ideal choice for natural language processing and semantic understanding tasks. The FB15K-237 dataset is based on Freebase and is an improved version of FB15K. It not only removes the test leakage problem but also enhances the rigor of the dataset. It covers a wide range of relationship types, including people, places, events, and other fields such as "place of birth", "nationality", "director", and "actor". Although the number of entities in FB15K-237 is relatively small, the diversity of its relationship types makes it an excellent platform for evaluating the model's ability to model complex relationships.
[0094] Table 1 shows detailed statistics of these two datasets, covering the number of relationships, entities, and the size of training, validation, and test sets. Not only does it provide a solid foundation for experiments, but it also sets a clear benchmark for subsequent performance evaluation.
[0095] Table 1: Statistics.
[0096] Dataset Number of relations Number of entities Training set Validation set Test set FB157K-237 237 14541 272115 17535 20466 WN18RR 11 40943 86835 3034 3134
[0097] In the knowledge graph completion task, the key to evaluating model performance lies in measuring its prediction ability for missing triples. To comprehensively and objectively evaluate model performance, the experiment adopts two commonly used evaluation indicators: Mean Reciprocal Rank (MRR) and Hit@K. Mean Reciprocal Rank (MRR) is one of the core indicators for measuring the prediction accuracy of the model. It calculates the reciprocal of the predicted rank of each test triple by the model and takes the average to evaluate the overall performance of the model. The advantage of the MRR indicator is that it can comprehensively reflect the performance of the model in handling different difficulty samples, especially giving higher weight to correct predictions with higher rankings. Hit@K is another important indicator for measuring the prediction accuracy of the model, which reflects the ability of the model to include correct entities in the first K predictions.
[0098] Specifically, for each test triple, the model generates a ranked list of all possible tail entities. If the correct tail entity t is among the top K positions of the predicted list, the prediction of this triple is considered successful. The value of K is usually taken as 1, 3, 10, corresponding to Hit@1, Hit@3 and Hit@10 respectively. The advantage of the Hit@K index is that it can evaluate the prediction ability of the model from different granularities. Hit@1 emphasizes the prediction accuracy of the most likely result, while Hit@10 focuses more on the prediction reliability of the model within a certain range.
[0099] Further, Table 2 and Table 3 respectively show the performance comparison of the AttenE model designed in this embodiment and the classic model in the current knowledge graph completion field on the WN18RR and FB15K-237 data sets. From the data in the table, it can be seen that the AttenE model has achieved the best result in 6 out of 8 evaluation indexes on the two data sets, and the second best result in 2 out of 8 evaluation indexes. The results fully prove the excellent performance of the AttenE model in the knowledge graph completion task.
[0100] Table 2: Performance comparison of FB15K-237 data set.
[0101]
[0102]
[0103] Table 3: Performance comparison of WN18RR data set.
[0104] MRR Hit@10 Hit@3 Hit@1 DistMult 0.430 0.490 0.440 0.390 ComplEx 0.440 0.510 0.460 0.410 SimplE 0.398 0.427 - 0.483 TransE 0.226 0.501 - - TransR 0.401 0.465 0.389 0.401 TorusE 0.481 0.512 0.464 0.422 RotatE 0.476 0.571 0.492 0.428 RotatHS 0.478 0.565 0.494 0.434 ConvE 0.460 0.480 0.430 0.390 KMAE 0.448 0.524 0.465 0.415 CTKGC 0.459 0.521 0.472 0.426 M-DCN 0.475 0.540 0.485 0.440 MConvKGC 0.466 0.545 0.479 0.428 Ours 0.489 0.557 0.503 0.453
[0105] Analyzing the characteristics of the two data sets, the WN18RR data set has more entities and fewer relationships; in contrast, the FB15K-237 data set has more relationships and fewer entities. This indicates that the triple structure in the FB15K-237 data set is more complex, and the relationship types are more diverse. Therefore, it is more challenging to achieve good experimental results on the FB15K-237 data set.
[0106] Comparing the experimental results on the two data sets, it can be found that most of the models including the model of the embodiment perform better on the WN18RR data set. However, the model of the embodiment achieves significant performance improvement on both the FB15K-237 and WN18RR data sets. Specifically, the AttenE model improves the Hit@K index of the FB15K-237 by an average of 5.7, 7.1, and 7.3 percentage points, respectively, and improves the Hit@K index of the WN18RR by an average of 4.7, 4.8, and 3.1 percentage points, respectively. Obviously, the performance improvement of the model of the embodiment on the FB15K-237 data set is more significant, which fully proves that the model has stronger modeling ability when dealing with complex relationships.
[0107] From the modeling idea, the AttenE model of the embodiment has certain similarity with the ConvE model, both of which are committed to extracting the interactive features of entities and relationships, and scoring the joint vector of the head entity and the relationship and the tail entity through the inner product operation. However, compared with the ConvE model, the model of the embodiment improves the MRR index by about 3.4 percentage points, the Hit@10 index by about 4.4 percentage points, the Hit@3 index by about 3.3 percentage points, and the Hit@1 index by about 2 percentage points on the WN18RR data set. On the FB15K-237 data set, the model of the embodiment improves the MRR index by about 3.1 percentage points, the Hit@10 index by about 7.9 percentage points, the Hit@3 index by about 7.5 percentage points, and the Hit@1 index by about 6.5 percentage points. These results show that the entity-relation attention mechanism adopted by the model of the embodiment is superior to the convolutional neural network in terms of the ability to mine the interactive features of entities and relationships, so that it can more accurately predict the missing triple information in the knowledge graph completion task.
[0108] Embodiment 3 provides a knowledge graph completion system based on entity-relation attention, comprising:
[0109] An initialization module is configured to assign a fixed-length embedding vector to each entity and relationship in a knowledge graph based on a structured knowledge representation, and initialize the embedding vector using a first initialization method.
[0110] A feature mapping and reshaping module is configured to map and reshape the embedding vectors of the head entity and the relationship into matrix form, respectively.
[0111] A feature extraction module is configured to capture the deep relationship between the head entity and the relationship through an attention mechanism to generate a joint feature vector.
[0112] The knowledge graph completion module is configured to obtain a scoring result of the triple by calculating the joint feature vector and the embedding vector of the tail entity; sort and select all candidate triples according to the scoring result, and add the first selection result as a completion result to the knowledge graph to complete the knowledge graph.
[0113] It should be noted that the technical scheme of the knowledge graph completion system based on entity relation attention belongs to the same concept as the technical scheme of the knowledge graph completion method based on entity relation attention described above. The technical details of the technical scheme of the knowledge graph completion system based on entity relation attention in the present embodiment can be found in the description of the technical scheme of the knowledge graph completion method based on entity relation attention described above.
[0114] The above-mentioned unit modules can be embedded in or independent of the processor in the electronic device in hardware form, or can be stored in the memory in the electronic device in software form, so as to call and execute the operations corresponding to the above-mentioned modules by the processor.
[0115] The present embodiment also provides an electronic device, which includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. The processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The communication interface of the electronic device is configured to communicate with external terminals in wired or wireless mode. The wireless mode can be achieved through WIFI, operator network, NFC (near field communication) or other technologies. The computer program is executed by the processor to implement the knowledge graph completion method based on entity relation attention. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen. The input device of the electronic device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the electronic device, or an external keyboard, touchpad or mouse, etc.
[0116] The present embodiment also provides a computer readable storage medium having a computer program stored thereon, which is executed by the processor to implement the method proposed in the above-mentioned embodiments.
[0117] The storage medium proposed in the present embodiment belongs to the same inventive concept as the method proposed in the above-mentioned embodiments. The technical details not described in detail in the present embodiment can be found in the above-mentioned embodiments, and the present embodiment has the same beneficial effects as the above-mentioned embodiments.
[0118] Those skilled in the art can clearly understand the present application by the description of the above embodiments, and the present application can be realized by software and necessary general hardware, and of course, can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, and the computer software product can be stored in a computer readable storage medium, such as a floppy disk, a read-only memory (ROM), a random access memory (RAM), a FLASH memory, a hard disk, or an optical disc, etc., and includes a number of instructions to make an electronic device (which can be a personal computer, a server, or a network device, etc.) execute the method of the embodiments of the present application.
[0119] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application but not limit the present application, and although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or replaced equivalently without departing from the spirit and scope of the technical solutions of the present application, and all should be covered in the scope of the claims of the present application.
Claims
1. A knowledge graph completion method based on entity relationship attention, characterized in that, include: A fixed-length embedding vector is assigned to each entity and relation in the knowledge graph based on structured knowledge representation, and the embedding vector is initialized using a first initialization method; The embedding vectors of the head entity and the relation are mapped and reshaped into matrix form, respectively; The deep relationships between the head entities and relationships are captured through an attention mechanism to generate a joint feature vector; The scoring result of the triple is obtained by calculating the joint feature vector and the embedding vector of the tail entity; All candidate triples are sorted and selected according to the scoring results, and the first selection result is added to the knowledge graph as the completion result to complete the knowledge graph.
2. The knowledge graph completion method based on entity relationship attention as described in claim 1, characterized in that, The generation of the joint feature vector includes: Calculate the attention coefficient between the head entity and the relation, and convert the attention coefficient into a probability distribution; The joint feature vector is obtained by weighted aggregation of the vectors in the value matrix based on the normalized probability distribution.
3. The knowledge graph completion method based on entity relationship attention as described in claim 2, characterized in that, The generation of the joint feature vector also includes: The weighted aggregated joint feature vector is linearly transformed through a fully connected layer to map it into a joint feature vector consistent with the entity embedding dimension, which is then used for subsequent triplet scoring.
4. The knowledge graph completion method based on entity relationship attention as described in claim 3, characterized in that, The scoring results for obtaining the triplet include: To evaluate the veracity of the facts represented by the triples, the joint feature vector and the embedding vector of the tail entity are subjected to an inner product operation to obtain the inner product result; The inner product result reflects the similarity between the joint feature vector and the tail entity vector; The inner product result is nonlinearly transformed by an activation function to obtain the scoring result of the triplet.
5. The knowledge graph completion method based on entity relationship attention as described in claim 4, characterized in that, All candidate triples are sorted from highest to lowest according to the scoring results, and the top k triples are selected as the completion results and added to the knowledge graph to complete the knowledge graph. Here, k is a preset positive integer.
6. The knowledge graph completion method based on entity relationship attention as described in claim 1, characterized in that, The initialization includes: The initial weight distribution is set by the first initialization method, so that the variance of the input and output of each layer of the network remains consistent during forward propagation.
7. The knowledge graph completion method based on entity relationship attention as described in claim 6, characterized in that, The step of mapping and reshaping the embedding vectors of the head entity and the relation into matrix form includes: The embedding vectors of head entities and relations are mapped and reshaped into matrix form using learnable matrices. Let the embedding vector of the head entity be h, and the embedding vector of the relation be r. The mapping and reshaping process is then expressed as follows: Q=reshape(rW Q ),K=reshape(hW K ),V=reshape(hW V ) Where h, r∈d represent the head entity and relation, respectively, and W Q W K W V All are learnable matrices, Q,K,V∈d M ×d M This is the mapped and shaped matrix.
8. A knowledge graph completion system based on entity relation attention, employing the knowledge graph completion method based on entity relation attention as described in any one of claims 1 to 7, characterized in that, include: An initialization module is used to assign a fixed-length embedding vector to each entity and relation in a knowledge graph based on structured knowledge representation, and to initialize the embedding vector using a first initialization method. The feature mapping and reshaping module is used to map and reshape the embedding vectors of head entities and relations into matrix form, respectively. The feature extraction module is used to capture the deep relationships between the head entities and the relationships through an attention mechanism, and generate a joint feature vector; The knowledge graph completion module is used to obtain the scoring results of triples by calculating the joint feature vector and the embedding vector of the tail entity; sort and select all candidate triples according to the scoring results; and add the first selection result as the completion result to the knowledge graph to realize the completion of the knowledge graph.
9. An electronic device comprising a memory and a processor, characterized in that: The memory is used to store computer-executable instructions, and when the processor executes the computer-executable instructions, it implements the steps of the knowledge graph completion method based on entity relation attention as described in any one of claims 1 to 7.
10. A computer-readable storage medium having computer-executable instructions stored thereon, characterized in that: When the computer-executable instructions are executed by the processor, they implement the steps of the knowledge graph completion method based on entity relation attention as described in any one of claims 1 to 7.