A Knowledge Graph Adaptive Completion Method and Device Based on 3D Convolution
Through the 3D convolution-based method, sufficient interaction between entities and relationships is generated to generate more accurate knowledge vectors, which solves the problem of insufficient interaction and feature extraction in the existing technology, and improves the completion effect of the knowledge graph.
Patent Information
- Application Number
- CN202211247682.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-12
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2042-10-12
AI Technical Summary
The existing neural network-based knowledge graph completion method fails to make full use of the interaction and feature extraction of entities and relationships, resulting in poor complementation of knowledge graphs.
Using a 3D convolution method, the head entity vector is split into block vectors and reshapes into 3D convolution filters, convolution operations are performed with the relational vectors, convolutional feature maps are generated, and knowledge vectors are generated to complete through the internal product of the fully connected layer and the tail entity vector.
It improves the interaction between entities and relationships in the knowledge graph, improves the accuracy of the representation of knowledge vectors, and can better discover hidden entities and relationships.
Smart Images

Figure CN115630163B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of knowledge graphs, and particularly to a knowledge graph adaptive completion method and device based on 3D convolution. Background Art
[0002] A knowledge graph, also known as a knowledge base, is a special network structure where nodes represent entities and edges represent relationships. It was initially used by Google to optimize the results returned by search engines to improve search quality and user experience. A knowledge graph can effectively represent data resources, efficiently find complex associated information, and has outstanding semantic processing capabilities. Therefore, it has received extensive attention and research since its inception. As the scale of the knowledge graph continues to expand, it is troubled by the data sparsity problem, and the knowledge completeness far from meets the requirements. Therefore, the task of knowledge graph completion is extremely urgent. The purpose of knowledge graph completion is to find facts that are not discovered but actually exist, add new triples to the knowledge graph, make up for the missing entity and relationship information, and sequentially expand and improve the knowledge graph. Knowledge representation learning is an efficient means to achieve knowledge graph completion, and the performance of knowledge representation learning models often affects the effect of knowledge graph completion.
[0003] The neural network-based model is a typical knowledge representation method. This type of model performs in-depth modeling operations on entities and relationships, and this model has a relatively high accuracy in the knowledge graph completion task. However, most of the existing neural network-based models only use one-dimensional or two-dimensional convolution to operate on entities and relationships, and fail to fully maximize the interaction between entity-relationships, and can only capture a small amount of features. Summary of the Invention
[0004] Embodiments of this application provide a knowledge graph adaptive completion method and device based on 3D convolution to solve the problem that the interaction and feature extraction between entities and relationships in the existing methods are not sufficient.
[0005] Embodiments of this application provide a knowledge graph adaptive completion method based on 3D convolution, including:
[0006] Extracting triple information based on the knowledge base data to form a triple set including head entities, relationships, and tail entities;
[0007] Constructing head entity vectors, relationship vectors, and tail entity vectors based on the triple set, where the head entity vectors and tail entity vectors belong to the same vector space;
[0008] Reshaping the relationship vector into a 3D matrix; and
[0009] Split the head entity vector into several block vectors, reshape any of the split block vectors into a filter for 3D convolution, and the size of the filter, the number of filters have a corresponding relationship with the dimension of the head entity vector;
[0010] Use the 3D matrix as the input of the convolutional layer, and perform convolution on the input using Conv3D-E based on the constructed filter to generate a corresponding convolutional feature map based on any of the filters;
[0011] Flatten and stack each convolutional feature map into a target vector;
[0012] Use a fully connected layer to project the target vector into the vector space of the relation vector, and perform an inner product with the tail entity vector to obtain a knowledge vector;
[0013] Use the knowledge vector to complete the knowledge graph.
[0014] Optionally, the size of the filter, the number of filters have the following corresponding relationship with the dimension of the head entity vector:
[0015] d e = chwl
[0016] where d e represents the dimension of the head entity vector, c is the number of filters, and h, w, l respectively represent the height, width, and length of each filter.
[0017] Optionally, generating a corresponding convolutional feature map based on any of the filters includes:
[0018] Use any of the filters to generate a corresponding feature map, and the feature map generated by any of the filters belongs to the vector space where respectively represent the dimensions of the length, width, and height of the 3D matrix;
[0019] Perform a non-linear function ReLU operation on the generated feature map to generate a convolutional feature map.
[0020] Optionally, using a fully connected layer to project the target vector into the vector space of the relation vector and performing an inner product with the tail entity vector satisfies:
[0021] ψ(h, r, t) = f(W c + b) T t
[0022] where ψ(h, r, t) represents the triple scoring function, W represents the input of the 3D convolution, c represents the convolutional filter serial number, T represents the transpose, b represents the fully connected layer parameter, represents the vector space of the relation vector, d rd represents the dimension of the relation vector, f() represents a non-linear function, and t represents the tail entity vector.
[0023] Optionally, before obtaining the knowledge vector, the following training process is further included:
[0024] For any head entity and relation (h, r), score all candidate tail entities t simultaneously to obtain a corresponding score vector, where each dimension of the score vector corresponds to an entity and satisfies:
[0025]
[0026] where represents the score vector, and σ() represents the sigmoid function;
[0027] For each (h, r), minimize the cross-entropy loss function:
[0028]
[0029] where ε represents the set of entity vectors, represents the binary classification label, and when (h, r, t) is a true triple, the value is 1, otherwise the value is 0;
[0030] Perform iterations until the number of iterations reaches the specified number.
[0031] Optionally, using the knowledge vector to complete the knowledge graph includes:
[0032] Given an entity and a relation of a triple to be predicted, determine whether the given entity and relation exist in the training process. If so, represent the given entity and relation as vectors, and perform the following steps to complete entity prediction:
[0033] Traverse the entity set, which is a set including the head entity and the tail entity. Replace the vector of any entity in the entity set with the entity missing in the triple, and score the formed triple;
[0034] Determine the correctly predicted tail entity according to the scoring result;
[0035] Use the correctly predicted tail entity to complete the knowledge graph.
[0036] An embodiment of the present application further provides a computer device, including a processor and a memory. A computer program is stored on the memory, and when the computer program is executed by the processor, the steps of the knowledge graph adaptive completion method based on 3D convolution as described above are implemented.
[0037] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the aforementioned knowledge graph adaptive completion method based on 3D convolution are implemented.
[0038] In the embodiment of the present application, the relationship and the head entity vector are reshaped into a 3D cube, and then the head entity is used as the filter of the convolutional network; then the relationship is used as the input of the 3D convolutional network to interact with the head entity filter to obtain a feature map, and finally a knowledge vector representation is obtained. The learned vector representation is used for knowledge graph completion. The method of the present application can enable full interaction between entities and relationships, thereby greatly improving the accuracy of the representation of the knowledge vector representation.
[0039] The above description is only an overview of the technical solution of the present application. In order to be able to understand the technical means of the present application more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present application more obvious and understandable, the following specific embodiments of the present application are specifically cited. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] By reading the following detailed description of the preferred embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present application. And throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:
[0041] Figure 1 is a basic process example of the knowledge graph adaptive completion method according to the embodiment of the present application;
[0042] Figure 2 is an example of the entity and relationship interaction modeling effect according to the embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0043] Hereinafter, exemplary embodiments of the present disclosure will be described in more detail with reference to the drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be fully conveyed to those skilled in the art.
[0044] The embodiment of the present application provides a knowledge graph adaptive completion method based on 3D convolution, as Figure 1 shown, including the following steps:
[0045] In step S101, triple information is extracted based on the knowledge base data to form a triple set including a head entity, a relation, and a tail entity. In a specific example, the knowledge base data can be preprocessed to extract the triple information and form a triple set S = {(h, r, t)}, where (h, r, t) represents a triple, h represents the head entity, r represents the relation, and t represents the tail entity.
[0046] In step S102, a head entity vector, a relation vector, and a tail entity vector are constructed based on the triple set, where the head entity vector and the tail entity vector belong to the same vector space. The head entity h and the tail entity t can be embedded as vectors in the vector space, and the relation r is embedded in the vector space, where d e , d r respectively represent the dimensions of the entity and relation embedding vectors.
[0047] In step S103, the relation vector is reshaped into a 3D matrix; and
[0048] the head entity vector is split into several block vectors, and any one of the split block vectors is reshaped into a filter for 3D convolution, and the size and the number of the filters are in a corresponding relationship with the dimension of the head entity vector. The relation entity vector r is reshaped into a 3D matrix and used as the input of the convolutional layer. The head entity vector h is further split into block vectors h (1) , …, h (c) . The size of the block vectors can be equal, and then each is reshaped into a filter for 3D convolution In some embodiments, the size and the number of the filters are in the following corresponding relationship with the dimension of the head entity vector:
[0049] d e = chwl
[0050] where d e represents the dimension of the head entity vector, c is the number of filters, and h, w, and l respectively represent the height, width, and length of each filter.
[0051] In step S104, the 3D matrix is used as the input of the convolutional layer, and Conv3D-E is used to perform convolution on the input based on the constructed filters to generate corresponding convolution feature maps based on any one of the filters. After the head entity vector and the relation vector are reshaped, Conv3D-E uses the adaptively constructed head entity-specific filters to perform convolution on the input.
[0052] In step S105, each convolution feature map is flattened and stacked into a target vector.
[0053] In step S106, the target vector is projected into the vector space of the relation vector by using a fully connected layer, and an inner product is taken with the tail entity vector to obtain a knowledge vector. The convolutional feature map is flattened and stacked into a vector c. Then, this vector is projected through a fully connected layer and an inner product is taken with the tail entity vector, so that the triple score ψ(s, r, o) can be calculated.
[0054] In step S107, the knowledge graph is completed by using the knowledge vector.
[0055] In the embodiment of the present application, the relation and the head entity vector are reshaped into a 3D cube, and then the head entity is used as the filter of the convolutional network; then the relation is used as the input of the 3D convolutional network to interact with the head entity filter to obtain a feature map, and finally a knowledge vector representation is obtained. The learned vector representation is used to complete the knowledge graph. The method of the present application can enable full interaction between entities and relations, thereby greatly improving the accuracy of the knowledge vector representation.
[0056] In some embodiments, generating a corresponding convolutional feature map based on any one of the filters includes:
[0057] Generating a corresponding feature map by using any one of the filters, and the feature map generated by any one of the filters belongs to the vector space where respectively represent the dimensions of the length, width, and height of the 3D matrix;
[0058] Performing a ReLU operation of a non-linear function on the generated feature map to generate a convolutional feature map.
[0059] Specifically, in this example, each filter S (ι) is used to generate a feature map and then a ReLU of a non-linear function is performed. Figure 2 In (a) shows generating a feature map by convolving the input through an entity-specific filter, Figure 2 In (b) shows calculating each entry of the feature map by using the original entity and relation vectors. The adaptive convolution in this embodiment is very effective in entity-relation interaction modeling. It can perform rich interactions between the input entity and relation representations in different regions, and all the generated convolutional features will be able to capture such interactions.
[0060] In some embodiments, projecting the target vector into the vector space of the relation vector by using a fully connected layer and taking an inner product with the tail entity vector satisfy:
[0061] ψ(h, r, t) = f(W c + b) T t
[0062] Among them, ψ(h, r, t) represents the triple scoring function, W represents the input of the 3D convolution, c represents the serial number of the convolution filter, T represents the transpose, b represents the parameters of the fully connected layer, represents the vector space of the relationship vector, d r represents the dimension of the relationship vector, f() represents the non-linear function, and t represents the tail entity vector.
[0063] In some embodiments, before obtaining the knowledge vector, the method of this embodiment further includes a training process. In order to learn the model parameters, the traditional one-to-one scoring uses the triple (h, r, t) as the input and directly scores. Different from the traditional one-to-one scoring method, in this embodiment, one-to-many scoring is used to accelerate training and verification. (h, r) is used as the input and all candidate tail entities t are scored simultaneously to obtain a score vector Each dimension of the score vector corresponds to an entity t ∈ ε. For any head entity and relationship (h, r), all candidate tail entities t are scored simultaneously to obtain the corresponding score vector. Each dimension of the score vector corresponds to an entity and satisfies:
[0064]
[0065] Among them, represents the score vector, σ() represents the sigmoid function, and ψ(h, r, t) is the scoring function defined above, is the sigmoid function.
[0066] It further includes the following training process: For each (h, r), minimize the cross-entropy loss function:
[0067]
[0068] Among them, ε represents the entity vector set, represents the binary classification label. When (h, r, t) is a true triple, the value is 1, otherwise the value is 0;
[0069] Execute iterations until the number of iterations reaches the specified number. In the specific implementation process, Dropout can be used to prevent overfitting, and Dropout is used on the reshaped relationship representation, convolution feature map, and fully connected layer. At the same time, batch normalization can also be used to stabilize and accelerate the convergence of the model. In terms of the optimizer, the Adam optimizer and label smoothing in the ConvE model can be adopted. Repeat step S102 - step S106 until the number of iterations reaches the specified number to obtain the final knowledge vector representation.
[0070] In some embodiments, using the knowledge vector to complete the knowledge graph includes:
[0071] Given an entity and a relationship of a triple to be predicted, determine whether the given entity and relationship exist in the training process. If so, represent the given entity and relationship as vectors, and perform the following steps to complete entity prediction. Specifically, entities and relationships can be read from a file. Taking the prediction of the tail entity of a triple as an example (the process of predicting the head entity is similar and will not be elaborated here), the first two parts (h, r, t) of the triple are input, where t represents the tail entity to be predicted. First, determine whether the head entity h and the relationship r exist in the training process. If h ∈ E and r ∈ R, then perform vector representation on the head entity and the relationship, and perform tail entity prediction. Otherwise, end the prediction and give a prompt that the entity and relationship to be predicted have not been trained and cannot be predicted.
[0072] Traverse the entity set E, where the entity set is a set including the head entity and the tail entity, and replace the vector of any entity e i ∈ E (i = 1, 2, …, n) with the vector of the entity in the triple, and score the formed triple. The score of (h, r, e i ) can be calculated using a scoring function.
[0073] Determine the correctly predicted tail entity according to the scoring results, and use the correctly predicted tail entity to complete the knowledge graph. Arrange all the calculated scores in descending order, and the correctly predicted entity is saved at the end. The entity ranked last is the tail entity prediction result, representing the tail entity t corresponding to the head entity h and the relationship r, thereby completing the knowledge graph completion.
[0074] The applicant also verified the knowledge graph adaptive completion method of the present application, including the following steps:
[0075] Select the knowledge graph NELLL-995 in the real world, which is an online structured data set. It comes from the NELL data set, with a total of 75,492 entities, 200 entities, and 154,213 triples. In the experiment, it is divided into a training data set, a test data set, and a validation data set. Table 1 lists the detailed statistical data of NELL-995.
[0076] Table 1 Statistical results of the NELL-995 data set
[0077]
[0078] This embodiment performs knowledge graph completion from link prediction, analyzes the experimental results, and detects the usability of the model. Link prediction is a subtask of knowledge graph completion, which aims to predict the missing s or o for a given triple (s, r, o) by minimizing a scoring function and ranks a series of candidate entities. This application embodiment uses the following metrics to quantitatively represent the results of link prediction: MRR, Hits@1, Hits@3, Hits@10. MRR: The average of the reciprocal ranks of the entities of all correct triples. The larger the value of this metric, the better the performance of the model. Hits@n: It represents the hit rate among the top n, that is, the proportion of the entities of all correct triples ranked in the top n%. The larger the value of this metric, the stronger the ability of the model's representation learning and the more accurate the representation.
[0079] This application introduces a variety of knowledge representation learning models for comparison on the dataset NELL-995, such as R-GCN, ConvKB, ConvE, ConvR, DisMult, ComplEx, TransE. Table 2 lists the link prediction results of various models, and the bold ones represent the best performance results.
[0080] Table 2 Link Prediction Results on the NELL-995 Dataset
[0081]
[0082] The results in Table 2 show that: (1) On the dataset NELL-995, the model Conv3D-E proposed in this application has achieved good results in all metrics. Compared with the model ConvR, Conv3D-E has improved by 26%, 33%, 26%, and 18% respectively in the four metrics of MRR, Hits@1, Hits@3, and Hits@10, and the effect is much better than the baseline model. (2) Compared with other listed models, Conv3D-E has also achieved excellent results in the four metrics of MRR, Hits@1, Hits@3, and Hits@10.
[0083] The method of this application reshapes the head entity and relationship vectors into 3D cubes, and uses the head entity cube as the filter of the convolutional network to interact with the relationship cube, enabling deeper features to be extracted and more sufficient interaction between entity relationships, thereby making the knowledge representation more accurate. The entities predicted by the method of this application are not limited to the entities that have been recorded and stored, but can also discover hidden new entities.
[0084] This application embodiment also provides a computer device, including a processor and a memory. A computer program is stored on the memory, and when the computer program is executed by the processor, it implements the steps of the knowledge graph adaptive completion method based on 3D convolution as described above.
[0085] The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the aforementioned knowledge graph adaptive completion method based on 3D convolution are implemented.
[0086] It should be noted that in this article, the terms "including", "comprising" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including that element.
[0087] The serial numbers of the embodiments of the present application above are only for description and do not represent the superiority or inferiority of the embodiments.
[0088] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions for causing a terminal (which can be a mobile phone, computer, server or network device, etc.) to execute the methods described in the various embodiments of the present application.
[0089] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims. These all fall within the protection scope of the present application.
Claims
1. An adaptive knowledge graph completion method based on 3D convolution, characterized in that Including: Extracting triple information based on the knowledge base data to form a triple set including a head entity, a relation, and a tail entity; Constructing a head entity vector, a relation vector, and a tail entity vector based on the triple set, wherein the head entity vector and the tail entity vector belong to the same vector space; Reshaping the relation vector into a 3D matrix; and Splitting the head entity vector into several block vectors, reshaping any one of the split block vectors into a filter for 3D convolution, and the size of the filter and the number of the filters are in a corresponding relationship with the dimension of the head entity vector; Taking the 3D matrix as the input of the convolutional layer, and performing convolution on the input based on the constructed filter by using Conv3D-E to generate a corresponding convolutional feature map based on any one of the filters; Flattening and stacking each convolutional feature map into a target vector; Using a fully connected layer to project the target vector into the vector space of the relation vector and performing an inner product with the tail entity vector to obtain a knowledge vector; Completing the knowledge graph by using the knowledge vector.
2. The method for adaptive completion of a knowledge graph based on 3D convolution according to claim 1, characterized in that The size of the filter and the number of the filters are in the following corresponding relationship with the dimension of the head entity vector: Among them, represents the dimension of the head entity vector, and c is the number of filters. respectively represent the height, width, and length of each filter.
3. The knowledge graph adaptive completion method based on 3D convolution according to claim 2, wherein Generating a corresponding convolutional feature map based on any one of the filters includes: Generate a corresponding feature map using any one of the filters, and the feature map generated by any one of the filters belongs to a vector space , where , , respectively represent the dimensions of the length, width, and height of the 3D matrix; Performing a non-linear function ReLU operation on the generated feature map to generate a convolutional feature map.
4. The knowledge graph adaptive completion method based on 3D convolution according to claim 1, characterized in that Using a fully connected layer to project the target vector into the vector space of the relation vector and the inner product with the tail entity vector satisfies: Among them, represents the triple scoring function, W represents the input of the 3D convolution, c represents the convolution filter number, represents transpose, represents the parameters of the fully connected layer, , represents the vector space of the relation vector, represents the dimension of the relation vector, represents the non - linear function, represents the tail entity vector.
5. The method for adaptive completion of a knowledge graph based on 3D convolution according to claim 4, wherein Before obtaining the knowledge vector, the following training process is further included: For any head entity and relation , score all candidate tail entities t simultaneously to obtain a corresponding score vector, where each dimension of the score vector corresponds to an entity, satisfying: Among them, represents the score vector, () represents the sigmoid function; For each , minimize the cross-entropy loss function: Among them, represents a set of entity vectors, represents a binary classification label. When is a true triple, the value is 1, otherwise the value is 0; Performing iteration until the number of iterations reaches a specified number.
6. The method for adaptively completing a knowledge graph based on 3D convolution according to claim 5, wherein Completing the knowledge graph by using the knowledge vector includes: Given an entity and a relation of a triple to be predicted, determining whether the given entity and relation exist in the training process. If so, representing the given entity and relation as vectors, and performing the following steps to complete entity prediction: Traversing the entity set, the entity set being a set including a head entity and a tail entity, replacing the vector of any entity in the entity set with the entity missing in the triple, and scoring the formed triple; Determining the correctly predicted tail entity according to the scoring result; Completing the knowledge graph by using the correctly predicted tail entity.
7. A computer device, characterized in that, Including a processor and a memory, wherein a computer program is stored on the memory, and when the computer program is executed by the processor, the steps of the method for adaptively completing a knowledge graph based on 3D convolution according to any one of claims 1 to 6 are implemented.
8. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by the processor, the steps of the method for adaptively completing a knowledge graph based on 3D convolution according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Movie recommendation method fusing attention mechanism of knowledge graph
CN112765486A
Prediction method of graph convolution knowledge representation learning model CompSAGCN based on combined self-attention
CN112836065A