Named entity recognition method, device and computer equipment for power metering
By obtaining the Gaussian distribution characteristics of word vectors and combining bidirectional long and short-term memory networks and conditional random fields, the problem of low accuracy in identifying similar named entities in Chinese power metering reports is solved, achieving higher accuracy in naming entity recognition .
Patent Information
- Application Number
- CN202110837584.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-23
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2041-07-23
AI Technical Summary
Traditional naming entity recognition methods are difficult to accurately identify power metering named entities with similar names in Chinese power metering reports, resulting in low recognition accuracy.
By obtaining the Gaussian distribution characteristics of the word vector and inputting them into the bidirectional long and short-term memory network and conditional random field, word vector features are generated to determine the named entity, and using the Gaussian distribution characteristics to distinguish similar word vectors to improve recognition accuracy.
It effectively improves the accuracy of the recognition of named entities in power measurement, can accurately identify the differences between similar word vectors, and determine whether they are the same word vectors.
Smart Images

Figure CN113591479B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of named entity recognition, and in particular to a method, apparatus, computer equipment and storage medium for named entity recognition for power metering. Background Art
[0002] With the increasing popularity of knowledge graphs, people have a growing demand for knowledge graphs. For power metering knowledge graphs, it is often necessary to accurately identify and extract named entities of power metering from power metering texts before building them. In traditional technologies, deep learning models have been widely used in power metering, such as identifying named entities of power metering through long short-term memory neural networks (LSTM) and convolutional neural networks.
[0003] However, in Chinese electricity metering reports, the names of a large number of electricity metering named entities are similar, and traditional named entity recognition methods cannot accurately recognize them, resulting in low recognition accuracy of electricity metering named entities. Summary of the invention
[0004] Based on this, it is necessary to provide a method, device, computer equipment and storage medium for named entity recognition for electricity metering in response to the above technical problems.
[0005] A method for named entity recognition for electric power metering, the method comprising:
[0006] Obtain word vectors corresponding to multiple words in a corpus to be identified for describing power metering information;
[0007] Inputting multiple word vectors into a trained encoder, and obtaining the distribution characteristics of the Gaussian distribution corresponding to each word vector through the encoder;
[0008] Generate word vector features based on the distribution features corresponding to multiple word vectors;
[0009] The word vector feature is input into a preset conditional random field, and the named entities in the corpus to be identified are determined according to the labeling results output by the conditional random field.
[0010] In one embodiment, generating a word vector feature based on distribution features corresponding to a plurality of word vectors includes:
[0011] Combining the distribution features corresponding to the multiple word vectors to generate a first reference feature set and a second reference feature set; each element in the first reference feature set is a word vector; each element in the second reference feature set is an adjacent word vector pair;
[0012] Inputting the first reference feature set and the second reference feature set into a trained bidirectional long short-term memory network, and obtaining independent features corresponding to the first reference feature set and correlation features corresponding to the second reference feature set through the bidirectional long short-term memory network;
[0013] The independent features and the correlation features are fused to obtain word vector features.
[0014] In one embodiment, the combining of the distribution features corresponding to the plurality of word vectors to generate the second reference feature set includes:
[0015] Determine an arrangement order corresponding to the plurality of distribution features; the arrangement order corresponds to an arrangement order of each word in the corpus to be recognized;
[0016] According to the arrangement order, multiple groups of adjacent distribution features are obtained to obtain multiple groups of distribution feature pairs;
[0017] A second reference feature set is generated using multiple sets of distribution feature pairs.
[0018] In one embodiment, it also includes:
[0019] Acquire a pre-built power metering corpus; the power metering corpus includes a plurality of corpora for describing power metering information;
[0020] The preset word segmentation model is used to segment the corpus in the power metering corpus to obtain multiple words used to describe the power metering information;
[0021] The initialized word vector model is trained based on the obtained multiple words to obtain a trained word vector model, and the trained word vector model is used to obtain word vectors corresponding to words in the power metering corpus.
[0022] In one embodiment, it also includes:
[0023] Obtaining first word vectors corresponding to a plurality of words for describing the power metering information through the trained word vector model;
[0024] Inputting the first word vector into an encoder to be trained, and obtaining a first distribution feature of a Gaussian distribution corresponding to the first word vector through the encoder;
[0025] Inputting the first distribution feature into a decoder to be trained, and obtaining a predicted word vector based on the first distribution feature through the decoder;
[0026] Based on the first word vector, the predicted word vector and the loss function, the parameters of the encoder and the decoder are adjusted until the training end condition is met to obtain a trained encoder and decoder.
[0027] In one embodiment, it also includes:
[0028] Acquire a sample corpus and its corresponding label; the label includes a named entity of power metering in the sample corpus and an entity category corresponding to the named entity;
[0029] Segment the sample corpus using the trained segmentation model to obtain second word vectors corresponding to each of the multiple words after the segmentation, and obtain second distribution features corresponding to the second word vectors using the trained encoder;
[0030] Combining the plurality of second distribution features to generate a first sample feature set and a second sample feature set, and inputting the first sample feature set and the second sample feature set into a bidirectional long short-term memory network to be trained to obtain corresponding word vector features;
[0031] The word vector feature is input into a preset conditional random field, and the network parameters corresponding to the bidirectional long short-term memory network are adjusted according to the prediction result output by the conditional random field and the label, until the training end condition is met, thereby obtaining a trained bidirectional long short-term memory network.
[0032] In one embodiment, adjusting the network parameters corresponding to the bidirectional long short-term memory network according to the prediction result output by the conditional random field and the label includes:
[0033] Determine, through the conditional random field and based on the word vector feature, a prediction result corresponding to each word vector feature and a prediction score corresponding to the prediction result;
[0034] Determine the current conditional probability based on the prediction scores corresponding to multiple word vectors and the preset potential function;
[0035] When the conditional probability is less than a preset probability threshold, the network parameters corresponding to the bidirectional long short-term memory network are adjusted according to the prediction result and the label.
[0036] A named entity recognition device for electric power metering, the device comprising:
[0037] A word vector acquisition module, used to acquire word vectors corresponding to multiple words in a to-be-recognized corpus used to describe power metering information;
[0038] A distribution feature acquisition module, used to input multiple word vectors into a trained encoder, and obtain the distribution feature of the Gaussian distribution corresponding to each word vector through the encoder;
[0039] A word vector feature acquisition module is used to generate word vector features based on the distribution features corresponding to multiple word vectors;
[0040] The named entity determination module is used to input the word vector features into a preset conditional random field, and determine the named entities in the corpus to be identified according to the labeling results output by the conditional random field.
[0041] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any of the above methods when executing the computer program.
[0042] The above-mentioned named entity recognition method, device, computer equipment and storage medium for power metering can obtain the word vectors corresponding to each of the multiple words in the corpus to be recognized for describing power metering information, input the multiple word vectors into the trained encoder, obtain the distribution characteristics of the Gaussian distribution corresponding to each word vector through the encoder, generate word vector features based on the distribution characteristics corresponding to the multiple word vectors, and then input the word vector features into a preset conditional random field, and determine the named entities in the corpus to be recognized according to the labeling results output by the conditional random field. In this embodiment, by obtaining the distribution characteristics of the Gaussian distribution corresponding to the word vector, the difference between similar word vectors can be accurately identified, thereby judging whether two similar word vectors are the same word vector, and effectively improving the accuracy of named entity recognition for power metering. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A schematic diagram of a flow chart of a method for named entity recognition for power metering in an embodiment;
[0044] Figure 2 A schematic flow chart of a method for named entity recognition for power metering in another embodiment;
[0045] Figure 3 It is a structural block diagram of a named entity recognition device for power metering in one embodiment;
[0046] Figure 4 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0048] With the development of smart grid and big data, the demand for analysis and processing of power big data by enterprises and research institutions is becoming more and more urgent. There is a large amount of discrete power metering information in the power system. In order to obtain effective knowledge, knowledge can be extracted from discrete power metering information and a power metering knowledge graph can be constructed. The knowledge graph describes the concepts, entities and their relationships in the objective world in a structured form. For smart grid, the knowledge graph can represent power metering knowledge in a systematic way, so as to provide knowledge support and data support for the decision-making of smart grid in combination with data. The power metering knowledge graph is based on power metering knowledge, and the key to obtaining power metering knowledge is to identify and extract power metering entities from power metering texts, abstract knowledge based on entities, and construct knowledge graphs. Therefore, power metering entity recognition is a prerequisite for constructing power metering knowledge graphs. The purpose of power metering entity recognition is to identify power metering entities and their categories in specific fields, which is of great significance to the analysis of power metering content and the establishment of power metering knowledge graphs. The demand for efficient power metering entity recognition methods is also becoming more and more urgent.
[0049] In traditional technology, early entity recognition methods for power metering can be divided into dictionary or rule-based methods and statistical machine learning model-based methods. In recent years, deep learning models have been widely used in power metering, such as recognizing named entities for power metering through long short-term memory neural networks (LSTM) and convolutional neural networks.
[0050] However, in the electricity metering report, the names of a large number of electricity metering named entities are similar, and the traditional named entity recognition method cannot accurately recognize them, resulting in low recognition accuracy of electricity metering named entities.
[0051] In one embodiment, Figure 1 As shown, a method for named entity recognition of power metering is provided. This embodiment takes the method applied to a server as an example. It can be understood that the method can also be applied to a terminal, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method can include the following steps:
[0052] Step 101: Obtain word vectors corresponding to a plurality of words in a corpus to be identified for describing power metering information.
[0053] The word vector may be a vector obtained by mapping a word to a real number.
[0054] In practical applications, the server can obtain a corpus to be recognized that is used to describe power metering information. After segmenting the corpus to be recognized, the word vectors corresponding to each of the multiple words in the corpus to be recognized can be determined.
[0055] Step 102, input a plurality of word vectors into a trained encoder, and obtain the distribution characteristics of the Gaussian distribution corresponding to each word vector through the encoder.
[0056] The distribution characteristics may include the expectation and covariance of the Gaussian distribution.
[0057] After obtaining multiple word vectors, the multiple word vectors can be input into a pre-trained encoder, which encodes the input word vectors into features in the form of parameterized Gaussian distribution, so that the distribution features of the Gaussian distribution corresponding to each word vector can be obtained. After obtaining the distribution features of the Gaussian distribution corresponding to each word vector, the difference between the two word vectors can be reflected through the distribution features.
[0058] Specifically, in electricity metering, two similar named entities may have word vectors with high similarity, that is, similar named entities may obtain word vectors that are relatively similar. If the traditional distance measurement method is used to measure the word vector distance, it is easy to obtain a very small distance gap (the word vector dimension is also relatively high), which makes it difficult to distinguish different named entities. Based on this, in this embodiment, the distance measurement between word vectors can be converted into a difference measurement of expectation and covariance under a Gaussian distribution through feature representation, and the word vectors are encoded as distribution features that obey the Gaussian distribution. The difference in expectation and covariance of the features corresponding to different word vectors is used to determine whether the two word vectors are the same.
[0059] Step 103: Generate word vector features based on the distribution features corresponding to the multiple word vectors.
[0060] After obtaining the distribution features corresponding to multiple word vectors, the distribution features can be input into a trained bidirectional long short-term memory network (Bi-LSTM). After the input distribution features are processed by the bidirectional long short-term memory network, word vector features are generated.
[0061] Step 104: input the word vector feature into a preset conditional random field, and determine the named entities in the corpus to be identified according to the labeling results output by the conditional random field.
[0062] After obtaining the word vector features, the word vector features can be input into a preset conditional random field, which predicts the labeling results corresponding to each word based on the input word vector features, and then the named entities in the corpus to be identified can be determined based on the labeling results. After determining the named entities, the corpus to be identified can be labeled and saved based on the identified named entities.
[0063] In this embodiment, the word vectors corresponding to each of the multiple words in the corpus to be identified for describing the power metering information can be obtained, and the multiple word vectors are input into the trained encoder, and the distribution characteristics of the Gaussian distribution corresponding to each word vector are obtained through the encoder. Based on the distribution characteristics corresponding to the multiple word vectors, the word vector features are generated, and then the word vector features can be input into a preset conditional random field, and the named entities in the corpus to be identified are determined according to the labeling results output by the conditional random field. In this embodiment, by obtaining the distribution characteristics of the Gaussian distribution corresponding to the word vector, the difference between similar word vectors can be accurately identified, thereby judging whether two similar word vectors are the same word vector, and effectively improving the recognition accuracy of named entities in power metering.
[0064] In one embodiment, generating a word vector feature based on the distribution features corresponding to the multiple word vectors may include the following steps:
[0065] The distribution features corresponding to multiple word vectors are combined to generate a first reference feature set and a second reference feature set; the first reference feature set and the second reference feature set are input into a trained bidirectional long short-term memory network, and the independent features corresponding to the first reference feature set and the correlation features corresponding to the second reference set are obtained through the bidirectional long short-term memory network; the independent features and the correlation features are fused to obtain word vector features.
[0066] Each element in the first reference feature set is a distribution feature of a corresponding word vector, and each element in the second reference feature set corresponds to two adjacent distribution features.
[0067] In a specific implementation, after obtaining the distribution features corresponding to multiple word vectors, the multiple distribution features can be combined to generate a first reference feature set and a second reference feature set, and the first reference feature set and the second reference feature set are input into a trained bidirectional long short-term memory network. The independent features corresponding to the first reference feature set and the correlation features corresponding to the second reference set are obtained through the bidirectional long short-term memory network.
[0068] Specifically, the trained bidirectional long short-term memory network may include two processing modules, and the bidirectional long short-term memory network may also be called a two-order bidirectional long short-term memory network. The first reference feature set and the second reference feature set inputted may be processed respectively by two processing modules, the first processing module processes the first reference feature set, and the second processing module processes each element in the second reference feature set.
[0069] For example, for "current loss", when performing word segmentation, it may be divided into one word "current loss", or it may be divided into two words "current" and "loss of flow", but the correct way of division is to determine "current loss of flow" as a named entity, and its corresponding named entity category is phenomenon entity. If "current loss of flow" is divided into two entities, it is easy to cause "current" to be identified as an object entity during recognition, while "loss of flow" is not identified as an entity. In order to avoid the above-mentioned incorrect division, the distribution characteristics of the word vector are processed, and the first processing module processes based on the distribution characteristics corresponding to a single word vector. For example, the distribution feature corresponding to the "current" word vector is FL1, and the feature corresponding to the "loss of flow" word vector is FL2. The first processing module extracts features from FL1 and FL2 respectively, and the independent features corresponding to FL1 and FL2 are obtained, while the second processing module extracts features based on FL1 and FL2 at the same time to obtain the correlation features corresponding to the two, thereby preventing entity recognition errors.
[0070] After obtaining the independent features and the correlation features, the independent features and the correlation features may be fused to obtain word vector features reflecting the characteristics of multiple word vectors.
[0071] In this embodiment, the distribution features corresponding to multiple word vectors can be combined to generate a first reference feature set and a second reference feature set, and the first reference feature set and the second reference feature set are input into a trained bidirectional long short-term memory network. The independent features corresponding to the first reference feature set and the correlation features corresponding to the second reference set are obtained through the bidirectional long short-term memory network, and the independent features and the correlation features are fused to obtain word vector features. The distribution features of word vectors can be combined to prevent entity recognition errors caused by word segmentation errors.
[0072] In one embodiment, combining the distribution features corresponding to the multiple word vectors to generate the second reference feature set may include the following steps:
[0073] Determine an arrangement order corresponding to a plurality of distribution features; obtain a plurality of groups of adjacent distribution features according to the arrangement order to obtain a plurality of groups of distribution feature pairs; and use the plurality of groups of distribution feature pairs to generate a second reference feature set.
[0074] The arrangement order corresponding to the multiple distribution features corresponds to the arrangement order of each word in the corpus to be recognized.
[0075] In a specific implementation, after obtaining the distribution features corresponding to multiple word vectors, the arrangement order corresponding to the multiple distribution features can be determined. Specifically, the distribution features of the word vectors can be combined into a distribution feature expression of a corpus according to the arrangement order corresponding to the original words.
[0076] After obtaining the arrangement order corresponding to the multiple distribution features, multiple groups of adjacent distribution features can be obtained according to the arrangement order to obtain multiple groups of distribution feature pairs, each group of distribution feature pairs containing two adjacent distribution features. After obtaining multiple groups of distribution feature pairs, each group of distribution feature pairs can be determined as an element to generate a second reference feature set containing multiple elements.
[0077] In this embodiment, by determining the arrangement order corresponding to multiple distribution features, multiple groups of adjacent distribution features are obtained according to the arrangement order to obtain multiple groups of distribution feature pairs. The second reference feature set is generated by using multiple groups of distribution feature pairs. The feature distributions corresponding to adjacent word vectors can be combined to provide a data processing basis for preventing entity recognition errors caused by word segmentation errors.
[0078] In one embodiment, the method may further include the following steps:
[0079] A pre-built electric power metering corpus is obtained; a preset word segmentation model is used to segment the corpus in the electric power metering corpus to obtain a plurality of words for describing electric power metering information; an initialized word vector model is trained based on the obtained plurality of words to obtain a trained word vector model.
[0080] Among them, the power metering corpus includes multiple corpora used to describe power metering information, and the trained word vector model is used to obtain the word vectors corresponding to the words in the power metering corpus.
[0081] In the specific implementation, the entity types in general fields are generally people, places, organizations, etc., and the naming format is relatively standardized. Accordingly, many named entity datasets in general fields have been opened and used for model training. However, in the field of power metering, there is a lack of a public dataset that can be directly used for machine learning model training.
[0082] Based on this, a power metering corpus can be pre-built. Specifically, there is a large amount of corpus related to power metering in the power system. For example, it can be obtained from the developed power metering information processing system, or from the main information such as business reports and power metering statistics obtained from enterprises engaged in power work, or, for English corpus, corpus related to power metering can be obtained from the English knowledge base. After obtaining a large amount of corpus related to power metering, data cleaning can be performed to remove irrelevant information, and a power metering corpus including English corpus and Chinese corpus can be obtained.
[0083] After obtaining the power metering corpus, a preset word segmentation model can be used to segment the corpus in the power metering corpus to obtain multiple words for describing power metering information, such as structurally dividing sentences in the corpus based on multiple punctuation marks. After word segmentation, the currently obtained words can be used to train an initialized word vector model to obtain a trained word vector model, such as training a Word2Vec model, so that the model can be used to map words describing power metering information into word vectors later.
[0084] In this embodiment, a pre-constructed power metering corpus is obtained, and a preset word segmentation model is used to segment the corpus of the power metering corpus to obtain a plurality of words for describing power metering information. The plurality of words are used to train an initialized word vector model to obtain a trained word vector model. The power metering corpus and word vectors related to power metering can be constructed, and the named entity boundary model of power metering can be avoided, thereby providing a basis for the subsequent accurate identification of named entities of power metering.
[0085] In one embodiment, the method may further include the following steps:
[0086] Through the trained word vector model, first word vectors corresponding to multiple words used to describe power metering information are obtained; the first word vectors are input into the encoder to be trained, and the first distribution feature of the Gaussian distribution corresponding to the first word vector is obtained through the encoder; the first distribution feature is input into the decoder to be trained, and the predicted word vector is obtained through the decoder based on the first distribution feature; based on the first word vector, the predicted word vector and the loss function, the parameters of the encoder and the decoder are adjusted until the training end condition is met, so as to obtain the trained encoder and decoder.
[0087] In practical applications, after obtaining the trained word vector model, the first word vector corresponding to each of the multiple words used to describe the electricity metering information can be obtained through the trained word vector model. For example, for the sample fishing, it can be segmented through the preset word segmentation model, and the first word vector corresponding to each word can be determined through the trained word vector model.
[0088] In a specific implementation, a Gaussian autoencoder (AE) to be trained can be pre-set, and the autoencoder includes two parts: an encoder and a decoder. After obtaining the first word vector, the first word vector can be input into the encoder to be trained, and the encoder determines the Gaussian distribution corresponding to the first word vector and obtains its corresponding first distribution feature. After obtaining the first distribution feature, the first distribution feature can be input into the decoder to be trained, and the predicted word vector can be obtained by the decoder based on the first distribution feature. Then, based on the first word vector, the predicted word vector and the loss function, the parameters of the encoder and the decoder can be adjusted until the training end condition is met to obtain the trained encoder and decoder.
[0089] Specifically, the encoder can also be called a Gaussian encoder, and the encoding process of the encoder is as follows:
[0090] h=Encoder(x)=Neural(W;x)=Gaussian(μ(W1,x),σ(W2,x))
[0091] Among them, h represents the implicit expression corresponding to the word vector, μ represents expectation, σ represents covariance, and Neural represents a convolutional neural network.
[0092] The decoder can also be a convolutional neural network, and the word vector input to the encoder and the word vector output by the decoder have the same dimension.
[0093] The loss function can be shown as follows:
[0094]
[0095] Decoder stands for decoder. During the training process, the training goal is to make the word vector input to the encoder and the word vector output by the decoder as consistent as possible, so as to extract effective distribution features of the word vector through the encoder.
[0096] In this embodiment, a first word vector corresponding to each of a plurality of words used to describe power metering information is obtained through a trained word vector model, the first word vector is input into an encoder to be trained, a first distribution feature of a Gaussian distribution corresponding to the first word vector is obtained through the encoder, the first distribution feature is input into a decoder to be trained, and a predicted word vector is obtained through the decoder based on the first distribution feature; based on the first word vector, the predicted word vector and the loss function, the parameters of the encoder and the decoder are adjusted until the training end condition is met, and a trained encoder and decoder are obtained, providing a model basis for the subsequent accurate determination of the distribution features corresponding to the word vectors.
[0097] In one embodiment, the method may further include the following steps:
[0098] Acquire a sample corpus and its corresponding label; use a trained word segmentation model to segment the sample corpus, obtain second word vectors corresponding to multiple words after segmentation, and obtain second distribution features corresponding to the second word vectors through a trained encoder; combine multiple second distribution features to generate a first reference feature set and a second reference feature set, and input the first reference feature set and the second reference feature set into a bidirectional long short-term memory network to be trained to obtain corresponding word vector features; input the word vector features into a preset conditional random field, and adjust the network parameters corresponding to the bidirectional long short-term memory network according to the prediction results output by the conditional random field and the label until the training end condition is met to obtain a trained bidirectional long short-term memory network.
[0099] Among them, the label includes the named entity of electricity metering in this corpus and the entity category corresponding to the named entity. The label can be marked by the BIO annotation system. The entity category corresponding to each named entity can be any of the following: electricity metering indicators, electricity metering objects, electricity metering phenomena and electricity metering behaviors. Specifically, in electricity metering, the boundaries between different named entities are relatively vague. By introducing the above-mentioned entity categories, the corresponding entity categories can be determined while identifying the named entities, thereby improving the recognition efficiency.
[0100] For example, statistical electricity consumption data can be labeled as "electricity consumption", "meter reading rate", "current", "electricity", etc. and divided into electricity metering indicator entities. Objects, personnel, regions, and institutions related to electricity metering are identified as electricity metering object entities, such as "electricity meter", "Guangzhou Power Supply Bureau", etc. Phenomena generated by specific subjects in the electricity metering process are identified as electricity metering phenomenon entities, such as "abnormal electricity difference", "electricity meter stop", "current loss", "current imbalance", etc. Electricity metering operations for specific actions can be marked as electricity metering behavior entities, such as "meter reading", "abnormal maintenance", etc. Among them, the indicators and objects of electricity metering entities are mostly nouns, electricity metering phenomena are mostly combinations of nouns and verbs, and electricity metering behaviors are mostly verbs.
[0101] In practical applications, a sample corpus and its corresponding labels can be obtained, and the sample corpus is a corpus used to describe power metering information. After obtaining the sample corpus, a word segmentation model can be used to segment the sample corpus, and the second word vectors corresponding to the multiple words after segmentation can be obtained through the trained word vector model, and the second distribution features corresponding to the second word vectors can be obtained through the trained encoder.
[0102] After obtaining multiple second distribution features, the multiple second distribution features can be combined to generate a first reference feature set and a second reference feature set, and the first sample feature set and the second sample feature set are input into the bidirectional long short-term memory network to be trained to obtain corresponding word vector features, wherein each element in the first sample feature set can correspond to a distribution feature, and an element in the second sample feature set can correspond to two adjacent distribution features. The method for obtaining the first sample feature set and the second sample feature set is similar to the method for obtaining the first reference feature set and the second reference feature set, and is not elaborated in this embodiment.
[0103] After obtaining the corresponding word vector, the word vector feature can be input into the preset conditional random field. According to the prediction results and labels output by the conditional random field, the network parameters corresponding to the bidirectional long short-term memory network are adjusted until the training end conditions are met to obtain a trained bidirectional long short-term memory network.
[0104] In this embodiment, by obtaining a sample corpus and its corresponding labels, a word segmentation model is used to segment the sample corpus, and second word vectors corresponding to multiple words after segmentation are obtained. The second distribution features corresponding to the second word vectors are obtained through a trained encoder, and then the multiple second distribution features are combined to generate a first reference feature set and a second reference feature set. The first reference feature set and the second reference feature set are input into a bidirectional long short-term memory network to be trained to obtain corresponding word vector features, and the word vector features are input into a preset conditional random field. According to the prediction results and labels output by the conditional random field, the network parameters corresponding to the bidirectional long short-term memory network are adjusted until the training end conditions are met, and a trained bidirectional long short-term memory network is obtained, which can provide a model basis for quickly and accurately obtaining word vector features.
[0105] In one embodiment, adjusting the network parameters corresponding to the bidirectional long short-term memory network according to the prediction result output by the conditional random field and the label may include:
[0106] The prediction result corresponding to each word vector feature and the prediction score corresponding to the prediction result are determined based on the word vector feature through the conditional random field; the current conditional probability is determined according to the prediction scores corresponding to multiple word vectors and a preset potential function; when the conditional probability is less than a preset probability threshold, the network parameters corresponding to the bidirectional long short-term memory network are adjusted according to the prediction result and the label.
[0107] In practical applications, the entity recognition problem can be regarded as a sequence labeling problem. Considering the correlation between adjacent labels and named entities, the conditional random field (CRF) can be used to jointly model the label sequence and identify the named entities.
[0108] In this embodiment, after obtaining the word vector features corresponding to the sample corpus, the word vector features can be input into the conditional random field, and the conditional random field determines the prediction results corresponding to each word vector feature and the prediction scores corresponding to the prediction results based on the word vector features, wherein the prediction results can be the entity recognition results and entity categories corresponding to each word vector.
[0109] After obtaining the prediction score, the current conditional probability can be determined based on the prediction scores corresponding to multiple word vectors and the preset potential function. The potential function can be as follows:
[0110]
[0111] in, is the prediction score corresponding to the adjacent word vectors and their labels, is the prediction score corresponding to the i-th word vector and its label, both of which can be determined by a neural network.
[0112] The conditional probability can be determined by the following formula:
[0113]
[0114] When the conditional probability is less than the preset probability threshold, the network parameters corresponding to the bidirectional long short-term memory network can be adjusted according to the prediction results and labels to continuously improve the conditional probability as the training target of the model. When the conditional probability reaches the preset probability threshold, it can be determined that the prediction result of the current bidirectional long short-term memory network is consistent with the label, the training end condition is met, and a trained bidirectional long short-term memory network is obtained.
[0115] In this embodiment, the prediction result corresponding to each word vector feature and the prediction score corresponding to the prediction result can be determined based on the word vector feature through the conditional random field, and the current conditional probability can be determined according to the prediction scores corresponding to multiple word vectors and the preset potential function; when the conditional probability is less than the preset probability threshold, the network parameters corresponding to the bidirectional long short-term memory network are adjusted according to the prediction result and label, so as to effectively improve the recognition accuracy of the bidirectional long short-term memory network.
[0116] In order to enable those skilled in the art to better understand the above steps, the embodiment of the present application is illustrated below by using an example, but it should be understood that the embodiment of the present application is not limited to this.
[0117] like Figure 2 As shown in the figure, after obtaining the corpus to be recognized, it can be segmented and the word vectors corresponding to each word after segmentation can be obtained (corresponding to Figure 2The distribution features of each word vector under Gaussian distribution can be obtained through Gaussian autoencoder (AE). For Gaussian autoencoder, the encoder and decoder can be trained in advance to improve the recognition accuracy of distribution features.
[0118] After obtaining the distribution features corresponding to multiple word vectors, a first reference feature set and a second reference feature set can be generated, wherein each element in the first reference feature set corresponds to a distribution feature, and each element in the second reference feature set corresponds to two adjacent distribution features.
[0119] After obtaining the first reference feature set and the second reference feature set, they can be input into the trained bidirectional long short-term memory network. The bidirectional long short-term memory network can include two processing modules: a first processing module and a second processing module. Both processing modules include a bidirectional long short-term memory network module, wherein the first processing module can process the first reference feature set, that is, analyze and process each distribution feature separately to obtain the corresponding independent feature; the second processing module can process the second reference feature set, that is, process two adjacent distribution features each time to obtain the corresponding correlation feature.
[0120] After obtaining independent features and correlation features, they can be fused to generate word vector features, and then input into the conditional random field, so as to identify multiple named entities in the corpus to be identified through the conditional random field.
[0121] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0122] In one embodiment, Figure 3 As shown, a named entity recognition device for power metering is provided, and the device includes:
[0123] A word vector acquisition module 301 is used to acquire word vectors corresponding to a plurality of words in a to-be-recognized corpus for describing power metering information;
[0124] A distribution feature acquisition module 302 is used to input multiple word vectors into a trained encoder, and obtain the distribution feature of the Gaussian distribution corresponding to each word vector through the encoder;
[0125] A word vector feature acquisition module 303, used to generate a word vector feature based on distribution features corresponding to a plurality of word vectors;
[0126] The named entity determination module 304 is used to input the word vector features into a preset conditional random field, and determine the named entities in the corpus to be identified according to the labeling results output by the conditional random field.
[0127] In one embodiment, the word vector feature acquisition module 303 includes:
[0128] A reference feature set acquisition submodule is used to combine the distribution features corresponding to multiple word vectors to generate a first reference feature set and a second reference feature set; each element in the first reference feature set is a word vector; each element in the second reference feature set is an adjacent word vector pair;
[0129] A network processing submodule, configured to input the first reference feature set and the second reference feature set into a trained bidirectional long short-term memory network, and obtain independent features corresponding to the first reference feature set and associated features corresponding to the second reference feature set through the bidirectional long short-term memory network;
[0130] The word vector feature determination submodule is used to perform feature fusion on the independent feature and the correlation feature to obtain the word vector feature.
[0131] In one embodiment, the reference feature set acquisition submodule is specifically used to:
[0132] Determine an arrangement order corresponding to the plurality of distribution features; the arrangement order corresponds to an arrangement order of each word in the corpus to be recognized;
[0133] According to the arrangement order, multiple groups of adjacent distribution features are obtained to obtain multiple groups of distribution feature pairs;
[0134] A second reference feature set is generated using multiple sets of distribution feature pairs.
[0135] In one embodiment, the apparatus further comprises:
[0136] An electric power metering corpus acquisition module is used to acquire a pre-built electric power metering corpus; the electric power metering corpus includes a plurality of corpora for describing electric power metering information;
[0137] A corpus word segmentation module is used to segment the corpus in the power metering corpus using a preset word segmentation model to obtain a plurality of words used to describe the power metering information;
[0138] The word vector model training module is used to train the initialized word vector model based on the obtained multiple words to obtain a trained word vector model, and the trained word vector model is used to obtain the word vectors corresponding to the words in the power metering corpus.
[0139] In one embodiment, the apparatus further comprises:
[0140] A first word vector acquisition module, used to acquire first word vectors corresponding to each of a plurality of words used to describe the power metering information through a trained word vector model;
[0141] A first distribution feature acquisition module, used for inputting the first word vector into an encoder to be trained, and obtaining a first distribution feature of a Gaussian distribution corresponding to the first word vector through the encoder;
[0142] A decoding module, used for inputting the first distribution feature into a decoder to be trained, and obtaining a predicted word vector based on the first distribution feature through the decoder;
[0143] The first training module is used to adjust the parameters of the encoder and decoder based on the first word vector, the predicted word vector and the loss function until the training end condition is met to obtain the trained encoder and decoder.
[0144] In one embodiment, the apparatus further comprises:
[0145] A sample corpus acquisition module, used to acquire sample corpus and its corresponding label; the label includes a named entity of power metering in the sample corpus and an entity category corresponding to the named entity;
[0146] A second word vector acquisition module is used to segment the sample corpus using the trained word segmentation model, obtain second word vectors corresponding to each of the multiple words after the segmentation, and obtain second distribution features corresponding to the second word vectors through the trained encoder;
[0147] A sample feature set acquisition module, used to combine multiple second distribution features to generate a first sample feature set and a second sample feature set, and input the first sample feature set and the second sample feature set into a bidirectional long short-term memory network to be trained to obtain corresponding word vector features;
[0148] The second training module is used to input the word vector features into a preset conditional random field, and adjust the network parameters corresponding to the bidirectional long short-term memory network according to the prediction results output by the conditional random field and the labels, until the training end conditions are met, thereby obtaining a trained bidirectional long short-term memory network.
[0149] In one embodiment, the second training module includes:
[0150] A prediction score acquisition submodule, used to determine the prediction result corresponding to each word vector feature and the prediction score corresponding to the prediction result based on the word vector feature through the conditional random field;
[0151] The conditional probability determination submodule is used to determine the current conditional probability according to the prediction scores corresponding to multiple word vectors and the preset potential function;
[0152] A parameter adjustment submodule is used to adjust the network parameters corresponding to the bidirectional long short-term memory network according to the prediction result and the label when the conditional probability is less than a preset probability threshold.
[0153] For the specific definition of a named entity recognition device for electricity metering, please refer to the definition of a named entity recognition method for electricity metering mentioned above, which will not be repeated here. Each module in the above-mentioned named entity recognition device for electricity metering can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0154] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store word vectors. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for named entity recognition of power metering is implemented.
[0155] Those skilled in the art will understand that Figure 4The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0156] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0157] Obtain word vectors corresponding to multiple words in a corpus to be identified for describing power metering information;
[0158] Inputting multiple word vectors into a trained encoder, and obtaining the distribution characteristics of the Gaussian distribution corresponding to each word vector through the encoder;
[0159] Generate word vector features based on the distribution features corresponding to multiple word vectors;
[0160] The word vector feature is input into a preset conditional random field, and the named entities in the corpus to be identified are determined according to the labeling results output by the conditional random field.
[0161] In one embodiment, when the processor executes the computer program, the steps in the other embodiments described above are also implemented.
[0162] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0163] Obtain word vectors corresponding to multiple words in a corpus to be identified for describing power metering information;
[0164] Inputting multiple word vectors into a trained encoder, and obtaining the distribution characteristics of the Gaussian distribution corresponding to each word vector through the encoder;
[0165] Generate word vector features based on the distribution features corresponding to multiple word vectors;
[0166] The word vector feature is input into a preset conditional random field, and the named entities in the corpus to be identified are determined according to the labeling results output by the conditional random field.
[0167] In one embodiment, when the computer program is executed by a processor, the steps in the other embodiments described above are also implemented.
[0168] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0169] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0170] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for named entity recognition for power metering, characterized in that: The method comprises: Obtain word vectors corresponding to multiple words in a corpus to be identified for describing power metering information; Inputting multiple word vectors into a trained encoder, and obtaining the distribution characteristics of the Gaussian distribution corresponding to each word vector through the encoder, including: converting the distance measure between the word vectors into the difference measure of expectation and covariance under the Gaussian distribution through the feature representation through the encoder, and obtaining the distribution characteristics of the Gaussian distribution corresponding to each word vector; the distribution characteristics include the expectation and covariance of the Gaussian distribution; Based on the distribution features corresponding to multiple word vectors, generating word vector features, including: combining the distribution features corresponding to the multiple word vectors to generate a first reference feature set and a second reference feature set; each element in the first reference feature set is a word vector; each element in the second reference feature set is an adjacent word vector pair; inputting the first reference feature set and the second reference feature set into a trained bidirectional long short-term memory network, obtaining independent features corresponding to the first reference feature set and correlation features corresponding to the second reference feature set through the bidirectional long short-term memory network; performing feature fusion on the independent features and the correlation features to obtain word vector features; The word vector feature is input into a preset conditional random field, and the named entities in the corpus to be identified are determined according to the labeling results output by the conditional random field.
2. The method according to claim 1, characterized in that The combining of the distribution features corresponding to the multiple word vectors to generate a second reference feature set includes: Determine an arrangement order corresponding to the plurality of distribution features; the arrangement order corresponds to an arrangement order of each word in the corpus to be recognized; According to the arrangement order, multiple groups of adjacent distribution features are obtained to obtain multiple groups of distribution feature pairs; A second reference feature set is generated using multiple sets of distribution feature pairs.
3. The method according to claim 1, characterized in that Also includes: Acquire a pre-built power metering corpus; the power metering corpus includes a plurality of corpora for describing power metering information; The preset word segmentation model is used to segment the corpus in the power metering corpus to obtain multiple words used to describe the power metering information; The initialized word vector model is trained based on the obtained multiple words to obtain a trained word vector model, and the trained word vector model is used to obtain word vectors corresponding to words in the power metering corpus.
4. The method according to claim 3, characterized in that Also includes: Obtaining first word vectors corresponding to a plurality of words for describing the power metering information through the trained word vector model; Inputting the first word vector into an encoder to be trained, and obtaining a first distribution feature of a Gaussian distribution corresponding to the first word vector through the encoder; Inputting the first distribution feature into a decoder to be trained, and obtaining a predicted word vector based on the first distribution feature through the decoder; Based on the first word vector, the predicted word vector and the loss function, the parameters of the encoder and the decoder are adjusted until the training end condition is met to obtain a trained encoder and decoder.
5. The method according to claim 1, characterized in that Also includes: Acquire a sample corpus and its corresponding label; the label includes a named entity of power metering in the sample corpus and an entity category corresponding to the named entity; Segment the sample corpus using the trained segmentation model to obtain second word vectors corresponding to each of the multiple words after the segmentation, and obtain second distribution features corresponding to the second word vectors using the trained encoder; Combining the plurality of second distribution features to generate a first sample feature set and a second sample feature set, and inputting the first sample feature set and the second sample feature set into a bidirectional long short-term memory network to be trained to obtain corresponding word vector features; The word vector feature is input into a preset conditional random field, and the network parameters corresponding to the bidirectional long short-term memory network are adjusted according to the prediction result output by the conditional random field and the label, until the training end condition is met, thereby obtaining a trained bidirectional long short-term memory network.
6. The method according to claim 5, characterized in that The adjusting the network parameters corresponding to the bidirectional long short-term memory network according to the prediction result output by the conditional random field and the label includes: Determine, through the conditional random field and based on the word vector feature, a prediction result corresponding to each word vector feature and a prediction score corresponding to the prediction result; Determine the current conditional probability based on the prediction scores corresponding to multiple word vectors and the preset potential function; When the conditional probability is less than a preset probability threshold, the network parameters corresponding to the bidirectional long short-term memory network are adjusted according to the prediction result and the label.
7. A named entity recognition device for power metering, characterized in that: The device comprises: A word vector acquisition module, used to acquire word vectors corresponding to multiple words in a to-be-recognized corpus used to describe power metering information; A distribution feature acquisition module, used to input multiple word vectors into a trained encoder, and obtain the distribution features of the Gaussian distribution corresponding to each word vector through the encoder, including: converting the distance measure between the word vectors into the difference measure of expectation and covariance under the Gaussian distribution through the feature representation method through the encoder, and obtaining the distribution features of the Gaussian distribution corresponding to each word vector; the distribution features include the expectation and covariance of the Gaussian distribution; A word vector feature acquisition module is used to generate word vector features based on the distribution features corresponding to multiple word vectors; A named entity determination module, used to input the word vector feature into a preset conditional random field, and determine the named entity in the corpus to be identified according to the labeling result output by the conditional random field; The word vector feature acquisition module includes: A reference feature set acquisition submodule is used to combine the distribution features corresponding to multiple word vectors to generate a first reference feature set and a second reference feature set; each element in the first reference feature set is a word vector; each element in the second reference feature set is an adjacent word vector pair; A network processing submodule, configured to input the first reference feature set and the second reference feature set into a trained bidirectional long short-term memory network, and obtain independent features corresponding to the first reference feature set and correlation features corresponding to the second reference feature set through the bidirectional long short-term memory network; The word vector feature determination submodule is used to perform feature fusion on the independent feature and the correlation feature to obtain the word vector feature.
8. The device according to claim 7, characterized in that The reference feature set acquisition submodule is used to determine the arrangement order corresponding to multiple distribution features; the arrangement order corresponds to the arrangement order of each word in the corpus to be recognized; according to the arrangement order, multiple groups of adjacent distribution features are obtained to obtain multiple groups of distribution feature pairs; and the second reference feature set is generated using multiple groups of distribution feature pairs.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
