Knowledge graph link prediction method fusing multi-source information
By combining structural information modeling and text and path information joint modeling, the information sparsity and spatial limitations in knowledge graph link prediction are solved, the prediction performance and feature quality are improved, and the model training cost is reduced.
Patent Information
- Application Number
- CN202411191960.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-08-28
AI Technical Summary
The existing knowledge graph link prediction methods lack effective information when training sparse graphs, and there are low-related entities problems when training dense graphs. Graph neural network methods cannot capture long-distance structures, and pre-trained language models ignore spatial limitations and entity ambiguity.
Design a knowledge graph link prediction method that integrates multi-source information, combines structural information modeling and text and path information joint modeling models, and uses efficient message delivery and semantic filtering to encode using soft and hard prompts, and conducts integrated model training. Improve link prediction performance.
The performance of knowledge graph link prediction is improved, the training sparsity of graph neural network methods and the spatial limitations of pre-trained language models are avoided, the feature quality of entities and relationships is enhanced, and the model training cost is reduced.
Smart Images

Figure CN119204195A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of knowledge graph technology, and in particular to a knowledge graph link prediction method that combines structural information, text and path information. Background Art
[0002] Knowledge graph is a data set stored in the form of (head entity, relationship, tail entity) triples, which has been widely used in intelligent fields such as intelligent question answering, recommendation systems and vertical field retrieval. Most of the existing knowledge graphs are constructed manually or semi-automatically, and there is a common problem of incomplete information, which greatly restricts the effectiveness of knowledge graphs in downstream applications. Based on the existing triple set, the knowledge graph link prediction method fully explores the potential relationship between entities, predicts new facts or identifies erroneous knowledge, thereby further enriching and improving the existing knowledge graph.
[0003] Knowledge graph link prediction is a task based on sorting triple scores. The basic idea is: first, calculate the scores of the triples corresponding to the candidate entities in the entity set one by one according to a self-designed model; then sort the scores; finally, add the candidate entities with higher scores to the knowledge graph, thus realizing knowledge graph link prediction.
[0004] Knowledge graph link prediction models are usually based on structural information modeling or text information modeling. Knowledge graph representation learning is a traditional method based on structural information modeling. This type of method is simple and efficient, but only considers the triple information of the knowledge graph, resulting in insufficient modeling and performance degradation. Considering the topological structure information of the knowledge graph, a knowledge graph link prediction method based on graph neural network is proposed. The strategy is to iteratively aggregate messages from neighborhood entities to target entities to learn the topological structure. This type of method has achieved excellent performance and is widely used by modeling the structural information of the knowledge graph. However, this type of method cannot provide rich semantic associations between entities and relations, and is inherently susceptible to the incompleteness of the knowledge graph. In view of the limitations of the graph neural network-based method, in order to utilize the text description information of the knowledge graph, a knowledge graph link prediction method based on a pre-trained language model (PLM) is proposed. The strategy is to encode the text description information corresponding to entities and relations. This type of method also achieves excellent performance. However, the modeling of this type of method relies heavily on triples and their text description information, and cannot capture the long-distance structure in the knowledge graph. To a certain extent, it ignores the topological deviation and has spatial limitations. Summary of the invention
[0005] The technical problem to be solved by the present invention is: to propose a knowledge graph link prediction method that integrates multi-source information. In view of the problems that the current graph neural network method lacks effective information when training sparse graphs and has a large number of low-correlation entities when training dense graphs due to the small number of aggregation layers, and the pre-trained language model method ignores the spatial limitations and entity ambiguity problems, a lightweight integrated model is designed to combine a proposed structural information modeling model with a text and path information joint modeling model, thereby improving the link prediction performance.
[0006] The technical solution adopted by the present invention to solve the above technical problems is:
[0007] A knowledge graph link prediction method integrating multi-source information includes the following steps:
[0008] A knowledge graph link prediction method integrating multi-source information, characterized by comprising the following steps:
[0009] Step 1: Establish a structural information modeling model based on an efficient message passing mechanism, and use the optimized entity features for efficient message passing; the structural information modeling model first trains the transformed relationship graph through a graph autoencoder to obtain relationship features and entity features, and then filters out low-correlation entities through the calculated semantic threshold, and retains entities with close spatial distances;
[0010] Step 2: Establish a joint modeling model of text and path information based on text semantic enhancement; the text information modeling model first adds the soft prompts in prompt learning into semantic coding, then adds the preprocessed path information into the predefined hard prompts for path coding, and performs joint training of semantic and path coding;
[0011] Step 3: Integrate the different score distributions of the text information modeling model and the structural information modeling model, train the integration weights corresponding to the scores of the two models, and perform weighted summation and re-ranking of the scores to obtain an integrated model;
[0012] Step 4: After completing the integrated model training through step 3, use the model for the actual knowledge graph link prediction task.
[0013] Furthermore, the establishment process of the structural information modeling model is as follows:
[0014] Step 11: Initialize entity features; use random initialization to generate the initial feature matrix of the relationship is a real number matrix set with m rows and d columns, where m is the number of relationship types in the knowledge graph G and d is the embedding dimension; the original knowledge graph G is converted into a relationship graph G r , use the graph autoencoder to optimize the initial feature matrix of the relationship and transform the relationship graph G rThe structural knowledge of is integrated into the relationship features, and the initial feature matrix of the relationship and the adjacency matrix A r After two layers of graph convolutional network GCN, it is embedded into an intermediate vector
[0015] Z=GCN(h r ,A r )
[0016] Then use the dot product to reconstruct the original knowledge graph G:
[0017]
[0018] in is the graph adjacency matrix reconstructed by decoding; σ is the Sigmoid activation function; Z T is the transpose of the intermediate vector Z;
[0019] The neighborhood relationship types of entities are aggregated using attention. For each triple (e q ,r q ,e a )∈Tra, where Tra is the training set, e q is the query entity, r q To query the relationship, e a is the answer entity, and the initial entity features are obtained by weighted summation of the attention coefficients
[0020]
[0021]
[0022] in To query entity e q The set of neighborhood relationship types, For the relationship q The embedding For entity e q Neighborhood relationship r i Embedding, σ is the Sigmoid activation function, || is the feature concatenation operation;
[0023] Step 12: Efficient message passing: After L layers of efficient message passing, the valid message is passed from the query entity to the answer entity and other target entities. Before each layer of message passing, the entity-entity relevance β is calculated based on the target entity, source entity, and query entity. E , calculate the entity-relationship relevance β based on the target entity, source relationship, and query relationship R , and calculate an average relevance based on all target entities Then set a threshold β, and in the candidate entity set E′, The corresponding target entity is removed, thereby reducing interference messages through semantic level filtering; after semantic level filtering, each target entity after semantic level filtering is aggregated through an attention-based approach. Attention is used to distinguish the different weights of the target entity's neighborhood messages, thereby obtaining the neighborhood message embedding
[0024]
[0025]
[0026] in is the weight matrix of the lth layer; For entity e i Embedding at layer l-1; For the relationship i Embedding at layer l-1; The target entity e o The neighborhood entity set of The target entity e o The set of relationship types corresponding to the neighborhood entity set; β oj The relevance of each neighborhood message
[0027] Then the neighborhood message is embedded Merge the target entity's own message to get the initial target entity embedding
[0028]
[0029] in or is the connection operation; ⊙ is the Hadamard product; The target entity e o Embedding at layer l-1;
[0030] Compute each target entity embedding To query entity embeddings The spatial distance D is used to filter the target entities at the lth layer, and a specific number K of spatially similar entities are retained:
[0031]
[0032] Step 13: Use difficult negative samples for training; after L layers of message passing, the answer entity in the candidate entity set E′ and at most (L·K-1) other target entities are obtained, and the answer entity of the Lth layer is embedded into Input into the scoring function S:
[0033]
[0034] in is the weight matrix;
[0035] The logarithmic loss function is used when training with negative samples:
[0036]
[0037] Among them, Tra is a difficult negative sample set.
[0038] Furthermore, the process of establishing the text information modeling model is as follows:
[0039] Step 21: Semantic feature learning; semantic encoding is achieved through a semantic dual encoder, which is divided into a head entity-relation encoder BERT hr and tail entity encoder BERT t , head entity-relation encoder BERT hr Encode the head entity, head entity description, relation, relation description and soft hint, and the tail entity encoder BERT t Encode the tail entity and its description; insert entity soft hint embeddings before and after the input head entity Insert relation soft hint embedding before and after the entered relation Where E is the entity set; R is the relationship set;
[0040] The average pooling strategy is used to extract the hidden state from the last layer of the semantic dual encoder, and the cosine similarity is used to calculate the semantic feature score S r (h,r,t), as shown below:
[0041]
[0042] Where h is the head entity; r is the relationship; e hr BERT is the head entity-relation encoder hr Output head entity and relation embeddings; e t BERT is the tail entity encoder t Output tail entity embedding;
[0043] Step 22: Path feature learning; use the random walk algorithm to extract the relationship path corresponding to each triple in the data set, calculate and select the high-reliability path from the head entity to the tail entity; path encoding is implemented through a path dual encoder, which is divided into a hard prompt specification encoder BERT hP and tail entity encoder BERT t , Hard Hint Regularization Encoder BERT hPEncode the head entity and the highly reliable path from the head entity to the tail entity, and use the self-designed hard prompt specification encoder BERT hP Input:
[0044] Template="First path about[Entity]is[p1], second is[p2],,...,-th is[p i ].”
[0045] Where [Entity] is the header entity tag; [p i ] is the path label;
[0046] Input the hard template into BERT hP In the above example, the average pooling strategy is used to extract the hidden state from the last layer of the path dual encoder, and the head entity-path embedding e is obtained by L2 normalization. hP ; Tail Entity Encoder BERT with Path Dual Encoder t Tail Entity Encoder BERT with Semantic Dual Encoder t Share all parameters and use spatial distance to calculate the path feature score S P (h,r,t):
[0047] S P (h,r,t)=distance(e hP , e t )=-||e hP -e t ||
[0048] Where ‖·‖ is the L2 norm;
[0049] Step 23: Joint training strategy: Semantic feature learning and path feature learning are taken as one training round, and the self-supervised pre-trained language model is used to implement semantic feature learning and path feature learning, and joint training is performed:
[0050]
[0051] in is the loss function for semantic feature learning; ε is the scale parameter; The loss function for path feature learning; the goal of joint training is to minimize the loss value of the joint loss function.
[0052] Furthermore, the InfoNCE loss function is used in the semantic feature learning to perform path feature training:
[0053]
[0054] Where Train is the training set; N is the negative sample set consisting of a set number of non-answer entities with the highest scores corresponding to each query triple after the first round of iteration in the structural information modeling model training phase; t′ is the negative sample in the negative sample set; τ is the temperature coefficient, which is used to control the model’s discrimination of negative samples;
[0055] The maximum margin hinge loss function is used in path feature learning:
[0056]
[0057] Among them, Tra N is the set of negative triples, and λ is the interval distance.
[0058] Furthermore, step 3 is as follows:
[0059] Step 31: Preprocessing and feature extraction; use maximum and minimum value normalization to normalize the score Sc i (h, r, t) is linearly mapped to the interval [0, 1] to obtain the normalized score Sc i ′(h,r,t):
[0060]
[0061] Where min(·) is the minimum function; N all For any query triple (h, r, t a ) corresponds to all positive and negative sample sets; max(·) is the maximum value function; Sc i In ′(h, r, t), when i=1, it represents the score of the structural information modeling model, and when i=2, it represents the score of the text information modeling model.
[0062] Normalize the score to extract features and get the features f(Sc i ′,T):
[0063]
[0064] Where T = (h, r, t) is any positive or negative triple; mean(·) is the mean function; || is the feature concatenation operation; var(·) is the variance function; x (Sc ′, T) is the interaction feature of the two models:
[0065] x (Sc′,T) =[Sc1′,Sc1′×Sc2′,Sc1′-Sc2′,Sc2′]
[0066] Step 32: Integrate weight calculation and model training; respectively transform the features f(Sc i′,T) is passed to the multi-layer perceptron MLP to calculate the integrated weight
[0067]
[0068] Calculate the integrated score J(h,r,t):
[0069]
[0070] For any triple score Sc2(h,r,t) of the text information modeling model, there is a unique triple score Sc1(h,r,t) of the structural information modeling model.
[0071] The ensemble model is trained using the maximum margin hinge loss function:
[0072]
[0073] Among them, J is the training set corresponding to the integrated model; is the set of negative triples corresponding to the integrated model, N J is the negative sample set corresponding to any query triplet of the integrated model; m is the interval distance; J(h,r,t + ) is the query triple (h, r, t a ) corresponding to the integrated score of the positive triple; J(h,r,t - ) is the query triple (h, r, t a ) is the integrated score of the negative triples corresponding to .
[0074] The beneficial effects of the present invention are:
[0075] 1) In the graph neural network method, highly relevant messages are transmitted. On the one hand, the exponential growth of the number of entities can be avoided when training dense graphs, alleviating the over-smoothing problem and reducing the computational cost. On the other hand, when training sparse graphs, messages can be transmitted to deeper layers to learn more effective knowledge.
[0076] 2) Add soft prompts to the semantic dual encoder to alleviate the entity ambiguity problem existing in PLM and improve the feature quality of entities and relationships. At the same time, combine path information and text information, use hard prompts to standardize input, alleviate spatial limitations and improve model accuracy.
[0077] 3) The lightweight adaptive integration model complements the two types of models, greatly reducing the model training cost while further improving the evaluation effect of knowledge graph link prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] Figure 1It is the overall flow chart of the knowledge graph link prediction method in the present invention;
[0079] Figure 2 A schematic diagram of efficient message transmission of the present invention;
[0080] Figure 3 The schematic diagram of text semantic enhancement according to the present invention. DETAILED DESCRIPTION
[0081] This paper aims to propose a knowledge graph link prediction method that integrates multi-source information. On the one hand, it optimizes the existing graph neural network method, and on the other hand, it enriches the feature modeling of the pre-trained language model. The goal is to improve the model efficiency and accuracy of these two methods. At the same time, it attempts to complement these two improved methods to further improve the evaluation effect of the model. The overall implementation process is as follows: Figure 1 As shown in the figure, S1. The relationship optimization model is used to obtain higher quality initial entity features and relationship features, and low-correlated neighborhood entities are filtered from the semantic and spatial perspectives to pass the message to a deeper layer; S2. The soft prompts of prompt learning are applied to the semantic feature encoding, and the hard prompts are applied to the feature encoding of high-quality paths, and joint training is performed; S3. The scores corresponding to the structural modeling model and the text modeling model are preprocessed and feature extracted, and the integrated weights of the corresponding scores are obtained through training, and then the candidate entities are weighted summed; S4. When performing a specific link prediction task, the scores obtained by the integrated model are re-ranked, and finally the link prediction task is completed according to the score ranking results.
[0082] Example:
[0083] The following is an example of a knowledge graph G to be learned with n entities and m relationship types to be learned, and the scheme of the present invention is described in detail. The specific implementation process is as follows:
[0084] Step 1: Use optimized entity features for efficient message transmission. Figure 2 As shown in Figure 3, the whole process is divided into three sub-steps: entity feature initialization, efficient message passing, and training with difficult negative samples.
[0085] Step 11: Initialize entity features. Use a graph autoencoder (hereinafter referred to as graph autoencoder) to extract the structural knowledge between relationships on the converted relationship graph, and then use the optimized relationship features to initialize entity features. Generate the initial feature matrix of the relationship by random initialization. is a real number matrix set with m rows and d columns, where m is the number of relationship types in the knowledge graph G and d is the embedding dimension. r , use the graph autoencoder to optimize the initial feature matrix of the relationship and transform the relationship graph Gr The structural knowledge of is integrated into the relationship features, and the initial feature matrix of the relationship and the adjacency matrix A r After two layers of graph convolutional network GCN, it is embedded into an intermediate vector
[0086] Z=GCN(h r , A r )
[0087] Then use the dot product to reconstruct the original image G:
[0088]
[0089] in is the graph adjacency matrix reconstructed by decoding; σ is the Sigmoid activation function; Z T is the transpose of the intermediate vector Z.
[0090] Reconstructing the adjacency matrix Adjacency matrix A with the original image r Should be as similar as possible, because the adjacency matrix determines the structure of the graph. Therefore, the cross entropy loss function is used during training:
[0091]
[0092] Among them A ij is the element value (0 or 1) of the i-th row and j-th column in the adjacency matrix of the original image; is the corresponding element value in the reconstructed adjacency matrix.
[0093] The neighborhood relationship types of entities are aggregated using attention. For each triple (e q ,r q ,e a )∈Tra, where Tra is the training set, e q is the query entity, r q To query the relationship, e a is the answer entity, and the initial entity features are obtained by weighted summation of the attention coefficients
[0094]
[0095]
[0096] in To query entity e q The set of neighborhood relationship types, For the relationship q The embedding For entity e qNeighborhood relationship r i , σ is the Sigmoid activation function, and || is the feature concatenation operation.
[0097] Step 12: Efficient message delivery. After L layers of efficient message delivery, the valid message is delivered from the query entity to the answer entity and other target entities. In each layer, semantic filtering is first performed by calculating the entity-entity relevance and entity-relationship relevance of the target entity, and then spatial filtering is performed on the target entity after message aggregation, so as to deliver the valid message to the next layer. Specifically, before each layer of message delivery, the entity-entity relevance β is calculated based on the target entity, the source entity, and the query entity. E , calculate the entity-relationship relevance β based on the target entity, source relationship, and query relationship R , and calculate an average relevance based on all target entities Then set a threshold β, and in the candidate entity set E′, The corresponding target entity is removed, thereby reducing interference messages through semantic level filtering and reducing computational costs. After semantic level filtering, each target entity after semantic level filtering is aggregated through an attention-based approach. Attention is used to distinguish the different weights of the target entity's neighborhood messages, thereby obtaining the neighborhood message embedding
[0098]
[0099]
[0100] in is the weight matrix of the lth layer; For entity e i Embedding at layer l-1; For the relationship i Embedding at layer l-1; The target entity e o The neighborhood entity set of ; The target entity e o The set of relationship types corresponding to the neighborhood entity set; is the correlation degree corresponding to each neighborhood message.
[0101] After message passing, the obtained neighborhood message embedding It is also necessary to merge the target entity's own message to obtain the initial target entity embedding
[0102]
[0103] in or is the connection operation; ⊙ is the Hadamard product; The target entity e o Embedding at layer l-1.
[0104] Compute each target entity embedding To query entity embeddings The spatial distance D is used to filter the target entities at the lth layer, and a specific number K of spatially similar entities are retained:
[0105]
[0106] Step 13: Use difficult negative samples for training. After L layers of message passing, we get the answer entity in the candidate entity set E′ and at most (L·K-1) other target entities. Embed the answer entity of the Lth layer into Input into the scoring function S:
[0107]
[0108] in is the weight matrix; e q is the query entity, r q To query the relationship, e a The answer entity.
[0109] The model uses the logarithmic loss function:
[0110]
[0111] Among them, Tra is a difficult negative sample set.
[0112] Step 2: Use prompt learning to model text and path information. Figure 3 As shown in the figure, the whole process is divided into three sub-steps: semantic feature learning, path feature learning and joint training strategy.
[0113] Step 21, semantic feature learning, first pre-process the text information of entities and relations, then use the semantic dual encoder to encode the different parts corresponding to the query triple, and add soft hints to improve the encoding quality, and then calculate the cosine similarity to get the semantic feature score. Specifically, semantic encoding is implemented by a semantic dual encoder, which is divided into the head entity-relation encoder BERT hr and tail entity encoder BERT t , head entity-relation encoder BERT hr Encode the head entity, head entity description, relation, relation description and soft hint, and the tail entity encoder BERT t Encode the tail entity and its description. Insert entity soft hint embedding before and after the input head entity. Insert relation soft hint embedding before and after the entered relation
[0114] Where E is the entity set; is the relationship set; d is the dimension of the hidden state;
[0115] For the semantic dual encoder encoder BERT t , the input only contains the tail entity t and the corresponding text description. The hidden state is extracted from the last layer of the encoder using the average pooling strategy. The semantic feature score S is calculated using cosine similarity r (h,r,t), as shown in the following formula.
[0116]
[0117] Where h is the head entity; r is the relationship; e hr BERT is the head entity-relation encoder hr Output head entity and relation embeddings; e t BERT is the tail entity encoder t Output tail entity embedding.
[0118] The InfoNCE loss function is used for path feature training in semantic feature learning:
[0119]
[0120] Where Train is the training set; N is the negative sample set consisting of the 1000 non-answer entities with the highest scores corresponding to each query triple after the first round of iteration in the training phase of the structural information modeling model; t′ is the negative sample in the negative sample set; τ is the temperature coefficient, which is used to control the model's discrimination of negative samples.
[0121] Step 22, path feature learning, first pre-process the query triplet path information to obtain a highly reliable path, then encode the head entity and its highly reliable path, and use hard prompts to standardize the input, and then calculate the spatial distance to the tail entity to obtain the path feature score. Specifically, the random walk algorithm is used to extract multiple relationship paths corresponding to each triplet in the data set, and the relationship constraint resource allocation algorithm (PCRA, Path-constraint ResourceAllocation Algorithm) is used to calculate the highly reliable path from the head entity to the tail entity, and the three paths with the highest reliability are selected. Path encoding is implemented through a path dual encoder, which is divided into a hard prompt specification encoder BERT hP and tail entity encoder BERT t , Hard Hint Regularization Encoder BERT hPEncode the head entity and the three highly reliable paths from the head entity to the tail entity, and use the self-designed hard prompt specification encoder BERT hP Input:
[0122] Template="First path about[Entity]is[p1], second is[p2],thrid is[p3]."
[0123] Where [Entity] is the header entity tag; [p i ] is a path label.
[0124] Input the hard template into BERT hP In , the average pooling strategy is used to extract the hidden state from the last layer of the encoder and normalize it by L2 to obtain the head entity-path embedding e hP . Path Dual Encoder Encoder BERT t Encoder BERT with semantic dual encoder t Share all parameters and use spatial distance to calculate the path feature score S P (h,r,t):
[0125] S P (h,r,t)=distance(e hP ,e t )-||e hP -e t ||
[0126] Where ‖·‖ is the L2 norm.
[0127] The maximum margin hinge loss function is used in path feature learning:
[0128]
[0129] Among them, Tra is the training set, Tra N is the set of negative triples, where N is the negative sample set consisting of the 1000 non-answer entities with the highest scores corresponding to each query triple after the first round of iteration in the training phase of the structural information modeling model, and λ is the interval distance.
[0130] Step 23: Joint training strategy. Take the semantic feature learning module and the path feature learning module together as a training round, use the self-supervised pre-trained language model (PLM, Pre-trained Language Model) to implement semantic feature learning and path feature learning, and perform joint training:
[0131]
[0132] in is the loss function of the semantic feature learning module; ε is the scale parameter; is the loss function of the path feature learning module. The goal of joint training is to minimize the loss value of the joint loss function, thereby making full use of the implicit knowledge in PLM and the topological structure information of the knowledge graph.
[0133] Step 3: Integrate the different score distributions of the text information modeling model and the structural information modeling model. The integration process includes two sub-steps: preprocessing and feature extraction, and integration weight calculation and model training.
[0134] Step 31: Preprocessing and feature extraction. Use the maximum and minimum value normalization to normalize the score Sc i (h, r, t) is linearly mapped to the interval [0, 1] to obtain the normalized score Sc i ′(h,r,t):
[0135]
[0136] Where min(·) is the minimum function; N all For any query triple (h, r, t + ) corresponds to all positive and negative sample sets; max(·) is the maximum value function; Sc i In ′(h, r, t), when i=1, it represents the score of the text information modeling model, and when i=2, it represents the score of the structural information modeling model.
[0137] Perform feature extraction on the normalized score to obtain the features f(Sc i ′,T):
[0138]
[0139] Where T = (h, r, t) is any positive or negative triple; mean(·) is the mean function; || is the feature concatenation operation; var(·) is the variance function; x (Sc ′, T) is the interaction feature of the two models:
[0140] x (Sc′,T) =[Sc1′,Sc1′×Sc2′,Sc1′-Sc2′,Sc2′]
[0141] Step 32: Integrated weight calculation and model training. The features f(Sc i ′,T) is passed to the multi-layer perceptron MLP to calculate the integrated weights
[0142]
[0143] Where σ is the activation function; MLP i (·) It is possible to transform the dimension of the vector. The integrated model transforms the merged feature vector into a one-dimensional vector. T = (h, r, t) is any positive or negative triplet.
[0144] Calculate the integrated score J(h,r,t):
[0145]
[0146] in is the integration weight, T = (h, r, t) is any positive and negative triple, and the integrated model is any query triple (h, r, t + ) calculates the integrated weights of all positive and negative triplets corresponding to Sc i (h, r, t) is the score of any positive or negative triple. For any triple score Sc2(h, r, t) of the text information modeling model, there is a unique triple score Sc1(h, r, t) of the structural information modeling model.
[0147] The ensemble model is trained using the maximum margin hinge loss function:
[0148]
[0149] Among them, J is the training set corresponding to the integrated model; is the set of negative triples corresponding to the integrated model, N J is the negative sample set corresponding to any query triplet of the integrated model; m is the interval distance; J(h,r,t + ) is the query triple (h, r, t a ) corresponding to the integrated score of the positive triple; J(h,r,t - ) is the query triple (h, r, t a ) is the integrated score of the negative triples corresponding to .
[0150] Step 4: After completing the model training in step 3, the model can be used for the actual knowledge graph link prediction task. For example, for the missing triple (a, b, ?) to be completed, the tail entity that needs to be predicted is the possible existence of the head entity a based on the relationship b. For each query triple, the integrated scores of each candidate triple corresponding to the integrated model training and weighted sum are sorted, and the entity in the candidate triple with the highest score is used as the link prediction result.
[0151] Although the present invention is described herein with reference to the embodiments of the present invention, the above embodiments are only preferred embodiments of the present invention, and the embodiments of the present invention are not limited to the above embodiments. It should be understood that those skilled in the art can design many other modifications and implementations, which will fall within the scope and spirit of the principles disclosed in this application.
Claims
1. A knowledge graph link prediction method integrating multi-source information, characterized in that: The following steps are involved: Step 1: Establish a structural information modeling model based on an efficient message passing mechanism and use the optimized entity features for efficient message passing; The structural information modeling model first trains the transformed relationship graph through the graph autoencoder to obtain relationship features and entity features, and then filters out low-correlation entities through the calculated semantic threshold, and retains entities with close spatial distances; Step 2: Establish a joint modeling model of text and path information based on text semantic enhancement; the text information modeling model first adds the soft prompts in prompt learning into semantic coding, then adds the preprocessed path information into the predefined hard prompts for path coding, and performs joint training of semantic and path coding; Step 3: Integrate the different score distributions of the text information modeling model and the structural information modeling model, train the integration weights corresponding to the scores of the two models, and perform weighted summation and re-ranking of the scores to obtain an integrated model; Step 4: After completing the integrated model training through step 3, use the model for the actual knowledge graph link prediction task.
2. According to claim 1, a knowledge graph link prediction method integrating multi-source information is characterized in that: The establishment process of the structural information modeling model is as follows: Step 11: Initialize entity features; use random initialization to generate the initial feature matrix of the relationship is a real number matrix set with m rows and d columns, where m is the number of relationship types in the knowledge graph G and d is the embedding dimension; the original knowledge graph G is converted into a relationship graph G r , use the graph autoencoder to optimize the initial feature matrix of the relationship and transform the relationship graph G r The structural knowledge of is integrated into the relationship features, and the initial feature matrix of the relationship and the adjacency matrix A r After two layers of graph convolutional network GCN, it is embedded into an intermediate vector Z=GCN(h r ,A r ) Then use the dot product to reconstruct the original knowledge graph G: in is the graph adjacency matrix reconstructed by decoding; σ is the Sigmoid activation function; Z T is the transpose of the intermediate vector Z; The attention method is used to aggregate the neighborhood relationship types of entities. For each triple (e q ,r q ,e a )∈Tra, where Tra is the training set, e q is the query entity, r q To query the relationship, e a is the answer entity, and the initial entity features are obtained by weighted summation of the attention coefficients in To query entity e q The set of neighborhood relationship types, For the relationship q The embedding For entity e q Neighborhood relationship r i Embedding, σ is the Sigmoid activation function, || is the feature concatenation operation; Step 12: Efficient message passing: After L layers of efficient message passing, the valid message is passed from the query entity to the answer entity and other target entities. Before each layer of message passing, the entity-entity relevance β is calculated based on the target entity, source entity, and query entity. E , calculate the entity-relationship relevance β based on the target entity, source relationship, and query relationship R , and calculate an average relevance based on all target entities Then set a threshold β, and in the candidate entity set E′, The corresponding target entity is removed, thereby reducing interference messages through semantic level filtering; after semantic level filtering, each target entity after semantic level filtering is aggregated through an attention-based approach. Attention is used to distinguish the different weights of the target entity's neighborhood messages, thereby obtaining the neighborhood message embedding in is the weight matrix of the lth layer; For entity e i Embedding at layer l-1; For the relationship i Embedding at layer l-1; The target entity e o The neighborhood entity set of The target entity e o The set of relationship types corresponding to the neighborhood entity set; The relevance of each neighborhood message Then the neighborhood message is embedded Merge the target entity's own message to get the initial target entity embedding in or is the connection operation; ⊙ is the Hadamard product; The target entity e o Embedding at layer l-1; Compute each target entity embedding To query entity embeddings The spatial distance D is used to filter the target entities at the lth layer, and a specific number K of spatially similar entities are retained: Step 13: Use difficult negative samples for training; after L layers of message passing, the answer entity in the candidate entity set E′ and at most (L·K-1) other target entities are obtained, and the answer entity of the Lth layer is embedded into Input into the scoring function S: in is the weight matrix; The logarithmic loss function is used when training with negative samples: Among them, Tra is a difficult negative sample set.
3. According to claim 2, a knowledge graph link prediction method integrating multi-source information is characterized in that: The decoded and reconstructed graph adjacency matrix is the same as the original graph adjacency matrix A r It should be as similar as possible, using the cross entropy loss function during training: Among them A ij is the element value (0 or 1) of the i-th row and j-th column in the adjacency matrix of the original image; is the corresponding element value in the reconstructed adjacency matrix.
4. A knowledge graph link prediction method integrating multi-source information according to claim 2 or 3, characterized in that: The establishment process of the text information modeling model is as follows: Step 21: semantic feature learning; Semantic encoding is achieved through a semantic dual encoder, which is divided into a head entity-relation encoder BERT hr and tail entity encoder BERT t , head entity-relation encoder BERT hr Encode the head entity, head entity description, relation, relation description and soft hint, and the tail entity encoder BERT t Encode the tail entity and its description; Insert entity soft hint embeddings before and after the input head entity Insert relation soft hint embedding before and after the entered relation Where E is the entity set; R is the relationship set; The average pooling strategy is used to extract the hidden state from the last layer of the semantic dual encoder, and the cosine similarity is used to calculate the semantic feature score S r (h,r,t), as shown below: Where h is the head entity; r is the relationship; e hr BERT is the head entity-relation encoder hr Output head entity and relation embeddings; e t BERT is the tail entity encoder t Output tail entity embedding; Step 22: Path feature learning; The random walk algorithm is used to extract the relationship path corresponding to each triple in the data set, and the high-reliability path from the head entity to the tail entity is calculated and selected; the path encoding is implemented through a path dual encoder, which is divided into a hard prompt specification encoder BERT hP and tail entity encoder BERT t , Hard Hint Regularization Encoder BERT hP Encode the head entity and the highly reliable path from the head entity to the tail entity, and use the self-designed hard prompt specification encoder BERT hP Input: Template="Firstpathabout[Entity]is[p1],secondis[p2],,…,-this[p i ].” Where [Entity] is the header entity tag; [p i ] is the path label; Inputting hard template Remplate to BERT hP In the above example, the average pooling strategy is used to extract the hidden state from the last layer of the path dual encoder, and the head entity-path embedding e is obtained by L2 normalization. hP ; Tail Entity Encoder BERT with Path Dual Encoder t Tail Entity Encoder BERT with Semantic Dual Encoder t Share all parameters and use spatial distance to calculate the path feature score S P (h,r,t): s P (h,r,t)=distance(e jP ,e t )=-‖e hP -e t ‖ Where ‖·‖ is the L2 norm; Step 23: Joint training strategy: Semantic feature learning and path feature learning are taken as one training round, and the self-supervised pre-trained language model is used to implement semantic feature learning and path feature learning, and joint training is performed: in is the loss function for semantic feature learning; ε is the scale parameter; The loss function for path feature learning; the goal of joint training is to minimize the loss value of the joint loss function.
5. A knowledge graph link prediction method integrating multi-source information according to claim 4, characterized in that: The InfoNCE loss function is used in the semantic feature learning to perform path feature training: Where Train is the training set; N is the negative sample set consisting of a set number of non-answer entities with the highest scores corresponding to each query triple after the first round of iteration in the structural information modeling model training phase; t′ is the negative sample in the negative sample set; τ is the temperature coefficient, which is used to control the model’s discrimination of negative samples; The maximum margin hinge loss function is used in path feature learning: Among them, Tra N is the set of negative triples, and λ is the interval distance.
6. A knowledge graph link prediction method integrating multi-source information according to claim 5, characterized in that: The step 3 is as follows: Step 31: Preprocessing and feature extraction; use maximum and minimum value normalization to normalize the score Sc i (h, r, t) is linearly mapped to the interval [0, 1] to obtain the normalized score Sc i ′(h,r,t): Where min(·) is the minimum function; N all For any query triple (h, r, t a ) corresponds to all positive and negative sample sets; max(·) is the maximum value function; Sc i In ′(h, r, t), when i=1, it represents the score of the structural information modeling model, and when i=2, it represents the score of the text information modeling model. Normalize the score to extract features and get the features f(Sc i ′,T): Where T = (h, r, t) is any positive or negative triple; mean(·) is the mean function; || is the feature concatenation operation; var(·) is the variance function; x (sc′,T) is the interaction feature of the two models: x (sc′,T) =[Sc1′,Sc1′×Sc2′,Sc1′-Sc2′,Sc2′] Step 32: Integrate weight calculation and model training; respectively transform the features f(Sc i ′,T) is passed to the multi-layer perceptron MLP to calculate the integrated weight γ Ti : γ Ti =σ(MLP i (f(Sc i ′,T)) Calculate the integrated score J(h,r,t): J(h,r,t)=γ T1 ·Sc1(h,r,t)+γ T2 ·Sc2(h,r,t) For any triple score Sc2(h,r,t) of the text information modeling model, there is a unique triple score Sc1(h,r,t) of the structural information modeling model. The ensemble model is trained using the maximum margin hinge loss function: Among them, J is the training set corresponding to the integrated model; is the set of negative triples corresponding to the integrated model, N J is the negative sample set corresponding to any query triplet of the integrated model; m is the interval distance; J(h,r,t + ) is the query triple (h, r, t a ) corresponding to the integrated score of the positive triple; J(h,r,t - ) is the query triple (h, r, t a ) is the integrated score of the negative triples corresponding to .
7. A knowledge graph link prediction method integrating multi-source information according to claim 6, characterized in that: The step 4 is specifically as follows: sorting the integrated scores of each candidate triple corresponding to the integrated model training and weighted sum, and taking the entity in the candidate triple with the highest score as the link prediction result.
8. The method for predicting links in a knowledge graph by integrating multi-source information according to claim 6, characterized in that: The usage relationship constraint resource allocation algorithm selects the three paths with the highest reliability as high-reliability paths.
Citation Information
Patent Citations
Complex question multi-hop intelligent question answering method based on knowledge graph representation learning
CN115757715A
Knowledge graph completion method and system based on triplex semantic aggregation of isoproton graph
CN116842185A
Cited By
Electromechanical equipment knowledge graph link prediction method fused with large language model
CN120806101A
