Knowledge graph completion method and system for power system
By building a power system knowledge graph completion model through meta-learning and graph attention network, the problems of insufficient reliability and accuracy in existing technologies are solved, and efficient management and analysis of power grid data are achieved.
Patent Information
- Application Number
- CN202510057296.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2045-01-14
AI Technical Summary
Existing power system knowledge graph completion methods have deficiencies in reliability and accuracy, making it difficult to effectively manage and analyze massive heterogeneous, multi-source data in the power grid.
Meta-learning and graph attention network are used to construct a power system knowledge graph completion model, which realizes knowledge graph completion through feature extraction, aligned embedding, missing edge prediction, enhanced node embedding and self-attention mechanism.
The reliability and accuracy of power system knowledge graph completion are improved, and the effectiveness of power grid data management and analysis is enhanced.
Smart Images

Figure CN119962648B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of electrical automation, and particularly relates to a knowledge graph completion method and system for a power system. BACKGROUND
[0002] With the development of economy and technology and the improvement of people's living standards, electric energy has become an essential secondary energy in people's production and life, bringing endless convenience to people's production and life. Therefore, guaranteeing the stable and reliable supply of electric energy has become one of the most important tasks of the power system.
[0003] With the acceleration of the digitalization process of the power grid, power enterprises have accumulated a large amount of heterogeneous and multi-source data, including equipment information, topological relationship, running state, fault record, dispatching history, etc. These data contain rich knowledge, but usually have problems such as incomplete data, noise interference and information island. Therefore, in the management and analysis of power grid data, the knowledge graph completion technology has gradually become one of the important methods to solve the informatization and intelligentization of the power system.
[0004] At present, researchers have proposed various types of power system knowledge graph completion schemes, such as embedding methods based on graph neural networks, prediction schemes based on self-supervised learning, and completion schemes based on multi-modal data. However, these existing schemes have problems of poor reliability and poor accuracy in the specific operation process. SUMMARY
[0005] One of the purposes of the present application is to provide a knowledge graph completion method for a power system with high reliability and good accuracy.
[0006] The second purpose of the present application is to provide a system for implementing the knowledge graph completion method for a power system.
[0007] The knowledge graph completion method for a power system provided by the present application comprises the following steps:
[0008] S1. Obtain data information of the power system;
[0009] S2. Construct a knowledge graph support set and a query set of the power system according to the data information obtained in step S1;
[0010] S3. Construct a power system knowledge graph completion primary model based on meta-learning and graph attention network;
[0011] S4. Train the power system knowledge graph completion primary model constructed in step S3 using the data set obtained in step S2 to obtain a power system knowledge graph completion model;
[0012] S5. Adopting the power system knowledge graph completion model obtained in step S4, the power system knowledge graph is completed.
[0013] The meta-learning and graph attention network based on step S3 constructs a power system knowledge graph completion primary model, which specifically includes the following steps:
[0014] The constructed power system knowledge graph completion primary model has a processing process including the following steps:
[0015] A. Constructing a feature extraction network based on meta-learning for extracting embedded features of input data;
[0016] B. Aligning the embedded features obtained in step A to obtain aligned embeddings;
[0017] C. Based on the aligned embeddings obtained in step B, predict the missing edges in the knowledge graph to obtain candidate triples;
[0018] D. Based on the graph neural network, obtain the enhanced node embedding of the completed knowledge graph, and update the edge set of the graph neural network to generate enhanced entity embedding;
[0019] E. Based on the self-attention mechanism, adjust the feature weight coefficient, and generate the final entity embedding;
[0020] F. According to the entity embedding obtained in step E, perform self-confidence evaluation and completion, and select triples to update the knowledge graph.
[0021] The meta-learning based feature extraction network of step A is used to extract the embedded features of the input data, which specifically includes the following steps:
[0022] The support set is processed by a first local encoder to obtain a support set first feature embedding;
[0023] The query set is processed by a second local encoder to obtain a query set first feature embedding;
[0024] The support set first feature embedding is processed by a first global encoder to obtain a support set long-distance feature embedding;
[0025] The query set first feature embedding is processed by a second global encoder to obtain a query set long-distance feature embedding;
[0026] The processing processes of the first local encoder and the second local encoder are the same, and both include the following steps:
[0027] The size of the input entity embedding and the relationship embedding is set to d;
[0028] The obtained data information is subjected to feature extraction through convolution to obtain local features between entities and adjacent relationships; wherein the kernel size of the convolution is 3*3, the input channel number is d, the output channel number is d, and the step length is 1;
[0029] The output of the convolution is processed through an activation function; the activation function f(x) is
[0030] The obtained data information is processed through maximum pooling to realize dimension reduction; wherein the kernel size of the maximum pooling is 2*2, and the step length is 2;
[0031] The obtained data information is subjected to full connection operation to map the feature information into embedding output;
[0032] The embedding output is processed through an activation function again; the activation function f(x) is
[0033] The processing procedures of the first global encoder and the second global encoder are the same, and each includes the following steps:
[0034] The input knowledge graph triplets are subjected to dimension adjustment, so that the output embedding dimension is d2;
[0035] The obtained data information is subjected to graph convolution operation to generate long-distance embedding features based on relationship adjacency information; the kernel size of the graph convolution is 1*1, the step length is 1, and the output channel number is d2;
[0036] The obtained data information is subjected to global pooling processing to aggregate the embedding of all nodes to generate global features;
[0037] The global features are subjected to full connection operation to be mapped into embedding output;
[0038] The embedding output is processed through an activation function; the activation function f(x) is
[0039] The step B aligns the embedding features obtained in the step A to obtain aligned embedding, and specifically includes the following steps:
[0040] The support set global feature embedding g S and the query set global feature embedding g Q are spliced to obtain the global feature embedding g con after splicing of the support set and the query set; con g S =αg Q +(1-α)g con , and α is a set weight;
[0041] The g con is subjected to full connection operation to generate aligned embedding gA ;
[0042] g A The activation function is processed; the activation function f(x) is
[0043] The obtained data information is subjected to attention weight calculation operation to obtain g S , g Q and the weight matrix of g A .
[0044] Step C is based on the alignment embedding obtained in step B to predict the missing edges in the knowledge graph to obtain candidate triples, specifically including the following steps:
[0045] Based on the alignment embedding result obtained in step B, the edge prediction and knowledge graph expansion are performed, the missing edges in the knowledge graph are predicted, and new candidate triples are generated;
[0046] The obtained data information is calculated to obtain the expansion score and is normalized to obtain a new attention distribution;
[0047] The predicted edge set is added to the knowledge graph, the candidate edges with a confidence higher than a set value are added to the knowledge graph, and the node set is updated to obtain an expanded knowledge graph;
[0048] Among them, based on the alignment embedding result obtained in step B, the edge prediction and knowledge graph expansion are performed, the missing edges in the knowledge graph are predicted, and new candidate triples are generated, specifically including the following steps:
[0049] For the alignment embedding result obtained in step B:
[0050] If (h, r,?), calculate t p1 as t p1 =g a -(h+r);
[0051] If (?, r, t), calculate h p1 as h p1 =g a -(r+t);
[0052] In the knowledge graph, a set of triples (h, r, t) is represented by a head entity h, a relationship r and a tail entity t, wherein (h, r,?) represents a set of incomplete triples with missing tail entities in the knowledge graph,? is a missing entity; (?, r, t) represents a set of incomplete triples with missing head entities in the knowledge graph; t p1 is the tail entity in the query set calculated by feature embedding, g a is the aligned feature embedding, h p1To calculate the head entity in the query set through feature embedding;
[0053] The score function score(h, r, t) is used to calculate the score of each candidate edge, and the top several edges with the highest scores are selected as the completion candidate edges;
[0054] For the completion candidate edges:
[0055] If (h, r,?), t is calculated p2 For t p2 = argmax t score(h, r, t);
[0056] If (?, r, t), h is calculated p2 For h p2 = argmax h score(h, r, t);
[0057] Where t p2 is the tail entity predicted by the score function; argmax t () represents the argument function, and the value of t when the score reaches the maximum; h p2 is the head entity predicted by the score function; argmax h () represents the argument function, and the value of h when the score reaches the maximum;
[0058] Finally, the candidate edge set is output;
[0059] The obtained data information is calculated to obtain an extended score and normalized to obtain a new attention distribution, and the specific steps include:
[0060] For the missing query entity e n (h, r,?), a candidate entity set composed of adjacent entities e n-1 (h, r, t) is obtained, and the extended score is initialized, and the candidate entity e n The extended score S k {e n} in k steps is
[0061]
[0062] In the formula, e n-1 is the adjacent entity of e n , || is a feature connector, is the query set global feature embedding of the entity e n-1 in the kth step; is the query set global feature embedding of the entity e n in the kth step; MLP() is a multi-layer perception processing function;
[0063] selecting a plurality of edges with the maximum probability for updating the knowledge graph;
[0064] adding the selected edges to the edge set E and adding the tail entities not visited to the node set V, completing the expansion of the knowledge graph G, and obtaining the expansion score of the entity in the expanded graph through k steps, normalizing the score to obtain a new attention distribution,
[0065] p k (e q )=softmax(S k {e1},...,S k {e n})
[0066] where p k (e q ) is the answer score distribution of all graphs; the output probability distribution is 0 if an entity is not added to the expanded graph.
[0067] The graph neural network based on step D obtains the enhanced node embedding of the completed knowledge graph, and updates the edge set of the graph neural network to generate enhanced entity embedding, specifically including the following steps:
[0068] processing the data information obtained in step C based on the R-GCN network;
[0069] processing the obtained data information using global pooling to aggregate entity embedding and generate enhanced graph embedding;
[0070] processing the enhanced graph embedding data information through the graph neural network to generate enhanced entity embedding;
[0071] The processing of the data information obtained in step C based on the R-GCN network specifically includes the following steps:
[0072] performing graph convolution operation on the input data information; the step of graph convolution is 1;
[0073] performing full connection operation on the obtained data information, thereby performing linear transformation; the full connection operation is represented as h′ i =W·h i +b, where h′ i is the new feature vector of node i after transformation, W is the weight matrix, h i is the original feature vector of node i, and b is the bias term used to translate the converted feature vector;
[0074] performing attention operation on the obtained data information: setting K head attention mechanisms to calculate the attention coefficient between each adjacent node; performing node splicing, represented as eij = LeakyReLU(a T · [Wh i || Wh j ]), where e ij is the original attention score between node i and node j, LeakyReLU() is an enhanced nonlinear activation function, a T is the transpose of the attention weight vector used to calculate the attention weight between node i and node j, Wh i is the new feature vector of node i after transformation by the weight matrix W, Wh j is the new feature vector of node j after transformation by the weight matrix W, [Wh i || Wh j ] is a weighted summation formula, and [Wh i || Wh j ] = a1Wh i + (1 - a1) Wh j , a1 is a set weight; the attention weight normalization operation is represented as a ij is the normalized attention coefficient;
[0075] The weighted summation of the neighbor node features is represented as where is the new feature representation of node i after updating by the graph attention network, h′ j is the new feature representation of node j after processing by the fully connected layer;
[0076] The obtained data information is calculated by a number of independent attention heads, represented as:
[0077] Given the feature h i of each node, the feature is mapped to a number of subspaces through different linear transformations;
[0078] It is assumed that there are H attention heads, and the feature space dimension of each attention head is d'. There is a corresponding weight matrix W h for each attention head, and h takes values of 1, 2,..., H.
[0079] Each attention head uses its own attention weight to aggregate the features of the neighbor node j of node i , represented as is the feature of node i updated by the hth attention head;
[0080] The outputs of all attention heads are spliced to obtain the output feature is || is a splicing operation;
[0081] Output features The output features are processed using an activation function, denoted as The updated feature vector for node i, and ReLU() is an activation function.
[0082] Step E describes adjusting the feature weight coefficients based on the self-attention mechanism and generating the final entity embedding, which includes the following steps:
[0083] The obtained data information is processed based on the self-attention mechanism, denoted as to generate the final embedding; where Att(Q, K, V) is the final feature embedding, softmax() is an activation function, Q is a query matrix representing the query features of each node, K is a key matrix representing the key features of each node, and V is a value matrix representing the value features of each node, d k is a scaling factor.
[0084] According to the obtained data information, generate the query matrix, key matrix, and value matrix; and through QK T generate an attention weight matrix.
[0085] According to the obtained attention weight matrix, perform weighted summation on V to generate the final entity embedding.
[0086] Step F describes performing confidence evaluation and completion based on the entity embedding obtained in step E, and selecting triplets to update the knowledge graph, which includes the following steps:
[0087] The confidence of the data information calculated using the following formula is obtained:
[0088]
[0089] where Con is the confidence, and z is a normalization factor.
[0090] According to the obtained confidence, the final prediction result is obtained using the following steps:
[0091] According to the size of the confidence, all predicted triplets are sorted, and the higher the confidence, the higher the ranking.
[0092] Set a confidence threshold; when the confidence corresponding to a certain triplet is greater than the confidence threshold, the triplet is determined to be a valid predicted triplet, otherwise the triplet is determined to be an invalid predicted triplet.
[0093] Update all valid predicted triplets to the knowledge graph to enhance the completeness of the graph, and complete and update the knowledge graph.
[0094] The application further provides a system for implementing the method for completing the knowledge graph of the power system, comprising a data acquisition module, a data set construction module, a model construction module, a model training module and a knowledge graph completion module; the data acquisition module, the data set construction module, the model construction module, the model training module and the knowledge graph completion module are sequentially connected; the data acquisition module is used for acquiring data information of the power system and uploading the data information to the data set construction module; the data set construction module is used for constructing a knowledge graph support set and a query set of the power system according to the received data information and the acquired data information and uploading the data information to the model construction module; the model construction module is used for constructing a preliminary model for completing the knowledge graph of the power system based on meta-learning and a graph attention network according to the received data information and uploading the data information to the model training module; the model training module is used for training the constructed preliminary model for completing the knowledge graph of the power system by using the obtained data set, obtaining a model for completing the knowledge graph of the power system and uploading the data information to the knowledge graph completion module; and the knowledge graph completion module is used for completing the knowledge graph of the power system by using the obtained model for completing the knowledge graph of the power system according to the received data information.
[0095] The method for completing the knowledge graph of the power system provided by the application constructs and trains a model for completing the knowledge graph of the power system based on meta-learning and a graph attention network, so that the application can not only complete the knowledge graph of the power system, but also has higher reliability and better accuracy. BRIEF DESCRIPTION OF DRAWINGS
[0096] Figure 1 The application provides a method flowchart of the method.
[0097] Figure 2 The application provides a function module schematic diagram of the system. DETAILED DESCRIPTION
[0098] As shown in the method flowchart of the method, the method for completing the knowledge graph of the power system provided by the application comprises the following steps: Figure 1
[0099] S1. Acquiring data information of the power system;
[0100] S2. Constructing a knowledge graph support set and a query set of the power system according to the data information obtained in step S1;
[0101] S3. Constructing a preliminary model for completing the knowledge graph of the power system based on meta-learning and a graph attention network; specifically comprising the following steps:
[0102] The constructed preliminary model for completing the knowledge graph of the power system comprises the following steps in the processing process:
[0103] A. Constructing a feature extraction network based on meta-learning for extracting embedding features of input data; specifically including the following steps:
[0104] Processing the support set using a first local encoder to obtain the first feature embedding of the support set;
[0105] Processing the query set using a second local encoder to obtain the first feature embedding of the query set;
[0106] Processing the first feature embedding of the support set using a first global encoder to obtain the remote feature embedding of the support set;
[0107] Processing the first feature embedding of the query set using a second global encoder to obtain the remote feature embedding of the query set;
[0108] The processing procedures of the first local encoder and the second local encoder are the same, and each includes the following steps:
[0109] The size of the input entity embedding and the relationship embedding is set to d (preferably 256);
[0110] The obtained data information is subjected to feature extraction by convolution to obtain the local features between entities and adjacent relationships; wherein the kernel size of the convolution is 3x3, the input channel number is d, the output channel number is d, and the step is 1;
[0111] The output of the convolution is processed by an activation function; the activation function f(x) is
[0112] The obtained data information is processed using maximum pooling to achieve dimension reduction; wherein the kernel size of the maximum pooling is 2x2 and the step is 2;
[0113] The obtained data information is subjected to a full connection operation to map the feature information to an embedding output;
[0114] The embedding output is again processed by an activation function; the activation function f(x) is
[0115] The processing procedures of the first global encoder and the second global encoder are the same, and each includes the following steps:
[0116] Adjusting the dimension of the input knowledge graph triplets so that the output embedding dimension is d2;
[0117] Performing graph convolution operation on the obtained data information to generate remote embedding features based on relationship adjacency information; the kernel size of the graph convolution is 1x1, the step is 1, and the output channel number is d2;
[0118] The obtained data information is globally pooled to aggregate embedding of all nodes to generate global features;
[0119] The global features are fully connected to be mapped to embedding output;
[0120] The embedding output is processed by an activation function; the activation function f(x) is
[0121] B. Aligning the embedding features obtained in step A to obtain aligned embedding; specifically comprising the following steps:
[0122] The global feature embedding g S of the support set obtained in step A is Q The global feature embedding g con of the query set is con Spliced to obtain the global feature embedding g S of the support set and the query set after splicing; Q , and a is a set weight;
[0123] The g con is fully connected to map to generate aligned embedding g A ;
[0124] The g A is processed by an activation function; the activation function f(x) is
[0125] The obtained data information is subjected to attention weight calculation operation to obtain the weight matrix of g S , g Q and g A ;
[0126] In addition, during training, the following formula is used for optimization:
[0127] L = Σ||g S -g Q || 2 + λ·R(f θ )
[0128] In the formula, L is the loss function; λ is the regularization coefficient; R(f θ ) is the regularization term;
[0129] C. Based on the aligned embedding obtained in step B, predict the missing edges in the knowledge graph to obtain candidate triplets; specifically comprising the following steps:
[0130] Based on the aligned embedding result obtained in step B, edge prediction and knowledge graph expansion are performed to predict the missing edges in the knowledge graph and generate new candidate triplets;
[0131] The obtained data information is calculated to obtain an extended score and normalized to obtain a new attention distribution;
[0132] The predicted edge set is added to the knowledge graph, candidate edges with a confidence higher than a set value are added to the knowledge graph, and the node set is updated to obtain an extended knowledge graph;
[0133] The alignment embedding result obtained in step B is used for edge prediction and knowledge graph extension, missing edges in the knowledge graph are predicted, and new candidate triples are generated, and the specific steps include the following steps:
[0134] For the alignment embedding result obtained in step B:
[0135] If (h, r,?), t is calculated p1 t is calculated as h p1 = g a -(h+r);
[0136] If (?, r, t), h is calculated p1 h is calculated as h p1 = g a -(r+t);
[0137] A set of triples (h, r, t) is represented by a head entity h, a relationship r and a tail entity t in the knowledge graph, wherein (h, r,?) represents a set of incomplete triples with missing tail entities in the knowledge graph,? is a missing entity; (?, r, t) represents a set of incomplete triples with missing head entities in the knowledge graph; t p1 g is calculated by feature embedding to query the set of tail entities, g a h is the aligned feature embedding, h p1 h is calculated by feature embedding to query the set of head entities;
[0138] The score function score(h, r, t) is used to calculate the score of each candidate edge, and the top several edges with the highest score are selected as the completion candidate edges;
[0139] For the completion candidate edges:
[0140] If (h, r,?), t is calculated p2 t is calculated as h p2 = argmax t score(h, r, t);
[0141] If (?, r, t), h is calculated p2 h is calculated as h p2 = argmax h score(h, r, t);
[0142] wherein, tp2 tail entity predicted by the scoring function; argmax t () denotes the argument function, the value of t when the score is maximum; h p2 head entity predicted by the scoring function; argmax h () denotes the argument function, the value of h when the score is maximum;
[0143] Finally, output the candidate edge set;
[0144] The obtained data information is calculated to obtain an expansion score and normalized to obtain a new attention distribution, and the method comprises the following steps:
[0145] For a missing query entity e n (h, r,?), a candidate entity set composed of adjacent entities e n-1 (h, r, t) is obtained, and an expansion score is initialized, and the candidate entity e n The expansion score S k {e n} in the kth step is
[0146]
[0147] In the formula, e n-1 is an adjacent entity of e n , || is a feature connector, is the query set global feature embedding of the entity e n-1 in the kth step; is the query set global feature embedding of the entity e n in the kth step; MLP() is a multi-layer perception processing function;
[0148] Select a number of edges with the maximum probability to update the knowledge graph;
[0149] Add the selected edges to the edge set E, and add the tail entities that have not been visited to the node set V, complete the expansion of the knowledge graph G, and after k steps, the expansion score of the entity in the expanded graph can be obtained, the score is normalized to obtain a new attention distribution,
[0150] p k (e q ) = softmax(S k {e1},...,S k {e n})
[0151] In the formula, p k (e q ) is the answer score distribution of all graphs; output the probability distribution, if an entity is not added to the expanded graph, the corresponding score is 0;
[0152] D. obtaining the enhanced node embedding of the completed knowledge graph based on the graph neural network, and updating the edge set of the graph neural network to generate the enhanced entity embedding; specifically comprising the following steps:
[0153] processing the data information obtained in step C based on the R-GCN network;
[0154] processing the obtained data information using global pooling to aggregate entity embedding and generate enhanced graph embedding;
[0155] processing the enhanced graph embedding data information through the graph neural network to generate the enhanced entity embedding;
[0156] wherein the processing of the data information obtained in step C based on the R-GCN network specifically comprises the following steps:
[0157] performing graph convolution operation on the input data information; the step of graph convolution is 1;
[0158] performing full connection operation on the obtained data information to perform linear transformation; the full connection operation is represented as h' i =W·h i +b, where h' i is the new feature vector of node i after transformation, W is the weight matrix, h i is the original feature vector of node i, and b is the bias term used to translate the converted feature vector;
[0159] performing attention operation on the obtained data information: setting K head attention mechanisms to calculate the attention coefficients between each adjacent node; performing node splicing, represented as e ij =LeakyReLU(a T ·[Wh i ||Wh j ]), where e ij is the original attention score between node i and node j, LeakyReLU() is an enhanced nonlinear activation function, a T is the transpose of the attention weight vector used to calculate the attention weight between node i and node j, Wh i is the new feature vector of node i after transformation by the weight matrix W, Wh j is the new feature vector of node j after transformation by the weight matrix W, [Wh i ||Wh j ] is a weighted sum algorithm and [Wh i ||Wh j ]=α1Wh i +(1-α1)Wh j, and a1 is a set weight; attention weight normalization operation is performed, denoted as a ij is a normalized attention coefficient;
[0160] The neighbor node features are weighted and summed, denoted as wherein is the new feature representation of node i after the graph attention network update, h′ j is the new feature representation of node j after the full connection layer processing;
[0161] The obtained data information is subjected to feature calculation by a plurality of independent attention heads, denoted as:
[0162] Given the feature h i of each node, the feature is mapped to a plurality of subspaces through different linear transformations;
[0163] It is set that there are H attention heads, and the feature space dimension of each attention head is d'. Each attention head has a corresponding weight matrix W h , and h takes values of 1, 2,..., H.
[0164] Each attention head uses its own attention weight to weight and aggregate the features of the neighbor node j of node i, denoted as is the feature of node i updated by the hth attention head. The outputs of all attention heads are spliced to obtain the output feature
[0165] is || is a splicing operation.
[0166] The output feature is processed by an activation function, denoted as is the updated feature vector of node i, and ReLU() is an activation function.
[0167] E. Based on the self-attention mechanism, the feature weight coefficient is adjusted, and the final entity embedding is generated; specifically including the following steps:
[0168] The obtained data information is processed based on the self-attention mechanism, denoted as to generate the final embedding; wherein Att(Q, K, V) is the final feature embedding, softmax() is an activation function; Q is a query matrix, representing the query feature of each node; K is a key matrix, representing the key feature of each node; V is a value matrix, representing the value feature of each node; d k is a scaling factor.
[0169] According to the obtained data information, a query matrix, a key matrix and a value matrix are generated; and through QK T An attention weight matrix is generated;
[0170] According to the obtained attention weight matrix, V is weighted and summed to generate a final entity embedding;
[0171] F. According to the entity embedding obtained in step E, confidence evaluation and completion are performed, and a triple pair knowledge graph is updated; specifically including the following steps:
[0172] The confidence of the data information obtained by the following formula is calculated:
[0173]
[0174] In the formula, Con is the confidence; z is a normalization factor;
[0175] According to the obtained confidence, the following steps are used to obtain the final prediction result:
[0176] According to the size of the confidence, all predicted triples are sorted, and the higher the confidence, the higher the ranking;
[0177] Set a confidence threshold; when the confidence corresponding to a certain triple is greater than the confidence threshold, the triple is determined to be an effective predicted triple, otherwise the triple is determined to be an invalid predicted triple;
[0178] All effective predicted triples are updated to the knowledge graph to enhance the integrity of the graph, and the knowledge graph is completed and updated;
[0179] S4. The power system knowledge graph completion model is trained by using the data set obtained in step S2 to obtain the power system knowledge graph completion model.
[0180] S5. The power system knowledge graph completion model obtained in step S4 is used to complete the power system knowledge graph.
[0181] As Figure 2The system of the application is shown in the functional module schematic diagram: the system for implementing the knowledge graph completion method for the power system disclosed in the application comprises a data acquisition module, a data set construction module, a model construction module, a model training module and a knowledge graph completion module; the data acquisition module, the data set construction module, the model construction module, the model training module and the knowledge graph completion module are sequentially connected; the data acquisition module is used for acquiring data information of the power system and uploading the data information to the data set construction module; the data set construction module is used for constructing a knowledge graph support set and a query set of the power system according to the received data information and the acquired data information and uploading the data information to the model construction module; the model construction module is used for constructing a preliminary model for completing the knowledge graph of the power system based on meta-learning and a graph attention network according to the received data information and uploading the data information to the model training module; the model training module is used for training the constructed preliminary model for completing the knowledge graph of the power system by using the obtained data set, obtaining a model for completing the knowledge graph of the power system and uploading the data information to the knowledge graph completion module; and the knowledge graph completion module is used for completing the knowledge graph of the power system by using the obtained model for completing the knowledge graph of the power system according to the received data information.
Claims
1. A knowledge graph completion method for a power system, comprising the following steps: S1. obtaining data information of the power system; S2. constructing a knowledge graph support set and a query set of the power system according to the data information obtained in step S1; S3. constructing a power system knowledge graph completion primary model based on meta-learning and a graph attention network; specifically comprising the following steps: The constructed power system knowledge graph completion primary model, the processing process comprises the following steps: A. Construct a feature extraction network based on meta-learning, which is used to extract embedding features of input data; Comprising the following steps: The support set is processed by a first local encoder to obtain a support set first feature embedding; The query set is processed by a second local encoder to obtain a query set first feature embedding; The support set first feature embedding is processed by a first global encoder to obtain a support set long-distance feature embedding; The query set first feature embedding is processed by a second global encoder to obtain a query set long-distance feature embedding; B. Aligning the embedding features obtained in step A to obtain aligned embedding; C. Based on the aligned embedding obtained in step B, predicting the missing edges in the knowledge graph to obtain candidate triples; comprising the following steps: Based on the aligned embedding result obtained in step B, edge prediction and knowledge graph expansion are performed to predict the missing edges in the knowledge graph and generate new candidate triples; The obtained data information is calculated to obtain an expansion score and is normalized to obtain a new attention distribution; The predicted edge set is added to the knowledge graph, the candidate edges with a confidence higher than a set value are added to the knowledge graph, and the node set is updated to obtain an expanded knowledge graph; D. Based on the graph neural network, the completed knowledge graph enhanced node embedding is obtained, and the edge set of the graph neural network is updated to generate enhanced entity embedding; comprising the following steps: The data information obtained in step C is processed based on the R-GCN network; The obtained data information is processed by global pooling to aggregate entity embedding and generate enhanced graph embedding; The enhanced graph embedding data information is processed by the graph neural network to generate enhanced entity embedding; E. Based on the self-attention mechanism, adjust the feature weight coefficient, and generate the final entity embedding; F. According to the entity embedding obtained in step E, perform confidence evaluation and completion, and select triples to update the knowledge graph; S4. Using the data set obtained in step S2, the power system knowledge graph completion primary model constructed in step S3 is trained to obtain a power system knowledge graph completion model; S5. Using the power system knowledge graph completion model obtained in step S4, the knowledge graph of the power system is completed. 2.The knowledge graph completion method for power systems of claim 1, characterized in that Step A constructs a feature extraction network based on meta-learning, which is used to extract embedding features of input data, specifically comprising the following steps: The processing process of the first local encoder and the second local encoder is the same, which comprises the following steps: The size of the input entity embedding and the relationship embedding is set to d; The obtained data information is processed by convolution to extract features, so as to obtain the local features between entities and adjacent relationships; wherein the kernel size of the convolution is 3x3, the input channel number is d, the output channel number is d, and the step is 1; The output of the convolution is processed through an activation function; the activation function f(x) is The obtained data information is processed by maximum pooling to realize dimension reduction, wherein the kernel size of the maximum pooling is 2x2 and the step length is 2; The obtained data information is subjected to full connection operation to map the feature information into embedding output; The embedded output is again processed by an activation function; the activation function f(x) is The processing procedures of the first global encoder and the second global encoder are the same, and each includes the following steps: The input knowledge graph triplets are subjected to dimension adjustment, so that the output embedding dimension is d2; The obtained data information is subjected to graph convolution operation to generate long-distance embedding features based on relationship adjacency information; the kernel size of the graph convolution is 1x1, the step length is 1, and the output channel number is d2; The obtained data information is subjected to global pooling processing to aggregate the embeddings of all nodes to generate global features; The global features are subjected to full connection operation to be mapped into embedding output; The embedded output is processed by an activation function; the activation function f(x) is 3.The knowledge graph completion method for power systems of claim 2, characterized in that The step B aligns the embedding features obtained in the step A to obtain aligned embedding, and specifically includes the following steps: concatenate the global feature embedding g of the support set obtained in step A S and the global feature embedding g of the query set Q to obtain the global feature embedding g of the support set and the query set after splicing con g con = αg S + (1-α)g Q , α is a set weight; g con A fully connected operation is performed to map the generated aligned embedding g A ; g A with an activation function; the activation function f(x) is The obtained data information is subjected to attention weight calculation operation to obtain g S , g Q and g A weight matrix. 4.The knowledge graph completion method for power systems of claim 3, wherein The step C predicts the missing edges in the knowledge graph based on the aligned embedding obtained in the step B to obtain candidate triplets, and specifically includes the following steps: The step C predicts the missing edges in the knowledge graph based on the aligned embedding obtained in the step B to obtain candidate triplets, and specifically includes the following steps: For the aligned embedding obtained in the step B: If (h, r,?), then compute t p1 For t p1 = g a -(h + r); If (?, r, t), then compute h p1 For h p1 = g a - (r + t); In the knowledge graph, a set of triples (h, r, t) is represented by the head entity h, the relation r, and the tail entity t, where (h, r, ?) represents an incomplete triple in the knowledge graph with the tail entity missing, and ? represents the missing entity; (?, r, t) represents an incomplete triple in the knowledge graph with the head entity missing; t p1 To calculate the tail entity in the query set through feature embedding, g a is the feature embedding after alignment, h p1 To calculate the head entity in the query set through feature embedding; A score function score(h, r, t) is used to calculate the score of each candidate edge, and the top several edges with the highest scores are selected as the completed candidate edges; For the completed candidate edges: If (h, r,?), then compute t p2 For t p2 = argmax t score(h, r, t); If (?, r, t), then compute h p2 For h p2 = argmax h score(h, r, t); where t p2 is the tail entity predicted by the scoring function; argmax t () denotes the argument function, the value of t at which the score is maximized; h p2 is the head entity predicted by the scoring function; argmax h () denotes the argument function, the value of h at which the score is maximized; Finally, the candidate edge set is output; The step D calculates the expansion score of the obtained data information and normalizes it to obtain a new attention distribution, and specifically includes the following steps: For missing query entities e n (h,r,?), obtain a set of candidate entities consisting of neighboring entities e n-1 (h,r,t) and initialize an expansion score, candidate entity e n The expansion score S k {e n} is where e n-1 is the adjacent entity of e n , || is a feature connector, is the query set global feature embedding of the k-th step entity e n-1 ; is the query set global feature embedding of the k-th step entity e n ; MLP() is a multi-layer perceptron processing function; The several edges with the maximum probability are selected to update the knowledge graph; The selected edges are added to the edge set E, and the tail entities that have not been visited are added to the node set V, so that the expansion of the knowledge graph G is completed, and after k steps, the expansion score of the entity in the expanded graph is obtained, the score is normalized to obtain a new attention distribution, p k (e q )=softmax(S k {e1},...,S k {e n}) where p k (e q ) is the answer score distribution for all figures; the output probability distribution, where if an entity is not added to the extended graph, the corresponding score is 0. 5.The knowledge graph completion method for power systems of claim 4, characterized in that The step D calculates the expansion score of the obtained data information and normalizes it to obtain a new attention distribution, and specifically includes the following steps: The step C is processed based on the R-GCN network, and specifically includes the following steps: The input data information is subjected to graph convolution operation; the step length of the graph convolution is 1; The obtained data information is subjected to a full connection operation, thereby performing a linear transformation; the full connection operation is represented as h' = W - h + b i i where h' is a new feature vector of node i after transformation, W is a weight matrix, h is an original feature vector of node i, and b is a bias term used to translate the converted feature vector. i i where h' is a new feature vector of node i after transformation, W is a weight matrix, h is an original feature vector of node i, and b is a bias term used to translate the converted feature vector. The obtained data information is subjected to attention operation: K head attention mechanisms are set to calculate the attention coefficients between each adjacent node; node splicing is performed, denoted as e ij = LeakyReLU(a T · [Wh i || Wh j ]) where e ij is the original attention score between node i and node j, LeakyReLU() is an enhanced nonlinear activation function, a T is the transpose of the attention weight vector used to calculate the attention weight between node i and node j, Wh i is the new feature vector of node i after being transformed by the weight matrix W, Wh j is the new feature vector of node j after being transformed by the weight matrix W, [Wh i || Wh j ] is a weighted summation formula and [Wh i || Wh j ] = a1Wh i + (1-a1)Wh j , a1 is a set weight; The attention weight normalization operation is represented as α ij is the normalized attention coefficient; The neighbor node features are weighted and summed, denoted as wherein is the new feature representation of node i after the graph attention network update, h' j is the new feature representation of node j after the fully connected layer processing; The obtained data information is subjected to feature calculation by using several independent attention heads, and is represented as: Given the features h of each node i are mapped to several subspaces by different linear transformations; If H attention heads exist, and the feature space dimension of each attention head is d', then a corresponding weight matrix W exists for each attention head h , and h takes values of 1, 2,..., H. Each attention head adopts its own attention weight Weighted aggregation of features of neighbor node j of node i is denoted as is the updated feature of node i through the hth attention head concatenate the outputs of all attention heads to obtain an output feature for || is a concatenation operation; Output features with activation function, denoted as updated feature vector for node i, and ReLU() is the activation function. 6.The method for knowledge graph completion of power systems according to claim 5, characterized in that The step E adjusts the feature weight coefficient based on the self-attention mechanism and generates the final entity embedding, and specifically includes the following steps: The obtained data information is processed based on a self-attention mechanism, and is expressed as to generate a final embedding; wherein, Att(Q, K, V) is the final feature embedding, softmax() is an activation function; Q is a query matrix, representing the query feature of each node; K is a key matrix, representing the key feature of each node; V is a value matrix, representing the value feature of each node; d k is a scaling factor; According to the obtained data information, a query matrix, a key matrix and a value matrix are generated; and a QK T An attention weight matrix is generated; The attention weight matrix is obtained, and the final entity embedding is generated by weighted summation.
7. The knowledge graph completion method for power systems of claim 6, wherein The step F performs self-confidence evaluation and completion based on the entity embedding obtained in the step E, and selects triplets to update the knowledge graph, and specifically includes the following steps: The confidence of the obtained data information is calculated by using the following formula: In the formula, Con is the confidence level; z is a normalization factor; According to the obtained confidence level, the following steps are used to obtain the final prediction result: According to the size of the confidence level, all the predicted triplets are sorted, and the higher the confidence level, the higher the ranking; Set a confidence threshold; when the confidence level corresponding to a certain triplet is greater than the confidence threshold, the triplet is determined to be an effective prediction triplet, otherwise the triplet is determined to be an invalid prediction triplet; All effective prediction triplets are updated to the knowledge graph to enhance the integrity of the graph, and the knowledge graph is completed and updated. 8.A system for implementing the knowledge graph completion method for power systems according to any one of claims 1 to 7, characterized in that The system comprises a data acquisition module, a data set construction module, a model construction module, a model training module and a knowledge graph completion module; the data acquisition module, the data set construction module, the model construction module, the model training module and the knowledge graph completion module are sequentially connected; the data acquisition module is used to acquire data information of the power system and upload the data information to the data set construction module; The data set construction module is used to construct a knowledge graph support set and a query set of the power system according to the received data information and the acquired data information, and upload the data information to the model construction module; The model construction module is used to construct a preliminary model for completing the knowledge graph of the power system based on meta-learning and graph attention network according to the received data information, and upload the data information to the model training module; The model training module is used to train the constructed preliminary model for completing the knowledge graph of the power system by using the obtained data set, to obtain a power system knowledge graph completion model, and upload the data information to the knowledge graph completion module; The knowledge graph completion module is used to complete the knowledge graph of the power system by using the obtained power system knowledge graph completion model according to the received data information.
Citation Information
Patent Citations
Metalearning-based small sample knowledge graph completion method
CN115438192A
Knowledge graph completion method based on global and local comparative learning
CN117668256A