Sequence labeling method, system, computer readable storage medium and computer device
Through the sequence annotation method based on joint training, using the dynamic pre-training model and gating network, the problems of new word discovery, error accumulation and word polysemy in named entity recognition are solved, and fast and accurate named entity recognition and classification are achieved. , to meet the low-latency requirements of the industry.
Patent Information
- Application Number
- CN202011208873.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-03
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2040-11-03
AI Technical Summary
Existing named entity recognition technology has problems such as insensitivity to new word discovery, large error accumulation, difficulty in decoder processing of word polysemy, high cost and time-consuming artificial definition, and it is difficult to meet the low-latency requirements of the industry.
Adopt a sequence annotation method based on joint training, annotate data text through dual pointers, use a dynamic pre-training model for encoding, combine gating networks and loss functions for entity recognition and classification, reduce error accumulation, and dynamically fuse representations from different layers to improve the flexibility and efficiency of the model.
It achieves more accurate text encoding, reduces error propagation, can quickly handle polysemy issues, meets low-latency requirements, and improves model applicability and inference speed.
Smart Images

Figure CN112270181B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and more specifically, to a sequence labeling method, system, computer-readable storage medium and computer equipment based on joint training. Background Art
[0002] Named Entity Recognition (NER) is a very basic task in NLP, knowledge graph and other fields, which aims to locate and classify named entities in text into pre-defined categories, such as people, organizations, locations, time expressions, quantities, monetary values, percentages, etc. The effect of named entity recognition directly determines the effect of downstream tasks.
[0003] In November 2018, the Google team released the pre-trained model BERT, which achieved the best results in many NLP tasks and even surpassed human performance in some areas. However, due to the fixed mask mode and relatively small batch size used for training, the power of BERT still needs to be further developed. In 2019, Facebook released a deeper and larger pre-trained model, Roberta2. Roberta uses a larger batch size, more data, longer training time, and longer sentences. At the same time, it uses a dynamic mask method to remove the NSP task in Bert, so that Roberta achieves better performance and surpasses Bert in all indicators.
[0004] Different layers of BERT have different effects on downstream tasks [3]. Taking BERT-Base as an example, when the number of BERT-layer layers is lower, it can learn more shallow knowledge. When the number of BERT-layer layers is higher, it can understand more deep knowledge, such as reading comprehension.
[0005] Federated learning means that given m learning tasks, all or some of which are related but not exactly the same, the goal of federated learning is to help improve the performance of each task by using the knowledge contained in these m tasks.
[0006] The following three methods are mostly used in the prior art:
[0007] 1. Vocabulary + rules
[0008] Before machine learning and deep learning became popular, people dealt with NER problems mainly by combining dictionaries with rules. The dictionary-based NER method is usually the longest match between the trie tree and the set of record lengths. The trie tree is more efficient but occupies more memory, while the longest match of the set of record lengths has a slightly lower computational time efficiency than the trie (but much higher than word segmentation) and saves less memory space.
[0009] 2. Pipeline method of encoder and decoder
[0010] The input text is encoded by the encoder, and then the corresponding entity is found according to the decoder. Before 2018, the mainstream practice in the industry was to use bilstm for encoders and crf for decoders. After the emergence of Bert in 2018, the mainstream practice in the industry was to use bert to encode text. As for the decoder, there are more methods, including crf-based, softmax-based, and pointer-based.
[0011] 3. BERT+MRC
[0012] In recent years, NLP has been performing better and better in the field of reading comprehension (MRC). Whether in academia or industry, everyone is trying to convert NLP-related tasks into the form of MRC. In the direction of NER, BERT+MRC is a combination. By manually defining the question corresponding to each entity, and then finding the corresponding entity based on experience in the field of MRC.
[0013] However, in actual use, it is found that the above method still has the following defects:
[0014] 1. The form of vocabulary + rules is not sensitive to the discovery of new words and has low generalization ability for data.
[0015] 2. The pipeline solution for encoders and decoders is prone to error accumulation due to the pipeline solution. The current decoder cannot handle the problem of polysemy well. Due to the multi-classification at the token level, there is a problem of category imbalance, and Bert-Base is not the best encoder, so this solution still cannot achieve the best results.
[0016] 3. For the Bert+MRC solution, it is necessary to manually define the corresponding problems for each category, which requires specific experts to implement and is costly. In addition, the model training and model inference of this solution take a long time, so it is not suitable for the industry's requirements for low latency.
[0017] Therefore, there is an urgent need to develop a sequence labeling method, system, computer-readable storage medium and computer device based on joint training that overcome the above-mentioned defects. Summary of the invention
[0018] In view of the above problems, the present invention provides a sequence labeling method, characterized in that, based on a joint training method, the sequence labeling method comprises:
[0019] Data processing steps: annotating the original data text by double pointer method to obtain annotated data text;
[0020] Sequence labeling model construction step: training the dynamic pre-training model according to the labeling data text to obtain a sequence labeling model;
[0021] Sequence labeling step: labeling the real-time data text through the sequence labeling model.
[0022] In the above sequence labeling method, the labeling data text at least includes: the original data text, a set of first pointers, a set of last pointers, and a corresponding label set.
[0023] In the above sequence labeling method, the sequence labeling model construction step includes:
[0024] Encoding step: inputting the annotated data text into the dynamic pre-training model to obtain an encoding matrix;
[0025] A first loss function obtaining step: decoding the encoding matrix through a gating network to obtain entities and the first and last positions of the entities, and obtaining a first loss function according to the first and last positions of the entities;
[0026] A second loss function obtaining step: splicing the entity and the original data text to form a text pair classification form, and then classifying the original data text to obtain the category to which the entity belongs and the second loss function;
[0027] The sequence labeling model acquisition step: the sum of the first loss function and the second loss function is set as the final loss function, and then the dynamic pre-training model is back-propagated to update the parameters of the dynamic pre-training model to obtain the sequence labeling model.
[0028] In the above-mentioned sequence labeling method, the encoding step also includes: processing the labeled data text to obtain ID information, and then inputting the data corresponding to the ID information into the dynamic pre-training model to obtain a B*N*768 encoding matrix, where B refers to the batch size, N refers to the length of the sentence, and 768 is the output dimension of the dynamic pre-training model.
[0029] In the above-mentioned sequence labeling method, the encoding step further includes: assigning a parameter to the output of each layer of the dynamic pre-training model, and then multiplying the output of each layer by the corresponding parameter, and then adding them to obtain the final B*N*768 encoding matrix.
[0030] The present invention also provides a sequence labeling system, wherein based on a joint training method, the sequence labeling system comprises:
[0031] The data processing unit annotates the original data text by a double pointer method to obtain annotated data text;
[0032] A sequence labeling model construction unit is used to train a dynamic pre-training model according to the labeling data text to obtain a sequence labeling model;
[0033] The sequence labeling unit labels the real-time data text through the sequence labeling model.
[0034] In the above sequence labeling system, the sequence labeling model building unit includes:
[0035] An encoding module, inputting the annotated data text into the dynamic pre-training model to obtain an encoding matrix;
[0036] A first loss function obtaining module, which decodes the encoding matrix through a gating network to obtain entities and the first and last positions of the entities, and obtains a first loss function according to the first and last positions of the entities;
[0037] A second loss function obtaining module concatenates the entity and the original data text to form a text pair classification form, and then classifies the original data text to obtain the category to which the entity belongs and a second loss function;
[0038] The sequence labeling model acquisition module sets the sum of the first loss function and the second loss function as the final loss function, and then back-propagates the dynamic pre-training model to update the parameters of the dynamic pre-training model to obtain the sequence labeling model.
[0039] In the above-mentioned sequence labeling system, the encoding module processes the labeled data text to obtain ID information, and then inputs the data corresponding to the ID information into the dynamic pre-training model to obtain a B*N*768 encoding matrix, where B refers to the batch size, N refers to the length of the sentence, and 768 is the output dimension of the dynamic pre-training model; wherein the encoding module assigns a parameter to the output of each layer of the dynamic pre-training model, and then multiplies the output of each layer by the corresponding parameter, and then adds them to obtain the final B*N*768 encoding matrix.
[0040] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the sequence labeling method as described in any one of the above is implemented.
[0041] The present invention also 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 implements the sequence labeling method as described in any one of the above when executing the computer program.
[0042] In summary, compared with the prior art, the present invention is effective in that: the present invention encodes text based on the sequence labeling method of joint training to include more accurate information, and then jointly trains entity recognition and entity classification, and learns the loss of this part at the same time, reducing the error accumulation of loss in the transmission process. These enable the model to infer the model according to the context of the entity, thereby solving the problem of multiple meanings of a word. Compared with the methods of the prior art, the inference speed is also faster, which is very important in engineering.
[0043] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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.
[0045] Figure 1 is a flow chart of the sequence annotation method of the present invention;
[0046] Figure 2 Schematic diagram of the application of the sequence annotation method of the present invention
[0047] Figure 3 for Figure 1 A step-by-step flow chart of step S2;
[0048] Figure 4 This is a schematic diagram of the structure of the dynamic pre-training model;
[0049] Figure 5 is a schematic diagram of the structure of the sequence annotation system of the present invention;
[0050] Figure 6 It is a structural schematic diagram of the computer device of the present invention. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution 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, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0052] The exemplary embodiments and descriptions of the present invention are used to explain the present invention, but are not intended to limit the present invention. In addition, elements / components with the same or similar reference numerals used in the drawings and embodiments are used to represent the same or similar parts.
[0053] The terms “first”, “second”, “S1”, “S2”, etc. used in this document do not specifically refer to an order or sequence, nor are they used to limit the present invention. They are only used to distinguish elements or operations described with the same technical terms.
[0054] The directional terms used in this document, such as up, down, left, right, front or back, etc., are only used to refer to the directions of the drawings. Therefore, the directional terms used are used to illustrate and not to limit the present invention.
[0055] The words “include,” “including,” “have,” “contain,” etc. used in this document are open-ended terms, meaning including but not limited to.
[0056] As used herein, "and / or" includes any or all combinations of the items described.
[0057] As used herein, “plurality” includes “two” and “more than two”; as used herein, “plurality groups” includes “two groups” and “more than two groups”.
[0058] The terms "substantially" and "approximately" used herein are used to modify any quantity or error that may vary slightly, but these slight changes or errors do not change their essence. Generally speaking, the range of slight changes or errors modified by such terms may be 20% in some embodiments, 10% in some embodiments, 5% in some embodiments, or other values. Those skilled in the art should understand that the aforementioned values can be adjusted according to actual needs and are not limited thereto.
[0059] Certain terms used to describe the present application are discussed below or elsewhere in this specification to provide additional guidance to those skilled in the art regarding the description of the present application.
[0060] The present invention provides a sequence labeling method based on joint training, which aims to use the representation of different layers of Bert by using a dynamic fusion method, and utilize the encoder results of Bert more efficiently and flexibly; a joint training method is proposed to replace the pipeline method to learn the problem of sequence labeling. Specifically, a larger and more flexible dynamic pre-training model ROBERTA is used to encode the text to ensure that the encoding of the text can contain more accurate information, and then the entity recognition and entity classification are jointly trained, and the loss of this part is learned at the same time to reduce the error accumulation of the loss in the transmission process, which enables the model to infer the model according to the context of the entity, thereby solving the problem of multiple meanings of a word. Compared with the Bert+MRC method, the inference speed is also faster, which is very important for engineering. At the same time, it solves the problems that the encoder in the prior art is not flexible enough; the pipeline method is prone to error accumulation; the Bert+MRC method is difficult to start with, has high computing power requirements, and cannot meet the low latency requirements.
[0061] Please refer to the following Figure 1-Figure 2 , Figure 1 is a flow chart of the sequence annotation method of the present invention; Figure 2 Schematic diagram of the application of the sequence annotation method of the present invention. Figure 1-Figure 2 As shown, the sequence labeling method based on the joint training mode of the present invention includes:
[0062] Data processing step S1: annotate the original data text by double pointer method to obtain annotated data text.
[0063] Specifically, the original data text needs to be annotated first. The present invention obtains the annotated data text by adopting a double pointer method. In this embodiment, the annotated data text includes at least four parts, the original data text, a set of first pointers, a set of last pointers and a corresponding label set.
[0064] Sequence labeling model construction step S2: training the dynamic pre-training model according to the labeled data text to obtain the sequence labeling model.
[0065] Sequence labeling step S3: labeling the real-time data text through the sequence labeling model.
[0066] For further information, please refer to Figure 3 , Figure 3 for Figure 1 The step-by-step flow chart of step S2 in FIG. Figure 2 As shown, the sequence labeling model construction step S2 includes:
[0067] Encoding step S21: input the annotated data text into the dynamic pre-training model to obtain an encoding matrix; wherein, in this step, the annotated data text is processed to obtain ID information, and then the data corresponding to the ID information is input into the dynamic pre-training model to obtain an encoding matrix of B*N*768, wherein B refers to the size of the batch size (batch_size), N refers to the length of the sentence, and 768 is the output dimension of the dynamic pre-training model.
[0068] Specifically, the annotated data text is first processed to obtain the ID information corresponding to each sentence. In this embodiment, the ID information includes input_id, segment_id, mask_id, etc., and then the corresponding data is fed into the dynamic pre-training model. In this embodiment, the dynamic pre-training model of dynamic roberta is used to obtain a B*N*768 matrix, where B refers to the batch_size, N refers to the length of the sentence, and 768 is the output dimension of roberta.
[0069] Please refer to Figure 4 , Figure 4 This is a schematic diagram of the structure of the dynamic pre-training model. Figure 4 As shown, each layer output of the dynamic pre-training model has different effects on downstream tasks. The shallower the layer of BERT, the lower the representation obtained. Taking Roberta Base as an example, the model contains a total of 12 layers of transformer layers. The present invention assigns a parameter to the output of each layer, and the parameter is between 0 and 1. Finally, the outputs of these 12 layers are multiplied by the corresponding parameters, and then added to obtain the final encoder output, that is, the B*N*768 encoding matrix. Since the parameters of each layer are constantly changing with the model, Dynamic Roberta can dynamically combine the different outputs of Roberta, so as to use the encoder output more flexibly and efficiently.
[0070] First loss function obtaining step S22: decoding the encoding matrix through the gated network to obtain the entity and the first and last positions of the entity, and obtaining the first loss function according to the first and last positions of the entity.
[0071] Specifically, the encoding result, that is, the B*N*768 encoding matrix, is decoded and two sigmoid gated networks are used to predict the first and last positions of the entity. At this time, it is only necessary to identify whether the current entity (tokens) is an entity, without knowing specifically which category the current entity (tokens) belongs to. The first loss function of the model is the sum of the two pointer classification losses, denoted as loss_1
[0072] The second loss function is obtained in step S23: the entity and the original data text are concatenated to form a text pair classification form, and then the original data text is classified to obtain the category to which the entity belongs and the second loss function.
[0073] Specifically, after the first loss function is obtained in step S22, it can be obtained which are entities (tokens). In this step, the obtained can be concatenated with the original sentence to form a text pair classification form, that is, [CLS]+text_a+[SEP]+text_b+[SEP]. Then the text is classified to obtain the category to which it currently belongs. The second loss function at this time is recorded as loss_2.
[0074] Sequence labeling model acquisition step S24: The sum of the first loss function and the second loss function is set as the final loss function, and then the dynamic pre-training model is back-propagated to update the parameters of the dynamic pre-training model to obtain the sequence labeling model.
[0075] Therefore, the sequence labeling model obtained by the joint training method in the present invention can solve the problem of error accumulation on the one hand, and can handle the problem of polysemy on the other hand. In addition, compared with the BERT+MRC method, the model can be trained faster and meet the low latency requirement of model inference. At the same time, the present invention also adopts the dynamic fusion method of Roberta, which can utilize the output of Roberta more efficiently and flexibly, and can also be better applicable to downstream tasks.
[0076] It should be noted that although the present invention uses dynamic roberta as an example of a dynamic pre-training model, the present invention is not limited to this. In other embodiments, the dynamic pre-training model may also be xlnet, albert, t5, etc.
[0077] Please refer to Figure 5 , Figure 5 FIG. 1 is a schematic diagram of the structure of the sequence annotation system of the present invention. Figure 5 As shown, the sequence labeling system based on the joint training method of the present invention includes:
[0078] The data processing unit 11 annotates the original data text by a double pointer method to obtain annotated data text;
[0079] A sequence labeling model building unit 12 is used to train a dynamic pre-training model according to the labeling data text to obtain a sequence labeling model;
[0080] The sequence labeling unit 13 labels the real-time data text through the sequence labeling model.
[0081] Wherein, the sequence labeling model building unit 12 includes:
[0082] The encoding module 121 inputs the annotated data text into the dynamic pre-training model to obtain an encoding matrix;
[0083] A first loss function obtaining module 122, which decodes the encoding matrix through a gating network to obtain entities and the first and last positions of the entities, and obtains a first loss function according to the first and last positions of the entities;
[0084] The second loss function obtaining module 123 concatenates the entity with the original data text to form a text pair classification form, and then classifies the original data text to obtain the category to which the entity belongs and the second loss function;
[0085] The sequence labeling model acquisition module 124 sets the sum of the first loss function and the second loss function as the final loss function, and then performs backpropagation on the dynamic pre-training model to update the parameters of the dynamic pre-training model to obtain the sequence labeling model.
[0086] Among them, the encoding module 121 processes the annotated data text to obtain ID information, and then inputs the data corresponding to the ID information into the dynamic pre-training model to obtain a B*N*768 encoding matrix, where B refers to the batch size, N refers to the length of the sentence, and 768 is the output dimension of the dynamic pre-training model; wherein the encoding module 121 assigns a parameter to the output of each layer of the dynamic pre-training model, and then multiplies the output of each layer by the corresponding parameter, and then adds them to obtain the final B*N*768 encoding matrix.
[0087] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the sequence labeling method as described in any one of the above is implemented.
[0088] Please refer to Figure 6 , Figure 6 FIG. 1 is a schematic diagram of the structure of the computer device of the present invention. Figure 6 As shown, the computer device of the present invention may include a processor 21 and a memory 22 storing computer program instructions.
[0089] Specifically, the processor 21 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0090] Among them, the memory 22 may include a large-capacity memory for data or instructions. By way of example and not limitation, the memory 22 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 22 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 22 may be inside or outside the data processing device. In a specific embodiment, the memory 22 is a non-volatile memory. In a specific embodiment, the memory 22 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-Only Memory, PROM for short), an erasable PROM (Erasable ProgrammableRead-Only Memory, EPROM for short), an electrically erasable PROM (Electrically Erasable ProgrammableRead-Only Memory, EEPROM for short), an electrically alterable ROM (Electrically Alterable Read-Only Memory, EAROM for short) or a flash memory (FLASH) or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0091] The memory 22 may be used to store or cache various data files that need to be processed and / or used for communication, as well as possible computer program instructions executed by the processor 21 .
[0092] The processor 21 implements any one of the sequence labeling methods in the above embodiments by reading and executing computer program instructions stored in the memory 22.
[0093] In some embodiments, the computer device may further include a communication interface 23 and a bus 20. Figure 6 As shown, the processor 21, the memory 22, and the communication interface 23 are connected via a bus 20 and communicate with each other.
[0094] The communication port 23 can realize data communication with other components such as external devices, image / data acquisition devices, databases, external storage, and image / data processing workstations.
[0095] The bus 20 includes hardware, software or both, and couples the components of the computer device to each other. The bus 20 includes but is not limited to at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not limitation, bus 20 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, bus 20 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
[0096] The computer device can execute any of the above-mentioned sequence labeling methods.
[0097] In summary, the present invention can solve the problem of error accumulation on the one hand, and deal with the problem of polysemy on the other hand. In addition, compared with the BERT+MRC method, the model can be trained faster and meet the low latency requirement of model inference. At the same time, the present invention also adopts the dynamic fusion method of Roberta, which can utilize the output of Roberta more efficiently and flexibly, and can also be better applied to downstream tasks.
[0098] 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 substitutions for some of the technical features therein; and these modifications or substitutions do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A sequence labeling method, characterized in that: Based on a joint training method, wherein the joint training method is to use a dynamic pre-training model ROBERTA to encode the text, and then jointly train entity recognition and entity classification, and simultaneously learn entity recognition loss and entity classification loss; the sequence labeling method includes: Data processing steps: annotating the original data text by a double pointer method to obtain annotated data text, wherein the double pointer includes a first pointer pointing to the first position of the entity and an last pointer pointing to the last position of the entity; Sequence labeling model construction step: training the dynamic pre-training model ROBERTA according to the labeled data text to obtain a sequence labeling model; Among them, each layer output of the dynamic pre-training model ROBERTA has different effects on downstream tasks. The dynamic pre-training model ROBERTA includes a transformer layer. The output of each transformer layer is assigned a parameter between 0 and 1. Finally, the outputs of all transformer layers are multiplied by the corresponding parameters, and then added to obtain the final encoder output. The parameters of each transformer layer are constantly changing with the model; Sequence labeling step: labeling the real-time data text through the sequence labeling model; The annotated data text includes at least: the original data text, a set of first pointers, a set of last pointers, and a set of classification labels corresponding to entities.
2. The sequence labeling method according to claim 1, characterized in that: The sequence labeling model construction step includes: Encoding step: inputting the annotated data text into the dynamic pre-training model to obtain an encoding matrix; A first loss function obtaining step: decoding the encoding matrix through a gating network to obtain entities and the first and last positions of the entities, and obtaining a first loss function according to the first and last positions of the entities; A second loss function obtaining step: splicing the entity and the original data text to form a text pair classification form, and then classifying the original data text to obtain the category to which the entity belongs and the second loss function; The sequence labeling model acquisition step: the sum of the first loss function and the second loss function is set as the final loss function, and then the dynamic pre-training model is back-propagated to update the parameters of the dynamic pre-training model to obtain the sequence labeling model.
3. The sequence labeling method according to claim 1, characterized in that: The encoding step also includes: processing the annotated data text to obtain ID information, and then inputting the data corresponding to the ID information into the dynamic pre-training model to obtain a B*N*768 encoding matrix, where B refers to the batch size, N refers to the length of the sentence, and 768 is the output dimension of the dynamic pre-training model.
4. The sequence labeling method according to claim 3, characterized in that: The encoding step further includes: assigning a parameter to the output of each layer of the dynamic pre-training model, multiplying the output of each layer by the corresponding parameter, and then adding them to obtain the final B*N*768 encoding matrix.
5. A sequence labeling system, characterized in that: Based on a joint training method, wherein the joint training method is to use a dynamic pre-training model ROBERTA to encode the text, and then jointly train entity recognition and entity classification, and simultaneously learn entity recognition loss and entity classification loss; the sequence labeling system includes: The data processing unit annotates the original data text by a double pointer method to obtain annotated data text, wherein the double pointer includes a first pointer pointing to the first position of the entity and an last pointer pointing to the last position of the entity; A sequence labeling model construction unit is used to train the dynamic pre-training model ROBERTA according to the labeling data text to obtain a sequence labeling model; Among them, each layer output of the dynamic pre-training model ROBERTA has different effects on downstream tasks. The dynamic pre-training model ROBERTA includes a transformer layer. The output of each transformer layer is assigned a parameter between 0 and 1. Finally, the outputs of all transformer layers are multiplied by the corresponding parameters, and then added to obtain the final encoder output. The parameters of each transformer layer are constantly changing with the model; A sequence labeling unit, which labels the real-time data text through the sequence labeling model; The annotated data text includes at least: the original data text, a set of first pointers, a set of last pointers, and a set of classification labels corresponding to entities.
6. The sequence annotation system according to claim 5, characterized in that: The sequence labeling model building unit includes: An encoding module, inputting the annotated data text into the dynamic pre-training model to obtain an encoding matrix; A first loss function obtaining module, which decodes the encoding matrix through a gating network to obtain entities and the first and last positions of the entities, and obtains a first loss function according to the first and last positions of the entities; A second loss function obtaining module concatenates the entity and the original data text to form a text pair classification form, and then classifies the original data text to obtain the category to which the entity belongs and a second loss function; The sequence labeling model acquisition module sets the sum of the first loss function and the second loss function as the final loss function, and then back-propagates the dynamic pre-training model to update the parameters of the dynamic pre-training model to obtain the sequence labeling model.
7. The sequence annotation system according to claim 6, characterized in that: The encoding module processes the annotated data text to obtain ID information, and then inputs the data corresponding to the ID information into the dynamic pre-training model to obtain a B*N*768 encoding matrix, where B refers to the batch size, N refers to the length of the sentence, and 768 is the output dimension of the dynamic pre-training model; The encoding module assigns a parameter to the output of each layer of the dynamic pre-training model, and then multiplies the output of each layer by the corresponding parameter, and then adds them together to obtain the final B*N*768 encoding matrix.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the sequence labeling method according to any one of claims 1 to 4 is implemented.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the sequence labeling method according to any one of claims 1 to 4 is implemented.
