Power equipment knowledge graph completion method and system based on Mamb-GPT model
By introducing the Mamba-GPT model and a prior knowledge injection mechanism in power equipment inspection, combined with the multi-layer Mamba block structure and dynamic update mechanism, the efficiency and accuracy problems in the construction and completion of power equipment knowledge graphs are solved, and the efficiency and accuracy problems in the construction and completion of power equipment are achieved. Efficient and accurate knowledge graph completion has improved the knowledge management and fault diagnosis capabilities of power equipment inspection.
Patent Information
- Application Number
- CN202411030988.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-07-30
AI Technical Summary
The existing method of power equipment inspection knowledge graph construction relies on manual labeling to consume time and effort, making it difficult to ensure the comprehensiveness and timeliness of knowledge, and shallow neural networks or traditional machine learning algorithms are difficult to make full use of the semantics of large-scale pre-trained language models. Understanding ability leads to low knowledge acquisition efficiency, insufficient domain knowledge integration and limited reasoning ability.
Introduce the Mamba-GPT model and a priori knowledge injection mechanism dedicated to power equipment. Through the multi-layer Mamba block structure and dynamic attention mechanism, the selection mechanism and loss function are optimized to achieve efficient and accurate completion of the power equipment knowledge graph, and are staged Dynamic updates to accommodate different time scales and data new and old levels.
It significantly improves the model's understanding of domain knowledge and long sequence processing efficiency, ensures the accuracy and interpretability of knowledge graph completion, improves the integrity and application value of power equipment inspection knowledge graphs, and enhances fault diagnosis and Maintain support capabilities in decision-making.
Smart Images

Figure CN119128166A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power equipment inspection, and specifically to a method and system for completing a knowledge graph of power equipment based on a Mamba-GPT model. Background Art
[0002] In recent years, with the rapid development of artificial intelligence technology, large language models have made significant progress in the field of natural language processing. Among them, the GPT (Generative Pre-trained Transformer) model based on the Transformer architecture has attracted much attention due to its powerful language understanding and generation capabilities. However, the traditional GPT model has problems such as high computational complexity and large memory consumption when processing long sequence inputs. To solve these problems, the Mamba block came into being. It greatly improved the efficiency and performance of the model by introducing innovative mechanisms such as the selective state space model (S4) and structured state space sequence (SSM). At the same time, knowledge graphs, as a structured knowledge representation method, play an increasingly important role in professional fields such as power equipment inspection. Knowledge graphs can not only effectively organize and manage complex domain knowledge, but also provide strong support for intelligent decision-making and fault diagnosis.
[0003] However, the existing knowledge graph construction methods for power equipment inspection still have some shortcomings. First, the traditional knowledge graph construction process often relies on manual annotation and expert knowledge, which is not only time-consuming and labor-intensive, but also difficult to ensure the comprehensiveness and timeliness of knowledge. Secondly, most of the existing knowledge graph completion methods are based on shallow neural networks or traditional machine learning algorithms, which make it difficult to fully utilize the semantic understanding capabilities of large-scale pre-trained language models. Furthermore, in professional fields such as power equipment inspection, how to effectively integrate domain-specific prior knowledge and improve the accuracy and interpretability of knowledge graph completion is still an urgent problem to be solved. Finally, existing methods often face challenges such as low efficiency and limited reasoning ability when dealing with knowledge graphs with long sequences and complex relationships.
[0004] At present, the knowledge graph completion technology for power equipment inspection still has problems such as low knowledge acquisition efficiency, insufficient domain knowledge integration, and limited reasoning ability. The present invention proposes a method for completing the knowledge graph of power equipment based on the Mamba-GPT model, aiming to solve the above problems. The method belongs to the field of artificial intelligence and knowledge engineering technology. By combining the efficient sequence processing capability of the Mamba block and the powerful language understanding ability of the GPT model, and introducing a priori knowledge injection mechanism dedicated to power equipment, the efficient and accurate completion of the knowledge graph of power equipment inspection is achieved. Summary of the invention
[0005] In view of the problems of existing power equipment inspection knowledge graph construction and completion methods, such as low knowledge acquisition efficiency, insufficient domain knowledge fusion, and low efficiency in processing long sequences and complex relationships, the present invention is proposed.
[0006] Therefore, the technical problem solved by the present invention is: to introduce the Mamba-GPT model and a priori knowledge injection mechanism dedicated to power equipment, to improve the model's ability to understand domain knowledge and long sequence processing efficiency, to dynamically update the completed power equipment inspection knowledge graph in stages, so that the system can update the knowledge graph in time according to different time scales and the newness of the data to adapt to different application scenarios and update needs.
[0007] To solve the above technical problems, the present invention provides the following technical solutions: a method for completing a knowledge graph of electric power equipment based on a Mamba-GPT model, comprising collecting and preprocessing data related to electric power equipment inspection, constructing a knowledge graph of electric power equipment inspection based on the preprocessed data related to electric power equipment inspection, and encoding text information in the knowledge graph; constructing a Mamba-GPT model, introducing a priori knowledge injection mechanism dedicated to electric power equipment, and optimizing the selection mechanism of Mamba blocks; inputting the text information in the encoded knowledge graph into the Mamba-GPT model, completing the knowledge graph of electric power equipment inspection, and dynamically updating and outputting the completed knowledge graph of electric power equipment inspection in stages.
[0008] As a preferred solution of the method for completing the knowledge graph of electric equipment based on the Mamba-GPT model of the present invention, wherein: constructing a knowledge graph of electric equipment inspection, and encoding the text information in the knowledge graph, including defining entities, the entities include electric equipment, components, fault types, maintenance operations, and establishing relationships between entities to form triples; converting the triples into text sequences, distinguishing different types of entities and relationships by marking; using the Word2Vec algorithm to generate word vectors; performing position encoding according to the position of the word vector in the text sequence, and using the position encoding as input.
[0009] As a preferred solution of the electric power equipment knowledge graph completion method based on the Mamba-GPT model of the present invention, wherein: using the Word2Vec algorithm, generating word vectors includes, in the Skip-Gram model, predicting the context words by a given central word, and the calculation formula of the loss function of the Skip-Gram model is as follows:
[0010]
[0011] Among them, L represents the loss function, T represents the length of the text sequence, k represents the window size, j is an unsummed variable with no actual physical meaning, and P(w t+j |wt ) indicates that the input word is w t When, word w t+j Probability of occurrence;
[0012] Among them, P(w t+j |w t ) is calculated by the soft maximization function, P(w t+j |w t ) is calculated as follows:
[0013]
[0014] in, and Represent the embedding vectors of the output word and the input word respectively, V represents the vocabulary, and v w Represents the embedding vector of word w, where w represents the vocabulary.
[0015] As a preferred solution of the method for completing the knowledge graph of electric equipment based on the Mamba-GPT model of the present invention, the formula taking the position code as input is as follows:
[0016] PE (pos2i) =sin(pos / 10000 2i / d )
[0017] PE (pos,2i+1) =cos(pos / 10000 2i / d )
[0018] Among them, PE represents the output value of position embedding, pos represents the position of the word in the text, d represents the maximum length of the word vector, and i represents the text position.
[0019] As a preferred solution of the electric power equipment knowledge graph completion method based on the Mamba-GPT model of the present invention, wherein: constructing the Mamba-GPT model, introducing a priori knowledge injection mechanism dedicated to electric power equipment, optimizing the selection mechanism of the Mamba block includes constructing a Mamba-GPT model structure based on the Mamba block, establishing the relationship between the input and output sequences of the Mamba block, and the calculation formula for the relationship between the input and output sequences of the Mamba block is as follows:
[0020]
[0021] y t =Ch t
[0022] Among them, x t represents the tth vector in the input sequence, h t represents the implicit state space, C are matrices, yt Represent the model output; construct a special knowledge graph in the field of power equipment, introduce knowledge graph data in related fields, and integrate the node representation and relationship of the knowledge graph into the knowledge graph in the field of power equipment through transfer learning; design a transfer learning strategy so that the knowledge graph can learn common features and patterns from knowledge in other fields; introduce a priori knowledge selection module based on dynamic attention mechanism in the input layer of Mamba block; fuse the node representation of the cross-domain knowledge graph obtained through transfer learning with the position encoding as input; add consistency constraints to the loss function of Mamba-GPT model, which include node consistency constraints and edge consistency constraints. The formula of node consistency constraints is as follows:
[0023]
[0024] Among them, L node represents the node consistency loss, υ i Represents a node in the knowledge graph, v i Represents the node υ generated by the model i The vector representation of Represents node υ in the knowledge graph i The true vector representation of ; the formula of the edge consistency constraint is as follows:
[0025]
[0026] Among them, L edge represents the edge consistency loss, (υ i ,υ j ) represents the connection node υ in the knowledge graph i and j One side of ij Represents the edge generated by the model (υ i ,υ j ), Represents the edge (υ i ,υ j ) is the true vector representation; the node consistency loss and the edge consistency loss are combined as the overall knowledge consistency loss, and the calculation formula of the overall knowledge consistency loss is as follows:
[0027] L consistency =λ node L node +λ edge L edge
[0028] Among them, L consistenyc represents the overall knowledge consistency loss, λ node represents the weight parameter used to balance the node consistency loss, λ noderepresents the weight parameter used to balance the edge consistency loss, L node represents the node consistency loss, L edge represents the edge consistency loss; a selection mechanism is introduced in the Mamba block so that and C can be changed with the input x t Changes, and the mapping relationship can be learned, the formula of the mapping relationship is as follows:
[0029] Δ=S Δ (x) = softplus(Linear(x))
[0030] C=S C (x)=Linear(x)
[0031] B=S B (x)=Linear(x)
[0032]
[0033] Among them, Linear(.) represents a linear function, Δ represents the sampling interval, S Δ (x) indicates that Δ is a function of the input x, softplus(Linear(x)) indicates a combined function, S C (x) means C is a function of input x, S B (x) means B is a function of input x, represents the matrix, represents a matrix, ΔA represents the product of Δ and A, I represents the identity matrix, and ΔB represents the product of Δ and B;
[0034] softplus(x)=log(1+e x )
[0035] Among them, softplus(x) represents the activation function, and x represents any independent variable describing the function; multiple layers of Mamba blocks are composed into a Mamba-GPT model.
[0036] As a preferred solution of the method for completing the knowledge graph of electric equipment based on the Mamba-GPT model of the present invention, the completion of the knowledge graph of electric equipment inspection includes: inputting the pre-processed data related to the electric equipment inspection into the Mamba-GPT model; converting the input text sequence into a vector sequence through multi-layer Mamba blocks; decoding the vector sequence to generate completed text information; converting the completed text information into a new knowledge graph triple to achieve the completion of the knowledge graph.
[0037] As a preferred solution of the method for completing the knowledge graph of electric equipment based on the Mamba-GPT model of the present invention, the power equipment inspection knowledge graph after dynamic updating in stages includes collecting short-term data, medium-term data and long-term data in daily inspection reports respectively, and preprocessing the collected short-term data, medium-term data and long-term data respectively; generating new knowledge triples according to the preprocessed short-term data, medium-term data and long-term data respectively, and calculating the loss function respectively; the formula of the loss function in the short-term update process is as follows:
[0038]
[0039] Among them, L short represents the loss function used for short-term updates, T represents the total number of moments, and f(·) represents the loss function based on the short-term prediction data x t and the current parameter θ t The generated new knowledge triples, y t represents the actual data point at time t, x s represents short-term data, θ t represents the current parameter, γ represents the regularization parameter, and M represents the parameter θ t The total number of t,j represents the jth parameter at time t, θ t-1,j represents the jth parameter at the t-1th moment; the formula of the loss function in the mid-term update process is as follows:
[0040]
[0041] Among them, L mid represents the loss function used for mid-term update, T represents the total number of moments, and g(·) represents the loss function used for mid-term prediction data x m and the current parameter θ t The generated new knowledge triples, y t represents the actual data point at time t, x m represents mid-term data, θ t represents the current parameter, β and λ represent regularization parameters, and M represents parameter θ t The total number of t,j represents the jth parameter at time t, θ t-1,j represents the jth parameter at the t-1th time, conflict(·) represents the conflict function, h, r, t represent the triple elements of the knowledge triple, and K represents the updated knowledge graph; the formula of the loss function in the long-term update process is as follows:
[0042]
[0043] Among them, L longrepresents the loss function used for long-term update, T represents the total number of moments, and h(·) represents the loss function based on the long-term prediction data x l and the new knowledge triples generated by the parameter set θ, y t represents the actual data point at time t, x l represents long-term data, θ represents the parameter set, α and κ both represent regularization parameters, M represents the total number of parameters θ, θ j represents the jth parameter, conflict(·) represents the conflict function, h, r, t represent the triple elements of the knowledge triples respectively, and K represents the updated knowledge graph; the gradient of the loss function required for the update is calculated, and the optimization algorithm is used to update the parameters in the completed power equipment inspection knowledge graph.
[0044] Another object of the present invention is to provide a power equipment knowledge graph completion system based on the Mamba-GPT model, including: an encoding module, which is used to collect and preprocess data related to power equipment inspection, construct a power equipment inspection knowledge graph based on the preprocessed data related to power equipment inspection, and encode the text information in the knowledge graph; a model construction module, which is used to construct the Mamba-GPT model, introduce a priori knowledge injection mechanism dedicated to power equipment, and optimize the Mamba block selection mechanism; a completion module, which is used to input the text information in the encoded knowledge graph into the Mamba-GPT model, complete the power equipment inspection knowledge graph, and dynamically update the completed power equipment inspection knowledge graph in stages and output it.
[0045] A computer device includes a memory and a processor, wherein the memory stores a computer program, and is characterized in that when the processor executes the computer program, the steps of the method for completing the knowledge graph of electric power equipment based on the Mamba-GPT model are implemented as described above.
[0046] A computer-readable storage medium having a computer program stored thereon, characterized in that when the computer program is executed by a processor, the steps of the method for completing the knowledge graph of electric power equipment based on the Mamba-GPT model are implemented as described above.
[0047] Beneficial effects of the present invention: The present invention provides a high-quality knowledge base for the field of power equipment inspection through systematic data processing and knowledge graph construction. The introduction of the Mamba-GPT model and the prior knowledge injection mechanism dedicated to power equipment significantly improves the model's ability to understand domain knowledge and the efficiency of long sequence processing. The use of knowledge transfer and consistency constraint methods ensures the accuracy and reliability of knowledge graph completion. The application of a multi-layer Mamba block structure realizes an efficient knowledge graph completion process. Through the synergistic effect of these steps, not only the integrity and accuracy of the power equipment inspection knowledge graph are improved, but also the application value of the knowledge graph in equipment fault diagnosis, maintenance decision-making and knowledge management is enhanced. The completed power equipment inspection knowledge graph is dynamically updated and output in stages, and the knowledge graph can be updated in time to adapt to different application scenarios and update requirements according to different time scales and the newness of the data. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0049] Figure 1 The model structure of a single Mamba block;
[0050] Figure 2 Mamba-GPT model architecture;
[0051] Figure 3 A schematic diagram of the structure of a computer device. DETAILED DESCRIPTION
[0052] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without creative work should fall within the scope of protection of the present invention.
[0053] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0054] Example 1
[0055] Reference Figure 1 to Figure 3 , as an embodiment of the present invention, provides a method for completing the knowledge graph of power equipment based on the Mamba-GPT model.
[0056] S1: Collect and preprocess data related to power equipment inspection, construct a knowledge graph for power equipment inspection based on the preprocessed data related to power equipment inspection, and encode the text information in the knowledge graph.
[0057] Specifically, collecting data related to power equipment inspection and preprocessing it includes collecting text data from inspection reports, maintenance records and operation manuals, using word segmentation tools to split the text into words or phrases, removing irrelevant stop words, identifying and annotating entities in the text, extracting key fields, unifying the format of data from different sources and merging them into a unified database or file, and performing data cleaning.
[0058] Furthermore, a knowledge graph of power equipment inspection is constructed, and the text information in the knowledge graph is encoded, including defining entities, including power equipment, components, fault types, maintenance operations, and establishing relationships between entities; converting triples into text sequences, designing tags, and distinguishing different types of entities and relationships; using the Word2Vec algorithm to generate word vectors; performing position encoding according to the position of the word in the text sequence, and using the position encoding as input.
[0059] Specifically, the Knowledge Graph is a complex structured data model used to represent and organize large-scale knowledge information. Its core structure consists of nodes and edges, forming an interconnected network. Nodes represent entities, which can be specific people, places, organizations, or abstract concepts or events. Edges represent semantic relationships between entities. The basic unit of the Knowledge Graph is a triple (subject-relationship-object). Since the graph structure of the Knowledge Graph is essentially different from traditional serialized text data, special data conversion and preprocessing are required to apply the Knowledge Graph to models based on sequence processing such as Mamba-GPT.
[0060] Furthermore, the data conversion method is to convert the task of knowledge graph completion into the task of text prediction. Assume that the knowledge graph for power equipment inspection includes triples: (transformer insulation failure - cause - transformer oil decomposition); (transformer oil decomposition - cause - oil chromatogram change); in order to obtain the triple of (oil chromatogram change - description - transformer insulation failure) through the above two triples, it is necessary to encode the text information in the knowledge graph first.
[0061] Furthermore, the text information in the knowledge graph is encoded, that is, the Chinese text is encoded into a word vector that can be processed by the neural network. The words in the text are converted into word vectors using the Word2Vec algorithm. Word2Vec mainly has two model structures, namely Skip-Gram and CBOW (Continuous BagofWords). The present invention uses the Skip-Gram model. In the Skip-Gram model, the goal is to predict the context words through a given central word. Specifically, for a text sequence {w1,w2,…,w T}, the Skip-Gram model tries to maximize the center word w during training t Its context word w t-k ,…,w t+k (where k is the window size). The loss function of the Skip-Gram model can be expressed as:
[0062]
[0063] Among them, L represents the loss function, T represents the length of the text sequence, k represents the window size, j is an unsummed variable with no actual physical meaning, and P(w t+j |w t ) indicates that the input word is w t When, word w t+j Probability of occurrence;
[0064] Among them, P(w t+j |w t ) is calculated by the soft maximization function, P(w t+j |w t ) is calculated as follows:
[0065]
[0066] in, and Represent the embedding vectors of the output word and the input word respectively, V represents the vocabulary, and v w Represents the embedding vector of word w, where w represents the vocabulary.
[0067] Furthermore, since the cost of directly calculating Softmax is very high, approximate methods such as negative sampling or hierarchical Softmax are usually used to optimize the training process.
[0068] Furthermore, after the Word2Vec algorithm, each word in the phrase in the triple is converted into a corresponding word vector, each input triple is converted into a vector sequence, and the input multiple vector sequences are connected head to tail in sequence to form the entire input vector sequence.
[0069] Furthermore, since the words in the text have a specific arrangement order, it is necessary not only to convert the words into vectors, but also to embed the position information into the input model. The formula for position embedding is as follows:
[0070] PE (pos2i) =sin(pos / 10000 2i / d ),
[0071] PE (pos,2i+1) =cos(pos / 10000 2i / d )
[0072] Among them, PE represents the output value of position embedding, pos represents the position of the word in the text, d represents the maximum length of the word vector, and i represents the text position.
[0073] Furthermore, the vector sequence of the positional encoding and the text is added together to obtain the final vector sequence as the input of Mamba-GPT.
[0074] S2: Construct the Mamba-GPT model, introduce the prior knowledge injection mechanism dedicated to power equipment, and optimize the selection mechanism of the Mamba block.
[0075] Specifically, the basic structure of the Mamba-GPT model is the Mamba block, also known as the Selective State Space Modules, which works as follows: Figure 1 The working principle of the Mamba block can be divided into two parts: the state space model and the selection mechanism. The input of the Mamba block is a vector sequence, and the output is also a vector sequence.
[0076] Furthermore, the Mamba block models the relationship between the input and output sequences using a state space model, and the calculation formula for the relationship between the input and output sequences of the Mamba block is as follows:
[0077]
[0078] y t =Ch t
[0079] Among them, x t represents the tth vector in the input sequence, h tRepresents the implicit state space, which is also represented by a vector. From the formula, it can be seen that the implicit space depends on all vectors before the t-th input vector, and thus has a memory function. C are matrices, y t Represents the model output;
[0080] Furthermore, a dedicated knowledge graph in the field of power equipment is constructed, and knowledge graph data in related fields is introduced. Through transfer learning, the node representation and relationships of the knowledge graph are integrated into the knowledge graph in the field of power equipment.
[0081] Furthermore, a transfer learning strategy is designed to enable the knowledge graph to learn common features and patterns from knowledge in other fields. A priori knowledge selection module based on the dynamic attention mechanism is introduced into the input layer of the Mamba block. The node representation of the cross-domain knowledge graph obtained through transfer learning is fused with the position encoding as the input. A consistency constraint is added to the loss function of the Mamba-GPT model. The consistency constraint includes node consistency constraint and edge consistency constraint. The formula of node consistency constraint is as follows:
[0082]
[0083] Among them, L node represents the node consistency loss, υ i Represents a node in the knowledge graph, v i Represents the node υ generated by the model i The vector representation of Represents node υ in the knowledge graph i The true vector representation of .
[0084] Furthermore, the formula for the edge consistency constraint is as follows:
[0085]
[0086] Among them, L edge represents the edge consistency loss, (υ i ,υ j ) represents the connection node υ in the knowledge graph i and j One side of ij Represents the edge generated by the model (υ i ,υ j ), Represents the edge (υ i ,υ j ) is the true vector representation of .
[0087] Furthermore, the node consistency loss and edge consistency loss are combined as the overall knowledge consistency loss. The calculation formula of the overall knowledge consistency loss is as follows:
[0088] L consistency =λ node L node +λ edge L edge
[0089] Among them, L consistenyc represents the overall knowledge consistency loss, λ node represents the weight parameter used to balance the node consistency loss, λ node represents the weight parameter used to balance the edge consistency loss, L node represents the node consistency loss, L edge represents the edge consistency loss.
[0090] Furthermore, in order to make different inputs have different effects on the model state, a selection mechanism is introduced in the Mamba block, so that A, B and C can all be affected by the input x. t Changes, and the mapping relationship can be learned, and its mapping relationship is expressed as:
[0091] Δ=S Δ (x) = softplus(Linear(x))
[0092] C=S C (x)=Linear(x)
[0093] B=S B (x)=Linear(x)
[0094]
[0095] Among them, Linear(.) represents a linear function, Δ represents the sampling interval, S Δ (x) indicates Δ is a function of the input x, softplus(Linear(x)) represents a combined function, S C (x) means C is a function of input x, S B (x) means B is a function of input x, represents the matrix, represents a matrix, ΔA represents the product of Δ and A, I represents the identity matrix, and ΔB represents the product of Δ and B;
[0096] softplus(x)=log(1+e x )
[0097] Among them, softplus(x) represents the activation function, and x represents any independent variable describing the function.
[0098] S3: Input the text information in the encoded knowledge graph into the Mamba-GPT model to complete the power equipment inspection knowledge graph, dynamically update the completed power equipment inspection knowledge graph in stages and output it.
[0099] Specifically, the completion of the power equipment inspection knowledge graph includes inputting the preprocessed vector sequence into the Mamba-GPT model, converting the input text sequence into a vector sequence through multi-layer Mamba blocks, decoding the vector sequence, generating the completed text information, and converting the completed text information into a new knowledge graph triple to complete the knowledge graph.
[0100] Furthermore, the Mamba-GPT model consists of multiple Mamba blocks, the structure of which is shown in the attached manual. Figure 2 As shown in the figure, the input text sequence is first converted into a vector sequence through a text embedding module, then converted into an output vector sequence through multiple layers of Mamba blocks, and finally the output vector is decoded into the output text.
[0101] Furthermore, the power equipment inspection knowledge graph that is dynamically updated and completed in stages includes collecting short-term data, medium-term data and long-term data in daily inspection reports, and preprocessing the collected short-term data, medium-term data and long-term data respectively; generating new knowledge triples according to the preprocessed short-term data, medium-term data and long-term data, and calculating the loss functions respectively.
[0102] Furthermore, the formula of the loss function in the short-term update process is as follows:
[0103]
[0104] Among them, L short represents the loss function used for short-term updates, T represents the total number of moments, and f(·) represents the loss function based on the short-term prediction data x t and the current parameter θ t The generated new knowledge triples, y t represents the actual data point at time t, x s represents short-term data, θ t represents the current parameter, γ represents the regularization parameter, and M represents the parameter θ t The total number of t,j represents the jth parameter at time t, θ t-1,j represents the jth parameter at time t-1;
[0105] Furthermore, the formula of the loss function in the mid-term update process is as follows:
[0106]
[0107] Among them, L mid represents the loss function used for mid-term update, T represents the total number of moments, and g(·) represents the loss function based on the mid-term prediction data x m and the current parameter θ t The generated new knowledge triples, y t represents the actual data point at time t, x m represents mid-term data, θ t represents the current parameter, β and λ represent regularization parameters, and M represents parameter θ t The total number of t,j represents the jth parameter at time t, θ t-1,j represents the jth parameter at time t-1, conflict(·) represents the conflict function, h, r, t represent the triple elements of the knowledge triples respectively, and K represents the updated knowledge graph;
[0108]
[0109] Among them, L long represents the loss function used for long-term update, T represents the total number of moments, and h(·) represents the loss function based on the long-term prediction data x l and the new knowledge triples generated by the parameter set θ, y t represents the actual data point at time t, x l represents long-term data, θ represents the parameter set, α and κ both represent regularization parameters, M represents the total number of parameters θ, θ j represents the jth parameter, conflict(·) represents the conflict function, h, r, t represent the triple elements of the knowledge triples respectively, and K represents the updated knowledge graph.
[0110] Furthermore, the gradient of the loss function required for updating is calculated, and an optimization algorithm (such as Adam) is used to update the parameters in the completed power equipment inspection knowledge graph.
[0111] In summary, the knowledge graph of power equipment inspection that is dynamically updated and completed in stages enables the system to update the knowledge graph of power equipment inspection in a timely manner according to different time scales and the newness and oldness of the data. Short-term updates can reflect the latest data changes and trends in a timely manner, ensuring that the system can respond quickly to dynamic changes. Due to the high frequency of short-term updates, it can capture small changes in data more accurately, more accurately, and facilitate instant decision-making. It has strong processing capabilities for emergencies or short-term fluctuations, and can quickly update the knowledge graph to reflect these changes and provide real-time data support; mid-term updates can balance short-term real-time requirements and long-term stable trends. Through appropriate frequency updates, it can better manage data changes, ensure that the system can respond to dynamic changes in a timely manner, and maintain the stability and consistency of the system, avoid unnecessary burdens on the system caused by too frequent updates, and adapt to faster business changes; long-term updates can more comprehensively analyze and understand the long-term trends of data, help the system predict future development directions and trends, and the data and analysis results provided by long-term updates can provide support for long-term strategic planning and decision-making, help stabilize model parameters, and reduce unnecessary updates caused by short-term fluctuations. A reasonable phased update strategy can help the system effectively manage computing resources and storage costs while ensuring data accuracy. Through phased updates, the system can achieve optimal utilization of resources without sacrificing quality.
[0112] Furthermore, in order to make the Mamba-GPT model suitable for the task of knowledge graph completion, the knowledge graph needs to be converted into text and fine-tuned. In order to fine-tune the input model, a part of the triples in the existing knowledge graph of power equipment inspection is used as input, and the other part of the triples to be completed is used as labels. The model can infer the connection between other entities based on the input, compare the output results with the labels, and feed back the differences to the model parameters for fine-tuning.
[0113] Furthermore, the fine-tuned hardware and software environment configurations are shown in Table 1.
[0114] Table 1 Fine-tuning software and hardware environment configuration table
[0115] GPU 4x NVIDIA RTX4090 CPU 2x Intel Xeon Gold 6248R (24 cores and 48 threads) Memory 256GB DDR4 storage 4TB NVMe SSD network 10Gbps Ethernet operating system Ubuntu 22.04LTS Deep Learning Frameworks PyTorch 2.0.0 CUDA 11.2 cuDNN 8.1 Python 3.10 Fine-tuning tools Pytorch Lightning
[0116] Example 2
[0117] Reference Figure 1 to Figure 3 , which is an embodiment of the present invention, provides a power equipment knowledge graph completion system based on the Mamba-GPT model, including:
[0118] The encoding module is used to collect and preprocess the data related to the inspection of power equipment, construct a knowledge graph of the inspection of power equipment based on the preprocessed data related to the inspection of power equipment, and encode the text information in the knowledge graph;
[0119] The model building module is used to build the Mamba-GPT model, introduce a priori knowledge injection mechanism dedicated to power equipment, and optimize the selection mechanism of Mamba blocks;
[0120] The completion module is used to input the text information in the encoded knowledge graph into the Mamba-GPT model, complete the power equipment inspection knowledge graph, and output the completed power equipment inspection knowledge graph.
[0121] For the specific limitations of the electric power equipment knowledge graph completion system based on the Mamba-GPT model, please refer to the limitations of the electric power equipment knowledge graph completion method based on the Mamba-GPT model mentioned above, which will not be repeated here. Each module in the above-mentioned electric power equipment knowledge graph completion system based on the Mamba-GPT model can be implemented in whole or in part through software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0122] Example 3
[0123] Reference Figure 3 , which is the third embodiment of the present invention. Based on the first two embodiments, the embodiment of the present invention provides a computer device, which may be a server, and its internal structure diagram may be as shown in FIG. Figure 3 As shown. The computer device includes a processor, a memory and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium.
[0124] The database of the computer device is used to store action detection data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in any of the above-mentioned sparse tensor operation acceleration method embodiments are implemented.
[0125] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0126] In one embodiment, an embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in any of the above-mentioned sparse tensor operation acceleration method embodiments are implemented.
[0127] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0128] Example 4
[0129] As an embodiment of the present invention, a method for completing the knowledge graph of electric equipment based on the Mamba-GPT model is provided. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through economic benefit calculation and simulation experiments.
[0130] Specifically, we use public knowledge graph datasets (FB15k-237 and WN18RR) to compare the Mamba-GPT model with several mainstream knowledge graph completion methods, including TransE, DistMult, ComplEx, and RotatE. The input of the Mamba-GPT model is in the form of triples in the knowledge graph (entity 1, relationship, entity 2), and the goal is to predict missing entities or relationships.
[0131] Furthermore, the knowledge graph data is preprocessed and converted into a format suitable for Mamba-GPT input. The preprocessed data is used to train the Mamba-GPT model, the completion effect of the model is evaluated on the test set, and various evaluation indicators are calculated.
[0132] Furthermore, the data for comparing knowledge graph completion methods based on the FB15k-237 dataset is shown in Table 2.
[0133] Table 2 Comparison data based on FB15k-237 dataset
[0134]
[0135] Furthermore, the data for comparing knowledge graph completion methods based on the WN18RR dataset is shown in Table 3.
[0136] Table 3 Comparison data based on WN18RR dataset
[0137]
[0138] In summary, it can be seen from the data in the table that the present invention relies on the Mamba-GPT model to better complete the knowledge graph completion task.
[0139] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A method for completing the knowledge graph of electric power equipment based on the Mamba-GPT model, characterized in that: include: Collect and preprocess data related to power equipment inspection, construct a knowledge graph of power equipment inspection based on the preprocessed data related to power equipment inspection, and encode the text information in the knowledge graph; Construct the Mamba-GPT model, introduce a priori knowledge injection mechanism dedicated to power equipment, and optimize the selection mechanism of Mamba blocks; The text information in the encoded knowledge graph is input into the Mamba-GPT model to complete the power equipment inspection knowledge graph, and the completed power equipment inspection knowledge graph is dynamically updated and output in stages.
2. The method for completing the knowledge graph of electric power equipment based on the Mamba-GPT model according to claim 1, characterized in that: The construction of the power equipment inspection knowledge graph and encoding the text information in the knowledge graph includes: Defining entities, including power equipment, components, fault types, and maintenance operations, and establishing relationships between the entities to form triples; Convert triples into text sequences and distinguish different types of entities and relations through tags; Use the Word2Vec algorithm to generate word vectors; According to the position of the word vector in the text sequence, position encoding is performed and the position encoding is used as input.
3. The method for completing the knowledge graph of electric power equipment based on the Mamba-GPT model as claimed in claim 2, characterized in that: The word vectors generated by using the Word2Vec algorithm include: In the Skip-Gram model, a given central word is used to predict the context words. The calculation formula of the loss function of the Skip-Gram model is as follows: Among them, L represents the loss function, T represents the length of the text sequence, k represents the window size, j is the unsummed variable and has no actual physical meaning, P(w t+j |w t ) indicates that the input word is w t When, word w t+j Probability of occurrence; Among them, P(w t+j |w t ) is calculated by the soft maximization function, P(w t+j |w t ) is calculated as follows: in, and Represent the embedding vectors of the output word and the input word respectively, V represents the vocabulary, and v w Represents the embedding vector of word w, where w represents the vocabulary.
4. The method for completing the knowledge graph of electric power equipment based on the Mamba-GPT model as claimed in claim 3, characterized in that: The formula for taking position encoding as input is as follows: ON (pos2i) =sin(pos / 10000 2i / d ) ON (pos,2i+1) =cos(pos / 10000 2i / d ) Among them, PE represents the output value of position embedding, pos represents the position of the word in the text, d represents the maximum length of the word vector, and i represents the text position.
5. The method for completing the knowledge graph of electric power equipment based on the Mamba-GPT model as claimed in claim 4, characterized in that: The construction of the Mamba-GPT model, the introduction of a priori knowledge injection mechanism dedicated to power equipment, and the optimization of the Mamba block selection mechanism include: constructing a Mamba-GPT model structure based on the Mamba block, establishing the relationship between the Mamba block input and output sequences, and the calculation formula for the relationship between the Mamba block input and output sequences is as follows: the t =Ch t Among them, x t represents the tth vector in the input sequence, h t represents the implicit state space, C are matrices, y t Represents the model output; Construct a specialized knowledge graph in the field of power equipment, introduce knowledge graph data in related fields, and integrate the node representation and relationship of the knowledge graph into the knowledge graph in the field of power equipment through transfer learning; Design transfer learning strategies to enable knowledge graphs to learn common features and patterns from knowledge in other fields; Introduce a priori knowledge selection module based on dynamic attention mechanism in the input layer of Mamba block; The node representation of the cross-domain knowledge graph obtained through transfer learning is fused with the position encoding as input; A consistency constraint is added to the loss function of the Mamba-GPT model. The consistency constraint includes a node consistency constraint and an edge consistency constraint. The formula of the node consistency constraint is as follows: Among them, L node represents the node consistency loss, υ i Represents a node in the knowledge graph, v i Represents the node υ generated by the model i The vector representation of Represents node υ in the knowledge graph i The true vector representation of ; The formula for the edge consistency constraint is as follows: Among them, L edge represents the edge consistency loss, (υ i ,υ j ) represents the connection node υ in the knowledge graph i and j One side of ij Represents the edge generated by the model (υ i ,υ j ), Represents the edge (υ i ,υ j )’s true vector representation; The node consistency loss and edge consistency loss are combined as the overall knowledge consistency loss. The calculation formula of the overall knowledge consistency loss is as follows: L consistency =λ node L node +λ edge L edge Among them, L consistenyc represents the overall knowledge consistency loss, λ node represents the weight parameter used to balance the node consistency loss, λ node represents the weight parameter used to balance the edge consistency loss, L node represents the node consistency loss, L edge represents edge consistency loss; Introducing a selection mechanism in the Mamba block, and C can be changed with the input x t Changes, and the mapping relationship can be learned, the formula of the mapping relationship is as follows: ΔS Δ (x)=softplus(Linear(x)) C=S C (x)=Linear(x) B=S B (x)=Linear(x) Among them, Linear(.) represents a linear function, Δ represents the sampling interval, S Δ (x) indicates that Δ is a function of the input x, softplus(Linear(x)) indicates a combined function, S C (x) means C is a function of input x, S B (x) means B is a function of input x, represents the matrix, represents a matrix, ΔA represents the product of Δ and A, I represents the identity matrix, and ΔB represents the product of Δ and B; softplus(x)=log(1+e x ) Among them, softplus(x) represents the activation function, and x represents any independent variable describing the function; Multiple layers of Mamba blocks are combined into a Mamba-GPT model.
6. The method for completing the knowledge graph of electric power equipment based on the Mamba-GPT model as claimed in claim 5, characterized in that: The completion of the knowledge graph of power equipment inspection includes: Input the pre-processed data related to power equipment inspection into the Mamba-GPT model; The input text sequence is converted into a vector sequence through multiple layers of Mamba blocks; Decode the vector sequence and generate the completed text information; The completed text information is converted into new knowledge graph triples to complete the knowledge graph.
7. The method for completing the knowledge graph of electric power equipment based on the Mamba-GPT model according to claim 6, characterized in that: The power equipment inspection knowledge graph after dynamic updating and completion in stages includes: Collect short-term data, medium-term data and long-term data from daily inspection reports respectively, and pre-process the collected short-term data, medium-term data and long-term data respectively; According to the preprocessed short-term data, medium-term data and long-term data, new knowledge triples are generated respectively, and the loss functions are calculated respectively; The formula of the loss function in the short-term update process is as follows: Among them, L short represents the loss function used for short-term updates, T represents the total number of moments, and f(·) represents the loss function based on the short-term prediction data x t and the current parameter θ t The generated new knowledge triples, y t represents the actual data point at time t, x s represents short-term data, θ t represents the current parameter, γ represents the regularization parameter, and M represents the parameter θ t The total number of t,j represents the jth parameter at time t, θ t-1,j represents the jth parameter at time t-1; The formula of the loss function during the mid-term update process is as follows: Among them, L mid represents the loss function used for mid-term update, T represents the total number of moments, and g(·) represents the loss function based on the mid-term prediction data x m and the current parameter θ t The generated new knowledge triples, y t represents the actual data point at time t, x m represents mid-term data, θ t represents the current parameter, β and λ represent regularization parameters, and M represents parameter θ t The total number of t,j represents the jth parameter at time t, θ t-1,j represents the jth parameter at time t-1, conflict(·) represents the conflict function, h, r, t represent the triple elements of the knowledge triples respectively, and K represents the updated knowledge graph; The formula of the loss function during the long-term update process is as follows: Among them, L long represents the loss function used for long-term update, T represents the total number of moments, and h(·) represents the loss function based on the long-term prediction data x l and the new knowledge triples generated by the parameter set θ, y t represents the actual data point at time t, x l represents long-term data, θ represents the parameter set, α and κ both represent regularization parameters, M represents the total number of parameters θ, θ j represents the jth parameter, conflict(·) represents the conflict function, h, r, t represent the triple elements of the knowledge triples respectively, and K represents the updated knowledge graph; Calculate the gradient of the loss function needed for updating, and use the optimization algorithm to update the parameters in the completed power equipment inspection knowledge graph.
8. A system using the method for completing the knowledge graph of electric equipment based on the Mamba-GPT model as claimed in any one of claims 1 to 7, characterized in that: include: The encoding module is used to collect and preprocess the data related to the inspection of power equipment, construct a knowledge graph of the inspection of power equipment based on the preprocessed data related to the inspection of power equipment, and encode the text information in the knowledge graph; Model building module, used to build the Mamba-GPT model, introduce a priori knowledge injection mechanism dedicated to power equipment, and optimize the selection mechanism of Mamba blocks; The completion module is used to input the text information in the encoded knowledge graph into the Mamba-GPT model, complete the power equipment inspection knowledge graph, dynamically update the completed power equipment inspection knowledge graph in stages and output it.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method for completing the knowledge graph of electric equipment based on the Mamba-GPT model described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for completing the knowledge graph of electric equipment based on the Mamba-GPT model described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Knowledge graph completion method based on large language model
CN117634604A
Target detection method and device, equipment and medium
CN118196398A
Extracting a knowledge graph from program source code
US20190005163A1
Cited By
Complex equipment fault diagnosis method and system based on multi-modal knowledge graph
CN120217264A
Real-time online action detection method based on Mama architecture
CN120412076A
