A method, device, electronic device and storage medium for named entity recognition

By jointly pre-training language models and combining BERT and ERNIE models, multi-layer semantic information of Chinese texts is extracted, which solves the problem of insufficient accuracy in Chinese named entity recognition and achieves efficient named entity recognition of Chinese texts.

CN114330350BActive Publication Date: 2024-10-11BEIJING INST OF ENVIRONMENTAL FEATURES
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210007201.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-05
Publication Date
2024-10-11
Estimated Expiration
2042-01-05

AI Technical Summary

Technical Problem

The existing technology has shortcomings in the accuracy of named entity recognition in Chinese text, and it is difficult to effectively keep up with the growth rate of data, especially in the context of the complexity of the Chinese language.

Method used

Using a named entity recognition method based on a joint pre-trained language model, combined with a character recognition model, word segmentation recognition model and sequence annotation model, character-level, vocabulary-level and syntax-level semantic information is extracted through the pre-trained BERT and ERNIE models, and through the loss function Weighted adjustment of model parameters to achieve named entity recognition of Chinese text.

Benefits of technology

It significantly improves the accuracy of named entity recognition in Chinese text, improves the recognition performance of named entities such as people, organizations, places, etc., and enhances the effect of entity recognition by fusing multi-layer semantic information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114330350B_ABST
    Figure CN114330350B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of computer deep learning, and in particular to a method, device, electronic device and storage medium for named entity recognition, the method comprising: obtaining Chinese text of known named entities and preprocessing to obtain text vectors of multiple known named entities; training a joint model based on the text vectors of the known named entities; the joint model comprises a character recognition model, a word segmentation recognition model and a sequence labeling model; obtaining Chinese text to be recognized and preprocessing to obtain the text vector to be recognized; inputting the text vector to be recognized into the trained joint model to perform named entity recognition. The present invention can improve the entity recognition performance of Chinese text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer deep learning technology, and in particular to a named entity recognition method, device, electronic device and storage medium. Background Art

[0002] With the advent of the information-based Internet era, the collection, analysis and processing of massive multi-source public opinion big data has become more complicated. The traditional information collection and processing methods based on manual intervention have been unable to keep up with the speed of data growth. At the same time, emerging artificial intelligence technologies with deep learning as the core have developed rapidly, expanding the processing capabilities of multi-source text data and promoting the development of technologies in the field of intelligent mining and analysis of public opinion big data. Named entity recognition aims to locate and classify important entity information in texts, such as proper nouns such as names of people, time and place, and organizations. Named entity recognition technology is an indispensable and important part of various natural language processing technologies such as information extraction, information retrieval, machine translation, and question-answering systems. It is one of the current hot research directions of intelligent public opinion analysis. At present, due to the particularity of the Chinese language, the accuracy of named entity recognition of Chinese texts through deep learning models needs to be improved. Summary of the invention

[0003] In response to at least some of the above-mentioned technical defects, an embodiment of the present invention provides a method, device, electronic device and storage medium for named entity recognition based on a joint pre-trained language model, which can improve the entity recognition performance for Chinese text.

[0004] In a first aspect, an embodiment of the present invention provides a method for named entity recognition, comprising:

[0005] Obtain Chinese text of known named entities and perform preprocessing to obtain text vectors of multiple known named entities;

[0006] Based on the text vectors of known named entities, the joint model is trained; the joint model includes a character recognition model, a word segmentation recognition model and a sequence labeling model; the character recognition model is a pre-trained language model, which is used to extract character features from the input text vector and output a first text representation vector containing character-level semantic information; the word segmentation recognition model is a pre-trained language model, which is used to extract word segmentation features from the input text vector and output a second text representation vector containing vocabulary-level and grammatical-level semantic information; the sequence labeling model is used to solve based on the fused first text representation vector and the second text representation vector to obtain a first sequence of entity categories that identify the text vector;

[0007] Obtain the Chinese text to be recognized and perform preprocessing to obtain the text vector to be recognized;

[0008] The text vector to be recognized is input into the trained joint model to perform named entity recognition.

[0009] Optionally, the joint model further includes a normalization layer, which is used to input the fused first text representation vector and the second text representation vector, perform normalization processing on them, and then output them to the sequence labeling model.

[0010] Optionally, for the joint model, fusing the first text representation vector and the second text representation vector includes:

[0011] For each character, the feature representing the character in the first text representation vector and the feature representing the character in the second text representation vector are concatenated to serve as the fused feature representing the character.

[0012] Optionally, the joint model further includes a classifier, and the classifier is used to perform a solution based on the second text representation vector to obtain a second sequence of entity categories of the identification text vector;

[0013] The training of the joint model includes:

[0014] Inputting the text vector of the known named entity into the joint model to obtain the first sequence and the second sequence;

[0015] Determine the standard annotation sequence corresponding to the text vector of the known named entity;

[0016] Constructing a first cross entropy loss function based on an error between the first sequence and a standard labeled sequence, constructing a second cross entropy loss function based on an error between the second sequence and a standard labeled sequence, weighting the first cross entropy loss function and the second cross entropy loss function to construct a loss function of the joint model, wherein the weight corresponding to the first cross entropy loss function is greater than the weight corresponding to the second cross entropy loss function;

[0017] Parameters of the joint model are adjusted based on the loss function of the joint model.

[0018] Optionally, the character recognition model adopts a BERT model, the word segmentation recognition model adopts an ERNIE model, and the sequence labeling model adopts a linear chain conditional random field.

[0019] In a second aspect, an embodiment of the present invention further provides a named entity recognition device, comprising:

[0020] An acquisition module is used to acquire Chinese text of known named entities and perform preprocessing to obtain text vectors of multiple known named entities;

[0021] A training module, used to train a joint model based on text vectors of known named entities; the joint model includes a character recognition model, a word segmentation recognition model and a sequence labeling model; the character recognition model is a pre-trained language model, used to extract character features from an input text vector, and output a first text representation vector containing character-level semantic information; the word segmentation recognition model is a pre-trained language model, used to extract word segmentation features from an input text vector, and output a second text representation vector containing vocabulary-level and grammatical-level semantic information; the sequence labeling model is used to solve based on the fused first text representation vector and the second text representation vector to obtain a first sequence of entity categories that identify the text vector;

[0022] A processing module is used to obtain the Chinese text to be recognized and perform preprocessing to obtain the text vector to be recognized;

[0023] The recognition module is used to input the text vector to be recognized into the trained joint model to perform named entity recognition.

[0024] Optionally, the joint model further includes a normalization layer, which is used to input the fused first text representation vector and the second text representation vector, perform normalization processing on them, and then output them to the sequence labeling model.

[0025] Optionally, the joint model further includes a classifier, and the classifier is used to perform a solution based on the second text representation vector to obtain a second sequence of entity categories of the identification text vector;

[0026] The training module trains the joint model, including performing the following operations:

[0027] Inputting the text vector of the known named entity into the joint model to obtain the first sequence and the second sequence;

[0028] Determine the standard annotation sequence corresponding to the text vector of the known named entity;

[0029] Constructing a first cross entropy loss function based on an error between the first sequence and a standard labeled sequence, constructing a second cross entropy loss function based on an error between the second sequence and a standard labeled sequence, weighting the first cross entropy loss function and the second cross entropy loss function to construct a loss function of the joint model, wherein the weight corresponding to the first cross entropy loss function is greater than the weight corresponding to the second cross entropy loss function;

[0030] Parameters of the joint model are adjusted based on the loss function of the joint model.

[0031] In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in any embodiment of this specification is implemented.

[0032] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, enables the computer to execute the method described in any embodiment of this specification.

[0033] The present invention provides a method, device, electronic device and storage medium for named entity recognition. The present invention adopts a joint model for named entity recognition. The joint model includes a pre-trained character recognition model and a word segmentation recognition model. The character recognition model is used to extract character features from an input text vector and output a first text representation vector containing character-level semantic information. The word segmentation recognition model is used to extract word segmentation features from the input text vector and output a second text representation vector containing vocabulary-level and grammatical-level semantic information. The fused first text representation vector and the second text representation vector are used for solving to obtain a first sequence of entity categories of the identification text vector, thereby realizing the recognition of named entities such as people, organizations, places, etc. in Chinese text. The present invention integrates the character-level, vocabulary-level and grammatical-level semantic information in Chinese text, and can effectively improve entity recognition performance. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0035] Figure 1 It is a schematic diagram of steps of a method for named entity recognition provided by one embodiment of the present invention;

[0036] Figure 2 It is a flowchart of another method for named entity recognition provided by one embodiment of the present invention;

[0037] Figure 3 (a) shows the statistical information of the People Daily dataset; Figure 3 (b) shows the statistical information of the MSRA-NER dataset;

[0038] Figure 4 It is a graph showing the results of named entity recognition by multiple models;

[0039] Figure 5It is a schematic diagram of the change of F1 value during the training process of the joint model (JPLM_NER) provided by the present invention for named entity recognition tasks on different data sets;

[0040] Figure 6 is a hardware architecture diagram of an electronic device provided by an embodiment of the present invention;

[0041] Figure 7 It is a structural diagram of a named entity recognition device provided by one embodiment of the present invention. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0043] Please refer to Figure 1 The embodiment of the present invention provides a method for named entity recognition for Chinese text, the method comprising:

[0044] Step 100, obtaining Chinese text of known named entities and preprocessing them to obtain text vectors of multiple known named entities.

[0045] The text vectors of known named entities can be used as samples to form training sets and test sets for subsequent training of deep learning models.

[0046] Step 102, training the joint model based on the text vectors of known named entities; wherein the joint model includes a character recognition model, a word segmentation recognition model and a sequence labeling model; the character recognition model is a pre-trained language model, which is used to extract character features from the input text vector and output a first text representation vector containing character-level semantic information; the word segmentation recognition model is a pre-trained language model, which is used to extract word segmentation features from the input text vector and output a second text representation vector containing vocabulary-level and grammatical-level semantic information; the sequence labeling model is used to solve based on the fused first text representation vector and the second text representation vector to obtain a first sequence of entity categories that identify the text vector.

[0047] In the joint model, the same text vector is input into the pre-trained character recognition model and word segmentation recognition model, and multiple semantic information is obtained by using the character recognition model and word segmentation recognition model, which are then integrated to form a deep semantic representation vector of the text, and the coding sequences corresponding to different entities are identified by the sequence annotation model. The first sequence output by the joint model is obtained, and then the codes appearing in the first sequence are decoded to realize the recognition of named entities such as people, organizations, and places. The specific correspondence between the codes in the identification text vector output by the sequence annotation model and the entity category can be set as needed and is not further limited here.

[0048] Step 104, obtain the Chinese text to be recognized and perform preprocessing to obtain the text vector to be recognized.

[0049] For Chinese text to be recognized that contains unknown entities, the text needs to be preprocessed to meet the input requirements of the joint model.

[0050] Step 106: input the text vector to be recognized into the trained joint model to perform named entity recognition.

[0051] Named entity recognition is an important part of natural language processing technology, and plays an irreplaceable and important role in applications such as information extraction, machine translation, and intelligent question and answer. The research and development of pre-trained language models are driving the further improvement of the performance of named entity recognition technology. The present invention proposes a named entity recognition technology that combines a character recognition model and a word segmentation recognition model. This technology uses a pre-trained character recognition model to extract semantic information from character-level text, and uses a pre-trained word segmentation recognition model enhanced with prior knowledge to extract semantic information at the Chinese vocabulary and grammar levels. After fusion, the implicit sequence constraint information is learned through a sequence annotation model, thereby improving the accuracy of named entity recognition tasks for Chinese text.

[0052] Preferably, if Figure 2 As shown, the joint model also includes a normalization layer, which is used to input the fused first text representation vector and the second text representation vector, and after normalization, output them to the sequence labeling model.

[0053] The input of the normalization layer is the fused first text representation vector and the second text representation vector, and the output is the deep semantic representation vector of the text, which serves as the input of the sequence labeling model. The normalization layer can simply concatenate the first text representation vector and the second text representation vector so that it contains semantic information at the character level and word level.

[0054] Further, to obtain the fused first text representation vector and the second text representation vector, for the joint model, fusing the first text representation vector and the second text representation vector includes:

[0055] For each character, the feature representing the character in the first text representation vector and the feature representing the character in the second text representation vector are concatenated as a new feature representing the character after fusion.

[0056] like Figure 2 As shown, for the input character w1, the element e in the corresponding first text representation vector is 1B and the second text represents the element e in the vector 1E After splicing (that is, e1 obtained by the ERNIE model), we get the new element e in the text representation vector after fusion. 1E +e 1B , the text representation vector obtained after fusion still represents each character and can enhance the semantic features of each character.

[0057] Preferably, if Figure 2 As shown, the joint model also includes a classifier, which is used to solve based on the second text representation vector to obtain a second sequence of entity categories of the identification text vector. Accordingly, in step 102, training the joint model includes the following steps:

[0058] Input the text vectors of known named entities into the joint model to obtain a first sequence and a second sequence;

[0059] Determine the standard annotation sequence corresponding to the text vector of the known named entity;

[0060] A first cross entropy loss function is constructed based on the error between the first sequence and the standard labeled sequence, a second cross entropy loss function is constructed based on the error between the second sequence and the standard labeled sequence, the first cross entropy loss function and the second cross entropy loss function are weighted to construct a loss function of the joint model, wherein the weight corresponding to the first cross entropy loss function is greater than the weight corresponding to the second cross entropy loss function;

[0061] The parameters of the joint model are adjusted based on the loss function of the joint model.

[0062] The text vectors of multiple known named entities are used as samples, and the above training steps are repeated to perform multiple rounds of training and parameter adjustment on the parameters of the joint model, and then the test set is used for testing to determine that the joint model converges, and a trained joint model can be obtained. The present invention uses the error loss of two output sequences (i.e., the first sequence and the second sequence) to jointly adjust the parameters of the joint model, wherein the first sequence uses the fusion feature information obtained by the character recognition model and the word segmentation recognition model, and the second sequence uses the feature information obtained by the word segmentation recognition model. When adjusting, the error between the first sequence and the standard annotation sequence is mainly used, but at the same time, the error between the second sequence and the standard annotation sequence is introduced in a weighted manner, which can strengthen the influence of word segmentation, grammar, etc. on entities and make the model converge quickly.

[0063] In some preferred implementations, the character recognition model adopts the BERT model, the word segmentation recognition model adopts the ERNIE model, and the sequence labeling model adopts the linear chain conditional random field (Linear CRF).

[0064] Furthermore, the preprocessing includes segmenting the input text into characters, adding [CLS] and [SEP] identifiers before and after the text according to the input requirements of the BERT model, and fixing the length of the input text by truncating the longer characters and filling the shorter ones.

[0065] The pre-trained BERT model uses a bidirectional transformer-encoder structure to capture the contextual semantic information of the text sequence and generate a dynamic word vector representation of the text sequence. The input text sequence usually needs to go through a series of processing to meet the input conditions of the BERT model, mainly including the following three parts:

[0066] 1. Character embeddings: Encode the input text sequence into a fixed-dimensional vector representation. For Chinese text, it is segmented by character, and the [CLS] identifier is added before the sentence and the [SEP] identifier is added after the sentence to mark the start and end of the text according to the task requirements. The text is tokenized through WordPiece tokenization, which is also equipped with a specific dictionary.

[0067] 2. Segment embeddings: Segment embeddings can distinguish two different sentences in a sentence pair. The specific implementation is to set a vector of the length of the sentence pair, with the first sentence position in the vector disposed at 0 and the second sentence position disposed at 1.

[0068] 3. Position embeddings: The theoretical principle of the attention mechanism does not take into account the position order of the text. Therefore, position embeddings are introduced to model the position information of the text character sequence, as shown in the following formula: Refers to the position information of the character. Indicates the text length of the sentence, is the dimension of the word vector, yes A specific dimension of:

[0069]

[0070] in, express POS The even-dimensional position encoding of the character at position, express POS The character at position is encoded in the odd-numbered dimension.

[0071] The input text sequence is processed through the above three steps and then fused as the text vector input to the BERT model. The parameters of the pre-trained BERT model itself are used to calculate the text embedding representation vector containing contextual semantic information, that is, the first text representation vector containing character-level semantic information.

[0072] Since the ERNIE model in the prior art itself considers and models prior semantic knowledge units, it is more sensitive to the entity feature information of Chinese text, and can thus learn a text semantic representation vector that includes vocabulary and grammar levels.

[0073] The input requirements of the ERNIE model are basically the same as those of the BERT model. Therefore, the text vectors that fuse character embedding representation, segment embedding representation, and position embedding representation can be simultaneously input into the ERNIE model to obtain the text sequence word vector output after dynamic calculation, that is, the second text representation vector containing lexical and grammatical semantic information. The ERNIE model takes into account a large amount of vocabulary, entity, and entity relationship information during the pre-training process, so as to directly model the prior semantic knowledge units of the real world, thereby enhancing the semantic representation ability of the model. For Chinese text, the BERT model uses a single character as the basic unit for modeling, while the ERNIE model has better real semantic knowledge learning capabilities, especially for Chinese text containing a large number of vocabulary phrases. Therefore, the ERNIE model extracts lexical and grammatical feature information from the input Chinese text sequence and fuses it with the information extracted by the BERT model to enhance the deep semantic information, thereby further improving the entity recognition performance.

[0074] After obtaining the first text representation vector calculated by the BERT model and the second text representation vector calculated by the ERNIE model, the two are concatenated and normalized as the final text sequence vector containing deep semantic information. Specifically, the normalization layer can use the LayerNorm layer to calculate the mean and variance of the batch training samples and standardize the concatenated (ie fused) text representation vector representation. The formula is as follows:

[0075]

[0076] in, represents the concatenated text representation vector, represents the normalized representation vector, and Respectively represent the mean and variance of the input text representation vector, It is an additional value to maintain numerical stability, the default value is 1e-5, and are learnable affine transformation parameters.

[0077] The linear chain conditional random field learns the input, normalized representation vector and solves the maximum likelihood probability of the output sequence. The conditional random field is a probabilistic structural model that can maximize the fit of the output sequence for the input text sequence. Since the label information of adjacent data is taken into account, the implicit constraint relationship of the standard annotation sequence can be learned from specific training, thereby improving the effect of named entity recognition. Its parameterized expression is as follows:

[0078]

[0079] in, represents the input sequence, Indicates that in a given x The output sequence when Indicates that in a given x hour y The conditional probability distribution of y i express y Middle i output nodes, the transfer characteristic function is , which means that the definition is i The output node context k A local characteristic function, Indicates i The first output node l Node characteristic function, and is the weight coefficient, is the normalization factor.

[0080] After the calculation of the linear chain conditional random field, the predicted output sequence corresponding to the input text can be obtained, and the error between the predicted output sequence (i.e., the first sequence) and the standard annotation sequence is calculated by the loss function; in addition, the second text representation vector calculated by the ERNIE model is directly solved by the fully connected classifier to obtain the predicted output sequence (i.e., the second sequence) corresponding to the input text, and the error between the second sequence and the standard annotation sequence is calculated; the above two errors (or losses) are calculated using the cross entropy function, and the specific formula is as follows:

[0081]

[0082] in, Indicates input, x n,c Indicates the first n Sample No. cCategory prediction results, Indicates the goal, y n,c Indicates the first n Sample No. c Category true result, w c represents the weight coefficient, Indicates the number of categories for label classification, l n Indicates n The cross entropy calculated from samples, reduction represents loss, mean represents average value, when reduction=mean, the cross entropy corresponding to all samples in the input minibatch is averaged as the cross entropy loss, sum represents sum, when reduction=sum, the cross entropy corresponding to all samples in the input minibatch is summed as the cross entropy loss, l ( x , y ) represents the cross entropy loss function of the current minibatch, which is the dimension information of the minibatch.

[0083] The joint model loss function consists of two parts, and the formula is as follows:

[0084]

[0085] in and Represent the second cross entropy loss function and the first cross entropy loss function respectively, and is a hyperparameter and satisfies the constraint condition. Preferably, the weight of the first cross entropy loss function is between 65% and 80%.

[0086] The present invention also uses a public data set to verify the performance of the named entity recognition method provided by the present invention:

[0087] Taking the public opinion analysis of news reports as the application scenario, key named entities are selected as the identification objects. Aiming at the needs of intelligent analysis and processing of massive public opinion data, the above method is used to identify and extract entities such as people, time, place, and organization in the text of news reports, providing structured information description for further public opinion analysis.

[0088] The present invention uses the public open source evaluation Chinese data sets People Daily and MSRA-NER as test data, and the data information is shown in Figure 3 (a) and Figure 3 (b) respectively. The People Daily data set is released by People's Daily, and it is necessary to identify the named entities related to people (PER), places (ORG), organizations (LOC), and time and date (T); the MSRA-NER data set is released by Microsoft Research Asia, and its goal is to identify the named entity information such as people (PER), places (ORG), and organizations (LOC) in the text. The text sequence data annotation of known named entities adopts the annotation format of BIO.

[0089] The BERT model, BERT+CRF model, ERNIE model and the joint model (i.e. JPLM_NER) provided by the present invention are used for named entity recognition respectively. The final results are compared as follows: Figure 4 As shown, the results show that: 1. Compared with the use of a single pre-trained language model, the performance of the named entity recognition method based on the joint model of the present invention is further improved; 2. The introduction of CRF has a better optimization effect on sequence labeling tasks such as named entity recognition.

[0090] Figure 5 This is a diagram showing the changes in F1 value during the training process of the joint model (JPLM_NER) for named entity recognition tasks on different datasets. Figure 5 It can be seen that when EPOCH (i.e., all samples in the data set are counted once) is cycled to 5, the performance of the joint model on the two data sets stabilizes to a better level.

[0091] like Figure 6 , Figure 7 As shown, an embodiment of the present invention provides a named entity recognition device. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. From the hardware level, Figure 6 As shown, it is a hardware architecture diagram of an electronic device in which a named entity recognition device provided by an embodiment of the present invention is located, except Figure 6 In addition to the processor, memory, network interface, and non-volatile memory shown, the electronic device in the embodiment may also include other hardware, such as a forwarding chip responsible for processing messages, etc. Taking software implementation as an example, Figure 7 As shown, as a device in a logical sense, the CPU of the electronic device in which it is located reads the corresponding computer program in the non-volatile memory into the memory and runs it. A named entity recognition device provided in this embodiment includes an acquisition module 701, a training module 702, a processing module 703 and a recognition module 704; wherein:

[0092] The acquisition module 701 is used to acquire Chinese text of known named entities and perform preprocessing to obtain text vectors of multiple known named entities;

[0093] The training module 702 is used to train the joint model based on the text vector of the known named entity; the joint model includes a character recognition model, a word segmentation recognition model and a sequence labeling model; the character recognition model is a pre-trained language model, which is used to extract character features from the input text vector and output a first text representation vector containing character-level semantic information; the word segmentation recognition model is a pre-trained language model, which is used to extract word segmentation features from the input text vector and output a second text representation vector containing vocabulary-level and grammatical-level semantic information; the sequence labeling model is used to solve based on the fused first text representation vector and the second text representation vector to obtain a first sequence of entity categories that identify the text vector;

[0094] The processing module 703 is used to obtain the Chinese text to be recognized and perform preprocessing to obtain the text vector to be recognized;

[0095] The recognition module 704 is used to input the text vector to be recognized into the trained joint model to perform named entity recognition.

[0096] In this embodiment, the acquisition module 701 can be used to implement step 100 of the above-mentioned named entity recognition method, the training module 702 can be used to implement step 102 of the above-mentioned named entity recognition method, the processing module 703 can be used to implement step 104 of the above-mentioned named entity recognition method, and the recognition module 704 can be used to implement step 106 of the above-mentioned named entity recognition method.

[0097] Optionally, the joint model further includes a normalization layer, which is used to input the fused first text representation vector and the second text representation vector, perform normalization processing, and then output them to the sequence labeling model.

[0098] Further, for the joint model, fusing the first text representation vector and the second text representation vector includes:

[0099] For each character, the feature representing the character in the first text representation vector and the feature representing the character in the second text representation vector are concatenated to serve as the fused feature representing the character.

[0100] Optionally, the joint model further includes a classifier, which is used to perform a solution based on the second text representation vector to obtain a second sequence of entity categories identifying the text vector; accordingly, the training module 702 trains the joint model, including performing the following operations:

[0101] Input the text vectors of known named entities into the joint model to obtain a first sequence and a second sequence;

[0102] Determine the standard annotation sequence corresponding to the text vector of the known named entity;

[0103] A first cross entropy loss function is constructed based on the error between the first sequence and the standard labeled sequence, a second cross entropy loss function is constructed based on the error between the second sequence and the standard labeled sequence, the first cross entropy loss function and the second cross entropy loss function are weighted to construct a loss function of the joint model, wherein the weight corresponding to the first cross entropy loss function is greater than the weight corresponding to the second cross entropy loss function;

[0104] The parameters of the joint model are adjusted based on the loss function of the joint model.

[0105] Preferably, the character recognition model adopts the BERT model, the word segmentation recognition model adopts the ERNIE model, and the sequence labeling model adopts the linear chain conditional random field.

[0106] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on a named entity recognition device. In other embodiments of the present invention, a named entity recognition device may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0107] The information interaction, execution process and other contents between the modules in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention. For specific contents, please refer to the description in the embodiment of the method of the present invention, and no further description is given here.

[0108] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, a method for named entity recognition in any embodiment of the present invention is implemented.

[0109] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the processor executes a method for named entity recognition in any embodiment of the present invention.

[0110] Specifically, a system or device equipped with a storage medium can be provided, on which software program code that implements the functions of any of the above-mentioned embodiments is stored, and a computer (or CPU or MPU) of the system or device can be enabled to read and execute the program code stored in the storage medium.

[0111] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.

[0112] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer via a communication network.

[0113] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.

[0114] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion module connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or expansion module is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.

[0115] It should be noted that, in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical factors in the process, method, article or device including the elements.

[0116] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk, etc., various media that can store program codes.

[0117] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for named entity recognition, characterized in that: include: Obtain Chinese text of known named entities and perform preprocessing to obtain text vectors of multiple known named entities; Based on the text vectors of known named entities, the joint model is trained; the joint model includes a character recognition model, a word segmentation recognition model and a sequence labeling model; the character recognition model is a pre-trained language model, which is used to extract character features from the input text vector and output a first text representation vector containing character-level semantic information; the word segmentation recognition model is a pre-trained language model, which is used to extract word segmentation features from the input text vector and output a second text representation vector containing vocabulary-level and grammatical-level semantic information; the sequence labeling model is used to solve based on the fused first text representation vector and the second text representation vector to obtain a first sequence of entity categories that identify the text vector; Obtain the Chinese text to be recognized and perform preprocessing to obtain the text vector to be recognized; Inputting the text vector to be recognized into the trained joint model to perform named entity recognition; Among them, the character recognition model adopts the BERT model, the word segmentation recognition model adopts the ERNIE model, and the sequence labeling model adopts the linear chain conditional random field.

2. The method according to claim 1, characterized in that The joint model also includes a normalization layer, which is used to input the fused first text representation vector and the second text representation vector, perform normalization processing, and then output them to the sequence labeling model.

3. The method according to claim 1, characterized in that For the joint model, fusing the first text representation vector and the second text representation vector includes: For each character, the feature representing the character in the first text representation vector and the feature representing the character in the second text representation vector are concatenated to serve as the fused feature representing the character.

4. The method according to claim 2, characterized in that: The joint model further includes a classifier, the classifier being used to perform a solution based on the second text representation vector to obtain a second sequence of entity categories of the identification text vector; The training of the joint model includes: Inputting the text vector of the known named entity into the joint model to obtain the first sequence and the second sequence; Determine the standard annotation sequence corresponding to the text vector of the known named entity; Constructing a first cross entropy loss function based on an error between the first sequence and a standard labeled sequence, constructing a second cross entropy loss function based on an error between the second sequence and a standard labeled sequence, weighting the first cross entropy loss function and the second cross entropy loss function to construct a loss function of the joint model, wherein the weight corresponding to the first cross entropy loss function is greater than the weight corresponding to the second cross entropy loss function; Parameters of the joint model are adjusted based on the loss function of the joint model.

5. A named entity recognition device, characterized in that: include: An acquisition module is used to acquire Chinese text of known named entities and perform preprocessing to obtain text vectors of multiple known named entities; A training module, used to train a joint model based on text vectors of known named entities; the joint model includes a character recognition model, a word segmentation recognition model and a sequence labeling model; the character recognition model is a pre-trained language model, used to extract character features from an input text vector, and output a first text representation vector containing character-level semantic information; the word segmentation recognition model is a pre-trained language model, used to extract word segmentation features from an input text vector, and output a second text representation vector containing vocabulary-level and grammatical-level semantic information; the sequence labeling model is used to solve based on the fused first text representation vector and the second text representation vector to obtain a first sequence of entity categories that identify the text vector; A processing module is used to obtain the Chinese text to be recognized and perform preprocessing to obtain the text vector to be recognized; A recognition module, used for inputting the text vector to be recognized into the trained joint model to perform named entity recognition; Among them, the character recognition model adopts the BERT model, the word segmentation recognition model adopts the ERNIE model, and the sequence labeling model adopts the linear chain conditional random field.

6. The device according to claim 5, characterized in that The joint model also includes a normalization layer, which is used to input the fused first text representation vector and the second text representation vector, perform normalization processing, and then output them to the sequence labeling model.

7. The device according to claim 6, characterized in that The joint model further includes a classifier, the classifier being used to perform a solution based on the second text representation vector to obtain a second sequence of entity categories of the identification text vector; The training module trains the joint model, including performing the following operations: Inputting the text vector of the known named entity into the joint model to obtain the first sequence and the second sequence; Determine the standard annotation sequence corresponding to the text vector of the known named entity; Constructing a first cross entropy loss function based on an error between the first sequence and a standard labeled sequence, constructing a second cross entropy loss function based on an error between the second sequence and a standard labeled sequence, weighting the first cross entropy loss function and the second cross entropy loss function to construct a loss function of the joint model, wherein the weight corresponding to the first cross entropy loss function is greater than the weight corresponding to the second cross entropy loss function; Parameters of the joint model are adjusted based on the loss function of the joint model.

8. An electronic device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 4 is implemented.

9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed in a computer, the computer is caused to execute the method according to any one of claims 1 to 4.