A Chinese named entity recognition method and device with dynamic fusion of dictionary information
By using the self-attention mechanism to dynamically fuse dictionary information and optimizing the Transformer layer to improve position coding in Chinese named entity recognition, combined with conditional random fields, the problem of insufficient dictionary information fusion and position information capture in the existing technology is solved, and efficient Named entity recognition and good migration performance.
Patent Information
- Application Number
- CN202111260751.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-28
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-10-28
AI Technical Summary
Existing Chinese named entity recognition technology lacks effective dictionary information fusion and location information capture when processing Chinese text, resulting in poor model performance in named entity recognition, poor migration performance, and inability to fully utilize the parallel processing capabilities of the GPU.
The self-attention mechanism is used to dynamically fuse dictionary information, and the position coding is improved through the optimized Transformer layer, combined with conditional random fields for prediction, to achieve effective modeling of contextual semantics and position information.
It improves the accuracy and reasoning speed of Chinese named entity recognition, enhances the model's migration and parallel processing capabilities, and has good performance on different data sets.
Smart Images

Figure CN113988074B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of deep learning natural language processing, and in particular to a Chinese named entity recognition method and device that dynamically integrates dictionary information. Background Art
[0002] Named entity recognition is a basic task in natural language processing, and plays an important role in downstream tasks such as relation extraction, information retrieval, knowledge question answering, and machine translation. Entity recognition mainly includes accurate identification of entity boundaries and correct classification of entity categories. Chinese named entity recognition is more difficult than English named entity recognition. Generally speaking, entity recognition mainly includes three feature methods based on character granularity, word granularity, and word-word mixture. Previous studies have found that because Chinese word segmentation often has unregistered words in the dictionary, and there may be incorrect word segmentation boundaries. In named entity recognition, the boundaries of entities are generally the boundaries of word segmentation. The above two situations will have a serious negative impact on the effect of named entity recognition. Therefore, methods based on character granularity are better than methods based on word segmentation. Since word information is also crucial, a word-word mixture method based on character granularity and integrating potential word information into it has emerged.
[0003] For named entities in different vertical fields, there is almost no perfect word segmentation algorithm model, which will have a negative effect on the subsequent named entity recognition. In order to make full use of word segmentation information and solve the problem of word segmentation errors mentioned above, researchers proposed a method to fuse word information using dictionaries. A very classic algorithm model, Lattice LSTM, through the ingenious improvement of the internal encoding structure of LSTM, enables it to cleverly fuse the word information hidden in the dictionary into the words in the sentence when encoding the sentence. This method of fusing word-word information greatly enriches the content of the encoding, and ultimately achieves the best model performance on multiple datasets of named entity recognition.
[0004] However, the proposed Lattice LSTM structure, which integrates vocabulary information through sophisticated design, is very complex and can only be adapted to encoders such as LSTM, with poor transfer performance. Moreover, LSTM cannot process sentences in parallel.
[0005] Recently, the method of integrating vocabulary information by designing the CNN neural network structure has achieved good results in Chinese named entity recognition. CNN is used to process the characters in the sentence and the potential word information in the sentence in parallel; a feedback layer is added to the high-level semantic information to solve the word conflict problem in the sentence. This method effectively speeds up the training speed of the model and achieves the best performance on multiple datasets of Chinese named entity recognition. However, this vocabulary fusion method does not have good transferability.
[0006] The Transformer encoder has been widely used in many natural language processing tasks, such as machine translation. It has achieved the best results in many fields when combined with the pre-trained model BERT. Unlike the traditional RNN network structure, the Transformer can make full use of the parallel processing capabilities of the GPU and can model long-distance context information well. However, the native Transformer lacks the ability to capture position information well, which makes it perform poorly in named entity recognition tasks, and even worse than LSTM. Summary of the invention
[0007] In view of the deficiencies in the prior art, the present invention provides a Chinese named entity recognition method and device that dynamically integrates dictionary information. In Chinese named entity recognition, self-attention is used as a word information fuser to give full play to the important role of dictionary in Chinese named entity recognition; an optimized and improved Transformer is used as a context encoder to model context semantics and position information, making full use of the powerful parallel capability of Transformer.
[0008] To achieve the above object, the present invention adopts the following technical solutions:
[0009] A Chinese named entity recognition method that dynamically integrates dictionary information, the recognition method comprising the following steps:
[0010] S1, receiving the sentence to be recognized, and matching the relevant words from the dictionary for each word in the sentence;
[0011] S2, using self-attention as a word information fuser to dynamically learn the relevance weights between characters and corresponding words to fuse word information; the fusion process includes:
[0012] Perform linear transformation and tanh activation function on the embedding representation of each word set, use self-attention to calculate the character embedding representation and the attention score of the embedding representation of each word in each word set, and normalize the attention scores of the four word sets to obtain the word weights of the four sets; use the weights to perform weighted summation on the vocabulary embeddings in each set on the four sets; splice the last dimension of the word embedding representation to obtain the word fusion information representation;
[0013] S3, uses an improved Transformer layer to incorporate position information by optimizing the initial position encoding while modeling the semantic information of the context;
[0014] S4, input the context representation learned in step S3 into the conditional random field for prediction.
[0015] Furthermore, in step S2, the fusion process includes the following sub-steps:
[0016] S21, for sentence S = {x1, x2, x3, ..., x n Each word x in i , match relevant words from the dictionary L, i = 1, 2, ..., n, n is the total number of words in the sentence;
[0017] S22, put the matched words into four different sets, the method is as follows:
[0018]
[0019] When a vocabulary set is empty, a special symbol "None" is added to it; B(x i )、M(x i )、E(x i )、S(x i ) respectively represent the number of characters in the sentence that match the i-th character in the dictionary with the character x i Beginning, x i In the middle of a word, with x i Ending, x i A set of words that constitute a single word. x,y Represents the word composed of the xth to yth characters in the sentence;
[0020] S23, in the embedding layer, self-attention is used to learn the relevance weights of each word in the four sets to fuse word information:
[0021] fusion=[e c (x i );u(B);u(M);u(E);u(S)]
[0022] u(α)=weight(α)e w (y),y∈α
[0023] weight(α)=softmax([score(B);score(M);score(E);score(S)])[α]
[0024] score(β)=e c (x i )v(β) T
[0025] v(β)=tanh(e w(y)X+b),y∈β
[0026] Among them, e c 、e w Represent the character embedding and word embedding lookup tables respectively, [;] represents the concatenation operation on the last dimension of the vector, [] represents the corresponding value operation in weight according to the symbols B, M, E, and S; fusion is the word fusion function; u is the function used to perform weighted summation on each word set; weight is the function that normalizes the attention weights of the four word sets; the score function is used to calculate the attention score of the character and the corresponding word set; the v function performs a linear transformation and an activation function on the word vector representation of each word set.
[0027] Furthermore, in step S3, the process of using the improved Transformer layer to model the semantic information of the context includes the following steps:
[0028] S31, for the problem of missing position direction, the following relative position encoding method is adopted, which is defined as follows:
[0029]
[0030]
[0031] Among them, i and j represent the absolute positions of the current token and the context token respectively; R i-j =R -(i-j) ;
[0032] S32, two sets of matrix parameters are used to project word embedding and position embedding into independent spaces. The improved attention calculation method is as follows:
[0033] Q (w) ,K (w) ,V (w) =IW (qw) ,IW (kw) ,IW (vw)
[0034] Q (p) ,K (p) =RW (qp) ,RW (kp)
[0035] Mid i,j =Q i (w) K j (w)T +Q i-j p K (w)T +Q i (w) Ki-j (p)T +uK i-j (p)T
[0036] Attention(i,j)=softmax(Mid i,j )V (w)
[0037] Where W qw ,W kw ,W vw Represents the parameter matrix for projecting word embeddings, W qp ,W kp represents another set of parameter matrices for projecting position embedding; I represents the input vector of the sentence; R represents the relative position encoding mentioned above; Q (w) , K (w) 、V (w) They represent the query, key, and value vectors after projecting the input respectively; Q (p) , K (p) Respectively represent the query and key vectors after the relative position encoding projection; Mid i,j , Attention(i,j) represent the attention scores and normalized attention weights of the i-th word and the j-th word respectively.
[0038] S33, uses un-scaled attention calculation to enhance the distribution of attention scores in named entity recognition.
[0039] Based on the above method, the present invention also provides a Chinese named entity recognition device that dynamically integrates dictionary information, and the recognition device includes:
[0040] Input layer, used to receive sentences to be recognized;
[0041] The vocabulary matching layer is used to match the relevant vocabulary from the dictionary for each word in the sentence;
[0042] The word information fusion layer is used to use self-attention as a word information fuser to dynamically learn the relevance weights between characters and corresponding words to fuse word information; the fusion process includes:
[0043] Perform linear transformation and tanh activation function on the embedding representation of each word set, use self-attention to calculate the character embedding representation and the attention score of the embedding representation of each word in each word set, and normalize the attention scores of the four word sets to obtain the word weights of the four sets; use the weights to perform weighted summation on the word embeddings in each set on each of the four sets;
[0044] The final embedding layer is used to concatenate the last dimension of the word embedding representation to obtain the word fusion information representation;
[0045] Improved transformation layer to incorporate position information by optimizing the initial position encoding while modeling the semantic information of the context;
[0046] The CRF layer is used to input the context representation learned by the improved transformation layer into the conditional random field for prediction.
[0047] The beneficial effects of the present invention are:
[0048] The present invention proposes a neural network method with good effect in Chinese named entity recognition, fast inference speed, and flexible migration and fusion of dictionary information structure; self-attention is used as a word information fuser in Chinese named entity recognition to give full play to the important role of dictionary in Chinese named entity recognition; the optimized and improved Transformer is used as a context encoder to model context semantics and position information, making full use of the powerful parallel capability of Transformer. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 It is a flow chart of a Chinese named entity recognition method that dynamically integrates dictionary information according to an embodiment of the present invention.
[0050] Figure 2 It is a schematic diagram of the principle of the influence of the positional relationship between characters on model recognition in an embodiment of the present invention.
[0051] Figure 3 It is a schematic diagram of a recognition example of a Chinese named entity recognition device that dynamically integrates dictionary information according to an embodiment of the present invention.
[0052] Figure 4 It is a schematic diagram of absolute position correlation. DETAILED DESCRIPTION
[0053] The present invention will now be described in further detail with reference to the accompanying drawings.
[0054] It should be noted that the terms such as "upper", "lower", "left", "right", "front", "back", etc. cited in the invention are only for the convenience of description and are not used to limit the scope of implementation of the present invention. Changes or adjustments in their relative relationships should be regarded as the scope of implementation of the present invention without substantially changing the technical content.
[0055] Figure 1 is a flow chart of a Chinese named entity recognition method for dynamically integrating dictionary information according to an embodiment of the present invention. Figure 1 , the identification method comprises the following steps:
[0056] S1, receiving the sentence to be recognized, and matching the relevant words from the dictionary for each word in the sentence.
[0057] S2, using self-attention as a word information fuser to dynamically learn the relevance weights between characters and corresponding words to fuse word information; the fusion process includes:
[0058] Perform linear transformation and tanh activation function on the embedding representation of each word set, use self-attention to calculate the character embedding representation and the attention score of the embedding representation of each word in each word set, and normalize the attention scores of the four word sets to obtain the word weights of the four sets; use the weights to perform weighted summation on the vocabulary embeddings in each set on each of the four sets; and concatenate the last dimension of the word embedding representation to obtain the word fusion information representation.
[0059] S3, uses an improved Transformer layer to incorporate position information by optimizing the initial position encoding while modeling the semantic information of the context.
[0060] S4, input the context representation learned in step S3 into the conditional random field for prediction.
[0061] 1. Principle Description
[0062] 1. Word information fusion layer
[0063] In the field of Chinese named entity recognition, vocabulary carries rich entity information, which is crucial to the recognition effect. However, incorrect word segmentation information may accumulate and have a negative impact on subsequent entity recognition. At present, most methods of integrating vocabulary information into characters are to carefully design a word fusion structure that adapts to the network within the model structure. However, this is very time-consuming and labor-intensive, and it is not realistic to migrate to a better encoder. To address this problem, this embodiment designs a self-attention network in the embedding layer to dynamically fuse word information, solves the problem of migration difficulties, and achieves good results.
[0064] In order to improve the computational efficiency and transferability, this embodiment designs a method in the embedding layer that uses self-attention as a word information fuser to dynamically learn the correlation weights between characters and corresponding words.
[0065] First, for the sentence S = {x1,x2,x3,...,x n Each word x in i To match the relevant words from the dictionary L. Then, put the matched words into four different sets as follows:
[0066]
[0067]
[0068]
[0069]
[0070] When a vocabulary set is empty, we add a special symbol "None" to it. So far, we have obtained four vocabulary sets related to each word in the sentence. After that, in the embedding layer, self-attention is used to learn the relevance weights of the word and each word in the four sets to fuse the word information:
[0071] fusion=[e c (x i );u(B);u(M);u(E);u(S)]
[0072] u(α)=weight(α)e w (y),y∈α
[0073] weight(α)=softmax([score(B);score(M);score(E);score(S)])[α]
[0074] score(β)=e c (x i )v(β) T
[0075] v(β)=tanh(e w (y)X+b),y∈β
[0076] Among them, e c , e w Represent the character embedding and word embedding lookup tables respectively, [;] represents the concatenation operation on the last dimension of the vector, and [] represents the corresponding value operation in the weight according to the symbols B, M, E, and S. First, the embedding representation of each word set is linearly transformed and the tanh activation function is performed, and then self-attention is used to calculate the attention score of the character embedding representation and the embedding representation of each word in each word set, and the attention scores of the four word sets are normalized to obtain the word weights of the four sets. In each of the four sets, the weights are used to perform weighted summation on the vocabulary embeddings in each set. In order to retain the word information as much as possible, the last dimension of the word embedding representation is finally concatenated to obtain the word fusion information representation.
[0077] 2. Improved Transformer Layer
[0078] Due to its powerful parallel processing ability and its ability to better model the context of long-distance sequences, the Transformer is widely used in natural language processing. To achieve efficiency, this embodiment uses a Transformer encoder to learn context information. However, the native Transformer does not perform well in terms of named entities and mainly has the following two problems:
[0079] (1) Lack of directionality in native positional encoding: In temporal tasks, the information of position is very important. Named entity recognition is a kind of temporal task. In a sentence, the positional relationship between words plays an important role in the recognition effect of the model. For example, see Figure 2 , generally a place name will follow immediately after the keyword "in", and a person's name usually appears before the keyword "eat", and this relative position is very important for the classification of named entity recognition results.
[0080] The formula for defining the absolute positional encoding in the native Transformer is as follows:
[0081] PE t,2i = sin(t / 10000 2i / d ),
[0082] PE t,2i+1 = cos(t / 10000 2i / d )
[0083] where t is the subscript index of the word in the sentence, 2i and 2i + 1 are the dimensions with even and odd subscripts in the positional encoding, and d represents the dimension size of the positional encoding.
[0084] In the NER task, the neural network model needs to extract the feature information of entities, and this feature information is closely related to the positional information of words in the context. The native Transformer can well model the semantic information of the context, but there are some defects in modeling the positional information. As the formula for calculating the absolute positional encoding in the native Transformer mentioned above is used to calculate the similarity between any two absolute positions PE i PE k , where i and k represent the current position and the context position respectively, and the result is as Figure 4 shown. It can be clearly found that this is a symmetric matrix centered on the main diagonal, which indicates that the similarity between the absolute positions i and k only depends on the distance between them and has nothing to do with their directionality. This is also a problem of lack of position direction perception in the native Transformer's positional encoding.
[0085] (2) Word embedding and position embedding share parameter matrices, causing information confusion:
[0086] Before calculating the attention score, the native Transformer directly adds the position code to the word embedding in order to add position information. The formula is as follows:
[0087] score i,j =(w e (i)+p e (i))W q [(w e (j)+p e (j))W k ] T
[0088] =(w e (i)+p e (i))W q W k T (w e (j)+p e (j)) T
[0089] =w e (i)W q W k T w e (j)+p e (i)W q W k T w e (j)+w e (i)W q W k T p e (j)+p e (i)W q W k T p e (j)
[0090] The score i,j represents the attention score of any two context tokens with position information. e ,p e Represent the embedding lookup table of words and positions respectively. It can be found that word embedding and position embedding share a set of W q ,W kThe word embedding contains the semantic information of the context, while the position embedding is only related to the position information and should not be affected by the context semantics. For example, at the semantic level, the correlation between two words in the context is very high, which does not mean that the two words are also close in position.
[0091] For the above two problems, this embodiment proposes an improved Transformer layer.
[0092] First, to solve the problem of missing position direction, this embodiment adopts a new relative position encoding method, which is defined as follows:
[0093]
[0094]
[0095] Here, i and j represent the absolute positions of the current token and the context token respectively. i-j =R -(i-j) , which solves the relative position problem. In order to better represent word embedding and position embedding, this embodiment uses two sets of matrix parameters to project them into independent spaces. The improved attention calculation method is as follows:
[0096] Q (w) ,K (w) ,V (w) =IW (qw) ,IW (kw) ,IW (vw)
[0097] Q (p) ,K (p) =RW (qp) ,RW (kp)
[0098] Mid i,j =Q i (w) K j (w)T +Q i-j p K (w)T +Q i (w) K i-j (p)T +uK i-j (p)T
[0099] Attention(i,j)=softmax(Mid i,j )V (w)
[0100] Here Wqw ,W kw ,W vw represents the parameter matrix for projecting word embedding, and W qp ,W kp Represents another set of parameter matrices for projecting position embeddings. And un-scaled attention calculation is used to strengthen the distribution of attention scores in named entity recognition. Finally, we input the learned context representation into the conditional random field for prediction.
[0101] Correspondingly, based on the aforementioned method, this embodiment also mentions a Chinese named entity recognition device that dynamically integrates dictionary information, and the recognition device includes an input layer, a vocabulary matching layer, a word information fusion layer, a final embedding layer, an improved transformation layer and a CRF layer.
[0102] The input layer is used to receive the sentence to be recognized.
[0103] The vocabulary matching layer is used to match the relevant vocabulary from the dictionary for each word in the sentence.
[0104] The word information fusion layer is used to use self-attention as a word information fuser to dynamically learn the relevance weights between characters and corresponding words to fuse word information; the fusion process includes:
[0105] Perform linear transformation and tanh activation function on the embedding representation of each word set, use self-attention to calculate the character embedding representation and the attention score of the embedding representation of each word in each word set, and normalize the attention scores of the four word sets to obtain the word weights of the four sets; use the weights to perform weighted summation on the word embeddings in each set on each of the four sets.
[0106] The final embedding layer is used to concatenate the last dimension of the word embedding representation to obtain the word fusion information representation.
[0107] Improved transformation layer is used to incorporate position information by optimizing the initial position encoding while modeling the semantic information of the context.
[0108] The CRF layer is used to input the context representation learned by the improved transformation layer into the conditional random field for prediction.
[0109] Figure 3 It is a schematic diagram of a recognition example of a Chinese named entity recognition device that dynamically integrates dictionary information in an embodiment of the present invention. The recognition device of this embodiment can effectively recognize the complex Chinese named entity of Renmin University of China.
[0110] 2. Experimental Verification
[0111] Datasets: This example introduces four public datasets that are commonly used in Chinese named entity recognition: MSRA and OntoNotes datasets mainly involve the news field; Weibo and Resume datasets mainly involve the media and social fields. For OntoNotes, a training set, validation set, and test set with word granularity are provided.
[0112] Experimental setup: In the embedding layer, this example uses 50-dimensional pre-trained word embedding and word embedding vectors. In the word fusion self-attention, the dimension of the head is set to 50, and the dimension of the final word fusion representation is 250. In the improved Transformer, the number of heads is set to 4, and the dimension of each head is set to 64. The initial learning rate is set to 0.001 and the Adamax optimizer is used.
[0113] Comparison experiment with previous models:
[0114] We conducted comparative experiments with some previous models on the Chinese named entity recognition dataset. The comparison results are shown in Table 1.
[0115] Table 1
[0116]
[0117] Table 1 shows the settings of the OntoNotes dataset, which is divided into three groups: "Gold seg", "Auto seg" and "No seg". In this dataset, standard word segmentation (Gold seg) is provided. "Gold seg" and "Auto seg" can be trained in two modes: character-based and word-based. In word-based grouping, several phenomena can be observed: first, on the basis of word segmentation, incorporating single-word information and double-word information can enhance the expressiveness of features; second, due to word boundary errors in automatic word segmentation, when the standard word segmentation is replaced by automatic word segmentation, the F1 value drops from 75.77% to 71.70%. "Adapter" refers to the proposed method of integrating word information using self-attention. "No seg" is a word-based method. It can be found that the effect of using vocabulary enhancement on the native Transformer is even worse than that of Lattice LSTM, but on the improved Transformer, it has achieved a good improvement effect.
[0118] Table 2, Table 3, and Table 4 show the comparative performance on the three datasets of Resume / MSRA / WeiboNER respectively. This example mainly compares some classic models, semi-supervised models, and some recent models with good results.
[0119] Table 2
[0120]
[0121] Table 3
[0122]
[0123] Table 4
[0124]
[0125] Table 5 shows the relative inference speed comparison of different models on the test set data when the batch size is 1.
[0126] Table 5
[0127]
[0128] From the experimental results, it is not difficult to find that the performance of the native Transformer on the four data sets is even worse than that of LSTM. Transformer can model long-distance context information very well, but its performance in named entity recognition is poor because it cannot capture and integrate location information very well.
[0129] The improved Transformer of this embodiment optimizes the initial position encoding and improves the self-attention calculation method, so that it can not only model the context content information well, but also integrate the position information well. In addition, this embodiment also makes full use of the important role of dictionary information in Chinese named entity recognition, designs a self-attention word fuser to fuse word embedding information, and fully demonstrates the powerful parallel capability of Transformer.
[0130] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.
Claims
1. A Chinese named entity recognition method that dynamically integrates dictionary information, characterized in that: The identification method comprises the following steps: S1, receiving the sentence to be recognized, and matching the relevant words from the dictionary for each word in the sentence; S2, using self-attention as a word information fuser to dynamically learn the relevance weights between characters and corresponding words to fuse word information; the fusion process includes: Perform linear transformation and tanh activation function on the embedding representation of each word set, use self-attention to calculate the character embedding representation and the attention score of the embedding representation of each word in each word set, and normalize the attention scores of the four word sets to obtain the word weights of the four sets; use the weights to perform weighted summation on the vocabulary embeddings in each set on the four sets; splice the last dimension of the word embedding representation to obtain the word fusion information representation; S3, uses an improved Transformer layer to incorporate position information by optimizing the initial position encoding while modeling the semantic information of the context; S4, input the context representation learned in step S3 into the conditional random field for prediction; In step S3, the process of modeling the semantic information of the context using the improved Transformer layer includes the following steps: S31, for the problem of missing position direction, the following relative position encoding method is adopted, which is defined as follows: Among them, i and j represent the absolute positions of the current token and the context token respectively; R i-j =R -(i-j) ; R i-j (2i) , R i-j (2i+1) They represent the even and odd dimensions of the vector representation of the relative position of the i-th word relative to the j-th word in the sentence; d represents the dimension size of the position encoding; S32, two sets of matrix parameters are used to project word embedding and position embedding into independent spaces. The improved attention calculation method is as follows: Q (w) ,K (w) ,V (w) JIW (qw) ,IW (kw) ,IW (vw) Q (p) ,K (p) =RW (qp) ,RW (kp) Mid i,j =Q i (w) K j (w)T +Q i-j p K (w)T +Q i (w) K i-j (p)T +uK i-j (p)T Attention(i,j)=softmax(Mid i,j )V (w) Where W qw ,W kw ,W vw Represents the parameter matrix for projecting word embeddings, W qp ,W kp represents another set of parameter matrices for projecting position embedding; I represents the input vector of the sentence; R represents the relative position encoding mentioned above; Q (w) , K (w) 、V (w) They represent the query, key, and value vectors after projecting the input respectively; Q (p) , K (p) Respectively represent the query and key vectors after the relative position encoding projection; Mid i,j , Attention(i,j) represents the attention score and normalized attention weight of the i-th word and the j-th word respectively; S33, uses un-scaled attention calculation to enhance the distribution of attention scores in named entity recognition.
2. The Chinese named entity recognition method based on dynamic fusion dictionary information according to claim 1 is characterized in that: In step S2, the fusion process includes the following sub-steps: S21, for sentence S = {x1, x2, x3, ..., x n Each word x in i , match relevant words from the dictionary L, i = 1, 2, ..., n, n is the total number of words in the sentence; S22, put the matched words into four different sets, the method is as follows: When a vocabulary set is empty, a special symbol "None" is added to it; B(x i )、M(x i )、E(x i )、S(x i ) respectively represent the number of characters in the dictionary that match the i-th character in the sentence with x i Beginning, x i In the middle of a word, with x i Ending, x i A word set that constitutes a word alone; W x,y Represents the word composed of the xth to yth characters in the sentence; S23, in the embedding layer, self-attention is used to learn the relevance weights of each word in the four sets to fuse word information: fusion=[e c (x i );u(B);u(M);u(E);u(S)] u(α)=weight(α)e w (y),y∈a weight(α)=softmax([score(B);score(M);score(E);score(S)])[α] score(β)=e c (x i )v(b) T v(β)=tanh(e w (y)X+b),y∈β Among them, e c 、e w Represent the character embedding and word embedding lookup tables respectively, [; ] represents the concatenation operation on the last dimension of the vector, [] represents the corresponding value operation in weight according to the symbols B, M, E, and S; fusion is the word fusion function; u is the function used to perform weighted summation on each word set; weight is the function that normalizes the attention weights of the four word sets; the score function is used to calculate the attention score of the character and the corresponding word set; the v function performs a linear transformation and an activation function on the word vector representation of each word set.
3. A Chinese named entity recognition device based on the method of claim 1 or 2 that dynamically integrates dictionary information, characterized in that: The identification device comprises: Input layer, used to receive sentences to be recognized; The vocabulary matching layer is used to match the relevant vocabulary from the dictionary for each word in the sentence; The word information fusion layer is used to use self-attention as a word information fuser to dynamically learn the relevance weights between characters and corresponding words to fuse word information; the fusion process includes: Perform linear transformation and tanh activation function on the embedding representation of each word set, use self-attention to calculate the character embedding representation and the attention score of the embedding representation of each word in each word set, and normalize the attention scores of the four word sets to obtain the word weights of the four sets; use the weights to perform weighted summation on the word embeddings in each set on each of the four sets; The final embedding layer is used to concatenate the last dimension of the word embedding representation to obtain the word fusion information representation; Improved transformation layer to incorporate position information by optimizing the initial position encoding while modeling the semantic information of the context; The CRF layer is used to input the context representation learned by the improved transformation layer into the conditional random field for prediction.
