Chinese named entity recognition method and device based on vocabulary enhancement and multi-features
By extracting and fusing multiple features of Chinese text sequences, and using the gating mechanism to enhance character features, the problem of low recognition accuracy and recall rate in the existing technology is solved, and more accurate Chinese named entity recognition is achieved.
Patent Information
- Application Number
- CN202111202239.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-15
- Publication Date
- 2024-10-22
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing Chinese named entity recognition methods do not make full use of the character features of Chinese text sequences, lexical features corresponding to characters, and pre-training features, resulting in low recognition accuracy and recall rates.
Using a method based on vocabulary enhancement and multi-features, by extracting character features, vocabulary features and pre-training features of the input sequence, the gating mechanism is used to integrate the vocabulary features into the character features, and then linearly spliced and then encoded to extract contextual features and predict Optimal tag sequence.
It improves the precision and recall rate of Chinese named entity recognition, avoids word segmentation errors, makes full use of vocabulary information, and enhances the accuracy of entity boundaries and classification.
Smart Images

Figure CN114021549B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of information extraction, and more specifically, relates to a Chinese named entity recognition method and device based on vocabulary enhancement and multiple features. Background Art
[0002] From a research perspective, named entity recognition can be mainly divided into two categories: one is based on traditional methods, including dictionary and template-based methods, unsupervised learning-based methods, and feature-based supervised learning methods; the other is based on deep learning methods, which can be summarized into character-based and word-based methods according to the different input forms.
[0003] Initial research methods were conducted by constructing vocabulary information and template rules. Most of these methods were conducted by industry experts who manually constructed special dictionaries or templates based on the characteristics of the data set for matching and recognition. Generally speaking, when the formulated rules can accurately reflect the language characteristics of the data set, the recognition effect is better, but the rules depend on the text style of the specific data set and are expensive to construct. Another noteworthy issue is that the system based on dictionaries and template rules has poor portability and is not easy to be transplanted to other fields. Clustering methods are widely used in unsupervised named entity recognition. This type of method predicts entities that are classified into various clusters by constructing vocabulary information, patterns, and text information statistics of domain language on large-scale text data. Entities in the same cluster are close in semantic space and have similar contextual information. Clustering-based methods tend to favor high-quality general texts, and the recognition rate is not high on other texts. Most feature-based supervised learning methods use the theoretical basis of probability statistics, so they are also called probability statistics-based methods. The main idea of this type of method to solve the problem of named entity recognition is sequence labeling, that is, training the labeling model through large-scale corpus to label each position of the sentence. Feature engineering is a common link based on traditional probability and statistical models. It refers to the manual feature selection and processing of data sets. However, feature engineering of data sets takes a lot of time, which makes this type of method have certain limitations.
[0004] In the deep learning-based named entity recognition model, there are two typical models: character-based models and word-based models. For English named entity recognition, there is a natural space segmentation in English words. Therefore, in English named entity recognition, word-based research is usually carried out. In addition, in order to make more full use of semantic information, some studies introduce the information of the characters that make up the word on the basis of English words. For Chinese named entity recognition, the expression of sentences is character by character. Although some research works have achieved some results in Chinese word segmentation, word segmentation errors still exist and will affect the recognition effect of downstream models. Therefore, Chinese named entity recognition models are usually based on the character level, but the character-based model ignores the semantic information of Chinese vocabulary, and lexical information is of great significance for determining entity boundaries. For example, for the word "Wuhan", for the single character "Han", it may be marked as a single entity representing the nation. If the lexical information "Wuhan" is introduced on its basis, it is easier to correctly identify it as the end of the geographic location entity. Summary of the invention
[0005] In view of the above defects or improvement needs of the prior art, the present invention proposes a Chinese named entity recognition method and device based on vocabulary enhancement and multiple features, with the aim of solving the problem that the existing entity recognition methods do not fully utilize the semantic information such as the character features of the Chinese text sequence, the vocabulary features corresponding to the characters, and the pre-trained features, resulting in low recognition accuracy and recall rate.
[0006] To achieve the above-mentioned objectives, the present invention provides a Chinese named entity recognition method based on vocabulary enhancement and multiple features, comprising the following steps: S1, extracting character features, vocabulary features and pre-trained features of an input sequence; S2, integrating the vocabulary features into the character features using a gating mechanism to achieve vocabulary enhancement of the character features; S3, linearly concatenating the character features after vocabulary enhancement and the pre-trained features to obtain the final features of the input sequence; S4, encoding the final features to extract context features; S5, predicting the optimal label sequence of the input sequence based on the context features.
[0007] Furthermore, the S1 includes: S11, using a bidirectional long short-term memory network to extract position features of an input sequence, using a convolutional neural network to extract local morphological features of the input sequence, and linearly concatenating the position features and local morphological features to obtain character features of the input sequence; S12, introducing vocabulary information corresponding to characters through string pattern matching, including vocabulary information starting with characters, with characters as the middle part, ending with characters, and single characters, and extracting the vocabulary features in a frequency-weighted average manner; S13, using a pre-trained BERT-wwm model to extract pre-trained features of the input sequence.
[0008] Furthermore, in S2, the calculation method of the gating mechanism is:
[0009] X c,w =X c *σ(X w W G +b G )
[0010] Among them, σ is the sigmoid function, W G , b G is a learnable parameter, X c is the character feature, X w is the vocabulary feature corresponding to the character, X c,w is the character feature after vocabulary enhancement.
[0011] Furthermore, in S2, the calculation method of the gating mechanism is:
[0012] X c,w =G*X c +(1-G)*X w
[0013] Where G = σ(X c W C +X w W W +b G ), σ is the sigmoid function, W C , W W , b G is a learnable parameter, X c is the character feature, X w is the vocabulary feature corresponding to the character, X c,w is the character feature after vocabulary enhancement.
[0014] Furthermore, in S3, the final feature of the input sequence is expressed as:
[0015]
[0016] Among them, X is the final feature of the input sequence, X c,w is the character feature after vocabulary enhancement, X t is the pre-trained feature, Represents linear concatenation.
[0017] Furthermore, the S5 includes: S51, using a fully connected layer to map the extracted context features into a score matrix of the label corresponding to each character; S52, using a linear chain conditional random field to decode the score matrix, and combining the score matrix and the conditional transfer matrix of the conditional random field to calculate the probability of each label sequence, thereby predicting the optimal label sequence of the input sequence.
[0018] On the other hand, the present invention also provides a Chinese named entity recognition device based on vocabulary enhancement and multiple features, including: a feature extraction module, used to extract character features, vocabulary features and pre-trained features of an input sequence; a vocabulary enhancement module, used to integrate the vocabulary features into the character features using a gating mechanism to achieve vocabulary enhancement of the character features; a multi-feature combination module, used to linearly concatenate the character features after vocabulary enhancement and the pre-trained features to obtain the final features of the input sequence; a context encoding module, used to encode the final features to extract context features; and a label decoding module, used to predict the optimal label sequence of the input sequence based on the context features.
[0019] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects:
[0020] (1) The present invention first extracts the character features, vocabulary features and pre-trained features of the input sequence; then, the vocabulary features are integrated into the character features using a gating mechanism to achieve vocabulary enhancement of the character features; then, the character features and pre-trained features after vocabulary enhancement are linearly concatenated to obtain the final features of the input sequence; finally, the final features are encoded to extract context features, and the optimal label sequence of the input sequence is predicted based on the context features. In this way, the present invention makes full use of the character features of the Chinese text sequence, the vocabulary features corresponding to the characters, and the pre-trained features, and can improve the recognition precision and recall rate.
[0021] (2) The present invention uses a bidirectional long short-term memory network and a convolutional neural network to extract the features of the Chinese character sequence and linearly concatenate the extracted features, which takes into account the long-range dependent positional features and local morphological features of the characters, thereby making the extracted character features more complete.
[0022] (3) The present invention integrates vocabulary information into a single character through a string pattern matching method without word segmentation, which avoids the recognition error of entity boundaries and entity classification error caused by Chinese word segmentation errors. In order to make full use of vocabulary information, the present invention constructs a set of words that start with a character, use a character as the middle part, end with a character, and form a single word, and then extracts the vocabulary features of the corresponding set by weighted average of word frequency, and then uses a gating mechanism to achieve vocabulary enhancement of characters, thereby integrating vocabulary information into the corresponding characters, which makes more full use of the vocabulary information corresponding to the characters, and uses a gating mechanism to control the fusion of vocabulary information and character information, so that vocabulary features can assist in determining certain dimensions of character features to participate in the determination of entity fragments, making the recognition of entity fragments more accurate.
[0023] (4) The character features after linear concatenation vocabulary enhancement of the present invention and the pre-trained features extracted by the pre-trained model construct a multi-feature strategy model, which further improves the index of Chinese named entity recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is a flowchart of a Chinese named entity recognition method based on vocabulary enhancement and multiple features provided by the present invention;
[0025] Figure 2 It is a structural block diagram of a Chinese named entity recognition device based on vocabulary enhancement and multiple features provided by the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention 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 invention and are not intended to limit the present invention. The characteristics, operations or features described in the specification can be combined in any appropriate manner to form various implementation methods. At the same time, the steps or actions in the method description can also be replaced or adjusted in order in a manner that is obvious to those skilled in the art. Therefore, the various sequences in the specification and the accompanying drawings are only for the purpose of clearly describing a certain embodiment and do not mean that they are necessary sequences, unless otherwise specified that a certain sequence must be followed. In addition, the technical features involved in the various implementation methods of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0027] In the present invention, the terms "first", "second", etc. (if any) in the present invention and the accompanying drawings are used to distinguish similar objects but not necessarily to describe a specific order or sequence.
[0028] The present invention first combines a bidirectional long short-term memory network and a convolutional neural network to extract Chinese character features, so that the extracted features have both long-distance dependent positional features and local morphological features. Then, without word segmentation, the vocabulary information corresponding to the characters is introduced through string pattern matching, including vocabulary information starting with characters, with characters as the middle part, ending with characters, and single characters, and the vocabulary features are extracted in a frequency-weighted average manner. Afterwards, the vocabulary features are integrated into the character features through a gating mechanism to achieve vocabulary enhancement of the characters. Next, the pre-trained BERT-wwm model is used to extract the pre-trained features of the character sequence. Finally, the character features after vocabulary enhancement and the pre-trained features are linearly spliced to form a multi-feature strategy model, thereby improving the recognition indicators of Chinese named entity recognition.
[0029] Figure 1 It is a flowchart of a Chinese named entity recognition method based on vocabulary enhancement and multiple features provided by the present invention. The recognition method includes operations S1 to S5.
[0030] S1, extracts character features, vocabulary features and pre-trained features of the input sequence;
[0031] S2, integrating the lexical features into the character features using a gating mechanism to achieve lexical enhancement of the character features;
[0032] S3, linearly concatenating the character features after vocabulary enhancement and the pre-trained features to obtain the final features of the input sequence;
[0033] S4, encoding the final features to extract context features;
[0034] S5, predicting an optimal label sequence for the input sequence based on the context features.
[0035] Specifically, the steps are as follows:
[0036] 1. Character features, vocabulary features and pre-trained feature extraction
[0037] 1.1 Character feature extraction
[0038] For character vector sequences, the present invention not only uses convolutional neural networks to extract local morphological features, but also uses bidirectional long short-term memory networks to extract long-distance dependent positional features, thereby better encoding the positional information of the sequence. The present invention linearly concatenates the character features extracted by each unit of the bidirectional long short-term memory network with the local character features extracted by each of the multiple convolution kernels in the convolutional neural network to represent the feature vector of a single character. In this way, local morphological features are retained while long-distance dependent positional features are used.
[0039] Let the character feature representation after passing through the word embedding vector matrix be E c , and the character features extracted by the present invention are as shown in formula (1).
[0040]
[0041] Among them, dropout is a strategy to prevent overfitting, denotes linear concatenation. The dimensions of the character features extracted by the BiLSTM network and the CNN network are the same.
[0042] 1.2. Lexical feature extraction
[0043] For each character, define the set Begin as the set of words starting with this character, the set Middle as the set of words with this character as the middle part, the set End as the set of words ending with this character, and the set Single as the case of this character forming a word alone. For the convenience of expression, take the first letter of the set respectively, and hereinafter these four sets are abbreviated as "BMES", and the formal representation is as shown in formula (2).
[0044]
[0045] Among them, w i,j refers to the subsequence from i to j in the input sequence, L represents the pre-trained dictionary, and n represents the sequence length. If a certain set of characters is empty, in order to enable parallel computing during model training, the present invention uses the "NULL" identifier to fill the empty set.
[0046] For a given dictionary, first construct a lexical prefix tree, and then sequentially match the substrings of the input sentence sequence. Specifically, two indexes are used to move forward and backward to locate the sentence fragments, and then the matched words are distributed to the "BMES" sets corresponding to the characters that make up the word. For example, the word "Union Hospital" is distributed to the B set of "协", the M set of "和", the M set of "医", and the E set of "院". It can be seen that the model structure of the present invention not only introduces the lexical information ending with a character, but also introduces the lexical information starting with a character, the lexical information with a character as the middle part, and the information of a single character forming a word, which makes the utilization of lexical information more sufficient.
[0047] The next step is to map the vocabulary information in the set into a vector representation of a fixed dimension. Here, the "BMES" set of characters is mapped into a vector representation respectively, so as to extract the vocabulary features of the four categories of situations corresponding to the characters. For the "BMES" set corresponding to the characters, there may be multiple words in any set. In order to make full use of the word frequency semantic information of the data set, the present invention uses word frequency to perform weighted averaging on the word vectors corresponding to the words in the "BMES" set, thereby generating a vocabulary vector representation of the corresponding set.
[0048] The specific scheme for extracting lexical features is introduced below. For a certain character in the "BMES" set, the total frequency of all words is as shown in formula (3), and p(w) represents the frequency of word w.
[0049]
[0050] S x To represent any one of the characters in the "BMES" set, then S x The corresponding feature vector is expressed as shown in formula (4).
[0051]
[0052] Among them, e w is the word embedding vector matrix.
[0053] For a certain character, after extracting the corresponding features of the corresponding "BMES" set, the present invention concatenates these feature vectors, as shown in formula (5), to serve as all the lexical information that this character can incorporate, including the situations where it starts, is in the middle, ends, and forms a separate word.
[0054]
[0055] 1.3 Pre-training feature extraction
[0056] For a given text sequence s, the present invention uses the Tokenizer of BERT-wwm to encode the input sequence form "[CLS]+character sequence+[SEP]" to generate a token-id. Among them, "[CLS]" and "[SEP]" are sentence separation marks. During training, the BERT-wwm model takes sentence pairs as input, and uses 0 and 1 to identify tokens to distinguish between two sentence pairs. For ease of processing, the present invention uses a single sentence as input, so it is only necessary to generate an all-0 sequence seg-id, and use the token-id and seg-id as the input of BERT-wwm, so as to extract the features of the pre-trained character sequence, as shown in formula (6).
[0057] Xt =BERT-wwm(token-id(s),seg-id,mask) (6)
[0058] Among them, mask means filling and marking the input sequence. Usually 1 is used to indicate that the bit is the original character, and 0 is used to indicate that the bit is the filling character. This allows the text sequence to be input into the BERT-wwm model in batches for iterative training.
[0059] 2. Gating mechanism for vocabulary enhancement
[0060] Lexical information is helpful for identifying the boundaries of named entities. For example, the word "university" identifies the end of a specific organizational entity, a certain university. Therefore, lexical information can be used to control the corresponding character information and assist character features in flowing into the lower layer. For example, the forget gate, input gate, and output gate of the long short-term memory network all use gating mechanisms to determine the inflow of certain dimensional features, which allows the features to flow in as many time steps as possible. Without these control gates, the features can easily disappear in the conversion of each time step.
[0061] The present invention proposes two gating mechanisms to control the fusion of vocabulary information and character information, so that vocabulary features can assist in determining certain dimensions of character features to participate in the determination of entity fragments.
[0062] Gating mechanism 1. As shown in formula (7).
[0063] X c,w =Gate(X c ,X w )=X c *σ(X w W G +b G ) (7)
[0064] Among them, σ is the sigmoid function, W G , b G is a learnable parameter, X c is the character feature, X w is the lexical feature corresponding to the character. Just as the sigmoid function is used to control the flow of information in the LSTM model, because the value range of the sigmoid function is (0, 1), the lexical feature acted by the sigmoid function is multiplied with the character feature accordingly, so that the lexical feature is mapped to a dimension close to 0 to shield the information of the corresponding character feature dimension, and the dimension close to 1 selects the information of the corresponding character dimension to flow, thereby achieving the effect of integrating lexical information into character information, so as to realize the lexical enhancement of characters.
[0065] Gating mechanism 2. The calculation process is shown in formulas (8) and (9).
[0066] G=σ(X c W C +X w W W +b G ) (8)
[0067] X c,w =G*X c +(1-G)*X w (9)
[0068] Among them, σ is the sigmoid function, W C , W W 、b G is a learnable parameter, X c is the character feature, X w is the lexical feature corresponding to the character. As can be seen from the above formula, if the G value is large, the model tends to select the input string feature X c If the G value is small, the model tends to select vocabulary features X w , which allows the model to dynamically select character features or vocabulary features to flow into the downstream context encoding layer during training.
[0069] Gating mechanism 1 uses lighter learnable parameters, so it works better on smaller datasets, while gating mechanism 2 uses more learnable parameters and works better on larger datasets.
[0070] 3. Multi-feature strategy mode
[0071] As mentioned above, the present invention extracts character features and vocabulary features and introduces vocabulary features into character features by vocabulary enhancement. In addition, a pre-trained BERT-wwm model is used to extract character sequence features. For the extracted multiple features, the present invention combines them by linear splicing, that is, splicing the character features after vocabulary enhancement and the character sequence features extracted by the pre-training model to obtain the final input sequence features, as shown in formula (10).
[0072]
[0073] Among them, X c,w is the character feature after vocabulary enhancement, X t Features extracted for the pre-trained model.
[0074] 4. Context encoding layer extracts context relevance
[0075] First, the final feature representation of the input sequence is encoded through a bidirectional long short-term memory network (BiLSTM) to extract context features, and then the extracted features are mapped to the scores of the labels corresponding to each character using a fully connected layer, and finally the label scores are input to the label decoding layer for decoding. Since the present invention uses adaptive feature extraction, the context encoding layer can also be replaced by other representative encoding networks, such as ID-CNN, Transformer, etc.
[0076] 5. Label decoding layer predicts the best label sequence for the input sequence
[0077] The present invention uses a linear chain conditional random field to decode the label scores. The conditional random field calculates and predicts the probability of a certain label sequence through the score matrix obtained by the context coding layer and its own conditional transfer matrix, and the specific calculation method is completed by the Viterbi algorithm.
[0078] Figure 2 This is a structural block diagram of a Chinese named entity recognition device based on vocabulary enhancement and multiple features provided by the present invention. Figure 2 The recognition device 200 includes a feature extraction module 210, a vocabulary enhancement module 220, a multi-feature combination module 230, a context encoding module 240 and a label decoding module 250.
[0079] The feature extraction module 210 performs operation S1, for example, to extract character features, vocabulary features, and pre-trained features of the input sequence;
[0080] The vocabulary enhancement module 220, for example, performs operation S2 for integrating the vocabulary features into the character features by using a gating mechanism to achieve vocabulary enhancement of the character features;
[0081] The multi-feature combination module 230 performs operation S3, for example, to linearly concatenate the character features after vocabulary enhancement and the pre-trained features to obtain the final features of the input sequence;
[0082] The context encoding module 240, for example, performs operation S4 to encode the final feature to extract the context feature;
[0083] The label decoding module 250, for example, performs operation S5 to predict the best label sequence of the input sequence based on the context feature.
[0084] The identification device 200 is used to perform the above Figure 1 For details not covered in this embodiment, please refer to the aforementioned Figure 1 The identification method in the illustrated embodiment will not be described in detail here.
[0085] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A Chinese named entity recognition method based on vocabulary enhancement and multiple features, characterized in that: The following steps are involved: S1, extracts character features, vocabulary features and pre-trained features of the input sequence; S2, integrating the lexical features into the character features using a gating mechanism to achieve lexical enhancement of the character features; S3, linearly concatenating the character features after vocabulary enhancement and the pre-trained features to obtain the final features of the input sequence; S4, encoding the final features to extract context features; S5, predicting an optimal label sequence for the input sequence based on the context feature; The method of integrating the vocabulary features into the character features by using the gating mechanism includes method 1 or method 2; The first method is: X c,w =X c *σ(X w W G +b G ) The second method is: X c,w =G*X c +(1-G)*X w Among them, X c,w is the character feature after vocabulary enhancement, X c is the character feature, σ is the sigmoid function, Xw is the vocabulary feature corresponding to the character, G = σ(X c W C +X w W W +b G ), W G , W C , W W , b G are learnable parameters.
2. According to the Chinese named entity recognition method based on vocabulary enhancement and multiple features according to claim 1, it is characterized in that: The S1 includes: S11, extracting position features of the input sequence using a bidirectional long short-term memory network, extracting local morphological features of the input sequence using a convolutional neural network, and linearly concatenating the position features and local morphological features to obtain character features of the input sequence; S12, introducing vocabulary information corresponding to the characters by means of string pattern matching, including vocabulary information starting with the characters, using the characters as the middle part, ending with the characters, and words consisting of a single character, and extracting the vocabulary features by means of word frequency weighted average; S13, using the pre-trained BERT-wwm model to extract pre-trained features of the input sequence.
3. The Chinese named entity recognition method based on vocabulary enhancement and multiple features according to claim 1 is characterized in that: In S3, the final feature of the input sequence is expressed as: Among them, X is the final feature of the input sequence, X c,w is the character feature after vocabulary enhancement, X t is the pre-trained feature, Represents linear concatenation.
4. The Chinese named entity recognition method based on vocabulary enhancement and multiple features according to claim 1 is characterized in that: The S5 includes: S51, using a fully connected layer to map the extracted context features into a score matrix of the label corresponding to each character; S52, using a linear chain conditional random field to decode the score matrix, combining the score matrix and the conditional transfer matrix of the conditional random field to calculate the probability of each label sequence, thereby predicting the optimal label sequence of the input sequence.
5. A Chinese named entity recognition device based on vocabulary enhancement and multiple features, characterized in that: include: A feature extraction module is used to extract character features, vocabulary features, and pre-trained features of an input sequence; A vocabulary enhancement module, used to integrate the vocabulary features into the character features by using a gating mechanism to achieve vocabulary enhancement of the character features; A multi-feature combination module, used for linearly concatenating the character features after vocabulary enhancement and the pre-trained features to obtain the final features of the input sequence; A context encoding module, used for encoding the final features to extract context features; A label decoding module, used for predicting an optimal label sequence of the input sequence based on the context feature; The method of integrating the vocabulary features into the character features by using the gating mechanism includes method 1 or method 2; The first method is: X c,w =X c *σ(X w W G +b G ) The second method is: X c,w =G*X c +(1-G)*X w Among them, X c,w is the character feature after vocabulary enhancement, X c is the character feature, σ is the sigmoid function, Xw is the vocabulary feature corresponding to the character, G = σ(X c W C +X w W W +b G ), W G , W C , W W , b G are learnable parameters.
