A knowledge graph completion method for power equipment based on self-learning prompts
By combining the self-learning prompt mechanism and pre-trained language model in the power equipment knowledge graph, the knowledge graph completion problem of grid equipment failures and defects in the power system is solved, effective processing of sparse data sets and comprehensive understanding of the knowledge graph, and significantly improved the physical completion performance.
Patent Information
- Application Number
- CN202411814146.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-04
AI Technical Summary
Failures and defects of power grid equipment in power systems lead to system instability and security problems. Traditional link prediction methods are difficult to capture meaningful graph structures, resulting in suboptimal entity and relationship representations.
The power equipment knowledge graph completion method based on self-learning prompts is adopted. By collecting equipment defect reports, the equipment defect knowledge graph is constructed, and the equipment defect knowledge graph is trained using a dual encoder. The self-learning prompt mechanism and a pre-trained language model (BERT-chinese) are combined to understand the semantic nuances in the knowledge graph entities and relationships.
Effectively process sparse data sets, comprehensively understand the interconnectivity in the knowledge graph, improve entity completion performance, solve the prediction inaccurate problems caused by long-tail entities, and significantly improve the completion effect of the knowledge graph.
Smart Images

Figure CN119760150A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of power systems, and in particular to a method for completing a knowledge graph of power equipment based on self-learning prompts. Background Art
[0002] With the continuous development and expansion of power systems, the number and complexity of power grid equipment are also increasing, and the faults and defects in them can lead to system instability and safety issues. Therefore, timely diagnosis of power grid equipment defects has become the key to the operation of power systems. However, due to the rarity of key events that occur in the daily operation of power systems, electrical equipment defect datasets usually exhibit long-tail entities and long-tail relations, that is, relatively rare and uncommon entities and relations in the dataset. This poses a challenge to traditional link prediction methods because they have difficulty capturing meaningful graph structures, resulting in suboptimal entity and relationship representations. To address this limitation, a key aspect of knowledge graph learning is to obtain a comprehensive understanding of textual information. An effective way is to use pre-trained language models. However, obtaining pre-trained language models for specific fields is expensive and challenging. At the same time, how to thoroughly develop the potential of pre-trained models has become one of the current research hotspots. Summary of the invention
[0003] In order to solve the above problems, the present invention proposes a method for completing the knowledge graph of electric power equipment based on self-learning prompts, a terminal device and a storage medium.
[0004] The specific plan is as follows:
[0005] A method for completing a knowledge graph of electric power equipment based on self-learning prompts comprises the following steps:
[0006] S1: Collect equipment defect reports from power grid companies, extract entities and relationships between them, and build an equipment defect knowledge graph based on triples consisting of entities and relationships;
[0007] S2: Obtain the description information of entities and relationships, and create an equipment defect dataset by combining entities, relationships and corresponding description information;
[0008] S3: construct a dual encoder, and train the dual encoder through positive samples and negative samples obtained from device defect reports; the dual encoder includes a query encoder for processing the description information of the head entity and the relationship in the query information and a candidate entity encoder for processing the description information of the candidate tail entity; in the query encoder, in addition to inputting the description information of the head entity and the relationship in the query information, a prompt is also introduced into the input sequence, and when the prompt is a hard prompt, a fixed token is used as the prompt; when the prompt is a soft prompt, a fixed number of randomly initialized prompts are used as sequence prefixes, including selecting a fixed number of prompts from the candidate tail entity set according to the query information;
[0009] S4: Completing the equipment defect knowledge graph through the trained dual encoder.
[0010] Furthermore, entities are identified through named entity recognition technology, and relations between entities are identified through semantic relation extraction technology.
[0011] Furthermore, step S1 also includes text cleaning and word segmentation before extracting the entities and the relationships between the entities.
[0012] Furthermore, the types of entities include: voltage level, line, station line type, defective equipment, equipment type, equipment type, component type, component, location, defect description, defect content, defect nature and classification basis.
[0013] Furthermore, both the query encoder and the candidate entity encoder adopt the BERT-chinese network structure.
[0014] Furthermore, during the prompt usage, MLP and softmax function are used to generate scores for tokens selected as prompts.
[0015] Furthermore, the process of prompt selection is represented as follows: using the embedded feature vectors of several nodes around the entity as the knowledge base, the entity and its description information are passed through an MLP to generate prompts in the knowledge base.
[0016] The present invention adopts the above technical solution, combined with a self-learning prompt mechanism, which generates prompts for specific situations without any additional information, called self-learning. This combined with Prompt Engineering effectively leverages the power of pre-trained language models to understand the semantic nuances in knowledge graph entities and relations. This innovative approach enables our model to effectively process sparse datasets, thereby fully understanding the interconnectedness in the knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 Shown is a flow chart of a method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0018] To further illustrate various embodiments, the present invention provides drawings. These drawings are part of the disclosure of the present invention, which are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in this field should be able to understand other possible implementations and advantages of the present invention.
[0019] The present invention will now be further described with reference to the accompanying drawings and specific implementation methods.
[0020] The embodiment of the present invention provides a method for completing the knowledge graph of electric equipment based on self-learning prompts, such as Figure 1 As shown, the method comprises the following steps:
[0021] S1: Collect equipment defect reports from power grid companies, extract the entities and relationships between them, and build an equipment defect knowledge graph based on the triples composed of entities and relationships.
[0022] In this embodiment, the equipment defect report collected is presented in plain text form. Through text analysis technology, entities and relationships in the report can be identified. Specifically, named entity recognition technology can be used to identify entities such as equipment names and locations in the text, and text analysis and semantic relationship extraction technology can be used to identify the relationship between entities.
[0023] Furthermore, in order to improve the efficiency of entity and relationship extraction, this embodiment also includes text cleaning and word segmentation of the equipment defect report before performing entity and relationship extraction.
[0024] In the ontology design of this embodiment, the defective equipment and defect content are taken as the core, and the key information including the location and manifestation of the defect is specifically expressed, and the knowledge graph ontology of power equipment fault with equipment fault as the core is designed. The knowledge graph contains 13 entity types, namely: voltage level, line, station line type, defective equipment, equipment type, equipment type, component type, component, location, defect description, defect content, defect nature, classification basis; and contains 13 relationships, namely:
[0025] (1)_Power station / line_voltage level
[0026] (2)_Power station / line_station line type
[0027] (3) Power station / line defective equipment
[0028] (4) Defective equipment Component type
[0029] (5) Defective equipment Equipment type
[0030] (6)_Device type_Device category
[0031] (7) _Part Type_Part
[0032] (8) _Part_Defective part
[0033] (9)_Defect location_Defect description
[0034] (10)_Defect content_Defect description
[0035] (11) Defect content Classification basis
[0036] (12) Defect content Defect nature
[0037] (13) Classification basis: Nature of defect
[0038] When constructing a knowledge graph, the ontology definition extracts corresponding entities and relationships from unstructured data to generate structured triples, and constructs the knowledge graph database content based on the above ontology structure.
[0039] S2: Obtain the description information of entities and relationships, and create an equipment defect dataset by combining entities, relationships and corresponding description information.
[0040] The description information can be obtained directly from the report text or from other reference materials, without limitation.
[0041] The equipment defect dataset is used to find the descriptive information of entities and relationships used in subsequent use.
[0042] S3: Build a dual encoder and train the dual encoder using positive and negative samples obtained from device defect reports.
[0043] The dual encoder includes a query encoder for processing the description information of the head entity and the relationship in the query information and a candidate entity encoder for processing the description information of the candidate tail entity. Both adopt the BERT-chinese network structure, hereinafter referred to as the first BERT model and the second BERT model.
[0044] The principle of the traditional dual encoder is: the first BERT model determines the head entity relation-aware embedding based on the description information corresponding to the head entity and the description information corresponding to the relationship in the triple to be predicted; the second BERT model determines the candidate tail entity embedding based on the description information of the candidate tail entity; based on the similarity between the head entity relation-aware embedding and the candidate entity relation-aware embedding (such as using a two-layer MLP), the score of the candidate tail entity is calculated.
[0045] This embodiment incorporates a self-learning prompt mechanism to generate prompts for specific situations without requiring any additional information. It also leverages the power of a pre-trained language model (BERT-chinese) to understand the semantic nuances in knowledge graph entities and relations. The dual encoder constructed in this embodiment can effectively process sparse datasets, thereby fully understanding the interconnectedness in the knowledge graph to improve entity completion performance.
[0046] LMKE is selected as the backbone network. In the query encoder, in addition to inputting the description information of the head entity and relationship in the query information into the pre-trained language model, considering the development potential of prompt engineering on the pre-trained language model, in order to fully utilize the potential of PLM, this embodiment introduces additional prompts in the input sequence. The hard prompt method uses fixed tokens as prompts, and the soft prompt method uses a fixed number of randomly initialized prompts as sequence prefixes, including selecting a fixed number of prompts from the candidate tail entity set according to the query information. This method provides greater flexibility and ensures the variability of prompts for different queries. In order to improve efficiency and parameter reuse, the candidate set is selected as a set of graph entity embeddings. To some extent, prompt selection can also be interpreted as identifying the entities most relevant to a given query. MLP and softmax function are used to generate scores for tokens selected as prompts. We use a fixed number of highest-scoring tokens as prompts. The process of prompt selection can be represented as follows: Using the embedded feature vectors of several nodes around the entity as the knowledge base, the entity and its supplementary information are generated in the knowledge base through an MLP, and given to the PLM together. The generation of prompts through self-learning not only greatly improves the effect of PLM in understanding the semantic nuances of knowledge graph entities and relationships, but also ensures that the number of parameters remains unchanged, thereby further improving the completion effect of the knowledge graph.
[0047] A contrastive learning method is used when training the dual encoder, and negative sampling is used for optimization to reduce the complexity of training, improve the speed and efficiency of training, and solve the problem of inaccurate prediction caused by long-tail entities in the knowledge graph of power grid equipment defects.
[0048] S4: Completing the equipment defect knowledge graph through the trained dual encoder.
[0049] The present invention focuses on the completion of the knowledge graph of power equipment defects, embeds the knowledge graph into a low-dimensional vector space, constructs a knowledge graph embedding model based on a dual encoder, and combines a self-learning prompt mechanism to generate prompts for specific situations without the need for any additional information. The combination of the prompt enhances the ability of the pre-trained language model to understand the semantic nuances in the knowledge graph entities and relationships. By contrasting the learning strategy, the training process is optimized to reduce the complexity of training, improve the speed and efficiency of training, and solve the problem of inaccurate prediction caused by long-tail entities in the knowledge graph of power grid equipment defects. It can effectively process sparse data sets, thereby fully understanding the interconnectivity in the knowledge graph to improve the entity completion performance; and it has been proven in experiments that it performs well in the entity completion task on the knowledge graph of power grid equipment defects.
[0050] Although the present invention has been specifically shown and described in conjunction with the preferred embodiments, it should be understood by those skilled in the art that various changes may be made to the present invention in form and details without departing from the spirit and scope of the present invention as defined by the appended claims, all of which are within the scope of protection of the present invention.
Claims
1. A method for completing the knowledge graph of electric power equipment based on self-learning prompts, characterized in that: The following steps are involved: S1: Collect equipment defect reports from power grid companies, extract entities and relationships between them, and build an equipment defect knowledge graph based on triples consisting of entities and relationships; S2: Obtain the description information of entities and relationships, and create an equipment defect dataset by combining entities, relationships and corresponding description information; S3: construct a dual encoder, and train the dual encoder through positive samples and negative samples obtained from the device defect report; the dual encoder includes a query encoder for processing the description information of the head entity and the relationship in the query information and a candidate entity encoder for processing the description information of the candidate tail entity; In the query encoder, in addition to inputting the description information of the head entity and relationship in the query information, hints are also introduced in the input sequence. When the hint is a hard hint, a fixed number of tokens are used as hints; when the hint is a soft hint, a fixed number of randomly initialized hints are used as sequence prefixes, including selecting a fixed number of hints from the set of candidate tail entities according to the query information; S4: Completing the equipment defect knowledge graph through the trained dual encoder.
2. The method for completing the knowledge graph of electric power equipment based on self-learning prompts according to claim 1 is characterized in that: Entities are identified using named entity recognition technology, and the relationships between entities are identified using semantic relationship extraction technology.
3. The method for completing the knowledge graph of electric power equipment based on self-learning prompts according to claim 1 is characterized in that: Step S1 also includes text cleaning and word segmentation before extracting the entities and the relationships between them.
4. The method for completing the knowledge graph of electric power equipment based on self-learning prompts according to claim 1 is characterized in that: The types of entities include: voltage level, line, station line type, defective equipment, equipment type, equipment category, component category, component, location, defect description, defect content, defect nature and classification basis.
5. The method for completing the knowledge graph of electric power equipment based on self-learning prompts according to claim 1 is characterized in that: Both the query encoder and the candidate entity encoder adopt the BERT-chinese network structure.
6. The method for completing the knowledge graph of electric power equipment based on self-learning prompts according to claim 1 is characterized in that: During prompt usage, an MLP and softmax function are used to generate scores for tokens selected as prompts.
7. The method for completing the knowledge graph of electric power equipment based on self-learning prompts according to claim 1 is characterized in that: The process of prompt selection is represented as follows: using the embedded feature vectors of several nodes around the entity as the knowledge base, the entity and its description information are passed through an MLP to generate prompts in the knowledge base.
Citation Information
Cited By
Knowledge graph entity completion method
CN120851176A