Knowledge graph construction method, device, medium and chip for power operation text

By applying the ontology layer definition and the LEBERT-BiGRU-CRF model in the field of electric power operations for entity recognition and relationship annotation, and combining the knowledge graph construction method with vocabulary enhancement and attention mechanism, the problem of low recognition accuracy and entity overlap in the existing technology has been solved. , forming a high-accuracy knowledge graph suitable for knowledge query and reasoning in the field of electric power operations.

CN118469006BActive Publication Date: 2024-09-24NORTH CHINA ELECTRIC POWER UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410926138.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-11
Publication Date
2024-09-24
Estimated Expiration
2044-07-11

AI Technical Summary

Technical Problem

There is a lack of knowledge graph construction solutions for the field of electric power operations in the existing technology. The entity extraction and relationship extraction models are not sufficient for text feature mining, and the recognition accuracy is low. The coupling effect of entity recognition and knowledge extraction under the traditional pipeline model is poor, and it is difficult to solve the problem of entity overlap. .

Method used

A knowledge graph construction method is proposed that includes ontology layer definition, entity relationship extraction, entity disambiguation, and graph construction. By preprocessing the electric power text corpus, the LEBERT-BiGRU-CRF model is used for entity recognition and relationship annotation, combined with vocabulary enhancement and attention. The force mechanism is used to jointly extract entity relationships, and perform entity linking through the BERT encoder, and finally import the knowledge into the Neo4j graph database to form a visual knowledge graph.

Benefits of technology

It improves the accuracy of entity recognition and relationship extraction, solves the problems of entity overlap and poor coupling effect, and forms a knowledge graph with high accuracy and rich knowledge, which is suitable for knowledge query and reasoning in the field of electric power operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118469006B
    Figure CN118469006B
Patent Text Reader

Abstract

A knowledge graph construction method, device, medium and chip for electric power operation text overcome the defects of small amount of knowledge, low recognition rate and high resource occupation in the prior art. The method covers key links such as ontology layer definition, entity relationship extraction, entity disambiguation and graph construction. Through the steps of preprocessing electric power text corpus, constructing word vector table, entity type annotation, LEBERT‑BiGRU‑CRF model training, relationship annotation, entity relationship joint extraction and knowledge fusion disambiguation, entities and relationships are extracted from text and constructed into a visual electric power operation knowledge graph. Vocabulary enhancement and attention mechanism are introduced to improve recognition accuracy. The mode of entity recognition first and then joint extraction is adopted to effectively solve the entity overlap problem and optimize the knowledge extraction effect. The extracted entity relationship triples are imported into the graph database to form a knowledge base in the field of electric power operation, which is an efficient and accurate knowledge graph construction method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the electric power field, and in particular to a method, device, medium and chip for constructing a knowledge graph for electric power operation text. Background Art

[0002] Knowledge graph is a knowledge collection with a semantic network structure, which consists of entities, relationships between entities and attributes. It is presented in a graphical way and can intuitively show the relationship between entities. It is widely used in search engines, recommendation systems, question-answering systems, intelligent customer service and natural language processing. Knowledge graph is an emerging branch in the field of artificial intelligence. It forms a structured knowledge collection by structuring a large amount of data on the Internet. The construction of knowledge graph includes three processes: knowledge extraction, knowledge fusion and knowledge graph establishment:

[0003] Knowledge extraction: automatically extract entities and relationships between entities from the corpus;

[0004] Knowledge fusion: centralize the results of knowledge extraction, remove duplicate information, and perform corresponding processing based on the attributes of entities and relationships;

[0005] Knowledge graph establishment: Store the integrated knowledge data into the graph database to form a visual knowledge graph.

[0006] In the prior art, knowledge graph construction methods are mainly divided into rule-based methods and machine learning-based methods. The rule-based methods require manual definition of the corresponding rules of entities and relationships, and the methods are complex and have certain limitations; the machine learning-based methods need to solve two problems: entity recognition and relationship extraction. The main solutions are: dictionary-based entity recognition methods, which are based on vocabulary and have a low recognition rate; machine learning-based entity recognition methods, which mainly use models such as CRF (conditional random field) and HMM (hidden Markov model). These models require a large amount of manually labeled data, take a long time to train, and have high resource usage; deep learning-based entity recognition methods, which mainly use models such as LSTM and CNN. The model training effect is good, but the corpus needs to be segmented and there is an ambiguity problem.

[0007] With the advent of the era of power intelligence and big data, the amount of unstructured text content such as risk classification documents, equipment operation and maintenance documents, and safety operation instructions in the primary and secondary safety operations of power systems has gradually increased, and the knowledge content contained therein needs to be organized, stored, and utilized in a structured manner. In this context, most power grid information storage systems still use relational databases. Due to data redundancy and performance degradation, relational databases and devices are not suitable for dynamic unstructured data. How to make use of these valuable power big data, summarize the existing laws, conduct data mining, and conduct systematic analysis, and when this information needs to be queried, accurately locate the location of the data information in the shortest time. Knowledge extraction, integration, and storage of this unstructured and semi-structured data require the use of knowledge graph construction technology. However, in the power field, the knowledge graph construction technology in the power field has not yet been developed, and the main shortcomings of the existing technology are as follows:

[0008] (1) There is no systematic solution for building a knowledge graph for power operations.

[0009] (2) The entity extraction and relationship extraction models do not adequately mine text features, resulting in low recognition accuracy and poor recognition of entity overlap.

[0010] In terms of entity recognition, a text in a specific field has a large number of proper nouns and syntactic features, and the field features need to be taken into account in the optimization of recognition results. The method of using rule matching in relation extraction is lacking in extraction efficiency and versatility.

[0011] (3) In traditional methods, the coupling effect between entity recognition and knowledge extraction is poor.

[0012] In the process of building a single-domain knowledge graph, the current extraction of entities and relationships has limitations such as inconsistent formats and error amplification. In the traditional pipeline model, errors in entity recognition will be brought into relationship extraction.

[0013] (4) The traditional pipeline extraction model is not effective in solving the problem of entity overlap in sentences.

[0014] In the traditional pipeline extraction mode, the entities in the sentence are first identified and then the relationships between the entities are classified. This extraction method is difficult to solve the problem of multiple entity relationship triples in a single sentence and entity overlap (that is, the same entity exists in multiple entity relationship triples at the same time, which is the case with the device entity in the embodiment).

[0015] Therefore, how to construct a knowledge graph with high accuracy, rich knowledge and easy application is an urgent problem to be solved in this field. Summary of the invention

[0016] The technical problem to be solved by the present invention is to overcome the defects of the knowledge graph construction method in the prior art, such as small amount of knowledge, low recognition rate and high training resource occupation, and to propose a knowledge graph construction method.

[0017] In view of this, the present invention provides a knowledge graph construction method for the field of power operations, including ontology layer definition, entity relationship extraction, entity disambiguation, and graph construction.

[0018] In order to solve the above technical problems, this application provides the following technical solutions:

[0019] The present invention provides a knowledge graph construction method for electric power operation text, the method comprising:

[0020] Step 1: Integrate the collected power-related texts into documents, define the entities and relationship types contained therein in combination with the power-related professional knowledge, and obtain the entity type set and relationship type set;

[0021] The entity type collection is , the relationship type set is ;

[0022] Step 2: Preprocessing of the electric power text corpus.

[0023] This step is to pre-process the integrated documents by using sentence segmentation, logical completion, stop word removal, and useless sentence screening methods to obtain a preparatory corpus, and then randomly select 50% of the text corpus from the preparatory corpus, use the CBOW mode in the Word2Vec method to generate word vectors for all words, remove the vector representations of single words, special symbols, and sentence beginning and end markers, and obtain a word vector table in the field of power operations as the vocabulary enhancement part in the subsequent named entity recognition;

[0024] Step 3: Entity type annotation and vocabulary building,

[0025] According to the ontology-level entity types defined in step 1, the prepared corpus is annotated to obtain a power operation entity recognition dataset; the annotated samples are 20%-25% of the entire text corpus obtained after preprocessing, and it is necessary to ensure that the entity types are evenly distributed in the annotated samples;

[0026] Step 4: Train the model to extract named entities

[0027] The entity recognition dataset obtained in the above steps is sent to the LEBERT-BiGRU-CRF model for training. Based on the trained model, 50% of the content of the entire corpus is annotated;

[0028] Step 5: Relationship type labeling,

[0029] The entity recognition results output in step 4 are annotated with the types of relationships between entities in the SPO format to obtain a power operation entity relationship dataset with a scale of 50% of the entire corpus; the power operation entity relationship dataset is obtained;

[0030] Step 6: Joint extraction of entity relations,

[0031] The model is trained on the power operation entity relationship data set to obtain the power operation entity relationship joint extraction model; the power operation entity relationship joint extraction model performs entity relationship joint extraction on the entire corpus and outputs entity relationship triples;

[0032] Step 7: Knowledge fusion and disambiguation: perform entity linking on the entity relationship triples output above to form an entity library.

[0033] After the extraction is completed, the entity library needs to be linked to address the problem of multi-word synonyms. The BERT encoder is used to map the entity and its surrounding semantic information into the same vector space. A threshold is set for the similarity. Adjacent entities in the vector space are considered synonymous entities when their distance is less than or equal to the threshold, and their names and relationships are merged.

[0034] Step 8: Import the graph database and import the entity relationship triples obtained by knowledge extraction and fusion into the Neo4j graph database to form a visual knowledge graph of power operations.

[0035] Furthermore, the text preprocessing process of step 2 includes:

[0036] (1) First, use the sentence end punctuation as a separator to split it into several single sentences. For sentences that exceed the length, manually adjust the sentence length to ensure that the single sentence length L is less than or equal to 48;

[0037] (2) After the segmentation is completed, if there is a logical missing subject or object in the segmented sentence, logical completion is required;

[0038] (3) Use the stop word list to remove special symbols, and then filter the sentences to filter out useless sentences that do not contain any entity relationship triples, and keep the sentences to enter the model's preliminary corpus;

[0039] (4) Construct a vocabulary for the vocabulary enhancement part of the named entity recognition model in S4.

[0040] Furthermore, the text preprocessing process of step 2 includes:

[0041] 1. First, randomly select 50% of the text corpus from the prepared corpus formed in the previous step to construct the word vector table. If the number of words in the constructed word table is less than 1000, increase the number of texts appropriately;

[0042] 2. Use the Jieba word segmentation tool to segment the basic corpus and obtain all vocabulary information;

[0043] 3. Use the CBOW model in the Word2Vec method to generate word vectors for all words. The input is the target word and its context, and the output is the word vector representation of the target word. The vector length should be consistent with the model parameters in S4.

[0044] 4. Remove the vector representations of single words, special symbols, and sentence start and end markers to obtain a complete external word vector table in the field of power operations.

[0045] Preferably, the step 4 comprises:

[0046] (1) The bottom layer is the LEBERT model, which is a BERT model with vocabulary enhancement. The input sequence is initially divided into different characters and input into the LEBERT layer. The input sequence is , add the mark and position embedding to get the vector E= , E is then input into the Transformer encoder. The function of each Transformer layer is as shown in equations (1) and (2)

[0047] (1)

[0048] (2)

[0049] in, is the output of layer l, =E; LN is layer normalization; MHAttn is a multi-head attention mechanism; FFN is a two-layer fully connected feed-forward network with ReLU as the hidden activation function;

[0050] LEBERT adds a Lexicon Adapter module between the first and second layers of BERT Transformer to inject vocabulary information. For each position in the sequence , this module constructs a character-word pair vector representation as ( , ), Indicates character vector of positions, Indicates The characters corresponding to The word vectors are matched; the search is performed according to the external word list, and for each character in the sentence, the corresponding matching words in the text are found. The parameters stipulate that each character can match up to three words at most; because the lexical vectors introduced by the external dictionary and the character vectors have a dimensional mismatch problem, the word vectors are first nonlinearly mapped to align their dimensions with the character vectors;

[0051] (3)

[0052] After aligning the dimensions, we get Word vector table for each position For each character, the importance of all the words it matches is different, so you need to use As the query vector, the attention weight of each word is calculated as

[0053] (4)

[0054] in , Indicates The character corresponding to The weight of the word vector, Represents the bilinear attention weight matrix; at this time, the obtained word weights are used to perform weighted summation on the word vectors to obtain the word features after the word fusion corresponding to each character ;

[0055] (5)

[0056] Finally, the character features are added to the word features to obtain the feature fusion vector ;

[0057] (6)

[0058] At this point, the feature fusion vector already contains the vocabulary feature information. The obtained feature fusion vector is passed to the second layer of Transformer. The output result after 12 layers of Transformer is used as the output of the LEBERT layer.

[0059] (2) The LEBERT layer output vector obtained in the previous step is passed into the BiGRU, and the hidden layer outputs of the GRU in two directions are concatenated to obtain the output result of the BiGRU layer; in the CRF layer, the probability of each character being predicted as the corresponding entity is calculated. CRF is a probabilistic graphical model that regulates the output of the BiGRU to avoid label ambiguity.

[0060] Furthermore, the entity relationship joint extraction described in step 6 specifically includes:

[0061] (1) Given an input sentence S, the BERT pre-trained encoder obtains a sentence embedding h containing n tokens. First, a subset of potential relations in the sentence is predicted, and then only the subject and object under the potential relations need to be identified. The elements of the potential relation prediction are:

[0062] (7)

[0063] (8)

[0064] Where Avgpool is the average pooling operation, are trainable weights, is the Sigmod function; the potential relationship prediction process is a multi-label classification task. If the probability Exceeding the threshold , then assign label 1 to the corresponding label, otherwise assign label 0. In the future, only the predicted potential relationship needs to be used in the extraction process;

[0065] (2) Before labeling the subject and object, the attention mechanism is used to assign weights to the representation vector to make full use of the position information, improve the model recognition accuracy, and optimize the vector c. The optimization process is as follows:

[0066] (9)

[0067] (10)

[0068] (11)

[0069] In the formula, is the input vector to be optimized, To learn the function, The calculation process is regarded as the weighted average of the input vector. After the weight is determined, the optimized vector is obtained. ; The optimized vector uses a fully connected network to perform two sequence labeling operations to identify the subject and object respectively, which can effectively solve the problem of entity overlap. The operation for each token is as follows:

[0070] (12)

[0071] (13)

[0072] in is the jth relation representation in the training embedding matrix U, is the encoded representation of the i-th token, , is the training weight;

[0073] (3) After sequence annotation, we obtain the subject and object contained in all potential relations. Next, we use the global annotation matrix to determine the correct subject-object pair. First, we enumerate all subject-object pairs in the sentence, and then compare the scores of the entity pairs in the global correspondence matrix with the threshold. Compare and retain if the threshold is exceeded, otherwise filter; the values ​​corresponding to the elements in the matrix, that is, the confidence of the subject-object pair, are as follows:

[0074] (14)

[0075] in, , is the token encoding representation of the i-th and j-th positions in the input sentence that forms a potential subject-object pair, are trainable weights, is the Sigmod function; the correct subject-object pair combination relationship output by the global matrix can obtain the correct triple representation, which is expressed as: subject, relationship, object.

[0076] The present invention also provides a device for constructing a knowledge graph, the device comprising:

[0077] The acquisition module is used to integrate the collected power field related texts into the document, define the entity and relationship types contained therein in combination with the power field professional knowledge, and obtain the entity type set and the relationship type set;

[0078] The preprocessing module is used to preprocess the integrated documents by using sentence segmentation, logical completion, stop word removal, and useless sentence screening methods to obtain a preparatory corpus. Then, 50% of the text corpus is randomly selected from the preparatory corpus, and the CBOW mode in the Word2Vec method is used to generate word vectors for all words. The vector representations of single words, special symbols, and sentence start and end markers are removed to obtain a word vector table in the field of power operations, which is used as the vocabulary enhancement part in the subsequent named entity recognition.

[0079] A labeling module is used to label the prepared corpus according to the entity type of the ontology layer defined in step 1 to obtain a power operation entity recognition dataset;

[0080] The power operation entity recognition model is used to train the model on the power operation entity recognition dataset, input the preprocessed corpus, and output the entity label corresponding to each token;

[0081] The power operation entity relationship joint extraction model is used to train the model on the power operation entity relationship data set to obtain the power operation entity relationship joint extraction model;

[0082] An entity linking module is used to perform entity linking on the entity relationship triples output in step 8 to form an entity library;

[0083] The graph database is used to import the entity relationship triples obtained by knowledge extraction and fusion into the graph database to form a visual knowledge graph of power operations.

[0084] The present invention also provides a device for constructing a knowledge graph, comprising: at least one processor, a memory and a communication interface; the memory and the communication interface are coupled to the processor, and the memory stores program code; the processor calls the program code stored in the memory to execute the method described in any of the above embodiments.

[0085] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, and when the computer-readable storage medium is run on a computer, the computer executes the method described in any of the above embodiments.

[0086] The present invention further provides a chip, on which instructions are stored, and when the instructions are executed on a computer, the computer executes the method described in any of the above embodiments.

[0087] In the embodiment of the present invention, the goal of the electric power operation knowledge graph construction method is to extract entities and relationships between entities in the electric power operation field, and provide a platform for knowledge query and reasoning for electric power operations, including the following contents:

[0088] Knowledge extraction refers to extracting entities and relationships between entities from unstructured text;

[0089] Knowledge fusion refers to unifying the extracted knowledge, removing redundancy, and processing entities and relationships accordingly;

[0090] The establishment of a knowledge graph refers to storing the data after knowledge fusion into a graph database to form a visual knowledge graph.

[0091] In the method of the present invention, the main process of constructing the power operation knowledge graph includes:

[0092] Step 1: Preprocess the text corpus to obtain a prepared corpus;

[0093] Step 2: According to the entity type and relationship type definition of power operation, entity annotation is performed on the prepared corpus;

[0094] Step 3: Use the LEBERT-BiGRU-CRF model to perform entity recognition on the prepared corpus to obtain the power operation entity recognition model;

[0095] Step 4: Annotate the entity relationships of the power operation entity recognition model to obtain a power operation entity relationship dataset;

[0096] Step 5: Use the PRGCA model to perform entity-relationship joint extraction on the prepared corpus to obtain the power operation entity-relationship joint extraction model;

[0097] Step 6: Use the entity relationship joint extraction model to perform entity relationship joint extraction on the prepared corpus to obtain entity relationship triples;

[0098] Step 7: Perform entity linking on entity relationship triples to obtain an entity library;

[0099] Step 8: Import entity relationship triples into the graph database to form a knowledge graph for power operations.

[0100] This method obtains a pre-processing corpus by performing word segmentation, stop word removal, logical completion, and useless sentence screening on the text corpus in the field of power operation. Then, 50% of the text corpus is randomly selected from the pre-processing corpus, and the word vectors of all words are generated using the CBOW mode in the Word2Vec method. The vector representations of single words, special symbols, and sentence head and tail identifiers are removed to obtain a word vector table in the field of power operation, which can be used as the vocabulary enhancement part in the subsequent named entity recognition to improve the accuracy of named entity recognition. The pre-processing corpus is identified using the power operation entity recognition model, and then the entity relationship type of the power operation entity recognition result is annotated to obtain the power operation entity relationship data set. Finally, the PRGCA model is used to jointly extract entity relationships from the pre-processing corpus to obtain the power operation entity relationship joint extraction model. The power operation entity relationship joint extraction model performs entity relationship joint extraction on all corpora, outputs entity relationship triples, and entity links the triples to form an entity library. Then, the entity relationship triples obtained by knowledge extraction and fusion are imported into the graph database to form a visual power operation knowledge graph.

[0101] Compared with the prior art, the knowledge graph construction method for power operation text in the present invention has at least the following beneficial effects:

[0102] 1. The present invention proposes a knowledge graph construction process and method for power operation texts, including ontology definition, data processing, knowledge extraction and other processes, which effectively solves the problem of lack of knowledge graph construction methods in this field and solves the application gap in this field.

[0103] 2. The present invention introduces vocabulary enhancement and attention mechanisms into the entity recognition and entity relationship joint extraction models respectively, with the aim of fully extracting features such as words and positions in sentences to improve the model's recognition accuracy of entity relationships.

[0104] 3. The present invention uses a model of first entity recognition and auxiliary labeling, and then joint extraction to extract knowledge, which solves the problem of poor coupling effect between entity extraction and relationship extraction in the traditional pipeline mode.

[0105] 4. In the entity-relationship joint extraction model, the twice-labeling mode for the subject and object of each relationship can solve the problem of entity overlap, and even the problem of overlapping subjects and objects in the same triplet can be solved.

[0106] The following is a further explanation of a knowledge graph construction method for power operation texts of the present invention in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0107] Figure 1 A flowchart of a method for constructing a knowledge graph for electric power operation text according to the present invention;

[0108] Figure 2 This is a structural diagram of a LEBERT-BiGRU-CRF model in a knowledge graph construction method for electric power operation texts of the present invention;

[0109] Figure 3 A PRGCA model structure diagram of a knowledge graph construction method for electric power operation texts according to the present invention;

[0110] Figure 4 Simple knowledge graph example. DETAILED DESCRIPTION

[0111] In the existing technical solutions, the knowledge graph construction solutions for the power field are concentrated in sub-fields such as transformer operation and maintenance or distribution network equipment failure, especially the graph construction solutions for power system safety operations, especially relay protection operation texts, have not yet been involved. That is, there is no systematic knowledge graph construction solution for power operations.

[0112] At present, for entity extraction from unstructured text, a small number of methods use rule-based methods, most use methods that combine deep learning methods with probabilistic graph models (such as BiLSTM+CRF or BERT+CRF), and most relationship extraction methods use template matching and basic deep learning models. Knowledge fusion mainly refers to linking and aligning the extracted information to form a systematic and complete knowledge system to solve the problems of entity ambiguity and diversity, which mainly manifests in two aspects: polysemy and synonymy. For example, "Huadian" and "North China Electric Power University" have the same semantics and need to be linked and merged.

[0113] In terms of specific implementation, the existing methods first preprocess the unstructured text paragraphs (complete the subject, replace pronouns, and separate sentences), use BERT and CRF to build an entity recognition model, input the unstructured text paragraphs to obtain the entity recognition results, and then match the entity recognition results with the industry knowledge base to obtain entity relationship triples. The existing methods mainly use rule-based and embedding + similarity judgment methods for entity linking (i.e. knowledge fusion). Based on rules, such as "Baidu Co., Ltd." and "Baidu Technology Co., Ltd." are determined to be the same entity through string matching based on the rule template "Baidu". The embedding method uses word2vec to vectorize the entity and then combines cosine similarity to distinguish the link. Finally, all the entity relationship triples obtained are imported into the graph database to form a visual knowledge graph.

[0114] However, since there is no systematic knowledge graph construction scheme for power operation, there is no corresponding technology to realize the knowledge graph construction in this field. Therefore, based on the research of relevant existing technologies, the inventor provides a knowledge graph construction method for power operation text.

[0115] The algorithm flow chart of the knowledge graph construction method for power operation text in the present invention is as follows: Figure 1 As shown, it mainly includes the following steps:

[0116] S1: Integrate the collected power-related texts into documents. The document contents include but are not limited to "Grid Safety Work Regulations", "Power Secondary Operation Risk Classification Table", "Relay Protection Operation Risk Process Library" and other texts. Combined with the professional knowledge in the power field, define the entity and relationship types contained therein to ensure that all entity relationship types to be extracted are covered for subsequent annotation and model training. The entity type set is , the relationship type set is .

[0117] Power operation entity types include: organization, name, position, equipment, unit, material, power operation, technology, time, location, identification, event, contract, characteristics, attributes, etc. Power operation relationship types include: organization relationship, name relationship, position relationship, equipment relationship, unit relationship, material relationship, power operation relationship, technology relationship, time relationship, location relationship, identification relationship, event relationship, contract relationship, characteristic relationship, attribute relationship, etc. The definitions of power operation entity types and relationship types can refer to the relevant laws, regulations, standards, specifications, etc. in the field of power operation.

[0118] S2: Text preprocessing process

[0119] This process is to pre-process the integrated documents using sentence segmentation, logical completion, stop word removal, and useless sentence screening methods to obtain a preparatory corpus, and then randomly select 50% of the text corpus from the preparatory corpus, use the CBOW mode in the Word2Vec method to generate word vectors for all words, remove the vector representations of single words, special symbols, and sentence beginning and end markers, and obtain a word vector table in the field of power operation as the vocabulary enhancement part in the subsequent named entity recognition. The pre-processing method of text corpus in the field of power operation mainly includes:

[0120] (1) Sentence segmentation: First, use the sentence-end punctuation as a separator to split the sentence into several single sentences. For sentences that exceed the length, manually adjust the sentence segmentation to ensure that the length of a single sentence L is less than or equal to 48.

[0121] (2) Logical completion: After segmentation, if there is a logical missing subject or object in the segmented sentence, logical completion is required. The text corpus that is missing the necessary components is completed to make the sentence structure complete.

[0122] (3) Remove stop words: Use a stop word list to remove special symbols, and then filter the sentences to filter out useless sentences that do not contain any entity relationship triples, and retain the sentences to enter the model's preliminary corpus.

[0123] (4) Filter out useless sentences and build a vocabulary for the vocabulary enhancement part of the named entity recognition model in S4.

[0124] The specific method is as follows:

[0125] 1. First, randomly select 50% of the text corpus from the prepared corpus formed in the previous step to construct the word vector table. If the number of words in the constructed word table is less than 1000, increase the number of texts appropriately.

[0126] 2. Use the jieba word segmentation tool to segment the basic corpus and obtain all vocabulary information.

[0127] 3. Use the CBOW model in the Word2Vec method to generate word vectors for all words. The input is the target word and its context, and the output is the word vector representation of the target word. The vector length should be consistent with the model parameters in S4, which is set to 128 here.

[0128] 4. Remove the vector representations of single words, special symbols, and sentence start and end markers to obtain a complete external word vector table in the field of power operations.

[0129] S3: The annotation module annotates the corpus according to the entity types at the ontology level defined in S1 to obtain the power operation entity recognition dataset. The annotated samples are 20%-25% of the total text corpus obtained after preprocessing in S2, and it is necessary to ensure that the entity types are evenly distributed in the annotated samples. The sample entities are annotated based on the BIO annotation format, and the entity recognition dataset is obtained after the annotation is completed, which is used by the entity recognition model in S4.

[0130] S4: Send the entity recognition data set obtained in S3 to the power operation entity recognition model for training. Based on the trained model, 50% of the content of the entire corpus formed in S1 is labeled with entities.

[0131] The power operation entity recognition model is the LEBERT-BiGRU-CRF model. The specific model implementation method is as follows:

[0132] (1) The bottom layer is the LEBERT model, which is a BERT model with vocabulary enhancement. The input sequence is initially divided into different characters and input into the LEBERT layer. The input sequence is , add the mark and position embedding to get the vector E= , E is then input into the Transformer encoder, and the function of each Transformer layer is as follows (1) (2);

[0133] (1)

[0134] (2)

[0135] in, is the output of layer l, =E; LN is layer normalization; MHAttn is the multi-head attention mechanism; FFN is a two-layer fully connected feed-forward network with ReLU as the hidden activation function.

[0136] LEBERT adds a Lexicon Adapter module between the first and second layers of BERT Transformer to inject vocabulary information. For each position in the sequence , this module constructs a character-word pair vector representation as ( , ), Indicates character vector of positions, Indicates The characters corresponding to The word vectors are matched. The search is performed according to the external word list, and the corresponding matching words in the text are found for each character in the sentence. The parameters stipulate that each character can match up to three words. Because the lexical vectors introduced by the external dictionary have a dimensional mismatch with the character vectors, the word vectors are first nonlinearly mapped to align their dimensions with the character vectors.

[0137] (3)

[0138] After aligning the dimensions, we get Word vector table for each position For each character, the importance of all the words it matches is different, so you need to use As the query vector, the attention weight of each word is calculated as

[0139] (4)

[0140] in , Indicates The character corresponding to The weight of the word vector, Represents the bilinear attention weight matrix. At this time, the obtained word weights are used to perform weighted summation on the word vectors to obtain the word features after the word fusion corresponding to each character .

[0141] (5)

[0142] Finally, the character features are added to the word features to obtain the feature fusion vector .

[0143] (6)

[0144] At this point, the feature fusion vector already contains vocabulary feature information. The obtained feature fusion vector is passed to the second-layer Transformer, and the output result after 12 layers of Transformer is used as the output of the LEBERT layer.

[0145] (2) The output vector of the LEBERT layer obtained in the previous step is passed to the BiGRU, and the hidden layer outputs of the GRU in both directions are concatenated to obtain the output of the BiGRU layer. The probability of each character being predicted as the corresponding entity is calculated in the CRF layer. CRF is a probabilistic graphical model that regulates the output of the BiGRU to avoid label ambiguity.

[0146] S5: Annotate the entity recognition results output in S4 with the relationship types between entities in the SPO format, and the relationship types are also based on the scope defined in S1. The power operation entity relationship dataset is obtained, which is 50% of the total corpus.

[0147] S6: Send the labeled entity relationship dataset to the PRGCA model for training, and perform entity relationship joint extraction on the entire corpus. The specific calculation method is as follows:

[0148] (1) Given an input sentence S, the BERT pre-trained encoder obtains a sentence embedding h containing n tokens. First, a subset of potential relations in the sentence is predicted, and then only the subject and object under the potential relations need to be identified. The elements of the potential relation prediction are:

[0149] (7)

[0150] (8)

[0151] Where Avgpool is the average pooling operation, are trainable weights, is the Sigmod function. The potential relationship prediction process is a multi-label classification task. If the probability Exceeding the threshold , then assign label 1 to the corresponding label, otherwise assign label 0. In the future, only the predicted potential relationship needs to be used in the extraction process.

[0152] (2) Before labeling the subject and object, the attention mechanism is used to assign weights to the representation vector to make full use of the position information, improve the model recognition accuracy, and optimize the vector c. The optimization process is as follows:

[0153] (9)

[0154] (10)

[0155] (11)

[0156] In the formula, is the input vector to be optimized, To learn the function, The calculation process is regarded as the weighted average of the input vector. After the weight is determined, the optimized vector is obtained. The optimized vector uses a fully connected network to perform two sequence labeling operations to identify the subject and object respectively, which can effectively solve the problem of entity overlap. The operation for each token is as follows:

[0157] (12)

[0158] (13)

[0159] in is the jth relation representation in the training embedding matrix U, is the encoded representation of the i-th token, , are the training weights.

[0160] (3) After sequence annotation, we obtain the subject and object contained in all potential relations. Next, we use the global annotation matrix to determine the correct subject-object pair. First, we enumerate all subject-object pairs in the sentence, and then compare the scores of the entity pairs in the global correspondence matrix with the threshold. Compare, if it exceeds the threshold, it will be retained, otherwise it will be filtered. The value corresponding to the element in the matrix, that is, the confidence of the subject-object pair is as follows:

[0161] (14)

[0162] in, , is the token encoding representation of the i-th and j-th positions in the input sentence that forms a potential subject-object pair, are trainable weights, is the Sigmod function. The correct subject-object pair combination relationship output by the global matrix can obtain the correct triple representation, which is expressed as (subject, relationship, object).

[0163] S7: After the extraction is completed, it is necessary to link the entity library to address the problem of multi-word synonymy. The BERT encoder is used to map the entity and its surrounding semantic information into the same vector space. A threshold is set for the similarity. When the distance between adjacent entities in the vector space is less than or equal to the threshold, they are considered synonymous entities and their names and relationships are merged. The cosine similarity is calculated as follows:

[0164] (15)

[0165] S8: Import the entity relationship triples obtained by knowledge extraction and fusion into the Neo4j graph database to form a visual knowledge graph of power operations.

[0166] The following specific embodiments are used to further illustrate the application of the scheme of the present invention, but they are not intended to limit the scope of protection of the present invention.

[0167] In this specific embodiment, the text content used in the embodiment is as follows:

[0168] The line protection transformation operation is carried out while the corresponding 110kV primary equipment is not out of service.

[0169] At 110kV, the inspection risk level of the fault recording device is level four.

[0170] The 220kV corresponding primary equipment is out of service and the line protection inspection risk is level four.

[0171] According to the content of the corpus and domain expertise, the entity relationship types in the text are defined as (state, condition, equipment) and (equipment, behavior, action). In the BIO format of entity annotation, POS represents state, EQU represents equipment, and ACT represents action. First, the entity types are annotated as shown in the following table:

[0172] Table 1 Entity annotation examples

[0173]

[0174] After entity recognition is completed, the entity relationship annotation format is as follows:

[0175] Table 2 Entity relationship annotation examples

[0176]

[0177] After being annotated in the above annotation format, the entity relationship triples are obtained by performing knowledge extraction through the LEBERT-BiGRU-CRF entity recognition model and the PRGCA entity relationship joint extraction model (in this embodiment, there is no multi-word synonymy between entities, and entity linking is not required). The triples are stored in the form of a graph database to form a visual knowledge graph. The simple knowledge graph formed by the triples in this specific embodiment is as follows: Figure 4 shown.

[0178] The embodiments described above are merely descriptions of preferred implementation modes of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.

Claims

1. A knowledge graph construction method for electric power operation text, characterized in that: Includes steps: S1: Ontology layer entity relationship definition The collected power-related texts are integrated into the document, and the entities and relationship types contained therein are defined in combination with the power-related professional knowledge to obtain the entity type set and relationship type set, where the entity type set is , the relationship type set is ; S2: preprocessing process of electric power text corpus; S3: Entity type annotation and vocabulary building According to the ontology-level entity types defined in S1, the corpus is annotated. The annotated samples are 20%-25% of the entire text corpus obtained after S2 preprocessing. At the same time, it is necessary to ensure that the entity types are evenly distributed in the annotated samples. S4: Training the model to extract named entities The entity recognition dataset obtained in S3 is fed into the LEBERT-BiGRU-CRF model for training. Based on the trained model, 50% of the entire corpus formed by S1 is annotated; S5: Relationship type annotation The entity recognition results output in S4 are annotated with the types of entity relationships in SPO format, and a data set of entity relationships of power operations is obtained, which is 50% of the total corpus. S6: Joint extraction of entity relations The labeled entity relationship dataset is fed into the PRGCA model for training, and entity relationship joint extraction is performed on the entire corpus. The entity relationship joint extraction specifically includes: (1) Given an input sentence S, the BERT pre-trained encoder obtains a sentence embedding h containing n tokens. First, a subset of potential relations in the sentence is predicted, and then only the subject and object under the potential relations need to be identified. The elements of the potential relation prediction are: (7) (8) Where Avgpool is the average pooling operation, are trainable weights, is the Sigmod function; the potential relationship prediction process is a multi-label classification task. If the probability Exceeding the threshold , then assign label 1 to the corresponding label, otherwise assign label 0. In the future, only the predicted potential relationship needs to be used in the extraction process; (2) Before labeling the subject and object, the attention mechanism is used to assign weights to the representation vector to make full use of the position information, improve the model recognition accuracy, and optimize the vector c. The optimization process is as follows: (9) (10) (11) In the formula, is the input vector to be optimized, To learn the function, The calculation process is regarded as the weighted average of the input vector. After the weight is determined, the optimized vector is obtained. ; The optimized vector uses a fully connected network to perform two sequence labeling operations to identify the subject and object respectively, which can effectively solve the problem of entity overlap. The operation for each token is as follows: (12) (13) in is the jth relation representation in the training embedding matrix U, is the encoded representation of the i-th token, , is the training weight; (3) After sequence annotation, we obtain the subject and object contained in all potential relations. Next, we use the global annotation matrix to determine the correct subject-object pair. First, we enumerate all subject-object pairs in the sentence, and then compare the scores of the entity pairs in the global correspondence matrix with the threshold. Compare and retain if the threshold is exceeded, otherwise filter; the values ​​corresponding to the elements in the matrix, that is, the confidence of the subject-object pair, are as follows: (14) in, , is the token encoding representation of the i-th and j-th positions in the input sentence that forms a potential subject-object pair, are trainable weights, is the Sigmod function; the correct subject-object pair combination relationship output by the global matrix can obtain the correct triple representation, which is represented as: subject, relationship, object; S7: Knowledge Fusion Disambiguation After the extraction is completed, the entity library needs to be linked to address the problem of multi-word synonyms. The BERT encoder is used to map the entity and its surrounding semantic information into the same vector space. A threshold is set for the similarity. Adjacent entities in the vector space are considered synonymous entities when their distance is less than or equal to the threshold, and their names and relationships are merged. S8: Importing a graph database The entity relationship triples obtained by knowledge extraction and fusion are imported into the Neo4j graph database to form a visual knowledge graph of power operations.

2. A method for constructing a knowledge graph for electric power operation text according to claim 1, characterized in that: The text preprocessing process of S2 includes: (1) First, use the sentence end punctuation as a separator to split it into several single sentences. For sentences that exceed the length, manually adjust the sentence length to ensure that the single sentence length L is less than or equal to 48; (2) After the segmentation is completed, if there is a logical missing subject or object in the segmented sentence, logical completion is required; (3) Use a stop word list to remove special symbols, and then filter the sentences to filter out useless sentences that do not contain any entity relationship triples, and keep the sentences to enter the model's preparatory corpus; (4) Construct a vocabulary for the vocabulary enhancement part of the named entity recognition model in S4.

3. A method for constructing a knowledge graph for electric power operation text according to claim 2, characterized in that: The text preprocessing process of S2 includes: 1) First, randomly select 50% of the text corpus from the prepared corpus formed in the previous step to construct the word vector table. If the number of words in the constructed word table is less than 1000, increase the number of texts appropriately; 2) Use the Jieba word segmentation tool to segment the basic corpus and obtain all vocabulary information; 3) Use the CBOW model in the Word2Vec method to generate word vectors for all words. The input is the target word and its context, and the output is the word vector representation of the target word. The vector length should be consistent with the model parameters in S4. 4) Remove the vector representations of single words, special symbols, and sentence start and end markers to obtain a complete external word vector table in the power operation field.

4. A method for constructing a knowledge graph for electric power operation text according to claim 1, characterized in that: S4 specifically includes: (1) The bottom layer is the LEBERT model, which is a BERT model with vocabulary enhancement. The input sequence is initially divided into different characters and input into the LEBERT layer. The input sequence is , add the mark and position embedding to get the vector E= , E is then input into the Transformer encoder. The function of each Transformer layer is as shown in equations (1) and (2) (1) (2) in, is the output of layer l, =E; LN is layer normalization; MHAttn is a multi-head attention mechanism; FFN is a two-layer fully connected feed-forward network with ReLU as the hidden activation function; LEBERT adds a Lexicon Adapter module between the first and second layers of BERT Transformer to inject vocabulary information. For each position in the sequence , this module constructs a character-word pair vector representation as ( , ), Indicates character vector of positions, Indicates The characters corresponding to The word vectors are matched; the search is performed according to the external word list, and for each character in the sentence, the corresponding matching words in the text are found. The parameters stipulate that each character can match up to three words at most; because the lexical vectors introduced by the external dictionary and the character vectors have a dimensional mismatch problem, the word vectors are first nonlinearly mapped to align their dimensions with the character vectors; (3) After aligning the dimensions, we get Word vector table for each position For each character, the importance of all the words it matches is different, so you need to use As the query vector, the attention weight of each word is calculated as (4) in , Indicates The character corresponding to The weight of the word vector, Represents the bilinear attention weight matrix; at this time, the obtained word weights are used to perform weighted summation on the word vectors to obtain the word features after the word fusion corresponding to each character ; (5) Finally, the character features are added to the word features to obtain the feature fusion vector ; (6) At this point, the feature fusion vector already contains the vocabulary feature information. The obtained feature fusion vector is passed to the second layer of Transformer. The output result after 12 layers of Transformer is used as the output of the LEBERT layer. (2) The LEBERT layer output vector obtained in the previous step is passed into the BiGRU, and the hidden layer outputs of the GRU in two directions are concatenated to obtain the output result of the BiGRU layer; in the CRF layer, the probability of each character being predicted as the corresponding entity is calculated. CRF is a probabilistic graphical model that regulates the output of the BiGRU to avoid label ambiguity.

5. A knowledge graph construction device, the device applying the knowledge graph construction method for electric power operation text according to claim 1, the device comprising: The acquisition module is used to integrate the collected power field related texts into the document, define the entity and relationship types contained therein in combination with the power field professional knowledge, and obtain the entity type set and the relationship type set; The preprocessing module is used to preprocess the integrated documents by using sentence segmentation, logical completion, stop word removal, and useless sentence screening methods to obtain a preparatory corpus. Then, 50% of the text corpus is randomly selected from the preparatory corpus, and the CBOW mode in the Word2Vec method is used to generate word vectors for all words. The vector representations of single words, special symbols, and sentence start and end markers are removed to obtain a word vector table in the field of power operations, which is used as the vocabulary enhancement part in the subsequent named entity recognition. The annotation module is used to annotate the prepared corpus according to the defined entity types in the ontology layer to obtain a data set of entity recognition for power operations; The power operation entity recognition model is used to train the model on the power operation entity recognition dataset, input the preprocessed corpus, and output the entity label corresponding to each token; The power operation entity relationship joint extraction model is used to train the model on the power operation entity relationship data set to obtain the power operation entity relationship joint extraction model; An entity linking module, used for performing entity linking on the output entity relationship triples to form an entity library; The graph database is used to import the entity relationship triples obtained by knowledge extraction and fusion into the graph database to form a visual knowledge graph of power operations.

6. A knowledge graph construction device, characterized in that: include: at least one processor, memory, and communication interface; The memory and the communication interface are coupled to the processor, and the memory stores program code; The processor calls the program code stored in the memory to execute the method according to any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 4.

8. A chip, characterized in that:Instructions are stored on the chip, and when the instructions are executed on a computer, the computer is caused to execute the method according to any one of claims 1 to 4.