Knowledge graph completion method based on structure enhancement and relation semantics

By combining structural enhancement and relational semantics in knowledge graph completion, using graph neural network and two-layer attention mechanism, the problem of ignoring semantic information and local structural features in the existing technology is solved, and a more efficient knowledge graph is achieved Completion effect.

CN119474397APending Publication Date: 2025-02-18HOHAI UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411411654.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-10
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

The prior art ignores semantic information in entity description text and local structural features in neighborhoods in knowledge graph completion, resulting in insufficient feature extraction capabilities and incomplete information.

Method used

The knowledge graph completion method based on structural enhancement and relational semantics is adopted to mine structural information through graph neural networks, use a two-layer attention mechanism to combine the semantic information of entities and relationships, and improve feature expression capabilities through an adaptive feature fusion mechanism.

Benefits of technology

It improves the accuracy and efficiency of knowledge graph completion, makes full use of entity description text and structural information, and enhances the ability to capture local structural features.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119474397A_ABST
    Figure CN119474397A_ABST
Patent Text Reader

Abstract

The invention discloses a knowledge graph completion method based on structure enhancement and relation semantics. According to the method, on the basis of using triple structure information, additional text auxiliary information is introduced and fully fused, and entities and relations can be expressed more accurately. The method specifically comprises the following steps: (1) structural feature learning: aggregating neighbor features by using a graph neural network; then, from the perspective of entities and relationships, local structural features in a neighborhood are mined, and information is obtained through aggregation to obtain structural feature representation; and (2) text feature learning: adopting a double-layer attention mechanism including relation semantic level attention and neighbor semantic level attention, and aggregating neighbor entity description information to obtain text feature representation based on two learned attention values. And (3) a feature fusion stage: fusing the two learned features by using an adaptive feature fusion mechanism. And (4) a decoder: using ConvE as the decoder, and using the embedded convolutional network to obtain the score of the triple for prediction. According to the method, the structure information of the knowledge graph is fully utilized, the relation semantics in entity description are considered, and the completion precision of the knowledge graph is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a knowledge graph completion method based on structure enhancement and relational semantics, and belongs to the field of natural language processing. Background Art

[0002] With the rapid development of information technology and Internet technology, a large amount of data is produced and disseminated. How to mine the hidden value behind these massive amounts of data is a challenging task. As one of the key technologies in the field of artificial intelligence, knowledge graph can easily capture and store the structured relationships between entities, providing important support for its downstream applications such as question-answering systems, recommendation systems, and intelligent search. However, the knowledge graph is huge in scale, with a large number of entities, and there are countless complex semantic connections between entities, which makes many knowledge graphs still face the challenge of incomplete information.

[0003] Graph neural networks have been widely used in the field of knowledge graph completion due to their natural advantages in processing graph data. However, these graph neural network-based methods only utilize the triple structure information in the knowledge graph and ignore the additional information related to the triple, such as the entity description text. The text description of the entity contains rich semantics and can provide more auxiliary information for the entity, including the entity's category, background, semantic relationship, etc. This semantic information provides more detailed descriptions for sparsely structured entities and may mine potential new knowledge. Therefore, models that combine text information are an important direction for current and future research on knowledge graph representation learning.

[0004] Although models that consider both structural information and text information have made great progress, they still have the following problems: First, when using entity descriptions, these models usually treat text information as an independent instance to enhance the corresponding entity, without considering the relational semantic information related to it in the neighbor entity descriptions, and the entity description information is not fully utilized. Secondly, when using structural information, the graph neural network-based method transfers the information of neighbors by designing different aggregation functions for representation learning, ignoring some potential and crucial local structural features in the neighborhood, and the feature extraction capability is insufficient. Therefore, how to make full use of additional text auxiliary information on the basis of deeply mining the triple structure information of the knowledge graph is the key to improving the effect of knowledge graph completion. Summary of the invention

[0005] Purpose of the invention: In view of the deficiencies in the prior art, the present invention proposes a knowledge graph completion method based on structure enhancement and relational semantics, which can effectively improve the accuracy and efficiency of knowledge graph completion.

[0006] Technical solution: A knowledge graph completion method based on structure enhancement and relational semantics. The method includes the following steps:

[0007] (1) Structural feature learning, using graph neural networks to mine the structural information of knowledge graphs;

[0008] (2) Text feature learning: using a dual-layer attention mechanism, learning the most relevant semantic information for relations under relation semantic level attention and learning the best neighbor semantic representation under neighbor semantic level attention;

[0009] (3) In the feature fusion stage, the two learned features are fully integrated using an adaptive feature fusion mechanism;

[0010] (4) Decoder: ConvE is used as the decoder, and an embedded convolutional network is used to obtain the scores of the triples for prediction.

[0011] Preferably, in step (1), mining the structural information features of the knowledge graph specifically comprises the following steps:

[0012] (11) Neighbor feature aggregation: The graph attention mechanism is introduced to calculate the attention weight by combining the embedding representation of relations and entities. After weighting, the calculation results are passed to the target entity to capture the information around the target entity. The final aggregation function can be expressed as:

[0013]

[0014] in, Represents the layer l entity e i Neighborhood feature embedding representation, Represent the neighbor entities e at layer l respectively j The embedding representation and relation r ij The embedding representation of Represents entity e i Neighbor entity, (W nei ) l represents the linear transformation matrix of the lth layer, and σ is the nonlinear activation function.

[0015] (12) Local information mining: Explicitly mine local structural information in the neighborhood from the perspective of entities and relationships. For the target entity i from the perspective of relationships, take the relationship as the center and calculate the inner product of all connected relationships and entity i to obtain the relationship aggregation attention parameter The final aggregation function is as follows:

[0016]

[0017] in, Represents the layer l entity ei The relational feature embedding representation is Represents the relationship r at level l j The embedding representation of (W rel ) l Represents the linear transformation matrix of the lth layer.

[0018] For the target entity i from the entity perspective, with the target entity as the center, the inner product of all connected relationships and entity i is calculated to obtain the entity aggregation attention parameter The final aggregation function is as follows:

[0019]

[0020] (13) Structural feature representation generation: The calculated neighbor features, entity features, relationship features, and their own embedded representations are combined to obtain the final structural features, which are calculated as follows:

[0021]

[0022] in, Respectively represent the l+1th layer entity e i The structural feature embedding representation of

[0023] (14) Calculate the relationship embedding representation: The relationship embedding representation is updated using linear transformation. The process can be expressed as:

[0024]

[0025] in, represents the embedding representation of the l-th layer relation r, Represents the learnable parameter matrix of the lth layer.

[0026] Preferably, in step (2), the best relational semantic information is learned using a double-layer attention mechanism, which specifically includes the following steps:

[0027] (21) Initial semantic generation: The text description is represented as a set of n words T = (w1, w2, ..., w n ), the entire text description and all the words in it are input into BERT to obtain semantic representation Word Representation Then the dimensionality reduction is performed through a multi-layer perceptron, and the process can be expressed as:

[0028]

[0029] Among them, x i represents the initial semantic representation of entity i, w nrepresents the initial word embedding representation, W1 and W2 are linear transformation matrices.

[0030] (22) Word embedding generation: For entity description text under a specified relationship, the relationship feature representation obtained in structural feature learning is introduced under the relationship semantic level attention. The weighted cosine similarity is used to measure the semantic similarity between the specified relationship and each word. After aggregation, the word embedding representation based on relationship semantics is obtained. The process is as follows:

[0031]

[0032] Among them, m j Represents the text information of neighbor entity j, r ij Represents the relationship r in structural feature learning ij The embedding representation of represents the transpose of the initial word embedding representation vector of the neighbor entity, d represents the dimension of the relation vector embedding, and n is the number of words in the text description.

[0033] (23) Neighborhood semantic aggregation: Under the neighbor semantic level attention, calculate the attention parameters of each neighbor semantic And fuse the word embedding representations under multiple relational semantics to obtain the semantic representation of entity i’s neighbors Finally, the obtained results are combined with the initial semantic representation to obtain a more expressive semantic feature representation:

[0034]

[0035] Among them, α is a hyperparameter used to balance the contribution of neighbor semantic representation and initial semantic representation.

[0036] Preferably, in step (3), the two learned features are fully fused using an adaptive feature fusion mechanism. The specific steps are as follows:

[0037] (31) Add the two learned features to obtain the initial fusion feature

[0038]

[0039] (32) Using point-by-point convolution and global average pooling, features are extracted from the overall and local perspectives respectively, and the attention representation for the global features is calculated. and attention representation for local features Then the Sigmoid function is used for weighting to obtain the feature fusion attention weight parameter The process is as follows:

[0040]

[0041] (33) Based on the obtained feature fusion attention parameters, the final entity embedding vector h e It can be expressed as:

[0042]

[0043] Preferably, in step (4), ConvE is used as a decoder and an embedded convolutional network is used to obtain the scores of the triples for prediction:

[0044]

[0045] Among them, f is the activation function ReLU, vec represents the operation of expanding the tensor into a vector through the weight matrix W, * represents the convolution operation, and ω is the convolution kernel.

[0046] The beneficial effects of the present invention are:

[0047] First, based on the use of the attention mechanism to aggregate neighbor information, the method of the present invention also deeply explores the potential structural information in the neighborhood from the perspective of entities and relationships, thereby improving the expressive power of structural features. Secondly, the present invention further enhances the text feature learning ability by introducing a dual attention mechanism to combine the semantics of the entity itself with the semantic information of the neighbors. Finally, the present invention more flexibly handles different situations where the graph structure or entity description provides more information by adopting an adaptive feature fusion mechanism, thereby improving the completion accuracy of the knowledge graph. In summary, the present invention is an effective and efficient knowledge graph completion method with strong practical value and application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 A schematic diagram of a method flow of an embodiment of the present invention;

[0049] Figure 2 A schematic diagram of neighbor feature aggregation according to an embodiment of the present invention;

[0050] Figure 3 Schematic diagram of the encoding process based on the pre-trained language model according to an embodiment of the present invention;

[0051] Figure 4 This is a diagram illustrating the dual attention mechanism of an embodiment of the present invention;

[0052] Figure 5 Schematic diagram of adaptive feature fusion according to an embodiment of the present invention. DETAILED DESCRIPTION

[0053] The present invention provides a knowledge graph completion method based on structure enhancement and relational semantics. The method is applicable to text and image data of social networks. The main flow chart of the method is as follows: Figure 1 The specific steps are as follows:

[0054] Step (1) mining the structural information features of the knowledge graph specifically includes the following steps:

[0055] Step (11) Neighborhood feature aggregation: Figure 2 As shown, given a target entity i, through the combination operator Combine all connected relations and neighbor entities to obtain the neighborhood information of the corresponding connections, calculate the inner product of the neighborhood information and the embedding representation of the target entity i to capture their interaction information, and use Softmax to obtain the aggregate attention parameter:

[0056]

[0057] in, is the aggregate attention parameter, Represents entity e i Neighbor entities, is a neighbor triplet (e i , r ij , e j )’s interactive information, e i is the neighbor entity e i The embedding representation of j is the neighbor entity e j The embedding representation of r ij It is a relationship ij Then, the neighbor feature embedding representation is obtained by weighted summing of each connected neighborhood information and the corresponding aggregation attention parameter. The final aggregation function can be expressed as:

[0058]

[0059] in, Represents the layer l entity e i Neighborhood feature embedding representation, Represent the neighbor entities e at layer l respectively j The embedding representation and relation r ij The embedding representation of Represents entity e i Neighbor entity, (W nei ) l represents the linear transformation matrix of the lth layer, and σ is the nonlinear activation function.

[0060] Step (12) Local information mining: Given a target entity i, we take the relationship as the center, calculate the inner product of all connected relationships and the target entity i, and use the attention mechanism to obtain the relationship aggregation attention parameter:

[0061]

[0062] in, is the relation aggregation attention parameter, r j It is a relationship j The embedding representation of Represents entity e i Next, we apply the relation aggregation attention parameter to all relations connected to entity i and aggregate them to obtain the relation feature embedding representation. The final aggregation function can be expressed as:

[0063]

[0064] in, Represents the layer l entity e i The relational feature embedding representation is Represents the relationship r at level l j The embedding representation of (W rel ) l Represents the linear transformation matrix of the lth layer.

[0065] For the target entity i from the entity perspective, with the target entity as the center, the inner product of all connected relationships and entity i is calculated to obtain the entity aggregation attention parameter:

[0066]

[0067] in, is the entity aggregation attention parameter, e j is the embedding representation of neighbor entity j, Represents entity e i Next, we apply the entity aggregation attention parameter to all neighbors connected to entity i and aggregate them to obtain the entity feature embedding representation. The final aggregation function can be expressed as:

[0068]

[0069] Step (13) Structural feature representation generation: The calculated neighbor features, entity features, relationship features and their own embedded representations are merged to obtain the final structural features, which are calculated as follows:

[0070]

[0071] in, Respectively represent the l+1th layer entity e i The structural feature embedding representation of

[0072] Step (14) Calculate the relationship embedding representation: For the relationship embedding representation, use linear transformation to update it. The process can be expressed as:

[0073]

[0074] in, represents the embedding representation of the l-th layer relation r, Represents the learnable parameter matrix of the lth layer.

[0075] Step (2) uses a two-layer attention mechanism to learn the best relational semantic information. The specific process is as follows: Figure 4 shown.

[0076] Step (21) Initial semantic generation: The text description is represented as a set T containing n words = (w1, w2, ..., w n ).like Figure 3 As shown, the entire text description and all the words in it are input into BERT to obtain semantic representation Word Representation Then the dimensionality reduction is performed through a multi-layer perceptron, and the process can be expressed as:

[0077]

[0078] Among them, x i represents the initial semantic representation of entity i, w n represents the initial word embedding representation, W1 and W2 are linear transformation matrices.

[0079] Step (22) word embedding generation: For the entity description text under the specified relationship, under the relationship semantic level attention, the relationship feature representation obtained in the structural feature learning is introduced, and the weighted cosine similarity is used to measure the semantic similarity between the specified relationship and each word. After aggregation, the word embedding representation based on the relationship semantics is obtained. The process is as follows:

[0080]

[0081] Among them, m j Represents the text information of neighbor entity j, r ij Represents the relationship r in structural feature learning ij The embedding representation of represents the transpose of the initial word embedding representation vector of the neighbor entity, d represents the dimension of the relation vector embedding, and n is the number of words in the text description.

[0082] Step (23) Neighbor semantic aggregation: Calculate the text information under the specified relationship of each neighbor entity, aggregate it through the attention mechanism as the final neighbor semantic representation, and the process is as follows:

[0083]

[0084] in, represents the semantic representation of the neighbor of entity i, represents the neighbor semantic attention parameter, W3 represents the linear transformation matrix, Represents the neighbor set of entity i.

[0085] In order to avoid excessive aggregation of neighbor semantic information and thus lose its original features, it is combined with the initial semantic representation to generate the text feature representation output by text feature learning, which is calculated as follows:

[0086]

[0087] Among them, α is a hyperparameter used to balance the contribution of neighbor semantic representation and initial semantic representation.

[0088] Step (3) uses the adaptive feature fusion mechanism to fully fuse the two learned features. The fusion process is as follows: Figure 5 shown.

[0089] Step (31) adds the two learned features to obtain the initial fusion feature

[0090]

[0091] Step (32) uses point-by-point convolution and global average pooling to extract features from the overall and local perspectives, respectively, and calculates the attention representation for the global features and attention representation for local features The process is as follows:

[0092]

[0093] Among them, BN represents BatchNorm layer, PConv represents point-by-point convolution layer, σ represents nonlinear activation function, and G represents global average pooling layer. The two attention representations obtained are weighted by Sigmoid function to obtain the feature fusion attention weight parameter The process is as follows:

[0094]

[0095] Step (33) is based on the obtained feature fusion attention parameters, and the final entity embedding vector h e It can be expressed as:

[0096]

[0097] Step (4) uses ConvE as the decoder, uses the embedded convolutional network to obtain the score of the triplet for prediction, and uses the binary cross entropy loss function for optimization:

[0098]

[0099] Among them, f is the activation function ReLU, vec represents the operation of expanding the tensor into a vector through the weight matrix W, * represents the convolution operation, and ω is the convolution kernel.

[0100]

[0101] Where N represents the total number of candidate entities, y(t i )∈{0,1} is a referential function, outputting 1 to represent (h, r, t i )∈S is a positive triple, and output 0 means (h, r, t i )∈S′ is a negative triple.

[0102] The experimental verification is as follows:

[0103] The dataset used in this embodiment is the FB15K-237 dataset. The FB15K dataset is a knowledge graph extracted and constructed from the large human knowledge base Freebase. It consists of multi-source structured data and covers more than 39 million topics. In order to eliminate the problem of data leakage during testing, a more complete dataset FB15K-237 is constructed by removing the reverse relationship. In addition to the triple information, it also includes a specific text description of each entity. The description of the entity is obtained from the introduction part of the Wikipedia page of each entity.

[0104] In order to verify the effectiveness of the model, the present invention uses the following two indicators for evaluation: Hits@K and Mean Reciprocal Rank (MMR). Hits@K refers to the proportion of the correct answers of the test triples in the top K positions. The larger the value of this indicator, the higher the predicted correct entity ranking and the better the performance of the model. MMR is the mean reciprocal ranking, which represents the average value of the reciprocal ranking of the tested triples. This indicator takes into account the position of the highest-ranked correct result returned by the model. The closer it is to 1, the better the model performs in average ranking and the more accurate the completion result. The details are as follows:

[0105]

[0106] Among them, Q represents the total number of triplets in the test set, q represents the position of the correct tail entity (or head entity) in the results sorted by probability, and the value of K is generally 1, 3 or 10.

[0107] This example is implemented based on the Pytorch framework and trained on a single GPU. During training, the BatchSize is set to 256, label smoothing is set to 0.1, the embedding dimensions of entities and relations are uniformly set to 200, and the embedding size of the decoder is set to 200 to be consistent with the output layer. The learning rate selection range is {0.01, 0.001, 0.0005}, and 0.001 is finally selected. The dropout is set to 0.3 in structural feature learning and 0.5 in text feature learning. The models are trained using an early stopping strategy based on the convergence behavior of the validation set. The following are the experimental results verified on the dataset FB15K-237.

[0108] Table 1 Comparison of results on the FB15k-237 dataset

[0109]

[0110] As can be seen from the chart data, the method proposed in this paper considers using graph neural networks to fuse information around the target entity and enhances it through entity description text, which essentially improves the performance of knowledge graph completion. CompGCN and SE-GNN only consider the triple structure information of the knowledge graph itself, ignoring the rich semantic information in the entity description text; EDA-KGC and GenKGC only use entity description information as additional information to enhance entity representation, without considering the semantic emphasis of entity description text under different relationships. In addition, when these models use structural information, they only aggregate neighbor entities by designing different message functions, without deeply mining the local structural information that is crucial in the neighborhood. In addition, this example uses an adaptive mechanism to fuse features, thereby improving the completion effect of the knowledge graph. Compared with several other methods, the MRR and Hits@K indicators have been greatly improved, proving the effectiveness of this example.

[0111] The above content is a further detailed description of the present invention in combination with specific / preferred implementation methods. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

[0112] Parts of the present invention that are not described in detail belong to the well-known technologies of those skilled in the art.

Claims

1. A knowledge graph completion method based on structure enhancement and relational semantics, comprising the following steps: (1) Structural feature learning, using graph neural networks to mine the structural information of knowledge graphs; (2) Text feature learning: using a dual-layer attention mechanism, learning the most relevant semantic information for relations under relation semantic level attention and learning the best neighbor semantic representation under neighbor semantic level attention; (3) In the feature fusion stage, the two learned features are fully integrated using an adaptive feature fusion mechanism; ConvE is used as the decoder and an embedded convolutional network is used to obtain the scores of the triples for prediction.

2. A knowledge graph completion method based on structure enhancement and relational semantics as claimed in claim 1, characterized in that In step (1), mining the structural information features of the knowledge graph specifically includes the following steps: (11) Neighbor feature aggregation: The graph attention mechanism is introduced to calculate the attention weight by combining the embedding representation of relations and entities. After weighting, the calculation result is passed to the target entity to capture the information around the target entity and obtain the neighbor feature embedding representation (12) Local information mining: Explicitly mine local structural information in the neighborhood from the perspective of entities and relationships. For the target entity i from the perspective of relationships, take the relationship as the center and calculate the inner product of all connected relationships and entity i to obtain the relationship aggregation attention parameter Based on the aggregate attention parameter, all relations connected to entity i are aggregated to obtain the relation feature embedding representation. For the target entity i from the entity perspective, with the target entity as the center, the inner product of all connected relationships and entity i is calculated to obtain the entity aggregation attention parameter Based on the aggregate attention parameter, all relations connected to entity i are aggregated to obtain the relation feature embedding representation. (13) Structural feature representation generation: The calculated neighbor features, entity features, relationship features, and their own embedded representations are combined to obtain the final structural features, which are calculated as follows: in, Respectively represent the l+1th layer entity e i The structural feature embedding representation of (14) Calculate the relationship embedding representation: The relationship embedding representation is updated using linear transformation. The process can be expressed as: in, represents the embedding representation of the l-th layer relation r, Represents the learnable parameter matrix of the lth layer.

3. A knowledge graph completion method based on structure enhancement and relational semantics as claimed in claim 1, characterized in that In step (2), the dual-layer attention mechanism is used to learn the best relational semantic information, which specifically includes the following steps: (21) Initial semantic generation: The text description is represented as a set of n words T = (w1, w2, ..., w n ), the entire text description and all the words in it are input into BERT to obtain semantic representation Word Representation Then, the multi-layer perceptron is used to perform dimensionality reduction to obtain the initial semantic representation x of entity i. i and the initial word embedding representation w n . (22) Word embedding generation: For entity description text under a specified relationship, under the relational semantic level attention, the relational feature representation obtained in structural feature learning is introduced, and the weighted cosine similarity is applied to measure the semantic similarity between the specified relationship and each word. After aggregation, the word embedding representation m based on relational semantics is obtained. j . (23) Neighborhood semantic aggregation: Under the neighbor semantic level attention, calculate the attention parameters of each neighbor semantic And fuse the word embedding representations under multiple relational semantics to obtain the semantic representation of entity i’s neighbors Finally, the obtained results are combined with the initial semantic representation to obtain a more expressive semantic feature representation: Among them, α is a hyperparameter used to balance the contribution of neighbor semantic representation and initial semantic representation.

4. A knowledge graph completion method based on structure enhancement and relational semantics as claimed in claim 1, characterized in that In step (3), the two learned features are fully fused using an adaptive feature fusion mechanism. The specific steps are as follows: (31) Add the two learned features to obtain the initial fusion feature (32) Using point-by-point convolution and global average pooling, features are extracted from the overall and local perspectives respectively, and the attention representation for the global features is calculated. and attention representation for local features Then the Sigmoid function is used for weighting to obtain the feature fusion attention weight parameter The process is as follows: (33) Based on the obtained feature fusion attention parameters, the final entity embedding vector h e It can be expressed as: (34) Using ConvE as the decoder, we use an embedded convolutional network to obtain the scores of the triples for prediction: Among them, f is the activation function ReLU, vec represents the operation of expanding the tensor into a vector through the weight matrix W, * represents the convolution operation, and ω is the convolution kernel.

Citation Information

Cited By

  • Knowledge graph completion method based on potential neighbor perception

    CN120806099A