A method and system for automatically identifying grid operation violation codes
By combining YEDDA annotation and the BERT-BiLSTM-CRF Chinese NER model with the Bayesian principle, power grid operation violation codes can be automatically identified, solving the problems of low recognition efficiency and insufficient accuracy in existing technologies and realizing intelligent violation code management.
Patent Information
- Application Number
- CN202411618795.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2044-11-13
AI Technical Summary
In the existing technology, violation records at power grid operation sites are unstructured text data, which has low recognition and management efficiency and is prone to recognition errors and omissions, making it difficult to identify violation behavior codes efficiently and accurately.
The YEDDA annotation tool is used for entity annotation. The BERT-BiLSTM-CRF Chinese NER model is trained and combined with the Bayesian principle. Keywords are selected through the TF-IDF algorithm to construct the feature vector of the violation code. The posterior probability is calculated based on the BOW model for automatic identification.
It realizes the intelligent identification of power grid operation violation codes, improves the identification efficiency and accuracy, reduces the burden of manual review, and improves the safety management level of power grid operations.
Smart Images

Figure CN119721030B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of work violation identification, in particular to an electric power grid work violation code automatic identification method and system. BACKGROUND
[0002] The power system is a key national infrastructure, and the stability of the power grid is crucial to national security and economic development. Power grid work safety is a crucial link in the power industry. The occurrence of power grid work accidents has a serious adverse impact on the safety and stability of the entire society, therefore, managing and controlling the distribution network work violation risk is the key to ensuring the safety of distribution work.
[0003] Under this background, power grid work safety is particularly important, as it directly affects the safety of workers and property. Power grid site work often involves handling high-voltage power equipment and complex power systems, and any accident or failure can result in serious consequences such as personnel casualties, equipment damage, and power outages. Therefore, ensuring the safety of power grid work is crucial to protecting personnel and property interests. Currently, major power grid companies in China have accumulated vast amounts of historical work plans and violation record information, such as work conditions, work content, on-site work violation descriptions, and violation types, which are all first-hand data for safe work and a guide for safe work. Based on the violation data accumulated by power grid companies, risk factor analysis of violation behavior can not only effectively prevent the occurrence of safety accidents, but also further improve the quality of power grid work, which is of great significance to ensuring the safe operation of the power grid and improving overall operational efficiency. By using machine learning, deep learning, and other artificial intelligence technologies to deeply mine the text data recorded in historical work violations, typical work violation codes and their corresponding typical violation behaviors can be extracted, facilitating subsequent automatic and intelligent identification of violation descriptions, and helping to improve safety supervision efficiency and strengthen risk control capabilities. In summary, intelligent identification of work violations is of great significance to the safety construction and safe operation of the power grid. SUMMARY
[0004] In view of the above problems, the present application is proposed.
[0005] Therefore, the technical problem solved by the present application is: how to efficiently and accurately identify the violation behavior code of the power grid work site to improve the safety management level of power grid work and reduce the burden of manual review. Currently, since most of the violation records at the power grid work site are unstructured text data, identification and management work needs to rely on manual interpretation and annotation, which is low in efficiency and has the risk of identification errors and omissions.
[0006] To solve the above technical problems, the present application provides the following technical solution: an electric power grid work violation code automatic identification method, comprising the following steps,
[0007] collecting power grid operation data and performing text preprocessing;
[0008] The preprocessed field operation violation description text data is marked with entities by using a YEDDA marking tool, and is input into a BERT-BiLSTM-CRF Chinese NER model for training.
[0009] Based on the trained NER model, the violation description text is recognized, and the feature keywords of the violation code are extracted.
[0010] The feature vector of the violation code is constructed, and the probability of the violation type is calculated based on the Bayes principle, and the violation code with the highest posterior probability is selected as the recognition result.
[0011] As a preferred scheme of the power grid operation violation code automatic recognition method, the collecting power grid operation data and performing text preprocessing comprises,
[0012] The historical operation data is obtained from the power grid company, the description text data related to the violation behavior is screened out, the irrelevant content is removed, and the complete operation violation description text and the violation code label information are reserved.
[0013] As a preferred scheme of the power grid operation violation code automatic recognition method, the preprocessed field operation violation description text data is marked with entities by using a YEDDA marking tool, and is input into a BERT-BiLSTM-CRF Chinese NER model for training.
[0014] The unstructured text data formed by the power grid field operation violation description is marked with BIO entities, and the BIO three-entity marking is performed based on the YEDDA entity marking tool.
[0015] The marking categories include Object, Person, File, Action and Surrounding.
[0016] The unstructured text data of the power grid field operation violation description after the BIO marking is input into the BERT-BiLSTM-CRF Chinese NER model for training, and the trained model weight is obtained.
[0017] As a preferred scheme of the power grid operation violation code automatic recognition method, the input into the BERT-BiLSTM-CRF Chinese NER model for training comprises,
[0018] In the model training process, the best experimental parameters are obtained by adjusting the learning rate, the number of iterations, the number of batches, and the optimizer. In the model evaluation, the precision, recall and F1 value are selected as the indicators for evaluating the performance of the identification model, and the expression is:
[0019]
[0020] Where TP is the number of instances that the model predicts as positive samples and is actually positive samples, FP is the number of instances that the model predicts as positive samples but is actually negative samples, FN is the number of instances that the model predicts as negative samples but is actually positive samples, P represents the proportion of samples that are actually of a certain class among the samples that are predicted to be of that class, R represents the proportion of samples that are actually of a certain class among the samples that are correctly predicted to be of that class, and F1 represents the harmonic mean of the precision P and the recall R.
[0021] As a preferred scheme of the power grid operation violation code automatic identification method, the NER model is trained, the violation description text is identified, and the feature keywords of the violation code are extracted.
[0022] The field operation violation description text data is converted into a vector form, the entity recognition of the power grid field operation violation description text data is performed through the weight of the trained Chinese NER model, the words obtained by the entity recognition are sorted according to each violation code, and the word frequency is counted.
[0023] According to the TF-IDF algorithm, X key words corresponding to each violation code are selected, and a key word dictionary is sorted, and the expression is:
[0024]
[0025] Where, tf x,y is the number of times that the word x appears in the field operation violation description text data corresponding to the violation code y; df x represents the number of violation codes containing the word x; and N is the number of all violation codes.
[0026] As a preferred scheme of the power grid operation violation code automatic identification method, the NER model is trained, the violation description text is identified, and the feature keywords of the violation code are extracted.
[0027] The obtained key word dictionary has a total of S words, a classical vector of each violation code is constructed, the dimension of the classical vector is S, and each dimension corresponds to a corresponding word in the key word dictionary;
[0028] The classical vector of each violation code is constructed according to the X key words selected according to the TF-IDF algorithm;
[0029] Based on the BOW model, the corresponding positions in the S-dimensional vector corresponding to the X key words are assigned a value of 1, and other positions are assigned a value of 0, to obtain a classical vector of each violation code. According to the preprocessed power grid field operation violation description text data, a part of the power grid operation field violation description data corresponding to the violation codes is randomly selected, and the proportion of each violation code in the data is calculated as the prior probability.
[0030] As a preferred scheme of the power grid operation violation code automatic identification method, wherein the feature vector of the violation code is constructed, the probability of the violation type is calculated based on the Bayesian principle, and the violation code with the highest posterior probability is selected as the identification result.
[0031] For a new field operation violation description, the entity is identified by using the BERT-BiLSTM-CRF Chinese NER model, the corresponding feature vector form is obtained according to the BOW algorithm, the posterior probability of the field operation violation description text data corresponding to different violation types is calculated, and the violation code with the maximum posterior probability is taken as the prediction result, so as to realize intelligent automatic identification of the violation code.
[0032] Another object of the present application is to provide a power grid operation violation code automatic identification system, which can realize intelligent identification of the power grid operation violation description through data preprocessing, entity labeling, feature vector construction and Bayesian inference, so as to solve the problems of low efficiency and insufficient accuracy in the existing manual processing mode. The key entity in the violation description is automatically identified by using the NER model, and the automatic determination of the violation code is realized by combining the Bayesian classification, so as to solve the deficiency of relying on manual review in the prior art and improve the intelligent and automatic level of the power grid operation safety management.
[0033] To solve the above technical problems, the present application provides the following technical scheme: a power grid operation violation code automatic identification system, comprising: a data collection and preprocessing module, an entity labeling and NER model training module, a feature keyword extraction and feature vector generation module, and a violation identification module based on the Bayesian principle.
[0034] The data collection and preprocessing module is responsible for obtaining historical operation data from a power grid company and performing preliminary processing to screen out text data related to violation behavior. By eliminating irrelevant information, only the operation violation description text and the corresponding violation code label are retained.
[0035] The entity labeling and NER model training module uses the YEDDA labeling tool to perform BIO labeling on the preprocessed data, marks the violation behavior and scene elements in the text as specific categories, and inputs the labeled text data into the BERT-BiLSTM-CRF Chinese NER model for training.
[0036] The feature keyword extraction and feature vector generation module is based on the trained NER model to identify feature words in the violation description text, generate a keyword dictionary through a TF-IDF algorithm, and construct a classic vector of the violation code by using a BOW model, so as to vectorize the text data and calculate the prior probability of each violation code in the data;
[0037] The violation identification module based on the Bayesian principle is to construct a feature vector based on the NER model and the BOW algorithm for the input new violation description text, calculate the posterior probability of each violation type of the new violation description text through the Bayesian principle, select the violation code with the highest posterior probability as the final identification result, and realize the automatic identification and intelligent analysis of the violation code.
[0038] A computer device comprises a memory and a processor, the memory stores a computer program, and the processor realizes the steps of the power grid operation violation code automatic identification method when executing the computer program.
[0039] A computer readable storage medium stores a computer program, and the computer program realizes the steps of the power grid operation violation code automatic identification method when executed by a processor.
[0040] The power grid operation data is preprocessed in the application, and the data irrelevant to the violation behavior identification task is effectively eliminated. Secondly, the obtained field operation violation description text is subjected to BIO entity labeling, and the weight of the Chinese NER model is trained. Then, the obtained Chinese NER model weight is used to identify the entities of the field operation violation description text corresponding to the part of the violation codes selected at random for testing, the words and word frequencies of each violation code entity are counted and sorted, the keyword dictionary is selected by using the TF-IDF algorithm, and the classic vector corresponding to the violation code is obtained based on the BOW model. Then, the prior probability is calculated according to the proportion of each violation code in the historical record. Finally, according to the obtained prior probability and classic vector space of the violation code, the weight of the BERT-BiLSTM-CRF Chinese NER model trained and the BOW model are used to obtain the corresponding feature vector of a new field operation violation description, the posterior probability of the field operation violation description text data corresponding to different violation types is calculated by using the Bayesian principle, and the violation code with the maximum posterior probability is taken as the prediction result, so that the identification task of the violation code can be intelligently completed, and the efficiency and accuracy of the power grid management are improved. BRIEF DESCRIPTION OF DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and all other drawings obtained by those skilled in the art without creative labor based on these drawings should also belong to the protection scope of the present application.
[0042] Figure 1 The grid operation violation code automatic identification flow chart of the grid operation violation description entity identification provided by the first embodiment of the present application;
[0043] Figure 2 The YEDDA marking BIO process chart in the grid operation violation code automatic identification method provided by the third embodiment of the present application;
[0044] Figure 3 The data set entity marking and entity type quantity condition chart in the grid operation violation code automatic identification method provided by the third embodiment of the present application;
[0045] Figure 4 The recognition accuracy chart of the entity type label by the BERT-BiLSTM-CRF Chinese NER model in the grid operation violation code automatic identification method provided by the third embodiment of the present application;
[0046] Figure 5 The word cloud chart of the keyword dictionary in the grid operation violation code automatic identification method provided by the third embodiment of the present application;
[0047] Figure 6 The violation code prior probability chart in the grid operation violation code automatic identification method provided by the third embodiment of the present application;
[0048] Figure 7 The violation type automatic identifier recognition result chart in the grid operation violation code automatic identification method provided by the third embodiment of the present application. DETAILED DESCRIPTION
[0049] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific embodiments of the present application will be described in detail below with reference to the drawings in the specification. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should belong to the protection scope of the present application.
[0050] Embodiment 1, refer to Figure 1 For an embodiment of the present application, a grid operation violation code automatic identification method is provided, comprising:
[0051] The present application aims to process the unstructured text data formed by the field operation violation description of the power grid, use the YEDDA labeling tool to complete the BIO entity type labeling of the field operation violation description text of the power grid, train the BERT-BiLSTM-CRF Chinese NER model, and obtain the trained model weight of the Chinese NER model. Randomly select part of the power grid data corresponding to the violation code, use the trained Chinese NER model weight to perform entity recognition on the corresponding field operation violation description text, and obtain the corresponding words of each violation code. First, calculate the proportion of each violation code in the test data as the prior probability. Then, the key words of each violation code are obtained by the TF-IDF algorithm to form a key word dictionary. Then, the classical vector of each violation code is obtained, and the BOW model is used to convert the text data of the test data into a feature vector form. Then, according to the Bayes principle, the posterior probability of the corresponding field operation violation description text data corresponding to different violation types is calculated, and the violation code with the maximum posterior probability is taken as the prediction result, which can intelligently complete the identification task of the violation code and improve the efficiency and accuracy of the power grid management. The technical scheme is as follows:
[0052] As shown in Figure 1 The identification method constructs a violation identifier by processing unstructured text data, and the modeling process mainly includes: text preprocessing, BIO entity labeling and Chinese NER model training, selecting a key word dictionary and obtaining a classical vector of a violation code and a prior probability, and an identification model based on the Bayes principle.
[0053] Step 1, text preprocessing: for the power grid operation data obtained from the power grid company, the text preprocessing is performed, the data irrelevant to the identification task is removed, and the field operation violation description text data information and the corresponding violation code are retained;
[0054] Step 2, BIO entity labeling and Chinese NER model training: using the YEDDA labeling tool to perform entity labeling on the preprocessed field operation violation description text data, using the BIO three-element labeling method to perform entity labeling, and determining five entity categories Object, Person, File, Action and Surrounding through the analysis of the text data. The field operation violation description data labeled by BIO is put into the BERT-BiLSTM-CRF Chinese NER model for training, and the trained Chinese NER model weight is obtained;
[0055] Step 3, selecting the keyword dictionary and obtaining the classic vector and prior probability of the violation code: using the weight of the Chinese NER model trained in the previous step, randomly selecting part of the sorted power grid field violation description text data to perform entity recognition, obtaining the word corresponding to each violation code and its frequency. Use the TF-IDF algorithm to select the key words that best represent each violation code to form a keyword dictionary. Then, obtain the classic vector of each violation code, and use the BOW model to convert the test data text data into a feature vector form. Calculate the proportion of each violation code in the test data as the prior probability.
[0056] Step 4, recognition model based on Bayes principle: based on the Bayes principle, for a new field operation violation description, first use the BERT-BiLSTM-CRF Chinese NER model to identify the entity, then get the corresponding feature vector form according to the BOW algorithm, calculate the posterior probability of the corresponding field operation violation description text data corresponding to different violation types, and take the violation code with the maximum posterior probability as the prediction result, to realize the intelligent automatic recognition of the violation code.
[0057] Further, the text preprocessing of step 1 is as follows:
[0058] For the M pieces of power grid operation data obtained from the power grid company, the text preprocessing is performed, the data irrelevant to the recognition task is removed, and the complete field operation violation description text data and its corresponding category knowledge, such as violation code label information, are retained, and H pieces of power grid operation violation data are obtained by reorganizing.
[0059] Further, the BIO entity annotation and Chinese NER model training of step 2 are as follows:
[0060] The first work of the violation identification based on the named entity recognition technology is to perform BIO entity labeling on the unstructured text data formed by the violation description of the power grid field operation, and the entity labeling quality has a direct impact on the violation identification effect. Accurate and careful labeling of each entity in the violation description sentence is helpful to reliably describe the violation phenomenon, otherwise, if the entity labeling is inaccurate or incomplete, it may lead to deviation in understanding and identifying the operation violation. In this regard, based on the YEDDA entity labeling tool, BIO ternary entity labeling is performed on the H pieces of power grid field operation violation text data obtained after text preprocessing: B-begin, I-inside, O-outside. B-X represents the beginning of entity X, I-X represents the inside of entity X, and O represents an entity that does not belong to any type. Through the research and analysis of the power grid field operation violation text data, it is determined that the entity categories therein include Object, Person, File, Action and Surrounding, a total of 5 kinds. The H pieces of unstructured text data of the power grid field operation violation description labeled by BIO are input into the BERT-BiLSTM-CRF Chinese NER model for training, and the trained model weight is obtained.
[0061] The BERT-BiLSTM-CRF Chinese NER model is trained and evaluated, and the specific implementation process is as follows:
[0062] The labeled BIO power grid field operation violation description text data has a total of B characters, wherein the entity type quantity is respectively Person: p, Object: o, Surrounding: s, Action: a, and File: f, and the training data amount is set to B train , and the test data amount is B test . In the model training process, the best experimental parameters are obtained by adjusting the learning rate, iteration number, batch number and optimizer.
[0063] When the model is evaluated, the precision (Precision, P), recall (Recall, R) and F1 value are selected as the indexes for evaluating the performance of the identification model, and the calculation formulas of the three indexes are:
[0064]
[0065] Among them, TP is the number of instances that are predicted as positive samples by the model and are actually positive samples, FP is the number of instances that are predicted as positive samples by the model but are actually negative samples, FN is the number of instances that are predicted as negative samples by the model but are actually positive samples, P represents the proportion of samples that are actually of a certain class among the samples that are predicted to be of the class, R represents the proportion of samples that are correctly predicted to be of a certain class among the samples that are actually of the class, and F1 represents the harmonic mean of the precision P and the recall R, which is used to comprehensively evaluate the performance of the model.
[0066] Further, the selection of the keyword dictionary and the classical vector and prior probability of the violation code in step 3 are as follows:
[0067] In order to realize intelligent violation code automatic identification, the first preparation is to convert the field operation violation description text data into vector form. First, the Chinese NER model training weight obtained in step 2 is used to perform entity recognition on the power field operation violation description text data, and the words obtained by entity recognition are sorted according to each violation code, and the word frequency is counted. Then, according to the TF-IDF algorithm, X keywords corresponding to each violation code are selected, and these keywords are sorted into a dictionary, that is, a keyword dictionary, and the TF-IDF formula is as follows:
[0068]
[0069] Where, tf x,y is the number of times that the word x appears in the field operation violation description text data corresponding to the violation code y; df x represents the number of violation codes containing the word x; N is the number of all violation codes.
[0070] After obtaining the keyword dictionary, there are S words in total, and the classical vector of each violation code is constructed. The dimension of the classical vector is S, and each dimension corresponds to the corresponding word in the keyword dictionary. For the classical vector of each violation code, X key words are selected according to the TF-IDF algorithm, and based on the BOW model, the corresponding positions of the X key words in the S-dimensional vector are assigned a value of 1, and the other positions are assigned a value of 0, to obtain the classical vector of each violation code. According to the preprocessed power field operation violation description text data, a part of the power field operation violation description data corresponding to the violation code is randomly selected, and the proportion of each violation code in the data is calculated as the prior probability.
[0071] Further, the recognition model based on the Bayesian principle in step 4 is as follows:
[0072] Bayesian principle (Bayesian Principle) or Bayesian theorem is a mathematical method for updating probability. Bayesian principle has important applications in statistics, machine learning, data analysis and other fields. Based on the Bayesian principle, the present application realizes automatic violation recognition, and further improves the tolerance of the violation recognizer to noise, abnormal points and data set overlap.
[0073] In order to verify the effectiveness of the proposed power grid operation violation code automatic recognition method based on the Chinese NER model and the Bayesian principle, the present application tests the proposed method based on the keyword dictionary obtained in steps 1 to 3, the classical vector of the violation code, the prior probability and the trained Chinese NER model weight. The data amount of the test sample is N test , and the specific implementation process is as follows:
[0074] The K dominant violation codes corresponding to the power grid field operation violation data are taken as the labels of the test data. Then, the entities recognized by the BERT-BiLSTM-CRF Chinese NER model from N test pieces of power grid field operation violation description text data are converted into S-dimensional feature vectors by the BOW model wherein the dimension of the classical vector matrix of the K dominant violation codes is The prior probability of the K dominant violation codes is Based on the Bayesian principle, first, the cosine similarity between the feature vector of a piece of power grid field operation violation description text data and the classical vector of the K dominant violation codes is calculated, which is calculated by formula (3):
[0075]
[0076] wherein v1 and v2 are two vectors, · represents the dot product of the vectors, and ||v1|| and ||v2|| are the norms of the two vectors, respectively.
[0077] The posterior probability is calculated, that is, the probability that the feature vector of a given power grid field operation violation description text data belongs to a certain category, which is calculated by formula (4):
[0078]
[0079] wherein 1≤i≤K,1≤j≤N test , P(X j |C i ) represents the likelihood of the feature vector X j given the category C i , which is calculated by the cosine similarity here:
[0080] P(X j |C i )=cosine_similarity(X j ,C i )(5)
[0081] P r (C i ) is the prior probability of the category C i .
[0082] P(Xj is the evidence probability of the given feature vector X j , i.e. the weighted sum of the likelihoods of all violation code classes and the prior probability:
[0083]
[0084] where C i is the standard vector of the corresponding violation code class.
[0085] Finally, the predicted violation code class is the class with the largest posterior probability, which is given as follows:
[0086]
[0087] where, is the predicted violation code class, and P(C i |X j ) is the posterior probability calculated by the aforementioned formula.
[0088] The predicted violation code class is determined according to the largest posterior probability After that, it is compared with the true label in the grid violation data to verify the recognition effect of the method on the violation code.
[0089] Embodiment 2, which is an embodiment of the present application, provides a system of a grid operation violation code automatic recognition method, comprising: a data collection and preprocessing module, an entity annotation and NER model training module, a feature keyword extraction and feature vector generation module, and a violation recognition module based on the Bayesian principle;
[0090] The data collection and preprocessing module is responsible for obtaining historical operation data from the grid company and performing preliminary processing to screen out text data related to violation behavior. By eliminating irrelevant information, only the operation violation description text and the corresponding violation code label are retained;
[0091] The entity annotation and NER model training module uses the YEDDA annotation tool to perform BIO annotation on the preprocessed data, marks the violation behavior and scene elements in the text as specific categories, and inputs the annotated text data into the BERT-BiLSTM-CRF Chinese NER model for training;
[0092] The feature keyword extraction and feature vector generation module identifies the feature keywords in the violation description text based on the trained NER model, generates a keyword dictionary through the TF-IDF algorithm, and uses the BOW model to construct the classic vector of the violation code. The text data is vectorized, and the prior probability of each violation code in the data is calculated;
[0093] The violation identification module based on the Bayesian principle is for the input new violation description text, a feature vector is constructed based on the NER model and the BOW algorithm, and the posterior probability corresponding to each violation type is calculated through the Bayesian principle, the violation code with the highest posterior probability is selected as the final identification result, and automatic identification and intelligent analysis of the violation code are realized
[0094] If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the parts that contribute to the prior art or parts of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various program code storage media.
[0095] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered a list of executable instructions for implementing logical functions, and can be specifically embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus or device, such as a computer-based system, a system including a processor or other system that can fetch instructions from an instruction execution system, apparatus or device and execute the instructions, or in conjunction with these instructions execution systems, apparatus or devices. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transport programs for instruction execution systems, apparatus or devices or in conjunction with these instruction execution systems, apparatus or devices.
[0096] More specific examples (non-exhaustive list) of computer-readable medium include the following: electrical connections having one or more wires (electronic devices), portable computer disks (magnetic devices), random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memories), fiber optic devices, and portable compact disc read-only memories (CDROMs). In addition, the computer-readable medium can even be paper or other suitable medium on which the program can be printed, as the program can be electronically obtained, for example, by optical scanning of the paper or other medium, followed by editing, interpretation or necessary processing, if necessary, in other suitable ways, and then stored in a computer memory.
[0097] It should be understood that various parts of the present application can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, a plurality of steps or methods can be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, and as in another embodiment, it can be implemented using any or a combination of the following technologies, which are known in the art: discrete logic circuitry having logic gates for implementing logic functions on data signals, application specific integrated circuits having appropriate combinational logic gates, programmable gate arrays (PGA), field programmable gate arrays (FPGA), etc.
[0098] Embodiment 3, refer to Figures 2 to 7 Another embodiment of the present application is to verify the beneficial effects of the present application, and to demonstrate the scientific argument by economic benefit calculation and simulation experiment. In this embodiment, the existing traditional method and the method of this embodiment are experimented respectively.
[0099] Step 1, text preprocessing: for the power grid operation data obtained from the power grid company, first, text preprocessing is performed, and the data irrelevant to the task of violation identification is eliminated, and the recorded field operation violation description information and its corresponding violation code and other contents are reserved. Here, for the 24001 pieces of operation data of a certain power grid company in the south obtained by the present application, after text preprocessing, 15183 pieces of violation data are obtained, and the obtained violation data contains complete field operation violation description and its corresponding category knowledge. For example, according to the obtained violation data, it is known that the 15183 operation violation events contain A, B, C, D type violation codes. Specifically, for the field operation violation description of "directly placing tools and instruments on the ground", the violation code recorded by the power grid staff is "D16"; for the field operation violation description of "no safety fence and vehicle warning sign installed on the roadside construction", the violation code recorded by the power grid staff is "D25".
[0100] Step 2, BIO entity labeling and Chinese NER model training: Based on the named entity recognition technology, the first work of the violation identification is to label the entity of the unstructured text data formed by the power grid field operation violation description. The quality of entity labeling has a direct impact on the effect of violation identification. Accurate and careful labeling of each entity in the violation description sentence helps to reliably describe the violation phenomenon; on the contrary, if the entity labeling is inaccurate or incomplete, it may lead to deviation in understanding and identifying the operation violation. Here, based on the YEDDA entity labeling tool, the BIO entity labeling is carried out on the H pieces of violation data obtained after text preprocessing: B-begin, I-inside, O-outside. B-X represents the beginning of entity X, I-X represents the inside of entity X, and O represents an entity that does not belong to any type. Through the research and analysis of the field operation violation text data, the entity categories in it are determined to be Object, Person, File, Action and Surrounding, wherein the data marking process is as shown in Figure 2 , and the final data for character marking is as shown in Figure 3 . The 15183 pieces of field operation violation unstructured text data of the power grid field operation violation labeled by BIO are input into the BERT-BiLSTM-CRF Chinese NER model for training, and the trained Chinese NER model weight is obtained. In this embodiment, the training data amount is set to B train = 342351 characters, and the test data amount is set to B test = 85590 characters. In the model training process, the related parameters are respectively learning rate lr = 0.0001, iteration number epochs = 128, batch number batchsize = 128, and the best experimental parameters are obtained by selecting the optimizer Adam. The experimental results of the final BERT-BiLSTM-CRF Chinese NER model are as shown in Figure 4 , and the model weight is saved.
[0101] P (precision) represents the proportion of samples actually belonging to a certain class among the samples predicted to belong to the class, R (recall) represents the proportion of samples actually belonging to a certain class among the samples correctly predicted to belong to the class, and F1 represents the harmonic mean of the precision P and the recall R, which is used to comprehensively evaluate the performance of the model. The three indexes of the final model are respectively P = 94%, R = 94%, and F1 = 94%.
[0102] Step 3, selecting the keyword dictionary and obtaining the classic vector and prior probability of the violation code: In order to verify the effectiveness of the method of the present application, the intelligent automatic identification of violation code can be realized, 1899 pieces of power grid field operation violation data of 7 kinds of dominant violation codes (C13, C18, C27, C46, C57, C98, D18) are randomly selected for testing. The violation phenomenon descriptions corresponding to the violation codes are respectively "C13: passing or staying at the vertical below the high operation site and the place where the falling object may fall; high operation personnel throw tools, appliances and materials at will; C18: when working in urban areas, densely populated areas, passing roads or traffic intersections, the work site is not equipped with a fence (fence) or other safety measures; C27: operation personnel arbitrarily cross the safety fence or exceed the safety warning line; C46: working on a ladder without a dedicated support or not tied firmly, or the ladder is erected on unstable support, or the ladder has no anti-slip measures, or the ladder has no limit opening rope; C57: not wearing or not wearing safety helmet correctly; C98: not wearing goggles or protective mask during low-voltage non-stop operation; D18: insulating tools are not put into protective devices after use or during transportation". The primary preparation work is to convert the field operation violation description text data into vector form.
[0103] The Chinese NER model training weight obtained in step 2 is used for entity recognition of the field operation violation description text data. The words and their word frequencies obtained by entity recognition are sorted according to each violation code. According to the TF-IDF algorithm, 5 keywords corresponding to each violation code are selected:
[0104]
[0105] Among them, tf x,y is the number of times that the word x appears in the field operation violation description text data corresponding to the violation code y; df x represents the number of violation codes containing the word x; N is the number of all violation codes, and in this embodiment, N is 7.
[0106] After the keyword selection of all violation codes is completed, 33 words are obtained by removing duplicate words. These keywords are sorted into a dictionary, that is, a keyword dictionary, and the word cloud diagram is as shown in Figure 5 .
[0107] The keyword dictionary is obtained, and a total of 33 words are obtained. A classical vector of each violation code is constructed, and the dimension of the classical vector is 33. Each dimension corresponds to a corresponding word in the keyword dictionary. For the classical vector of each violation code, 5 key words selected according to the TF-IDF algorithm are constructed based on the BOW model. The corresponding positions of the X key words in the 33-dimensional vector are assigned a value of 1, and the other positions are assigned a value of 0, to obtain the classical vector of each violation code. According to the preprocessed power grid field operation violation description text data, the proportion of each violation code (8.91%, 27.13%, 11.81%, 18.83%, 13.20%, 10.31%, 9.81%) corresponding to 1798 field operation violation descriptions of 7 violation codes (C13, C18, C27, C46, C57, C98, D18) is calculated as the prior probability. The proportion of each violation code in the data is shown in the picture of Figure 6 .
[0108] Step 4, recognition model based on Bayesian principle: Bayesian principle (Bayesian principle) or Bayesian theorem is a mathematical method for updating probability. Bayesian principle has important applications in statistics, machine learning, data analysis and other fields. Based on the Bayesian principle, the present application realizes automatic violation recognition, and further improves the tolerance of the violation recognizer to noise, abnormal points and data set overlap.
[0109] In order to verify the effectiveness of the proposed method of automatically identifying power grid operation violation codes based on Chinese NER model and Bayesian principle, the present application tests the proposed method based on the classical vector of violation code and prior probability obtained in steps 1 to 3 and the trained BERT-BiLSTM-CRF Chinese NER model weight. The data amount of the test sample is N test , N test = 1899 in the present embodiment, and the specific implementation process is as follows:
[0110] The 7 types of dominant violation codes corresponding to the violation data are used as the labels of the test data. Then, the entities recognized by the BERT-BiLSTM-CRF Chinese NER model from 1899 power grid field operation violation description text data are converted into 33-dimensional feature vectors by the BOW model, where the classical vector matrix of K types of dominant violation codes has a dimension of , and the prior probability of K types of dominant violation codes is Based on the Bayesian principle, first, the cosine similarity between the feature vector of a power grid field operation violation description text data and the classical vector of 7 types of dominant violation codes is calculated by formula (3):
[0111]
[0112] where v1 and v2 are two vectors, represents the dot product of vectors, and ||v1|| and ||v2|| are the norms of the two vectors, respectively.
[0113] The posterior probability is calculated, i.e., the probability that the feature vector of the given power grid field operation violation description text data belongs to a certain category, as follows:
[0114]
[0115] where 1≤i≤7,1≤j≤1899, P(X j |C i ) represents the likelihood of the feature vector X i under the category C j , which is calculated by cosine similarity here:
[0116] P(X j |C i ) = cosine_similarity(X j , C i ) (5)
[0117] P r (C i ) is the prior probability of the category C i .
[0118] P(X j ) is the evidence probability of the given feature vector X j , i.e., the weighted sum of the likelihoods and prior probabilities under all violation code categories:
[0119]
[0120] where C i is the standard vector of the corresponding violation code category.
[0121] Finally, the predicted violation code category is the category with the maximum posterior probability, which is shown as follows:
[0122]
[0123] where is the predicted violation code category, and P(C i |X j ) is the posterior probability calculated by the aforementioned formula.
[0124] The predicted violation code category matrix is obtained, which is then compared with the true labels The comparison is performed to verify the identification effect of the method on the violation codes. The confusion matrix of the final identification result is shown in Table 6. Figure 7 For the violation code automatic identifier, the identifier performs relatively well in identifying the violation codes, and the accuracy rate reaches 88.52%. This means that according to the given power grid field operation violation text records, there is a 88.52% probability to correctly identify the corresponding violation codes. However, for some more complex or easily confused violation codes, the automatic identifier still has certain improvement space.
[0125] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application but not limit the present application. Although the present application 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 application can be modified or replaced equivalently without departing from the spirit and scope of the present application, and all should be covered in the scope of the claims of the present application.
Claims
1. A method for automatically identifying power grid operation violation codes, characterized in that: include: Collect power grid operation data and perform text preprocessing; The YEDDA annotation tool was used to annotate the pre-processed on-site work violation description text data and then trained it in the BERT-BiLSTM-CRF Chinese NER model. Based on the trained NER model, the violation description text is recognized and the characteristic keywords of the violation code are extracted; Construct the feature vector of the violation code, calculate the probability of the violation type based on the Bayesian principle, and select the violation code with the highest posterior probability as the recognition result; The YEDDA annotation tool is used to perform entity annotation on the pre-processed on-site operation violation description text data, and is put into the BERT-BiLSTM-CRF Chinese NER model for training, including: For the power grid field operation violation text data obtained after text preprocessing, the unstructured text data formed by the description of the power grid field operation violation is annotated with BIO entities, and BIO ternary entity annotation is performed based on the YEDDA entity annotation tool; Annotation categories include Object, Person, File, Action, and Surrounding; The unstructured text data of power grid field operation violations annotated with BIO is put into the BERT-BiLSTM-CRF Chinese NER model for training to obtain the trained model weights. The trained NER model is used to identify the violation description text and extract the characteristic keywords of the violation code, including: The text data describing on-site operation violations is converted into vector form. Entity recognition is performed on the text data using the weights of the trained Chinese NER model. The words obtained from entity recognition are sorted according to each violation code and the word frequency is counted. According to the TF-IDF algorithm, X keywords corresponding to each violation code are selected and organized into a key dictionary. The expression is: Among them, tf x,y is the number of times word x appears in the on-site operation violation description text data corresponding to violation code y; df x represents the number of violation codes containing word x; N is the number of all violation codes.
2. The method for automatically identifying power grid operation violation codes according to claim 1, wherein: The collecting of power grid operation data and performing text preprocessing includes: Obtain historical operation data from the power grid company, filter out the descriptive text data related to the violation behavior, and eliminate the content irrelevant to the recognition task, retaining the complete operation violation description text and its violation code label information.
3. The method for automatically identifying power grid operation violation codes according to claim 2, wherein: The training of the BERT-BiLSTM-CRF Chinese NER model includes: During model training, the best experimental parameters are obtained by adjusting the learning rate, number of iterations, number of batches, and optimizer. When evaluating the model, precision, recall, and F1 value are selected as indicators for evaluating the performance of the recognition model. The expression is: Among them, TP is the number of instances predicted by the model as positive samples and actually are positive samples, FP is the number of instances predicted by the model as positive samples but are actually negative samples, FN is the number of instances predicted by the model as negative samples but are actually positive samples, P is the proportion of samples predicted to belong to a certain category that actually belong to that category, R is the proportion of samples that actually belong to a certain category that are correctly predicted to belong to that category, and F1 is the harmonic mean of precision P and recall R.
4. The method for automatically identifying power grid operation violation codes according to claim 3, wherein: The method of identifying the violation description text based on the trained NER model and extracting the characteristic keywords of the violation code also includes: The obtained key dictionary has a total of S words. The classic vector of each violation code is constructed. The dimension of the classic vector is S, and the position of each dimension corresponds to the corresponding word in the key dictionary. The classic vector for each violation code is constructed using X key words selected by the TF-IDF algorithm; Based on the BOW model, the corresponding positions of the X key words in the S-dimensional vector are assigned a value of 1, and the other positions are assigned a value of 0 to obtain the classic vector of each violation code. Based on the preprocessed power grid field operation violation description text data, the power grid operation field violation description data corresponding to some violation codes are randomly selected from the data, and the proportion of each violation code in the data is calculated as the prior probability.
5. The method for automatically identifying power grid operation violation codes according to claim 4, characterized in that: The feature vector of the violation code is constructed, and the probability of the violation type is calculated based on the Bayesian principle, and the violation code with the highest posterior probability is selected as the recognition result, including: For new descriptions of on-site operation violations, the BERT-BiLSTM-CRF Chinese NER model is used to identify entities, and the corresponding feature vector form is obtained according to the BOW algorithm. The posterior probability of the corresponding on-site operation violation description text data corresponding to different violation types is calculated, and the violation code with the largest posterior probability is used as the prediction result to achieve intelligent and automatic recognition of violation codes.
6. A system using the method for automatically identifying power grid operation violation codes according to any one of claims 1 to 5, characterized in that: It includes data collection and preprocessing module, entity labeling and NER model training module, feature keyword extraction and feature vector generation module, and violation identification module based on Bayesian principle; The data collection and preprocessing module is responsible for obtaining historical operation data from the power grid company and performing preliminary processing to filter out text data related to violations, removing irrelevant information and retaining only the description text of the operation violation and the corresponding violation code label; The entity annotation and NER model training module uses the YEDDA annotation tool to perform BIO annotation on the pre-processed data, marks the violations and scene elements in the text as specific categories, and inputs the annotated text data into the BERT-BiLSTM-CRF Chinese NER model for training; The feature keyword extraction and feature vector generation module uses the trained NER model to identify feature words in the violation description text, generates a key dictionary using the TF-IDF algorithm, and constructs a classic vector of the violation code using the BOW model. It vectorizes the text data and calculates the prior probability of each violation code in the data. The violation recognition module based on the Bayesian principle constructs a feature vector for the input new violation description text based on the NER model and the BOW algorithm, calculates the posterior probability corresponding to each violation type through the Bayesian principle, selects the violation code with the highest posterior probability as the final recognition result, and realizes automatic recognition and intelligent analysis of the violation code.
7. 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 automatically identifying power grid operation violation codes according to any one of claims 1 to 5 are implemented.
8. 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 automatically identifying power grid operation violation codes as described in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Named entity identification method based on ELCTRA and electric power safety regulation data
CN117807998A
Text classification method and device, electronic equipment and readable storage medium
CN118170902A