Chinese named entity recognition method and device, medium and product

By introducing an attention-based soft dictionary and a three-affine decoder into the Chinese named entity recognition model, the problems of over-confidence and word information loss in Chinese named entity recognition are solved, and the accuracy and robustness of named entity recognition are improved. , significantly improving the F1 value and accuracy.

CN118839697APending Publication Date: 2024-10-25GUANGDONG UNIV OF PETROCHEMICAL TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410910692.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-10-25

AI Technical Summary

Technical Problem

Modern Chinese named entity recognition models based on neural networks are often troubled by the over-confidence problem, which affects the accuracy of named entity recognition. Especially in Chinese texts, due to the lack of explicit boundaries and the uncertainty of word boundaries, the results after word segmentation are Errors or omissions affect the accuracy of the model.

Method used

Introducing an attention-based soft dictionary and a three-affine decoder, through vocabulary enhancement in the embedding layer, and combining the BERT model and the bidirectional long-short-term memory network to build a tree-shaped scoring mechanism, allowing the model to focus on all the information of the entity and reduce word segmentation bands The word information is lost, and a Triaffine decoder is used in the decoding layer to involve the entity intermediate information in the decoding process.

Benefits of technology

It alleviates the over-confidence problem, improves the accuracy and robustness of Chinese named entity recognition, improves the performance of the model through vocabulary enhancement, and especially significantly improves the F1 value and accuracy when dealing with complex structures and noisy data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118839697A_ABST
    Figure CN118839697A_ABST
Patent Text Reader

Abstract

The invention discloses a Chinese named entity recognition method and device, a medium and a product, and relates to the technical field of information extraction, and the method comprises the steps: inputting a to-be-recognized statement into a trained Chinese named entity recognition model to obtain a Chinese named entity; the Chinese named entity recognition model comprises an embedding layer, a context coding layer and a decoding layer; the embedding layer comprises a BERT model, an attention-based soft dictionary and a splicing unit, and the splicing unit splices a first vector output by the BERT model and a second vector output by the attention-based soft dictionary and then inputs the spliced first vector and second vector into the context coding layer; the decoding layer comprises three feed-forward neural networks and a three-affine decoder, and the three feed-forward neural networks are connected between the context coding layer and the three-affine decoder in parallel; the three feed-forward neural networks respectively output a start tensor, a middle tensor and an end tensor representing spans, and the three affine decoders are used for scoring each span obtained by correlation. The Chinese named entity recognition accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information extraction technology, and in particular to a Chinese named entity recognition method, device, medium and product. Background Art

[0002] Named Entity Recognition (NER), also known as "proper name recognition", refers to the recognition of entities with specific meanings in text, mainly including names of people, places, institutions, proper nouns, etc. In recent years, some advanced NER models have achieved satisfactory results, but modern neural network-based NER models are often plagued by the overconfidence problem, which affects the accuracy of named entity recognition. Summary of the invention

[0003] The purpose of this application is to provide a Chinese named entity recognition method, device, medium and product, which can improve the accuracy of Chinese named entity recognition.

[0004] To achieve the above objectives, this application provides the following solutions:

[0005] In a first aspect, the present application provides a Chinese named entity recognition method, comprising:

[0006] Get the sentence to be recognized;

[0007] Inputting the sentence to be recognized into a trained Chinese named entity recognition model to obtain a Chinese named entity;

[0008] The Chinese named entity recognition model includes an embedding layer, a context encoding layer and a decoding layer; the embedding layer includes a BERT model, an attention-based soft dictionary and a splicing unit, the BERT model is used to convert the sentence to be recognized into a first vector, the attention-based soft dictionary is used to convert the sentence to be recognized into a second vector, and the splicing unit is used to splice the first vector and the second vector and input them into the context encoding layer; the decoding layer includes three feedforward neural networks and a three-affine decoder, and the three feedforward neural networks are connected in parallel between the context encoding layer and the three affine decoders; the three feedforward neural networks respectively output a start tensor, an intermediate tensor and an end tensor representing a span, and the three affine decoders are used to score each span obtained by association.

[0009] Optionally, the three feedforward neural networks are respectively a first feedforward neural network, a second feedforward neural network and a third feedforward neural network, the input ends of the first feedforward neural network, the second feedforward neural network and the third feedforward neural network are all connected to the output end of the context coding layer, and the output ends of the first feedforward neural network, the second feedforward neural network and the third feedforward neural network are all connected to the three affine decoders.

[0010] Optionally, the formula for scoring the span is expressed as:

[0011]

[0012] Among them, r ikj It represents the score of the span with the i-th token as the beginning, the k-th token as the middle, and the j-th token as the end. It is known that the i-th token is the beginning, the j-th token is the end, and the k-th token is the intermediate posterior probability; W is the score matrix, b is the bias term, is the output of the first feedforward neural network, is the output of the second feedforward neural network, is the output of the third feedforward neural network, T represents transposition, U triaffine is a tensor parameter.

[0013] Optionally, in converting the sentence to be recognized into a second vector, the attention-based soft dictionary is specifically used for:

[0014] Mapping each character in the sentence to be recognized into a character vector;

[0015] Match four word sets for each character vector according to the preset dictionary. The four word sets are respectively a set of words with the matched character as the starting position, the middle position, the ending position and a single character;

[0016] For each character, weight each word set internally according to the word frequency, and compress each internal weighted word set into a row vector of fixed dimension;

[0017] Concatenate the character vector and row vector of each character to obtain the reconstructed character;

[0018] The weighted vector is used to weight each internal weighted word set in the reconstructed character to obtain the second vector.

[0019] Optionally, the four word sets are represented as:

[0020]

[0021] Among them, ci represents the i-th character, B(c i ) is c i is the word set at the starting position, M(c i ) is c i is the word set in the middle position, E(c i ) is c i is the word set of the end position, S(c i ) is c i is a word set of single characters, L is the preset dictionary, is a universal quantifier; is an existential quantifier, w i,k The sentence to be identified is the sentence with c i Start with c k The word that ends and exists in the preset dictionary, n represents the number of characters in the sentence to be recognized.

[0022] Optionally, the second vector is expressed as:

[0023]

[0024] Among them, x i c i The second vector, e c (c i ) is c i A character vector of i1 、a i2 、a i3 and a i4 are weights, For B(c i ) to perform internal weighted word set, M(c i ) to perform internal weighted word set, is E(c i ) to perform internal weighted word set, is S(c i ) is used to perform internal weighting on the word set.

[0025] Optionally, the context encoding layer is a bidirectional long short-term memory network.

[0026] In a second aspect, the present application provides a computer device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any one of the above-described Chinese named entity recognition methods.

[0027] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described Chinese named entity recognition methods.

[0028] In a fourth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned Chinese named entity recognition methods.

[0029] According to the specific embodiments provided in this application, this application discloses the following technical effects:

[0030] The present application provides a Chinese named entity recognition method, device, medium and product, which introduces an attention-based soft dictionary in the embedding layer to perform vocabulary enhancement, and further performs vocabulary enhancement through a three-affine decoder, thereby reducing the word information loss caused by word segmentation, thereby alleviating the problem of over-confidence and improving the accuracy of Chinese named entity recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0032] Figure 1 A schematic diagram of the structure of a Chinese named entity recognition model provided in one embodiment of the present application;

[0033] Figure 2 When processing text for the span model, only the head and tail schematics of the entity fragment are considered;

[0034] Figure 3 A schematic diagram of the structure of three affine decoders provided in one embodiment of the present application;

[0035] Figure 4 A schematic diagram of an attention-based soft dictionary processing flow provided in an embodiment of the present application;

[0036] Figure 5 A schematic diagram of the difference in evaluation indicators between the model of the present application and the benchmark model provided in one embodiment of the present application;

[0037] Figure 6 A schematic diagram showing the combination of different components and Baseline provided in an embodiment of the present application;

[0038] Figure 7 A schematic diagram showing the comparison of F1 values ​​obtained by using the before and after attention models provided in an embodiment of the present application;

[0039] Figure 8 A schematic diagram of average F1 values ​​obtained by different pre-training models on four data sets provided in an embodiment of the present application;

[0040] Fig. 9 A schematic diagram of reliability and ECE values ​​of the benchmark model provided in one embodiment of the present application and the model of the present application on OntoNotes4 and ResumeNER;

[0041] Fig.10 A schematic diagram of the structure of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0042] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0043] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0044] The task of NER aims to identify the head and tail boundaries of an entity in a sentence and assign a category to the entire entity. Compared to English, in Chinese NER tasks, due to the lack of explicit boundaries, Chinese word segmentation must be performed first to obtain word boundaries. However, the uncertainty of word boundaries in Chinese may cause the results after word segmentation to be wrong or missing. Recently, a span-based NER model has been proposed. For Chinese, this method is character-based named entity recognition, which can avoid entity boundary errors without word segmentation. The advantage of the span structure is that it only focuses on the head and tail of the entity, which allows this method to more accurately capture entities with complex structures such as discontinuous and overlapping entities.

[0045] However, the span-based model also has its shortcomings. First, the span structure is applied to the character-level named entity recognition method. This method breaks down all words into individual characters. However, the boundaries of entities often coincide with the boundaries of words. When words are broken down, the information of the entity is also destroyed. Second, the span NER model only focuses on the head and tail of the entity during decoding. This single structure limitation means that the information in the middle of the entity is not involved in the decoding process. Figure 2An example of span model processing Chinese and English texts is given. The above two points show that the span-based model does not fully utilize word information. The lack of word information will affect the Chinese NER task. The lack of word information will also interfere with the training of the model and cause the overconfidence problem. The reason is that the trained model has adapted to the missing information and will confidently give prediction results when facing a new data set, but in fact it predicts wrong. The confidence of the predicted entity is much higher than the probability of its correctness.

[0046] The present application provides a Chinese named entity recognition method, which specifically includes the following steps.

[0047] Step 1: Get the sentence to be recognized.

[0048] Step 2: Input the sentence to be recognized into the trained Chinese named entity recognition model to obtain Chinese named entities.

[0049] like Figure 1 As shown, the Chinese named entity recognition model includes an embedding layer, a context encoding layer and a decoding layer; the embedding layer includes a BERT model, an attention-based soft dictionary and a splicing unit, the BERT model is used to convert the sentence to be recognized into a first vector, the attention-based soft dictionary is used to convert the sentence to be recognized into a second vector, and the splicing unit is used to splice the first vector and the second vector and input them into the context encoding layer; the decoding layer includes three feedforward neural networks (FFNN) and a triaffine decoder (Triaffine decoder), and the three feedforward neural networks are connected in parallel between the context encoding layer and the triaffine decoder; the three feedforward neural networks respectively output the start tensor, the middle tensor and the end tensor representing the span, and the triaffine decoder is used to score each span obtained by association.

[0050] The three feedforward neural networks are respectively a first feedforward neural network (FFNN_Start), a second feedforward neural network (FFNN_Middle) and a third feedforward neural network (FFNN_End), the input ends of the first feedforward neural network, the second feedforward neural network and the third feedforward neural network are all connected to the output end of the context coding layer, and the output ends of the first feedforward neural network, the second feedforward neural network and the third feedforward neural network are all connected to the three affine decoders.

[0051] The context encoding layer is a bidirectional long short-term memory network (BiLSTM).

[0052] This application introduces the Triaffine decoder to make the model focus on the entire information of the entity rather than just the head and tail, and achieve the purpose of enhancing vocabulary information by changing the decoding structure.

[0053] This application makes two changes to the baseline model (BERT-base-wwm+BiLSTM+Biaffine). (1) Attention-based soft lexicon embedding is added to the input layer, that is, attention-based soft lexicon embedding is added as a new input on the basis of the original single BERT embedding; (2) Triaffine decoder is introduced in the decoding layer, and the Biaffine decoder that only focuses on the head and tail of the entity fragment is replaced by the Triaffine decoder, and a tree-shaped scoring mechanism is constructed for the prediction calculation of the entity, so that all entity information is involved in the decoding process.

[0054] The Chinese named entity recognition model of this application is represented as BERT-base-wwm&Attentiona-basedSoftlexicon+BiLSTM+Triaffine.

[0055] The Triaffine decoder helps capture more grammatical and semantic information by scoring the joint dependency relationships of the head, tail and middle items of the text segment. This application uses the Triaffine structure in the span NER decoding layer to allow the information in the middle of the entity to participate in the decoding process, thereby achieving vocabulary enhancement.

[0056] The Chinese named entity recognition model also includes a softmax layer, and the input end of the softmax layer is connected to the output end of the Triaffine decoder.

[0057] In the Chinese named entity recognition model of this application, for Chinese character encoding, the full-word masked BERT pre-trained language model and the attention-based soft dictionary will convert the text into vector representations respectively. The two results are then concatenated and sent to the BiLSTM layer to obtain the contextual representation of the Chinese characters. Three independent FFNNs will receive the representation from the LSTM and output different tensors representing the beginning, middle, and end of the span. Finally, these three will be associated with the Triaffine decoder to obtain the score of each span in a sentence.

[0058] For the span NER model, after the input text is subjected to feature extraction, a text of length T (c1, c2, ···, c T ) will be encoded as a series of vectors x=x1,x2,···,x T , x i Represents the i-th character c in the text iFor the corresponding vectors, since the span structure itself has determined the boundaries of the entities, what the Triaffine decoder needs to do is to score each span over different entity types (including non-entities). Figure 3 The structure of the Triaffine decoder is explained. x is separately input into three independent feed-forward neural networks (FFNNs) to obtain the representations of each token as the start, middle, and end positions of an entity, which are h s ∈R T×d 、h m ∈R T×d and h e ∈R T×d ,where R T×d is a real matrix of dimension T×d, d is the dimension size of the second dimension of the real matrix, and d takes the value of 100 or 50. If the head of a span is the i-th token and the tail is the j-th token, the score r ikj of this span is calculated as follows:

[0059]

[0060] where r ikj represents the score of the span with the i-th token as the start, the k-th token as the middle, and the j-th token as the end; is the posterior probability that the k-th token is in the middle given that the i-th token is the start and the j-th token is the end; W is the score matrix, b is the bias term, is the output of the first feed-forward neural network, is the output of the second feed-forward neural network, is the output of the third feed-forward neural network, T represents transpose, and U triaffine is a tensor parameter.

[0061] The score formula for the span is divided into three parts by two plus signs.

[0062] The first part is the posterior probability that the k-th token is in the middle given that the i-th token is the head, the j-th token is the tail, and i < k < j. After the head and tail tokens of the entity are determined, the position and number of the tokens in the middle of the entity are also determined. Scoring is based on the "tree-shaped" structure - with the head and tail tokens as the "roots" and the middle tokens as the "branches". Specifically, each token will perform dot products with each other in the identities of the head, tail, and middle positions, and the calculation results are saved in the tensor U triaffine where U triaffine ∈R c×d×d×dis a learnable tensor parameter, c is the number of entity categories, which include names of people, places, events, and proper nouns. There can be multiple tokens in the middle. In order to calculate the score of the entire entity, the dimensions in the middle of the tensor are compressed. The einsum function in pytorch can effectively perform this operation. After compression:

[0063]

[0064] The second part is to determine the posterior probability that the i-th token is the head or the j-th token is the tail, which is also the mapping of the head and tail characters of the entity superimposed on the score matrix W. Where W∈R c×2d is a learnable parameter matrix.

[0065] The third part is the bias term b, which plays a role in balancing the model response.

[0066] Span Total Score r ikj ∈R T×T×c , represents the prediction score of each span in a sequence of length T (squeeze) on c entity categories (including non-entities). ikj It will be input into the softmax layer to convert the predicted score into a predicted probability

[0067]

[0068] Among them, the true value y ikj ∈R c is a one-hot vector, the predicted value is the probability value of the sample on all entity categories. This is the same as the general classification task, so this application chooses the cross entropy loss function to calculate the loss between the true value and the predicted value:

[0069]

[0070] Among them, L CE is the loss value.

[0071] In terms of converting the sentence to be recognized into a second vector, the attention-based soft dictionary is specifically used for:

[0072] Each character in the sentence to be recognized is mapped to a character vector, specifically: the input sequence s=c1,c2,···,c T (where c i Indicates that each character in the i-th word in the sentence s of length T is mapped to a character vector e c (c i ), ec (·) represents the operation of converting characters into word vectors.

[0073] According to the preset dictionary, four word sets are matched for each character vector, and the four word sets are respectively the sets of words with the matched characters as the starting position, the middle position, the ending position and the single character. The four word sets are collectively referred to as "BMES".

[0074] The four word sets are represented as:

[0075]

[0076] Among them, c i represents the i-th character, B(c i ) is c i is the word set at the starting position, M(c i ) is c i is the word set in the middle position, E(c i ) is c i is the word set of the end position, S(c i ) is c i is a word set of single characters, L is the preset dictionary, is a universal quantifier; is an existential quantifier, w i,k The sentence to be identified is the sentence with c i Start with c k The word that ends and exists in the preset dictionary, n represents the number of characters in the sentence to be recognized.

[0077] For each character, weight each word set internally according to the word frequency, where the word frequency is the number of times the word containing the character appears in the preset dictionary, and compress each internal weighted word set into a row vector of fixed dimension

[0078] Concatenate the character vector and row vector of each character to get the reconstructed character x i ′.

[0079]

[0080] The four word sets obtained above distinguish c to some extent i There are four positions, but sometimes the distinction may not be obvious. For example, when c i If more than two of the word sets have empty values, this method of weighting within the word set cannot clearly distinguish c i The position of the word makes it impossible to use the information of this position later. In order to more accurately evaluate c i Where is the entity located in the word vector Set trainable parameters between the four word sets. Enhance useful features and suppress weak features according to the importance between the four word sets. Figure 4 The attention-based soft dictionary method of this application is demonstrated.

[0081] The weighted word set in each reconstructed character is weighted by using a weighted vector to obtain the second vector, which is specifically:

[0082] First, the four word set vectors are merged into V i :

[0083]

[0084] Then a two-layer neural network is used to obtain a weighted vector a with a dimension of 1×4 and a value range of (0,1) i :

[0085] a i =softmax(qtanh(QV i T )).

[0086] Where: Q is the dimension d×d w ; q is a weight vector with dimension 1×d, both of which are trainable.

[0087] Finally, according to the weight vector a i The importance of the four word sets is weighted, and the weighted word set vector is cascaded with the character vector to obtain the character c i The final representation of (the second vector):

[0088]

[0089] Among them, x i c i The second vector, e c (c i ) is c i A character vector of i1 、a i2 、a i3 and a i4 are weights, For B(c i ) to perform internal weighted word set, M(c i ) to perform internal weighted word set, is E(c i ) to perform internal weighted word set, is S(c i ) is used to perform internal weighting on the word set.

[0090] This application performs vocabulary enhancement on the decoding layer of the span NER model for Chinese, builds a tree-shaped scoring mechanism for the entity decoding process using the Triaffine structure, and adds a soft dictionary embedding to the input layer of the model. The improved model can introduce more entity information, obtain more advanced performance than before, and alleviate the overconfidence problem, and improve the robustness of the model through vocabulary enhancement.

[0091] The following is an application scenario of legal document analysis to illustrate the application of a Chinese named entity recognition method in this application in a practical scenario.

[0092] 1. Objective: Automatically identify and extract key information such as legal terms, dates, case numbers, names of parties, and court names from legal documents for quick indexing and retrieval.

[0093] 2. Operation steps.

[0094] 1) Data preparation:

[0095] Collect a large amount of legal documents, including judgments, contracts, regulations, etc.

[0096] These documents are preprocessed to remove irrelevant content and standardize the format.

[0097] 2) Labeling data:

[0098] Manually annotate named entities in a portion of legal documents and determine the category of each entity (e.g., legal terms, dates, case numbers, party names, court names, etc.).

[0099] Use annotation tools (such as BRAT, Prodigy, etc.) to perform annotation work and generate training data sets.

[0100] 3) Training NER model:

[0101] Use the annotated dataset to train the Chinese named entity recognition model. Make sure the distribution of the training set and validation set is reasonable to evaluate the model performance.

[0102] During the training process, parameters need to be adjusted and optimized, and appropriate hyperparameters such as learning rate and batch size need to be selected.

[0103] 4) Model evaluation:

[0104] Use the validation set to evaluate the trained Chinese named entity recognition model and calculate indicators such as precision, recall, and F1-score.

[0105] Analyze error cases, understand the model’s weaknesses, and make necessary improvements.

[0106] 5) Deployment Model:

[0107] Deploy the trained Chinese named entity recognition model into the production environment and integrate it into the legal document analysis system.

[0108] Develop interfaces (such as APIs) for other systems or users to call.

[0109] 6) Application and monitoring:

[0110] Perform named entity recognition on new legal documents, extract key information and store it in the database.

[0111] Monitor the performance of the model regularly and make adjustments and optimizations based on feedback from actual use.

[0112] Continuously update the training data and retrain the model regularly to maintain its performance.

[0113] In order to demonstrate the technical effect of a Chinese named entity recognition method of the present application, this embodiment selects four public CNER datasets: OntoNotes4, MSRA, WeiboNER and Resume NER.

[0114] Hyperparameter settings for the Chinese named entity recognition model. Dropou is applied to FFNN and Triaffine at a rate of 0.2, and to LSTM at 0.5. The learning rate is set to 1e-3, 2e-3, or 3e-3, and BERT is fine-tuned using a learning rate of 1e-5 or 2e-5. Different learning rate combinations are selected on the four datasets to give the model weights initial values, and then a linear warm-up scheduler is used to adjust the learning rate during training. AdamW is used for model optimization. Table 1 shows the hyperparameter values ​​of the Chinese named entity recognition model for this application.

[0115] Table 1 Hyperparameter values ​​of Chinese named entity recognition model

[0116]

[0117] All four datasets are divided into three parts: training, development, and testing, except for MSRA. Since MSRA does not have a development set, we will directly train and then validate the final model. Recall, precision, and F1 values ​​are reported on the test sets of these four Chinese NER datasets. When both the boundary and the category are correctly predicted, the named entity is considered correct.

[0118] Tables 2-5 give the evaluation results of four Chinese datasets. On the OntoNotes4, Resume NER, and MSRA datasets, the Triaffine decoder and the soft dictionary of attention consistently improve the model performance against the baseline. The F1 values ​​on OntoNotes and Resume NER are improved by 0.46% and 0.11% respectively, and a comparable F1 score is achieved on MSRA.

[0119] Table 2 Evaluation results 1

[0120]

[0121] Table 3 Evaluation results 2

[0122]

[0123] Table 4 Evaluation results 3

[0124]

[0125] Table 5 Evaluation results 4

[0126]

[0127] Among them, Baseline represents the baseline model.

[0128] In order to clearly show the changes in accuracy, recall, and F1 value of the baseline model after improvement, the model of this application is subtracted from the evaluation criteria of the baseline model (including accuracy, recall, and F1 value) to obtain the difference (such as Figure 5 ). If the relevant evaluation standard difference is greater than zero, it means there is an improvement, otherwise it means a decrease.

[0129] analyze Figure 5 It can be seen that the model of this application has significantly improved precision and slightly decreased recall on the four data sets compared to the baseline model. This is consistent with expectations. More entity information will help the model more accurately predict the true type of the entity, which is the reason for the increase in precision. At the same time, the model will establish a higher standard to judge the type of the entity. Some entities are below this implicit standard, resulting in a slight decrease in recall.

[0130] In addition to Weibo NER, the model of this application obtains higher F1 scores on the other three datasets by sacrificing part of the recall rate (this is an important result.) The F1 value on Weibo NER is lower because it is noisier than the other three datasets. When a stricter model predicts a noisy dataset, more entities will be excluded from the correct answer. At this time, the improvement in precision is not enough to offset the decrease in recall, so the F1 score is lower than the baseline model.

[0131] The experimental results of the model of this application on all data sets including Weibo NER have proved that the introduction of the Triaffine decoder increases the threshold for the model to accept entities, and the model will only issue a prediction when it is very certain. This is a manifestation of the model's overconfidence problem being alleviated.

[0132] The attention-based soft dictionary and Triaffine decoder are introduced on the baseline model to study the contribution of these two parts. The other parts of the model are not changed and the ablation experiment is carried out with the same hyperparameters as the main experiment. The dataset used in the ablation experiment is OntoNotes 4, and the results are shown in Table 6.

[0133] Table 6 Ablation experiment results

[0134]

[0135] The experimental results are shown in Table 6. Two bar graphs were made based on Table 6 ( Figure 6 and Figure 7 ) to express the experimental conclusions obtained from it:

[0136] First, compared with the baseline model alone, the soft dictionary of attention and the Triaffine decoder contribute 0.08% and 0.32% F1 value improvement respectively. The combination of the two parts achieves the best results, with an F1 value improvement of 0.46% over the baseline model (see Figure 6 ).

[0137] Second, compared with the original soft dictionary, the F1 score of the model after introducing attention is improved by 0.75% (see Figure 7 ). The improved method does help improve the performance of named entity recognition tasks, which may be due to the fact that the attention mechanism of the word set embeds richer text features.

[0138] The Triaffine structure only works on the decoding layer of the model, and we want to explore the impact of different pre-trained model encoding inputs on the Triaffine structure.

[0139] The size of the pre-trained language model used in the baseline model is the basic size (768 hidden neurons, 12 layers), and the pre-training method is full-word masking. The basic size and large size (1024 hidden neurons, 24 layers) of the RoBERTa model and MacBERT model are used on the four Chinese NRE datasets. In order to prevent interference from other embeddings, only BERT embedding is used in the input layer. The experimental model is referred to as BBT (BERT+BiLSTM+Triaffine). Table 7 shows the F1 value of the experiment.

[0140] Table 7 Performance of the model on different BERTs

[0141]

[0142] Table 7 shows the F1 value of a single model on a single dataset. Figure 8 , the experimental results are analyzed using the average F1 value of the model on four datasets.

[0143] like Figure 8 As shown in the figure, the difference in F1 values ​​obtained by different BERTs is very small, and the maximum average F1 value difference is 0.58%. This proves that the combination of Triaffine decoder and pre-trained language model BERT has strong stability, and the performance of the overall model will not fluctuate strongly.

[0144] Among the three types of pre-trained models, MacBERT is currently the best. This may be because MacBERT uses similar words for masking in the pre-training task, which meets the need for vocabulary information in the Chinese NER task. In addition, the experimental results show that the performance of large-size BERT is generally better than that of the basic size because the large-size BERT receives more training.

[0145] The following is a confidence calibration experiment.

[0146] In some applications that require high reliability of the model, the evaluation of model performance not only relies on the F1 value but also needs to consider the problem of overconfidence. The overconfidence problem means that the neural network model will confidently give a prediction result, but in fact its prediction is wrong. For example, in a binary classification problem, the model predicts a negative class for a sample and gives a high score, but in fact the sample is a positive class.

[0147] How to judge the degree of overconfidence problem of the model? Someone proposed a confidence calibration method. Through calibration, the probability of the predicted class label generated by the model can reflect the degree of correctness of its true value. In order to prove the effect of the model of this application on the overconfidence problem, the confidence calibration of the model is performed according to the above confidence calibration method. The specific steps are as follows:

[0148] First, a trained model and a validation dataset are given. The dataset is predicted by the model to obtain the predicted entity set The actual entity set is ε. The model will have for each entity Generate a confidence According to the confidence The size of the entity set will be predicted Grouped in boxes of N (N=10) confidence intervals, entities falling into the nth interval together form a subset:

[0149]

[0150] For group n The accuracy of the set is:

[0151]

[0152] And the corresponding average confidence is:

[0153]

[0154] The reliability graph consists of n (n=1,2,······,N) groups of accuracy Acc n and confidence Conf n Compare and draw. ECE is through Acc n and Conf n The average weighted absolute difference between is calculated as:

[0155]

[0156] The better the calibration of the model, the closer the accuracy is to the average confidence level of each group. For a perfect reliability graph, the line connecting the accuracy points should be on the dotted line, and Conf n =Prec n , ECE=0.

[0157] The confidence calibration of the baseline model and the model of this application was compared, and all experiments set the same hyperparameters. Fig. 9 The reliability graph and ECE of the model on OntoNotes4 and Resume NER are shown. Fig. 9(a) is the reliability graph and ECE of the baseline model using the OntoNotes4 dataset, (b) is the reliability graph and ECE of the three-affine model using the OntoNotes4 dataset, (c) is the reliability graph and ECE of the baseline model using the Resume NER dataset, and (d) is the reliability graph and ECE of the three-affine model using the ResumeNER dataset. For both OntoNotes4 and Resume NER, the experimental accuracy of the baseline model is lower than the confidence level, indicating that the model is over-confident. Compared with the baseline model, the average accuracy curve generated by the model of this application is closer to the marked dotted line. On OntoNotes4 and Resume NER, the ECE values ​​of the baseline model are 0.0798 and 0.0823. After switching to the model of this application, the ECE values ​​are reduced by 0.0398 and 0.0171 respectively.

[0158] Experimental results show that the model of this application can obtain better calibration than before. This is a reflection of the alleviation of the overconfidence problem. During decoding, the model will be more strict in predicting entities. When a high-confidence entity conflicts with a low-confidence entity, the low-confidence entity will be discarded, and the predicted entity will become more accurate.

[0159] In summary, the present application applies the Triaffine decoder to the Chinese NER task based on the span structure. During decoding, the model will obtain more effective entity information, which will help the model establish a more stringent screening mechanism for entity prediction and improve the threshold for the model to accept entities. The addition of the Triaffine decoder sacrifices part of the recall rate to obtain a significant improvement in precision. The present application uses attention-based soft dictionary embedding to help the model obtain richer Chinese vocabulary features. The combination of these two improvements has helped the model of the present application achieve better performance.

[0160] The model of this application is built on a simple baseline (BERT-base-wwm+BiLSTM+Biaffine). Compared with the baseline model, the model of this application achieves a higher F1 value on three Chinese NER datasets.

[0161] In the main experiment, the improvement of precision is accompanied by a decrease in recall, indicating that the model of this application does not encourage overconfidence. The confidence calibration experiment further explains how the model of this application alleviates overconfidence - establishing a stricter prediction mechanism to filter out low-confidence entities, resulting in a significant improvement in precision and less overconfidence.

[0162] As shown in the results on the Weibo NER dataset in the main experiment, the Triaffine decoder produces a very low recall rate when facing a noisy dataset. This is risky, so be careful to apply it to noisy datasets. Future work will combine the Triaffine decoder with a variety of span NER models to study how to reduce the risk of reduced recall rate.

[0163] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Fig.10 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. 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 video tag processing data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication 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 Chinese named entity recognition method is implemented.

[0164] Those skilled in the art will understand that Fig.10 The 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.

[0165] In an exemplary embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0166] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0167] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0168] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0169] 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 the memory, database or other medium used in the embodiments provided in the present 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, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM may be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0170] The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. The non-relational database may include a distributed database based on blockchain, etc., but is not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, etc., but is not limited thereto.

[0171] 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.

[0172] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.

Claims

1. A Chinese named entity recognition method, characterized in that: The Chinese named entity recognition method comprises: Get the sentence to be recognized; Inputting the sentence to be recognized into a trained Chinese named entity recognition model to obtain a Chinese named entity; The Chinese named entity recognition model includes an embedding layer, a context encoding layer and a decoding layer; the embedding layer includes a BERT model, an attention-based soft dictionary and a splicing unit, the BERT model is used to convert the sentence to be recognized into a first vector, the attention-based soft dictionary is used to convert the sentence to be recognized into a second vector, and the splicing unit is used to splice the first vector and the second vector and input them into the context encoding layer; the decoding layer includes three feedforward neural networks and a three-affine decoder, and the three feedforward neural networks are connected in parallel between the context encoding layer and the three affine decoders; the three feedforward neural networks respectively output a start tensor, an intermediate tensor and an end tensor representing a span, and the three affine decoders are used to score each span obtained by association.

2. The Chinese named entity recognition method according to claim 1, characterized in that: The three feedforward neural networks are respectively a first feedforward neural network, a second feedforward neural network and a third feedforward neural network, the input ends of the first feedforward neural network, the second feedforward neural network and the third feedforward neural network are all connected to the output end of the context coding layer, and the output ends of the first feedforward neural network, the second feedforward neural network and the third feedforward neural network are all connected to the three affine decoders.

3. The Chinese named entity recognition method according to claim 2, characterized in that: The formula for scoring span is expressed as: Among them, r ikj It represents the score of the span with the i-th token as the beginning, the k-th token as the middle, and the j-th token as the end. It is known that the i-th token is the beginning, the j-th token is the end, and the k-th token is the intermediate posterior probability; W is the score matrix, b is the bias term, is the output of the first feedforward neural network, is the output of the second feedforward neural network, is the output of the third feedforward neural network, T represents transposition, U triaffine is a tensor parameter.

4. The Chinese named entity recognition method according to claim 1, characterized in that: In terms of converting the sentence to be recognized into a second vector, the attention-based soft dictionary is specifically used for: Mapping each character in the sentence to be recognized into a character vector; Match four word sets for each character vector according to the preset dictionary. The four word sets are respectively a set of words with the matched character as the starting position, the middle position, the ending position and a single character; For each character, weight each word set internally according to the word frequency, and compress each internal weighted word set into a row vector of fixed dimension; Concatenate the character vector and row vector of each character to obtain the reconstructed character; The weighted vector is used to weight each internal weighted word set in the reconstructed character to obtain the second vector.

5. The Chinese named entity recognition method according to claim 4, characterized in that: The four word sets are represented as: Among them, c i represents the i-th character, B(c i ) is c i is the word set at the starting position, M(c i ) is c i is the word set in the middle position, E(c i ) is c i is the word set of the end position, S(c i ) is c i is a word set of single characters, L is the preset dictionary, is a universal quantifier; is an existential quantifier, w i,k The sentence to be identified is the sentence with c i Start with c k The word that ends and exists in the preset dictionary, n represents the number of characters in the sentence to be recognized.

6. The Chinese named entity recognition method according to claim 5, characterized in that: The second vector is expressed as: Among them, x i c i The second vector, e c (c i ) is c i A character vector of i1 、a i2 、a i3 and a i4 are weights, For B(c i ) to perform internal weighted word set, M(c i ) to perform internal weighted word set, is E(c i ) to perform internal weighted word set, is S(c i ) is used to perform internal weighting on the word set.

7. The Chinese named entity recognition method according to claim 1, characterized in that: The context encoding layer is a bidirectional long short-term memory network.

8. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the Chinese named entity recognition method according to any one of claims 1 to 7.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the Chinese named entity recognition method described in any one of claims 1 to 7 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the Chinese named entity recognition method described in any one of claims 1 to 7 is implemented.