Training methods, related methods and related products of named entity recognition models

By employing a multi-task training method, the differences are calculated and parameters are updated using a pre-trained language model, which solves the problem of low training efficiency of natural language models in named entity recognition and achieves efficient named entity recognition results with a small amount of text.

CN117709344BActive Publication Date: 2024-11-19SHUXING TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311666327.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-06
Publication Date
2024-11-19
Estimated Expiration
2043-12-06

AI Technical Summary

Technical Problem

In existing technologies, natural language models have low training efficiency in named entity recognition tasks and struggle to effectively identify named entities in text, especially with a small amount of training text.

Method used

By acquiring the main and auxiliary task instructions from the training data, the pre-trained language model is used to execute the tasks, calculate the differences, and update the model parameters to improve the accuracy of the model in named entity recognition. A multi-task training method is adopted to enhance the model's understanding ability.

Benefits of technology

With a small amount of training text, the accuracy and efficiency of the named entity recognition model are significantly improved, enabling it to better understand the entity types in the text and making it suitable for named entity recognition in specific domains.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117709344B_ABST
    Figure CN117709344B_ABST
Patent Text Reader

Abstract

The present application discloses a training method, related methods and related products for a named entity recognition model. The method includes: obtaining training data, the training data includes a training text, a first task content of a main task, and a second task content of a first auxiliary task, the first task content includes determining a first entity word in the training text and an entity type of the first entity word, and the second task content includes determining the entity type contained in the training text; in the process of training a pre-trained language model using the training data, the pre-trained language model executes the main task to obtain a first execution result, executes the first auxiliary task to obtain a second execution result; determines a first difference between the first execution result and a first label of the main task; determines a second difference between the second execution result and a second label of the first auxiliary task; based on the first difference and the second difference, updates the parameters of the pre-trained language model to obtain a named entity recognition model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing technology, and in particular to a training method for a named entity recognition model, related methods and related products. Background Art

[0002] With the development of natural language processing technology, the applications of natural language processing are increasing, including named entity recognition (NER) based on natural language models. Before using natural language models to perform named entity recognition on text, the natural language model needs to be trained so that the natural language model has the ability to perform named entity recognition on text. Therefore, how to train the natural language model is of great significance. Summary of the invention

[0003] The present application provides a training method, related methods and related products for a named entity recognition model to train a model for named entity recognition of text, wherein the related methods include a named entity recognition method, and the related products include: a training device for a named entity recognition model, a named entity recognition device, an electronic device, a computer-readable storage medium, and a computer program product.

[0004] In a first aspect, a method for training a named entity recognition model is provided, the method comprising:

[0005] Acquire training data, the training data including training text, main task instructions and first auxiliary task instructions, the main task instructions including first task content of the main task, the first task content including determining a first entity word in the training text and an entity type of the first entity word, the first entity word being a named entity (NE), the first auxiliary task instructions including second task content of the first auxiliary task, the second task content including determining the entity type contained in the training text;

[0006] In the process of training the pre-trained language model using the training data, the pre-trained language model executes the main task according to the first task content in the main task instruction to obtain a first execution result, and the pre-trained language model executes the first auxiliary task according to the second task content in the first auxiliary instruction to obtain a second execution result;

[0007] Determine a first difference between the first execution result and the first label of the main task;

[0008] Determine a second difference between the second execution result and the second label of the first auxiliary task;

[0009] Based on the first difference and the second difference, the parameters of the pre-trained language model are updated to obtain a named entity recognition model, where the named entity recognition model is used to perform named entity recognition on the text.

[0010] In combination with any embodiment of the present application, the training data further includes an example of an entity type describing a second entity word, the second entity word is a named entity, and the second entity word is different from the first entity word;

[0011] The pre-trained language model executes the main task according to the first task content in the main task instruction to obtain a first execution result, including:

[0012] Under the prompt of the example, the pre-trained language model executes the main task according to the first task content in the main task instruction to obtain the first execution result.

[0013] In combination with any implementation manner of the present application, the training data further includes a second auxiliary task instruction, the second auxiliary task instruction includes a third task content of the second auxiliary task, and the third task content includes determining the first entity word from the training text;

[0014] Before updating the parameters of the pre-trained language model based on the first difference and the second difference to obtain a named entity recognition model, the method further includes:

[0015] In the process of training the pre-trained language model using the training data, the pre-trained language model executes the second auxiliary task according to the third task content in the second auxiliary task instruction to obtain a third execution result;

[0016] determining a third difference between the third execution result and a third label of the second auxiliary task;

[0017] The updating of the parameters of the pre-trained language model based on the first difference and the second difference to obtain a named entity recognition model includes:

[0018] Based on the first difference, the second difference and the third difference, the parameters of the pre-trained language model are updated to obtain the named entity recognition model.

[0019] In combination with any embodiment of the present application, the training data further includes a third auxiliary task instruction, the third auxiliary task instruction includes a fourth task content of the third auxiliary task, and the fourth task content includes determining the entity type of the words in the training text;

[0020] Before updating the parameters of the pre-trained language model based on the first difference, the second difference and the third difference to obtain the named entity recognition model, the method further includes:

[0021] In the process of training the pre-trained language model using the training data, the pre-trained language model performs the third auxiliary task according to the fourth task content in the third auxiliary task instruction to obtain a fourth execution result;

[0022] determining a fourth difference between the fourth execution result and a fourth label of the third auxiliary task;

[0023] The updating of the parameters of the pre-trained language model based on the first difference, the second difference and the third difference to obtain the named entity recognition model includes:

[0024] Based on the first difference, the second difference, the third difference and the fourth difference, the parameters of the pre-trained language model are updated to obtain the named entity recognition model.

[0025] In combination with any implementation manner of the present application, the updating of the parameters of the pre-trained language model based on the first difference, the second difference, the third difference and the fourth difference to obtain the named entity recognition model includes:

[0026] Determining a loss of the pre-trained language model based on the first difference, the second difference, the third difference, and the fourth difference, wherein the loss is positively correlated with the first difference, the second difference, the third difference, and the fourth difference;

[0027] Based on the loss, the parameters of the pre-trained language model are updated to obtain the named entity recognition model.

[0028] In combination with any implementation manner of the present application, the training data further includes preset entity types, and the fourth task content includes determining the entity type of the first entity term in the training text from the preset entity types.

[0029] In combination with any implementation manner of the present application, the first execution result and the third execution result both include text that describes the first entity word according to a preset sentence structure.

[0030] In combination with any implementation manner of the present application, the training data further includes preset entity types, and the first task content includes determining the entity type of the first entity term from the preset entity types.

[0031] In combination with any implementation manner of the present application, the pre-trained language model is a text-to-text conversion model.

[0032] In a second aspect, a method for named entity recognition is provided, the method comprising:

[0033] Get the text to be recognized;

[0034] A named entity recognition model is used to perform named entity recognition on the text to be recognized to obtain a named entity recognition result, wherein the named entity recognition model is obtained by training through the first aspect and any implementation manner thereof.

[0035] In combination with any implementation manner of the present application, after obtaining the named entity recognition result, the method further includes:

[0036] Based on the named entity recognition result, a target mapping relationship is determined, where the target mapping relationship is a mapping relationship between a target entity word in the to-be-recognized text and a target entity type of the target entity word, and the target entity word is a named entity.

[0037] In combination with any embodiment of the present application, the named entity recognition result describes the candidate entity type of the candidate entity term according to a preset sentence pattern, and the candidate entity term is a named entity;

[0038] The determining of the target mapping relationship based on the named entity recognition result includes:

[0039] Dividing the text used to describe the same candidate entity word in the named entity recognition result into the same sub-text to obtain at least one sub-text;

[0040] Based on the preset sentence pattern, determining the candidate entity words in each of the sub-texts and the candidate entity types in each of the sub-texts;

[0041] The target mapping relationship is determined based on the candidate entity terms and the candidate entity types.

[0042] In combination with any implementation manner of the present application, the determining the target mapping relationship based on the candidate entity words and the candidate entity types includes:

[0043] For the candidate entity words and the candidate entity types in the same sub-text, when the candidate entity words belong to the text to be recognized and the candidate entity type is a preset entity type, the mapping relationship between the candidate entity words and the candidate entity type is determined as the target mapping relationship.

[0044] In a third aspect, a training device for a named entity recognition model is provided, the training device comprising:

[0045] an acquisition unit, configured to acquire training data, wherein the training data includes a training text, a main task instruction, and a first auxiliary task instruction, wherein the main task instruction includes a first task content of a main task, wherein the first task content includes determining a first entity word in the training text and an entity type of the first entity word, wherein the first entity word is a named entity, and wherein the first auxiliary task instruction includes a second task content of the first auxiliary task, wherein the second task content includes determining an entity type contained in the training text;

[0046] an execution unit, configured to, in a process of training a pre-trained language model using the training data, cause the pre-trained language model to execute the main task on the training text according to the main task instruction to obtain a first execution result, and cause the pre-trained language model to execute the first auxiliary task on the training text according to the first auxiliary instruction to obtain a second execution result;

[0047] a determining unit, configured to determine a first difference between the first execution result and the first label of the main task;

[0048] The determining unit is configured to determine a second difference between the second execution result and the second label of the first auxiliary task;

[0049] An updating unit is used to update the parameters of the pre-trained language model based on the first difference and the second difference to obtain a named entity recognition model, wherein the named entity recognition model is used to perform named entity recognition on the text.

[0050] In combination with any embodiment of the present application, the training data further includes an example of an entity type describing a second entity word, the second entity word is a named entity, and the second entity word is different from the first entity word;

[0051] The execution unit is specifically used for:

[0052] Under the prompt of the example, the pre-trained language model executes the main task according to the first task content in the main task instruction to obtain the first execution result.

[0053] In combination with any implementation manner of the present application, the training data further includes a second auxiliary task instruction, the second auxiliary task instruction includes a third task content of the second auxiliary task, and the third task content includes determining the first entity word from the training text;

[0054] The execution unit is further configured to, in a process of training the pre-trained language model using the training data, cause the pre-trained language model to execute the second auxiliary task according to the third task content in the second auxiliary task instruction to obtain a third execution result;

[0055] The determining unit is further configured to determine a third difference between the third execution result and a third label of the second auxiliary task;

[0056] The updating unit is specifically used to update the parameters of the pre-trained language model based on the first difference, the second difference and the third difference to obtain the named entity recognition model.

[0057] In combination with any embodiment of the present application, the training data further includes a third auxiliary task instruction, the third auxiliary task instruction includes a fourth task content of the third auxiliary task, and the fourth task content includes determining the entity type of the words in the training text;

[0058] The execution unit is further configured to, in a process of training the pre-trained language model using the training data, cause the pre-trained language model to execute the third auxiliary task according to the fourth task content in the third auxiliary task instruction to obtain a fourth execution result;

[0059] The determining unit is further configured to determine a fourth difference between the fourth execution result and a fourth label of the third auxiliary task;

[0060] The updating unit is specifically used to update the parameters of the pre-trained language model based on the first difference, the second difference, the third difference and the fourth difference to obtain the named entity recognition model.

[0061] In combination with any implementation manner of the present application, the updating unit is specifically used for:

[0062] Determining a loss of the pre-trained language model based on the first difference, the second difference, the third difference, and the fourth difference, wherein the loss is positively correlated with the first difference, the second difference, the third difference, and the fourth difference;

[0063] Based on the loss, the parameters of the pre-trained language model are updated to obtain the named entity recognition model.

[0064] In combination with any implementation manner of the present application, the training data further includes preset entity types, and the fourth task content includes determining the entity type of the first entity term in the training text from the preset entity types.

[0065] In combination with any implementation manner of the present application, the first execution result and the third execution result both include text that describes the first entity word according to a preset sentence structure.

[0066] In combination with any implementation manner of the present application, the training data further includes preset entity types, and the first task content includes determining the entity type of the first entity term from the preset entity types.

[0067] In combination with any implementation manner of the present application, the pre-trained language model is a text-to-text conversion model.

[0068] In a fourth aspect, a named entity recognition device is provided, the named entity recognition device comprising:

[0069] An acquisition unit, used for acquiring the text to be recognized;

[0070] The recognition unit is used to perform named entity recognition on the text to be recognized by using a named entity recognition model to obtain a named entity recognition result. The named entity recognition model is obtained by training through the first aspect and any implementation manner thereof.

[0071] In combination with any embodiment of the present application, the named entity recognition device also includes: a determination unit, used to determine a target mapping relationship based on the named entity recognition result, the target mapping relationship being a mapping relationship between a target entity word in the text to be recognized and a target entity type of the target entity word, and the target entity word is a named entity.

[0072] In combination with any embodiment of the present application, the named entity recognition result describes the candidate entity type of the candidate entity term according to a preset sentence pattern, and the candidate entity term is a named entity;

[0073] The determining unit is specifically configured to:

[0074] Dividing the text used to describe the same candidate entity word in the named entity recognition result into the same sub-text to obtain at least one sub-text;

[0075] Based on the preset sentence pattern, determining the candidate entity words in each of the sub-texts and the candidate entity types in each of the sub-texts;

[0076] The target mapping relationship is determined based on the candidate entity terms and the candidate entity types.

[0077] In combination with any embodiment of the present application, the determination unit is specifically used to determine, for the candidate entity terms and the candidate entity types in the same sub-text, that the mapping relationship between the candidate entity terms and the candidate entity types is the target mapping relationship when the candidate entity terms belong to the text to be identified and the candidate entity type is a preset entity type.

[0078] In a fifth aspect, an electronic device is provided, comprising: a processor and a memory, the memory being used to store computer program codes, the computer program codes comprising computer instructions;

[0079] When the processor executes the computer instructions, the electronic device executes the first aspect and any one of its implementation modes; when the processor executes the computer instructions, the electronic device either executes the second aspect and any one of its implementation modes.

[0080] In a sixth aspect, another electronic device is provided, comprising: a processor, a sending device, an input device, an output device, and a memory, wherein the memory is used to store computer program codes, wherein the computer program codes include computer instructions;

[0081] When the processor executes the computer instructions, the electronic device executes the first aspect and any one of its implementation modes; when the processor executes the computer instructions, the electronic device either executes the second aspect and any one of its implementation modes.

[0082] In a seventh aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions;

[0083] When the program instructions are executed by the processor, the processor is caused to execute the first aspect and any one of its implementation modes described above; when the program instructions are executed by the processor, the processor is caused to execute the second aspect and any one of its implementation modes described above.

[0084] In an eighth aspect, a computer program product is provided, the computer program product comprising a computer program or instructions; when the computer program or instructions are run on a computer, the computer is caused to execute the above-mentioned first aspect and any one of its embodiments; when the program instructions are executed by a processor, the processor is caused to execute the above-mentioned second aspect and any one of its embodiments.

[0085] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application.

[0086] In the present application, the training data includes a training text, a main task instruction and a first auxiliary task instruction, wherein the main task instruction includes a first task content of the main task, the first task content includes determining a first entity word in the training text and an entity type of the first entity word, and the first auxiliary task instruction includes a second task content of the first auxiliary task, the second task content includes determining the entity type contained in the training text. Therefore, after acquiring the training data, the training device uses the training data to train the pre-trained language model, so that the pre-trained language model can perform the main task on the training text according to the first task content in the main task instruction to obtain a first execution result, and the pre-trained language model can perform the first auxiliary task on the training text according to the second task content in the first auxiliary instruction to obtain a second execution result. The training device can obtain a first difference for characterizing the effect of the pre-trained language model performing the main task by determining the difference between the first execution result and the first label of the main task. The training device can obtain a second difference for characterizing the effect of the pre-trained language model performing the first auxiliary task by determining the difference between the second execution result and the second label of the first auxiliary task. Therefore, the training device updates the parameters of the pre-trained language model based on the first difference and the second difference, which can improve the effect of the pre-trained language model in performing the main task and the effect of the pre-trained language model in performing the first auxiliary task. Since the effect of the pre-trained language model in performing the first auxiliary task is improved, the pre-trained language model can better understand the semantics of the entity type in the text, which is beneficial for the pre-trained language model to perform the main task, and the first task content of the main task is to perform named entity recognition on the text. Therefore, the training device updates the parameters of the pre-trained language model based on the first difference and the second difference to obtain a named entity recognition model, which can improve the accuracy of the named entity recognition model in performing named entity recognition on the text.

[0087] In addition, since the training object of the training method is a pre-trained language model, the training method can train a named entity recognition model using a small amount of training text. In other words, the training method can utilize the learning ability of the pre-trained language model to obtain a named entity recognition model through a few shot training. BRIEF DESCRIPTION OF THE DRAWINGS

[0088] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background technology, the drawings required for use in the embodiments of the present application or the background technology will be described below.

[0089] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0090] Figure 1 A flowchart of a method for training a named entity recognition model provided in an embodiment of the present application;

[0091] Figure 2 A schematic diagram of a training architecture of a named entity recognition model is also provided in an embodiment of the present application;

[0092] Figure 3 A flowchart of a method for named entity recognition provided in an embodiment of the present application;

[0093] Figure 4 A schematic diagram of the structure of a training device for a named entity recognition model provided in an embodiment of the present application;

[0094] Figure 5 A schematic diagram of the structure of a named entity recognition device provided in an embodiment of the present application;

[0095] Figure 6 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0096] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings 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.

[0097] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0098] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0099] The embodiments of the present application provide a training method for a named entity recognition model and a named entity recognition method, wherein the execution subject of the training method for a named entity recognition model is a training device for a named entity recognition model (hereinafter referred to as a training device), wherein the training device can be any electronic device that can execute the technical solution disclosed in the embodiment of the method of the present application. Optionally, the training device can be one of the following: a computer, a server.

[0100] It should be understood that the training method of the named entity recognition model can also be implemented by a processor executing a computer program code. The following describes the embodiment of the present application in conjunction with the accompanying drawings in the embodiment of the present application. Figure 1 , Figure 1 A flowchart of a method for training a named entity recognition model provided in an embodiment of the present application.

[0101] 101. Obtain training data.

[0102] In the embodiment of the present application, the training data includes training text, main task instructions and first auxiliary task instructions. The training text can be any text including named entities, and optionally, the training text is a sentence, for example, the training text is: where can I buy cheap hamburgers and fries within 1 mile.

[0103] The main task instruction includes the task content for the main task. In this article, the task content of the main task is referred to as the first task content. Specifically, the first task content includes determining the first entity word in the training text and the entity type of the first entity word. The first entity word is a named entity in the training text. In other words, determining the first entity word in the training text is to determine which words in the training text are named entities. For example, the main task instruction is: Please extract the words that are named entities and the entity types of the extracted words from the training text. The above entity types are types of named entities. For example, entity types include names of people, places, organizations, times, and products.

[0104] The first auxiliary task instruction includes the task content of the first auxiliary task. In this article, the task content of the first auxiliary task is referred to as the second task content. Specifically, the second task content includes determining the entity types contained in the training text. For example, the first auxiliary task instruction is: please extract the entity types in the training text.

[0105] It should be understood that the above-mentioned main task instructions and the first auxiliary task instructions are both used to instruct the pretrained language models (PLM) to perform corresponding tasks. Specifically, the main task instructions are used to instruct the pretrained language model to perform the main task based on the first task content, and the first auxiliary task instructions are used to instruct the pretrained language model to perform the first auxiliary task based on the second task content.

[0106] In one implementation of acquiring training data, the training device receives the training data input by the user through an input component. The input component includes at least one of the following: a keyboard, a mouse, a touch screen, a touch pad, and an audio input device.

[0107] In another implementation of obtaining training data, the training device receives the training data sent by the terminal. The terminal may be any of the following: a mobile phone, a computer, a tablet computer, or a server.

[0108] 102. In the process of training the pre-trained language model using the above-mentioned training data, the above-mentioned pre-trained language model executes the main task according to the first task content in the main task instruction to obtain a first execution result, and the above-mentioned pre-trained language model executes the first auxiliary task according to the second task content in the first auxiliary instruction to obtain a second execution result.

[0109] In the embodiment of the present application, the pre-trained language model is a pre-trained large natural language model, wherein the large natural language model refers to a natural language model with a complex model structure and many parameters. Optionally, the pre-trained language model is a text-to-text transfer transformer (T5).

[0110] In the process of training the pre-trained language model using the training data, the pre-trained language model executes the main task according to the first task content in the main task instruction to obtain the first execution result. Specifically, the pre-trained language model determines the first entity word in the training text and the entity type of the first entity word according to the first task content of the main task instruction to obtain the first execution result. For example, the training text is: Where can I buy cheap hamburgers and fries within 1 mile? The pre-trained language model processes the training text according to the main task instruction, and obtains the first execution result: hamburgers are dishes, fries are dishes, 1 mile is a location, and cheap is a price. That is to say, in the first execution result, hamburgers, fries, 1 mile, and cheap are all first entity words, the entity type of hamburgers is dishes, the entity type of fries is dishes, the entity type of 1 mile is a location, and the entity type of cheap is a price.

[0111] In the process of training the pre-trained language model using the training data, the pre-trained language model performs the first auxiliary task according to the second task content in the first auxiliary task instruction to obtain the second execution result. Specifically, the pre-trained language model determines the entity type contained in the training text according to the second task content of the first auxiliary task instruction to obtain the second execution result. For example, the training text is: Is there a cheap four-star restaurant nearby? The pre-trained language model processes the training text according to the first auxiliary task instruction, and the second execution result obtained is: the entity type of level exists in the training text, the entity type of location exists in the training text, and the entity type of price exists in the training text. That is to say, in the second execution result, the training text includes the following three entity types: level, location, and price.

[0112] 103. Determine a first difference between the first execution result and the first label of the main task.

[0113] In the embodiment of the present application, the first label is the label of the main task. Specifically, the first label includes the ground truth (GT) of the first entity word in the training text and the GT of the entity type of the first entity word. For example, the training text is: Where can I buy cheap hamburgers and fries within 1 mile? The first label includes hamburgers as dishes, fries as dishes, 1 mile as location, and cheap as price. That is, the GT of the first entity word includes hamburgers, fries, 1 mile, and cheap. The GT of the entity type of the first entity word includes the entity type of hamburgers as dishes, the entity type of fries as dishes, the entity type of 1 mile as location, and the entity type of cheap as price.

[0114] The first difference is the difference between the first execution result and the first label. The first difference represents the accuracy of the first execution result, that is, the first difference represents the effect of the pre-trained language model in performing the main task.

[0115] 104. Determine a second difference between the second execution result and the second label of the first auxiliary task.

[0116] In an embodiment of the present application, the second label is a label of the first auxiliary task. Specifically, the second label includes the GT of the entity type in the training text. For example, the training text is: Is there any cheap four-star restaurant nearby? The second label includes grade, location, and price. That is to say, in the second label, the training text includes the following three entity types: grade, location, and price.

[0117] The second difference is the difference between the second execution result and the second label. The second difference represents the accuracy of the second execution result, that is, the second difference represents the effect of the pre-trained language model performing the first auxiliary task.

[0118] 105. Based on the first difference and the second difference, update the parameters of the pre-trained language model to obtain a named entity recognition model.

[0119] In an embodiment of the present application, a named entity recognition model is used to perform named entity recognition on a text. Since the first difference characterizes the effect of the pre-trained language model in performing the main task, updating the parameters of the pre-trained language model based on the first difference can improve the effect of the pre-trained language model in performing the main task. Since the second difference characterizes the effect of the pre-trained language model in performing the main and first auxiliary tasks, updating the parameters of the pre-trained language model based on the second difference can improve the effect of the pre-trained language model in performing the first auxiliary task. Therefore, the training device updates the parameters of the pre-trained language model based on the first difference and the second difference, which can improve the effect of the pre-trained language model in performing the main task, as well as improve the effect of the pre-trained language model in performing the first auxiliary task.

[0120] Because the first auxiliary task is to determine the entity types contained in the training text based on the semantic information of the training text, improving the effect of the pre-trained language model in performing the first auxiliary task can enable the pre-trained language model to better understand the semantics of the entity type in the text, which is beneficial for the pre-trained language model to perform the main task. Therefore, when the training device updates the parameters of the pre-trained language model based on the first difference and the second difference to obtain the named entity recognition model, the ability of the named entity recognition model to perform the main task can be improved, that is, the accuracy of the named entity recognition model in named entity recognition of the text can be improved.

[0121] In one possible implementation, the training device determines the loss of the pre-trained language model based on the first difference and the second difference, wherein the loss is positively correlated with both the first difference and the second difference. Then, based on the loss of the pre-trained language model, the parameters of the pre-trained language model are updated by back propagation until the loss of the pre-trained language model converges, thereby obtaining a named entity recognition model.

[0122] In an embodiment of the present application, the training data includes a training text, a main task instruction, and a first auxiliary task instruction, wherein the main task instruction includes a first task content of the main task, the first task content includes determining a first entity word in the training text and an entity type of the first entity word, and the first auxiliary task instruction includes a second task content of the first auxiliary task, the second task content includes determining the entity type contained in the training text. Therefore, after acquiring the training data, the training device uses the training data to train the pre-trained language model, so that the pre-trained language model can perform the main task on the training text according to the first task content in the main task instruction to obtain a first execution result, and the pre-trained language model can perform the first auxiliary task on the training text according to the second task content in the first auxiliary instruction to obtain a second execution result. The training device can obtain a first difference for characterizing the effect of the pre-trained language model performing the main task by determining the difference between the first execution result and the first label of the main task. The training device can obtain a second difference for characterizing the effect of the pre-trained language model performing the first auxiliary task by determining the difference between the second execution result and the second label of the first auxiliary task. Therefore, the training device updates the parameters of the pre-trained language model based on the first difference and the second difference, which can improve the effect of the pre-trained language model in performing the main task and the effect of the pre-trained language model in performing the first auxiliary task. Since the effect of the pre-trained language model in performing the first auxiliary task is improved, the pre-trained language model can better understand the semantics of the entity type in the text, which is beneficial for the pre-trained language model to perform the main task, and the first task content of the main task is to perform named entity recognition on the text. Therefore, the training device updates the parameters of the pre-trained language model based on the first difference and the second difference to obtain a named entity recognition model, which can improve the accuracy of the named entity recognition model in performing named entity recognition on the text.

[0123] In addition, since the training object of this training method is a pre-trained language model, this training method can train a named entity recognition model using a small amount of training text. In other words, this training method can utilize the learning ability of the pre-trained language model to obtain a named entity recognition model through small sample training.

[0124] As an optional implementation, the training data also includes preset entity types, and the first task content includes determining the first entity word in the training text and determining the entity type of the first entity word from the preset entity type. In this case, determining the entity type of the first entity word is to determine the entity type of the first entity word from the preset entity type. For example, the preset entity types include: restaurant name, grade, welfare facilities, time, dishes, meals, location, price, then the first task content is to determine the first entity word in the training text and determine the entity type of the first entity word from the restaurant name, grade, welfare facilities, time, dishes, meals, location, price.

[0125] In this embodiment, when the training data also includes preset entity types and the first task content includes determining the entity type of the first entity word from the preset entity types, the main task is performed on the training text according to the first task content in the main task instructions, which can improve the ability of the pre-trained language model to recognize named entities of the preset entity types in the text, and further improve the recognition accuracy of the named entity recognition model obtained through training for named entities of the preset entity types in the text.

[0126] In a possible implementation scenario, since the named entity recognition model has the ability to recognize named entities of preset entity types in the text, by changing the preset entity type to the entity type of the named entity in a specific field, the named entity recognition model can be used to recognize named entities in a specific neighborhood. For example, after obtaining the named entity recognition model through training, when the preset entity type is changed to the entity type in the field of dressing, the named entity recognition model can be used to recognize named entities in the field of dressing. Optionally, the entity types in the field of dressing may include: characters, clothing, store names, grades, colors, styles, materials, and sizes. For another example, after obtaining the named entity recognition model through training, when the preset entity type is changed to the entity type in the legal field, the named entity recognition model can be used to recognize named entities in the legal field. Optionally, the entity types in the legal field may include: characters, time, place, motive, and event.

[0127] As an optional implementation, the training data also includes examples of entity types describing second entity terms, wherein the second entity terms are named entities and are different from the first entity terms. For example, the training text is: Where can I buy cheap burgers and fries within 1 mile, and examples include: noodle shop is the name of a restaurant, superior is the level, group meal is a welfare facility, late night is the time, vegetarian curry puff is the dish, sushi is the meal, dixie is the location, and under $10 per person is the price. The first entity terms in the training text include: burger, fries, 1 mile, cheap, and the second entity terms in the example text include: noodle shop, superior, group meal, late night, vegetarian curry puff, sushi, dixie, under $10 per person.

[0128] In this embodiment, the implementation process of the pre-trained language model executing the main task according to the first task content in the main task instruction to obtain the first execution result includes the following steps: the pre-trained language model executes the main task according to the first task content in the main task instruction under the example prompt to obtain the first execution result.

[0129] In the case where the training data includes examples, using the training data to train the pre-trained language model can enable the pre-trained language model to learn how to identify named entities and the entity type of the named entity from the examples through in-context learning (ICL), which is beneficial for the pre-trained language model to perform the main task. Therefore, under the prompt of the example, the pre-trained language model performs the main task according to the first task content in the main task instruction to obtain the first execution result, which can improve the effect of the pre-trained language model in performing the main task, and thus improve the training effect and training efficiency of the pre-trained language model.

[0130] Optionally, the number of examples of different entity types is the same. For example, in the examples of the training data, there are 12 entity types in total, and each entity type has 5 examples, then in the training data, there are 12×5=60 examples in total. In this way, the pre-trained language model can learn different entity types more balanced.

[0131] As an optional implementation, the training data further includes a second auxiliary task instruction, wherein the second auxiliary task instruction includes the task content of the second auxiliary task, and in this article, the task content of the second auxiliary task is referred to as the third task content. Specifically, the third task content includes determining the first entity words from the training text, in other words, the third task content includes finding out which words are named entities from the training text, that is, finding out the span of the named entity from the training text.

[0132] In this embodiment, the training device further performs the following steps before performing step 105:

[0133] 2001. In the process of training the pre-trained language model using the training data, the pre-trained language model executes the second auxiliary task according to the third task content in the second auxiliary task instruction to obtain a third execution result.

[0134] In the process of training the pre-trained language model using the training data, the pre-trained language model performs the second auxiliary task according to the third task content in the second auxiliary task instruction to obtain the third execution result. Specifically, the pre-trained language model determines the first entity words from the training text according to the third task content of the second auxiliary task instruction to obtain the third execution result. For example, the training text is: show me those restaurants with good reviews but cheap prices. The pre-trained language model processes the training text according to the second auxiliary task instruction, and the third execution result obtained is: good reviews is a first entity word, and cheap prices is a first entity word. That is to say, in the third execution result, the training text includes the following two first entity words: good reviews and cheap prices.

[0135] 2002. Determine a third difference between the third execution result and the third label of the second auxiliary task.

[0136] In the embodiment of the present application, the third label is the label of the second auxiliary task. Specifically, the third label includes the GT of the first entity word in the training text. For example, the training text is: Show me those restaurants with good reviews but cheap prices. The third label includes: good reviews and cheap prices. That is to say, in the third label, the training text includes the following two first entity words: good reviews and cheap prices.

[0137] The third difference is the difference between the third execution result and the third label. The third difference represents the accuracy of the third execution result, that is, the third difference represents the effect of the pre-trained language model performing the second auxiliary task.

[0138] After determining the third difference, the training device performs the following steps during the execution of step 105:

[0139] 2003. Based on the first difference, the second difference and the third difference, update the parameters of the pre-trained language model to obtain the named entity recognition model.

[0140] Since the third difference represents the effect of the pre-trained language model in performing the second auxiliary task, updating the parameters of the pre-trained language model based on the third difference can improve the effect of the pre-trained language model in performing the second auxiliary task. Specifically, updating the parameters of the pre-trained language model based on the third difference can enable the pre-trained language model to more accurately determine which words in the training text are named entities, that is, it can enable the pre-trained language model to more accurately determine the span of named entities in the text. And because the pre-trained language model accurately determines the span of named entities in the text, it is beneficial for the pre-trained language model to perform the main task. Therefore, in step 2003, the training device updates the parameters of the pre-trained language model based on the first difference and the second difference, and then updates the parameters of the pre-trained language model based on the third difference, which can further improve the ability of the pre-trained language model to perform the main task.

[0141] In one possible implementation, the training device determines the loss of the pre-trained language model based on the first difference, the second difference, and the third difference, wherein the loss is positively correlated with the first difference, the second difference, and the third difference. Then, based on the loss of the pre-trained language model, the parameters of the pre-trained language model are updated by back propagation until the loss of the pre-trained language model converges, thereby obtaining a named entity recognition model.

[0142] In this embodiment, the training data also includes a second auxiliary task instruction, wherein the second auxiliary task instruction includes a third task content of the second auxiliary task, and the third task content includes determining a first entity word from the training text. Therefore, the training device uses the training data to train the pre-trained language model, so that the pre-trained language model can perform the second auxiliary task on the training text according to the third task content in the second auxiliary instruction to obtain a third execution result. The training device can obtain a third difference used to characterize the effect of the pre-trained language model performing the second auxiliary task by determining the difference between the third execution result and the third label of the second auxiliary task. Therefore, the training device updates the parameters of the pre-trained language model based on the first difference, the second difference and the third difference, which can improve the effect of the pre-trained language model in performing the main task, as well as improve the effect of the pre-trained language model in performing the first auxiliary task, and improve the effect of the pre-trained language model in performing the second auxiliary task. Since improving the effect of the pre-trained language model in performing the first auxiliary task and improving the effect of the pre-trained language model in performing the second auxiliary task are both beneficial to the pre-trained language model in performing the main task, and the first task content of the main task is to perform named entity recognition on the text, the training device updates the parameters of the pre-trained language model based on the first difference, the second difference and the third difference to obtain a named entity recognition model, which can improve the accuracy of the named entity recognition model in performing named entity recognition on the text.

[0143] As an optional implementation, the first execution result and the third execution result both include text describing the first entity word in a preset sentence structure, for example, the preset sentence structure is A is a named entity, where A is the first entity word. In this way, the pre-trained language model can output the execution result of the third auxiliary task in the same way as the execution result of the main task, thereby enhancing the role of the third auxiliary task in promoting the main task, so that the effect of the pre-trained language model in executing the main task is further improved through the training of the pre-trained language model by the third auxiliary task.

[0144] As an optional implementation, the training data also includes a third auxiliary task instruction, wherein the third auxiliary task instruction includes the task content of the third auxiliary task, and in this article, the task content of the third auxiliary task is referred to as the fourth task content. Specifically, the fourth task content includes determining the entity type of the first entity word in the training text. In other words, the fourth task content is to determine the entity type of the named entity given which words in the training text are named entities, that is, to determine the entity type of the span given the span of the named entity in the training text.

[0145] In this embodiment, before executing step 2003, the training device further executes the following steps: 3001. In the process of training the pre-trained language model using the above-mentioned training data, the above-mentioned pre-trained language model executes the above-mentioned third auxiliary task according to the above-mentioned fourth task content in the above-mentioned third auxiliary task instruction to obtain a fourth execution result.

[0146] In the process of training the pre-trained language model using the training data, the pre-trained language model performs the third auxiliary task according to the fourth task content in the third auxiliary task instruction to obtain a fourth execution result. Specifically, the pre-trained language model determines the entity type of the first entity word in the training text according to the fourth task content of the third auxiliary task instruction to obtain the fourth execution result. For example, the training text is: Where is the best restaurant under 10 yuan in Minneapolis, and the fourth task content is: Please determine the entity type of the following words in the training text: best, Minneapolis, under 10 yuan. The pre-trained language model processes the training text according to the third auxiliary task instruction, and the fourth execution result obtained is: the best entity type is level, the entity type of Minneapolis is location, and the entity type of under 10 yuan is price.

[0147] 3002. Determine a fourth difference between the fourth execution result and a fourth label of the third auxiliary task.

[0148] In the embodiment of the present application, the fourth label is the label of the third auxiliary task. Specifically, the fourth label includes the GT of the entity type of the words in the training text. For example, the training text is: Where is the best restaurant under 10 yuan in Minneapolis? The content of the fourth task is: Please determine the entity types of the following words in the training text: best, Minneapolis, under 10 yuan. The fourth label includes: the entity type of the best is level, the entity type of Minneapolis is location, and the entity type of under 10 yuan is price.

[0149] The fourth difference is the difference between the fourth execution result and the fourth label. The fourth difference represents the accuracy of the fourth execution result, that is, the fourth difference represents the effect of the pre-trained language model performing the third auxiliary task.

[0150] After determining the fourth difference, the training device performs the following steps during the execution of step 105:

[0151] 3003. Based on the first difference, the second difference, the third difference and the fourth difference, update the parameters of the pre-trained language model to obtain the named entity recognition model.

[0152] Since the fourth difference represents the effect of the pre-trained language model in performing the third auxiliary task, updating the parameters of the pre-trained language model based on the fourth difference can improve the effect of the pre-trained language model in performing the third auxiliary task. Specifically, updating the parameters of the pre-trained language model based on the third difference can enable the pre-trained language model to more accurately determine the entity types of named entities in the training text. And because the pre-trained language model accurately determines the entity types of named entities in the text, it is beneficial for the pre-trained language model to perform the main task. Therefore, in step 3003, the training device updates the parameters of the pre-trained language model based on the first difference, the second difference and the third difference, and then updates the parameters of the pre-trained language model based on the fourth difference, which can further improve the ability of the pre-trained language model to perform the main task.

[0153] In one possible implementation, the training device determines the loss of the pre-trained language model based on the first difference, the second difference, the third difference and the fourth difference, wherein the loss is positively correlated with the first difference, the second difference, the third difference and the fourth difference. Then, based on the loss of the pre-trained language model, the parameters of the pre-trained language model are updated by back propagation until the loss of the pre-trained language model converges to obtain a named entity recognition model.

[0154] In this embodiment, the training data also includes a third auxiliary task instruction, wherein the third auxiliary task instruction includes a fourth task content of the third auxiliary task, and the fourth task content includes determining the entity type of the first entity word in the training text. Therefore, the training device uses the training data to train the pre-trained language model, so that the pre-trained language model can execute the third auxiliary task according to the fourth task content in the third auxiliary instruction to obtain a fourth execution result. The training device can obtain a fourth difference used to characterize the effect of the pre-trained language model executing the third auxiliary task by determining the difference between the fourth execution result and the fourth label of the third auxiliary task. Therefore, the training device updates the parameters of the pre-trained language model based on the first difference, the second difference, the third difference and the fourth difference, which can improve the effect of the pre-trained language model in executing the main task, as well as improve the effect of the pre-trained language model in executing the first auxiliary task, as well as improve the effect of the pre-trained language model in executing the second auxiliary task, and improve the effect of the pre-trained language model in executing the third auxiliary task. Since improving the effect of the pre-trained language model in performing the first auxiliary task, improving the effect of the pre-trained language model in performing the second auxiliary task, and improving the effect of the pre-trained language model in performing the third auxiliary task are all beneficial to the pre-trained language model in performing the main task, and the first task content of the main task is to perform named entity recognition on the text, the training device updates the parameters of the pre-trained language model based on the first difference, the second difference, the third difference and the fourth difference to obtain a named entity recognition model, which can improve the accuracy of the named entity recognition model in performing named entity recognition on the text.

[0155] As an optional implementation, before executing step 105, the training device determines the fourth difference by executing steps 3001 and 3002, and then performs the following steps in the process of executing step 105: based on the above-mentioned first difference, the above-mentioned second difference and the above-mentioned fourth difference, update the parameters of the above-mentioned pre-trained language model to obtain the above-mentioned named entity recognition model. In this way, the effect of the pre-trained language model in performing the main task can be improved, the effect of the pre-trained language model in performing the first auxiliary task can be improved, and the effect of the pre-trained language model in performing the third auxiliary task can be improved. Since improving the effect of the pre-trained language model in performing the first auxiliary task and improving the effect of the pre-trained language model in performing the third auxiliary task are both beneficial to the pre-trained language model in performing the main task, and the first task content of the main task is to perform named entity recognition on the text, the training device updates the parameters of the pre-trained language model based on the first difference, the second difference and the fourth difference to obtain the named entity recognition model, which can improve the accuracy of the named entity recognition model in performing named entity recognition on the text.

[0156] As an optional implementation, the training data also includes preset entity types, and the fourth task content includes determining the entity type of the first entity word in the training text from the preset entity types. For example, the preset entity types include: restaurant name, grade, welfare facilities, time, dishes, meals, location, and price. Then the fourth task content is to determine the entity type of the first entity word in the training text from the restaurant name, grade, welfare facilities, time, dishes, meals, location, and price.

[0157] In this embodiment, when the training data also includes preset entity types and the fourth task content includes determining the entity type of the first entity word in the training text from the preset entity types, the main task is performed on the training text according to the fourth task content in the third auxiliary task instruction, which can improve the ability of the pre-trained language model to recognize named entities of the preset entity types in the text, and further improve the recognition accuracy of the named entity recognition model obtained through training for named entities of the preset entity types in the text.

[0158] See also Figure 2 , Figure 2 A training architecture diagram of a named entity recognition model is also provided in the present application embodiment. Figure 2 As shown, the named entity recognition model is trained through the main task, the first auxiliary task, the second auxiliary task, and the third auxiliary task, wherein the main task is the named entity recognition task, the first auxiliary task is the entity type extraction task, the second auxiliary task is the first entity word determination task, and the third auxiliary task is the entity type determination task.

[0159] like Figure 2As shown, the information required to perform the main task includes: main task instructions, training text, preset entity type, and example, wherein the main task instruction includes the first task content of the main task. Specifically, the first task content is: please extract the first entity word that is a named entity from the training text based on the knowledge of the example, and determine the entity type of the first entity word from the preset entity type. The training text is: where can I buy cheap hamburgers and fries within 1 mile. The preset entity types include: restaurant name, grade, welfare facilities, time, dishes, meals, location, and price. The example is: noodle restaurant is the name of a restaurant, superior is the grade, group meal is the welfare facility, late night is the time, vegetarian curry corner is the dish, sushi is the meal, dixie is the location, and less than $10 per person is the price. The first execution result obtained by the named entity recognition model executing the main task according to the main task instruction is: hamburger is a dish, fries are dishes, 1 mile is the location, and cheap is the price.

[0160] It should be understood that the example guides the pre-trained language model to perform the main task by giving prompts to the pre-trained language model to perform the main task, but the training device does not need to update the parameters of the pre-trained language model based on the example.

[0161] Optionally, the first execution result is output in the form of text according to a preset first template. For example, the first template is A is B, wherein A is the first entity word determined by the named entity recognition model from the training text, and B is the entity type of the first entity word determined by the named entity recognition model.

[0162] like Figure 2 As shown, the information required to perform the first auxiliary task includes: the first auxiliary task instruction, the training text, wherein the first auxiliary task instruction includes the second task content of the first auxiliary task. Specifically, the second task content is: Please determine the entity type contained in the training text. The training text is: Is there a cheap four-star restaurant nearby? The second execution result obtained by the named entity recognition model when executing the first auxiliary task according to the first auxiliary task instruction is: the entity type of level exists in the training text, the entity type of location exists in the training text, and the entity type of price exists in the training text.

[0163] Optionally, the second execution result is output in the form of text according to a preset second template. For example, the second template is that the entity type C exists in the training text, wherein C is the entity type contained in the training text determined by the named entity recognition model.

[0164] like Figure 2As shown, the information required to perform the second auxiliary task includes: second auxiliary task instructions, training text, wherein the second auxiliary task instructions include the third task content of the second auxiliary task. Specifically, the third task content is: please determine the first entity word from the training text. The training text is: show me those restaurants with good reviews but cheap prices. The third execution result obtained by the named entity recognition model performing the second auxiliary task according to the second auxiliary task instructions is: good reviews is a first entity word, and cheap prices is a first entity word.

[0165] Optionally, the third execution result is output in the form of text according to a preset third template. For example, the third template is that D is a first entity word, wherein D is the first entity word determined by the named entity recognition model from the training text.

[0166] like Figure 2 As shown, the information required to perform the third auxiliary task includes: third auxiliary task instructions, training text, preset entity types, wherein the third auxiliary task instructions include the fourth task content of the third auxiliary task. Specifically, the fourth task content is: Please determine the entity type of the following first entity words from the preset entity types based on the training text: best, Minneapolis, under 10 yuan. The training text is: Where is the best restaurant under 10 yuan in Minneapolis. The preset entity types include: restaurant name, grade, welfare facilities, time, dishes, meals, location, price. The first execution result obtained by the named entity recognition model when executing the main task according to the main task instructions is: the best entity type is grade, the entity type of Minneapolis is location, and the entity type of under 10 yuan is price.

[0167] Optionally, the fourth execution result is output in the form of text according to a preset fourth template. For example, the entity type of E in the fourth template is F, wherein E is the first entity word determined in the training text, and F is the entity type of the first entity word determined by the named entity recognition model.

[0168] Based on Figure 2After training the named entity recognition model with the training architecture shown in the figure, the named entity recognition effect of the named entity recognition model is compared with that of the generative (state-of-the-art, SOTA) model using the CoNLL-2003 dataset. The generative models include: design challenges and misconceptions in neural sequence labeling (DCAM), end-to-end sequence labeling via bi-directional LSTM-CNNs-CRF (ESLV), uncertainty-aware label refinement for sequence labeling (UALR), deep contextualized entity representations with entity aware self-attention (DCER), a unified MRC framework for named entity recognition (AUMF), named entity recognition as dependency parsing (NERA), and pre-training for language understanding based on deep bidirectional transformers (Pre-training for language understanding based on deep bidirectional transformers). of deep bidirectional transformers for language under standing (LC-BERT), Denoising sequence-to-sequence pre-training for natural language generation, translation, and understandingand comprehension, LC-BART), template-based named entity recognition using BART (TemplateNER), Aunified generative framework for various NER subtasks (BARTNER), and a lightweight tuning paradigm for low-resource NER via plug gable prompting (LightNER). The specific comparison results are shown in Table 1.

[0169]

[0170]

[0171] Table 1

[0172] In Table 1, F1 is an indicator representing the accuracy of the named entity recognition of the model, wherein the named entity recognition is correct when the model correctly recognizes the named entities in the text and the model correctly recognizes the entity type of the named entity. The named entity recognition is incorrect when the model does not correctly recognize the named entities in the text. The named entity recognition is incorrect when the model does not correctly recognize the entity type of the named entity. Span-F1 is an indicator representing the recognition accuracy of the span of the model, wherein the recognition of the span is correct when the model correctly recognizes the named entities in the text, and the recognition of the span is incorrect when the model does not correctly recognize the named entities in the text. It can be seen from Table 1 that the performance of the named entity recognition model is at the same level as that of the SOTA model, and the span-F1 of the named entity recognition model is higher than the span-F1 of BARTNER.

[0173] In addition, Table 2 also shows that when the model is obtained through small sample training, the Figure 2 Comparison of the named entity recognition effect of the named entity recognition model trained with the training framework and the named entity recognition effect of BARTNER.

[0174]

[0175] Table 2

[0176] As shown in Table 2, when 10 samples, 20 samples, and 50 samples are sampled from the MIT Movie dataset as training samples, the accuracy of the named entity model is significantly higher than that of BARTNER. When 10 samples, 20 samples, and 50 samples are sampled from the MIT Restaurant dataset as training samples, the accuracy of the named entity model is significantly higher than that of BARTNER. When 10 groups of samples, 20 groups of samples, and 50 groups of samples are sampled from the Airline Travel Information System dataset (ATIS) as training samples, the accuracy of the named entity model is slightly lower than that of BARTNER, where 1 group of samples includes 100 to 200 samples. As can be seen from Table 2, based on Figure 2 The training framework shown in the figure can be used for small sample training to obtain better training results, so that the recognition accuracy of the trained named entity recognition model is higher.

[0177] See also Figure 3 , Figure 3 A flowchart of a named entity recognition method provided in an embodiment of the present application. The execution subject of the named entity recognition method is a named entity recognition device (hereinafter referred to as a recognition device) of a named entity recognition model, wherein the recognition device can be any electronic device that can execute the technical solution disclosed in the embodiment of the method of the present application. Optionally, the recognition device can be one of the following: a computer, a server.

[0178] 301. Obtain text to be recognized.

[0179] In the implementation of this application, the text to be recognized can be any text. Optionally, the text to be recognized is different from the training text.

[0180] In one implementation of obtaining the text to be recognized, the recognition device receives the text to be recognized input by the user through the input component. In another implementation of obtaining the text to be recognized, the recognition device receives the text to be recognized sent by the terminal.

[0181] In another possible implementation,

[0182] 302. Perform named entity recognition on the text to be recognized using a named entity recognition model to obtain a named entity recognition result.

[0183] In the embodiment of the present application, the named entity recognition model is obtained by training the training method of the named entity recognition model described above. The recognition device uses the named entity recognition model to perform named entity recognition on the text to be recognized, and can determine which words in the text to be recognized are named entities and the entity types of these words that are named entities. Therefore, the named entity recognition result obtained by executing step 302 includes which words in the text to be recognized are named entities and the entity types of these words that are named entities.

[0184] In an embodiment of the present application, after acquiring the text to be recognized, the recognition device uses a named entity recognition model to perform named entity recognition on the text to be recognized, and obtains a named entity recognition result, which can improve the accuracy of the named entity recognition result.

[0185] In a possible scenario, the text to be recognized is a text that needs to be translated. When the recognition device receives an instruction to translate the text to be recognized, it uses the named entity recognition model to perform named entity recognition on the text to be recognized to obtain a named entity recognition result. Based on the named entity recognition result, the text to be recognized is translated to improve the accuracy of the translation.

[0186] In another possible implementation scenario, the text to be recognized is a question raised by a user. When the recognition device receives an instruction to answer the text to be recognized, it uses the named entity recognition model to perform named entity recognition on the text to be recognized to obtain a named entity recognition result. Then, the answer is given based on the named entity recognition result, which can improve the accuracy of the answer.

[0187] As an optional implementation, after obtaining the named entity recognition result, the recognition device further performs the following steps:

[0188] 4001. Based on the above named entity recognition results, determine the target mapping relationship.

[0189] In an embodiment of the present application, the target mapping relationship is a mapping relationship between a target entity word in the text to be identified and a target entity type of the target entity word, wherein the target entity word is a named entity. That is to say, the target mapping relationship is a mapping relationship between a named entity and an entity type in the text to be identified. For example, the text to be identified is: Where can I buy cheap hamburgers and fries within 1 mile? The following words in the text to be identified are named entities: hamburgers, fries, 1 mile, cheap. At this time, the target entity words include: hamburgers, fries, 1 mile, cheap. Since the entity type of hamburgers is dishes, the entity type of fries is dishes, the entity type of 1 mile is location, and the entity type of cheap is price, the target mapping relationship includes: a mapping relationship between hamburgers and dishes, a mapping relationship between fries and dishes, a mapping relationship between 1 mile and locations, and a mapping relationship between cheap and prices. In one possible implementation, the target mapping relationship is obtained by forming a word pair of the target entity word and the target entity type. For example, if the target entity word is hamburger and the target entity type is dish, the target mapping relationship may be (hamburger, dish). In another possible implementation, the target mapping relationship is obtained by establishing an index between the target entity word and the target entity type. Since the result text is obtained by performing named entity recognition on the text to be recognized, the recognition device may determine the target mapping relationship based on the result text.

[0190] In this embodiment, after obtaining the named entity recognition result of the text to be recognized, the recognition device determines the target mapping relationship based on the result text, and the target mapping relationship can more directly reflect the relationship between the target entity words and the target entity types in the text to be recognized.

[0191] As an optional implementation, the named entity recognition result describes the candidate entity type of the candidate entity term in a preset sentence pattern, wherein the candidate entity term is a named entity, that is, the named entity recognition result describes the entity type of the named entity in the form of text, and the named entity in the named entity recognition result is called the candidate entity term, and the entity type of the candidate entity term is called the candidate entity type. For example, the named entity recognition result is: Xiao Ming is a person's name, then Xiao Ming is a candidate entity term, and the person's name is a candidate entity type. Moreover, the named entity result describes the candidate entity type of the candidate entity term in a preset sentence pattern, for example, the preset sentence pattern is X is Y, wherein X is a candidate entity term, and Y is a candidate entity type.

[0192] As an optional implementation manner, the result text describes the entity type of the entity word according to a preset sentence pattern;

[0193] The identification device performs the following steps during the execution of step 4001:

[0194] 5001. Divide the text in the named entity recognition result used to describe the same candidate entity word into the same sub-text to obtain at least one sub-text.

[0195] By dividing the text used to describe the same candidate entity word mentioned above into the same sub-text, the content in the same sub-text can be made to describe the same candidate entity word, and the content in different sub-texts can be made to describe different candidate entity words. When the number of candidate entity words in the named entity recognition result is 1, the number of sub-texts is 1. When the number of candidate entity words in the named entity recognition result is greater than 1, the number of sub-texts is greater than 1. Specifically, the number of sub-texts is the same as the number of candidate entity words.

[0196] For example, the named entity recognition results include: hamburger is a dish, 1 mile is a location, where hamburger and 1 mile are different candidate entity words. Therefore, hamburger is a dish is a subtext describing the candidate entity word hamburger, and 1 mile is a location is a subtext describing the candidate entity word 1 mile.

[0197] 5002. Based on the preset sentence pattern, determine the candidate entity words in each of the sub-texts and the candidate entity types in each of the sub-texts.

[0198] Since the positions of the candidate entity words and the candidate entity types are fixed in the preset sentence pattern, and the subtext also describes the candidate entity types of the candidate entity words according to the preset sentence pattern, the recognition device can determine the candidate entity words in the subtext and the candidate entity types of the candidate entity words based on the preset sentence pattern. For example, the preset sentence pattern is X is Y, where X is a candidate entity word and Y is a candidate entity type. According to the preset sentence pattern, it can be known that the words before "is" are candidate entity words and the words after "is" are candidate entity types. If hamburger is a dish is a subtext obtained by dividing the text to be recognized, then based on the preset sentence pattern, it can be determined that hamburger is a candidate entity word and dish is a candidate entity type.

[0199] 5003. Based on the candidate entity words and the candidate entity types, determine the target mapping relationship.

[0200] In one possible implementation method, for the above-mentioned candidate entity words and the above-mentioned candidate entity types in the same above-mentioned sub-text, when the above-mentioned candidate entity words belong to the above-mentioned text to be recognized and the above-mentioned candidate entity type is a preset entity type, the mapping relationship between the above-mentioned candidate entity words and the above-mentioned candidate entity type is determined to be the above-mentioned target mapping relationship.

[0201] In an embodiment of the present application, the preset entity type can be set according to actual needs. For example, if a named entity recognition model is needed to identify named entities and entity types in the legal field, then the preset entity type can be an entity type in the legal field. For another example, if a named entity recognition model is needed to identify named entities and entity types in the clothing field, then the preset entity type can be an entity type in the clothing field.

[0202] It should be understood that the preset entity types in the training method of the named entity recognition model are different from the preset entity types in the named entity recognition method. Specifically, in the training method of the named entity recognition model, the pre-trained language model is trained based on the preset entity type to obtain the named entity recognition model, which can enable the named entity recognition model to have the ability to recognize named entities of the preset entity type, while in the named entity recognition method, the preset entity type is the ability to recognize named entities of the preset entity type by the named entity recognition model, and to recognize named entities of a specific entity type. For example, the preset entity types in the training method of the named entity recognition model include: restaurant name, grade, welfare facilities, time, dishes, meals, location, price, and the preset entity types in the named entity recognition method include: people, clothing, store name, grade, color, style, material, size.

[0203] On the one hand, since the candidate entity word may be different from the target entity word, it is necessary to further determine whether the candidate entity word is the target entity word. Specifically, if the candidate entity word belongs to the text to be recognized, it means that the candidate entity word is the target entity word. On the other hand, the candidate entity type may not be the preset entity type, so it is also necessary to determine whether the candidate entity type is the preset entity type.

[0204] And because for the candidate entity terms and candidate entity types in the same sub-text, the candidate entity type is the entity type of the candidate entity term, so for the candidate entity terms and candidate entity types in the same sub-text, when the candidate entity term is the target entity term and the candidate entity type is the preset entity type, the mapping relationship between the candidate entity term and the candidate entity type can be determined as the target mapping relationship.

[0205] Based on this, the recognition device determines that the mapping relationship between the candidate entity words and the candidate entity types in the same sub-text is a target mapping relationship when the candidate entity words belong to the text to be recognized and the candidate entity type is a preset entity type. Optionally, for the candidate entity words and the candidate entity types in the same sub-text, when the candidate entity words do not belong to the text to be recognized, the mapping relationship between the candidate entity words and the candidate entity types is not a target mapping relationship. Optionally, for the candidate entity words and the candidate entity types in the same sub-text, when the candidate entity type is not a preset entity type, the mapping relationship between the candidate entity words and the candidate entity types is not a target mapping relationship.

[0206] In another possible implementation, the recognition device determines, for candidate entity terms and candidate entity types in the same subtext, that the mapping relationship between the candidate entity terms and the candidate entity types is a target mapping relationship when the candidate entity terms belong to the text to be recognized.

[0207] In yet another possible implementation, the recognition device determines, for candidate entity terms and candidate entity types in the same subtext, that a mapping relationship between the candidate entity terms and the candidate entity types is a target mapping relationship when the candidate entity types are preset entity types.

[0208] In yet another possible implementation, the recognition device determines the mapping relationship between the candidate entity term and the candidate entity type as the target mapping relationship.

[0209] In this embodiment, when the named entity recognition result describes the candidate entity type of the candidate entity word according to a preset sentence pattern, the text used to describe the same candidate entity word in the named entity recognition result is first divided into the same subtext to obtain at least one subtext. Then, based on the preset sentence pattern, the candidate entity words in each subtext and the candidate entity type in each subtext can be determined, and then the target mapping relationship can be determined based on the candidate entity words in each subtext and the candidate entity type in each subtext.

[0210] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0211] The method of the embodiment of the present application is described in detail above, and the device of the embodiment of the present application is provided below.

[0212] See also Figure 4 , Figure 4A structural diagram of a training device for a named entity recognition model provided in an embodiment of the present application, wherein the training device 1 for a named entity recognition model comprises: an acquisition unit 11, an execution unit 12, a determination unit 13, and an update unit 14, specifically:

[0213] An acquisition unit 11 is used to acquire training data, wherein the training data includes a training text, a main task instruction, and a first auxiliary task instruction, wherein the main task instruction includes a first task content of a main task, wherein the first task content includes determining a first entity word in the training text and an entity type of the first entity word, wherein the first entity word is a named entity, and wherein the first auxiliary task instruction includes a second task content of the first auxiliary task, wherein the second task content includes determining the entity type contained in the training text;

[0214] An execution unit 12 is used for, in the process of training the pre-trained language model using the training data, the pre-trained language model executes the main task on the training text according to the main task instruction to obtain a first execution result, and the pre-trained language model executes the first auxiliary task on the training text according to the first auxiliary instruction to obtain a second execution result;

[0215] A determining unit 13, configured to determine a first difference between the first execution result and the first label of the main task;

[0216] The determining unit 13 is used to determine a second difference between the second execution result and the second label of the first auxiliary task;

[0217] The updating unit 14 is used to update the parameters of the pre-trained language model based on the first difference and the second difference to obtain a named entity recognition model, and the named entity recognition model is used to perform named entity recognition on the text.

[0218] In combination with any embodiment of the present application, the training data further includes an example of an entity type describing a second entity word, the second entity word is a named entity, and the second entity word is different from the first entity word;

[0219] The execution unit 12 is specifically used for:

[0220] Under the prompt of the example, the pre-trained language model executes the main task according to the first task content in the main task instruction to obtain the first execution result.

[0221] In combination with any implementation manner of the present application, the training data further includes a second auxiliary task instruction, the second auxiliary task instruction includes a third task content of the second auxiliary task, and the third task content includes determining the first entity word from the training text;

[0222] The execution unit 12 is further configured to, in a process of training the pre-trained language model using the training data, cause the pre-trained language model to execute the second auxiliary task according to the third task content in the second auxiliary task instruction to obtain a third execution result;

[0223] The determining unit 13 is further configured to determine a third difference between the third execution result and the third label of the second auxiliary task;

[0224] The updating unit 14 is specifically configured to update the parameters of the pre-trained language model based on the first difference, the second difference and the third difference to obtain the named entity recognition model.

[0225] In combination with any embodiment of the present application, the training data further includes a third auxiliary task instruction, the third auxiliary task instruction includes a fourth task content of the third auxiliary task, and the fourth task content includes determining the entity type of the words in the training text;

[0226] The execution unit 12 is further configured to, in a process of training the pre-trained language model using the training data, cause the pre-trained language model to execute the third auxiliary task according to the fourth task content in the third auxiliary task instruction to obtain a fourth execution result;

[0227] The determining unit 13 is further configured to determine a fourth difference between the fourth execution result and a fourth label of the third auxiliary task;

[0228] The updating unit 14 is specifically configured to update the parameters of the pre-trained language model based on the first difference, the second difference, the third difference and the fourth difference to obtain the named entity recognition model.

[0229] In combination with any implementation manner of the present application, the updating unit 14 is specifically configured to:

[0230] Determining a loss of the pre-trained language model based on the first difference, the second difference, the third difference, and the fourth difference, wherein the loss is positively correlated with the first difference, the second difference, the third difference, and the fourth difference;

[0231] Based on the loss, the parameters of the pre-trained language model are updated to obtain the named entity recognition model.

[0232] In combination with any implementation manner of the present application, the training data further includes preset entity types, and the fourth task content includes determining the entity type of the first entity term in the training text from the preset entity types.

[0233] In combination with any implementation manner of the present application, the first execution result and the third execution result both include text that describes the first entity word according to a preset sentence structure.

[0234] In combination with any implementation manner of the present application, the training data further includes preset entity types, and the first task content includes determining the entity type of the first entity term from the preset entity types.

[0235] In combination with any implementation manner of the present application, the pre-trained language model is a text-to-text conversion model.

[0236] In an embodiment of the present application, the training data includes a training text, a main task instruction, and a first auxiliary task instruction, wherein the main task instruction includes a first task content of the main task, the first task content includes determining a first entity word in the training text and an entity type of the first entity word, and the first auxiliary task instruction includes a second task content of the first auxiliary task, the second task content includes determining the entity type contained in the training text. Therefore, after acquiring the training data, the training device uses the training data to train the pre-trained language model, so that the pre-trained language model can perform the main task on the training text according to the first task content in the main task instruction to obtain a first execution result, and the pre-trained language model can perform the first auxiliary task on the training text according to the second task content in the first auxiliary instruction to obtain a second execution result. The training device can obtain a first difference for characterizing the effect of the pre-trained language model performing the main task by determining the difference between the first execution result and the first label of the main task. The training device can obtain a second difference for characterizing the effect of the pre-trained language model performing the first auxiliary task by determining the difference between the second execution result and the second label of the first auxiliary task. Therefore, the training device updates the parameters of the pre-trained language model based on the first difference and the second difference, which can improve the effect of the pre-trained language model in performing the main task and the effect of the pre-trained language model in performing the first auxiliary task. Since the effect of the pre-trained language model in performing the first auxiliary task is improved, the pre-trained language model can better understand the semantics of the entity type in the text, which is beneficial for the pre-trained language model to perform the main task, and the first task content of the main task is to perform named entity recognition on the text. Therefore, the training device updates the parameters of the pre-trained language model based on the first difference and the second difference to obtain a named entity recognition model, which can improve the accuracy of the named entity recognition model in performing named entity recognition on the text.

[0237] In addition, since the training object of this training method is a pre-trained language model, this training method can train a named entity recognition model using a small amount of training text. In other words, this training method can utilize the learning ability of the pre-trained language model to obtain a named entity recognition model through small sample training.

[0238] See also Figure 5 , Figure 5 A schematic diagram of the structure of a named entity recognition device provided in an embodiment of the present application, the named entity recognition device 2 includes: an acquisition unit 21, a recognition unit 22, and optionally, the named entity recognition device 2 also includes a determination unit 23, specifically:

[0239] An acquisition unit 21, used for acquiring a text to be recognized;

[0240] The recognition unit 22 is used to perform named entity recognition on the text to be recognized by using a named entity recognition model to obtain a named entity recognition result. The named entity recognition model is obtained by training through the first aspect and any implementation manner thereof.

[0241] In combination with any embodiment of the present application, the named entity recognition device also includes: a determination unit 23, which is used to determine a target mapping relationship based on the named entity recognition result, wherein the target mapping relationship is a mapping relationship between a target entity word in the text to be recognized and a target entity type of the target entity word, and the target entity word is a named entity.

[0242] In combination with any embodiment of the present application, the named entity recognition result describes the candidate entity type of the candidate entity term according to a preset sentence pattern, and the candidate entity term is a named entity;

[0243] The determining unit 23 is specifically configured to:

[0244] Dividing the text used to describe the same candidate entity word in the named entity recognition result into the same sub-text to obtain at least one sub-text;

[0245] Based on the preset sentence pattern, determining the candidate entity words in each of the sub-texts and the candidate entity types in each of the sub-texts;

[0246] The target mapping relationship is determined based on the candidate entity terms and the candidate entity types.

[0247] In combination with any embodiment of the present application, the determination unit 23 is specifically used to determine, for the candidate entity terms and the candidate entity types in the same sub-text, that the mapping relationship between the candidate entity terms and the candidate entity types is the target mapping relationship when the candidate entity terms belong to the text to be identified and the candidate entity type is a preset entity type.

[0248] In an embodiment of the present application, after acquiring the text to be recognized, the recognition device uses a named entity recognition model to perform named entity recognition on the text to be recognized, and obtains a named entity recognition result, which can improve the accuracy of the named entity recognition result.

[0249] In some embodiments, the functions or modules included in the device provided in the embodiments of the present application can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be repeated here.

[0250] Figure 6 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. The electronic device 3 includes a processor 31 and a memory 32. Optionally, the electronic device 3 also includes an input device 33 and an output device 34. The processor 31, the memory 32, the input device 33 and the output device 34 are coupled via a connector, and the connector includes various interfaces, transmission lines or buses, etc., which are not limited in the embodiments of the present application. It should be understood that in each embodiment of the present application, coupling refers to mutual connection in a specific manner, including direct connection or indirect connection through other devices, for example, it can be connected through various interfaces, transmission lines, buses, etc.

[0251] The processor 31 may include one or more processors, for example, one or more central processing units (CPUs). When the processor is a CPU, the CPU may be a single-core CPU or a multi-core CPU. Optionally, the processor 31 may be a processor group consisting of multiple CPUs, and the multiple processors are coupled to each other via one or more buses. Optionally, the processor may also be other types of processors, etc., which are not limited in the embodiments of the present application.

[0252] The memory 32 can be used to store computer program instructions and various computer program codes including the program code for executing the program code of the present application. Optionally, the memory includes but is not limited to random access memory (RAM), read-only memory (ROM), erasable programmable read only memory (EPROM), or portable read only memory (CD-ROM), which is used for related instructions and data.

[0253] The input device 33 is used to input data and / or signals, and the output device 34 is used to output data and / or signals. The input device 33 and the output device 34 can be independent devices or an integrated device.

[0254] It can be understood that in the embodiment of the present application, the memory 32 can be used not only to store relevant instructions, but also to store relevant data. For example, the memory 32 can be used to store training data obtained through the input device 33, or the memory 32 can also be used to store the named entity recognition model obtained by the processor 31, etc. The embodiment of the present application does not limit the specific data stored in the memory.

[0255] Understandably, Figure 6 Only a simplified design of an electronic device is shown. In practical applications, the electronic device may also include other necessary components, including but not limited to any number of input / output devices, processors, memories, etc., and all electronic devices that can implement the embodiments of the present application are within the protection scope of the present application.

[0256] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0257] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. Those skilled in the art can also clearly understand that the descriptions of the various embodiments of the present application have different focuses. For the convenience and brevity of description, the same or similar parts may not be repeated in different embodiments. Therefore, for parts not described or not described in detail in a certain embodiment, refer to the records of other embodiments.

[0258] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0259] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0260] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0261] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).

[0262] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by a computer program to instruct the relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-mentioned method embodiments. The aforementioned storage medium includes: a read-only memory (ROM) or a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

Claims

1. A training method for a named entity recognition model, characterized in that: The method comprises: Acquire training data, the training data including training text, main task instructions and first auxiliary task instructions, the main task instructions including first task content of the main task, the first task content including determining a first entity word in the training text and an entity type of the first entity word, the first entity word being a named entity, the first auxiliary task instructions including second task content of the first auxiliary task, the second task content including determining the entity type contained in the training text; In the process of training the pre-trained language model using the training data, the pre-trained language model executes the main task according to the first task content in the main task instruction to obtain a first execution result, and the pre-trained language model executes the first auxiliary task according to the second task content in the first auxiliary task instruction to obtain a second execution result; Determine a first difference between the first execution result and the first label of the main task; Determine a second difference between the second execution result and the second label of the first auxiliary task; Based on the first difference and the second difference, the parameters of the pre-trained language model are updated to obtain a named entity recognition model, where the named entity recognition model is used to perform named entity recognition on the text.

2. The method according to claim 1, characterized in that The training data also includes examples of entity types describing second entity terms, the second entity terms are named entities, and the second entity terms are different from the first entity terms; The pre-trained language model executes the main task according to the first task content in the main task instruction to obtain a first execution result, including: Under the prompt of the example, the pre-trained language model executes the main task according to the first task content in the main task instruction to obtain the first execution result.

3. The method according to claim 1 or 2, characterized in that: The training data further includes a second auxiliary task instruction, wherein the second auxiliary task instruction includes a third task content of the second auxiliary task, and the third task content includes determining the first entity word from the training text; Before updating the parameters of the pre-trained language model based on the first difference and the second difference to obtain a named entity recognition model, the method further includes: In the process of training the pre-trained language model using the training data, the pre-trained language model executes the second auxiliary task according to the third task content in the second auxiliary task instruction to obtain a third execution result; determining a third difference between the third execution result and a third label of the second auxiliary task; The updating of the parameters of the pre-trained language model based on the first difference and the second difference to obtain a named entity recognition model includes: Based on the first difference, the second difference and the third difference, the parameters of the pre-trained language model are updated to obtain the named entity recognition model.

4. The method according to claim 3, characterized in that The training data further includes a third auxiliary task instruction, the third auxiliary task instruction includes a fourth task content of the third auxiliary task, and the fourth task content includes determining the entity type of the words in the training text; Before updating the parameters of the pre-trained language model based on the first difference, the second difference and the third difference to obtain the named entity recognition model, the method further includes: In the process of training the pre-trained language model using the training data, the pre-trained language model performs the third auxiliary task according to the fourth task content in the third auxiliary task instruction to obtain a fourth execution result; determining a fourth difference between the fourth execution result and a fourth label of the third auxiliary task; The updating of the parameters of the pre-trained language model based on the first difference, the second difference and the third difference to obtain the named entity recognition model includes: Based on the first difference, the second difference, the third difference and the fourth difference, the parameters of the pre-trained language model are updated to obtain the named entity recognition model.

5. The method according to claim 4, characterized in that The updating of the parameters of the pre-trained language model based on the first difference, the second difference, the third difference and the fourth difference to obtain the named entity recognition model includes: Determining a loss of the pre-trained language model based on the first difference, the second difference, the third difference, and the fourth difference, wherein the loss is positively correlated with the first difference, the second difference, the third difference, and the fourth difference; Based on the loss, the parameters of the pre-trained language model are updated to obtain the named entity recognition model.

6. The method according to claim 4, characterized in that The training data also includes preset entity types, and the fourth task content includes determining the entity type of the first entity term in the training text from the preset entity types.

7. The method according to claim 3, characterized in that The first execution result and the third execution result both include text describing the first entity word according to a preset sentence structure.

8. The method according to claim 1 or 2, characterized in that: The training data also includes preset entity types, and the first task content includes determining the entity type of the first entity term from the preset entity types.

9. The method according to claim 1 or 2, characterized in that: The pre-trained language model is a text-to-text conversion model.

10. A method for named entity recognition, characterized in that: The method comprises: Get the text to be recognized; A named entity recognition model is used to perform named entity recognition on the text to be recognized to obtain a named entity recognition result, wherein the named entity recognition model is trained by the method described in any one of claims 1 to 9.

11. The method according to claim 10, characterized in that After obtaining the named entity recognition result, the method further includes: Based on the named entity recognition result, a target mapping relationship is determined, where the target mapping relationship is a mapping relationship between a target entity word in the to-be-recognized text and a target entity type of the target entity word, and the target entity word is a named entity.

12. The method according to claim 11, characterized in that: The named entity recognition result describes the candidate entity type of the candidate entity term according to a preset sentence pattern, and the candidate entity term is a named entity; The determining of the target mapping relationship based on the named entity recognition result includes: Dividing the text used to describe the same candidate entity word in the named entity recognition result into the same sub-text to obtain at least one sub-text; Based on the preset sentence pattern, determining the candidate entity words in each of the sub-texts and the candidate entity types in each of the sub-texts; The target mapping relationship is determined based on the candidate entity terms and the candidate entity types.

13. The method according to claim 12, characterized in that The determining the target mapping relationship based on the candidate entity words and the candidate entity types includes: For the candidate entity words and the candidate entity types in the same sub-text, when the candidate entity words belong to the text to be recognized and the candidate entity type is a preset entity type, the mapping relationship between the candidate entity words and the candidate entity type is determined as the target mapping relationship.

14. A training device for a named entity recognition model, characterized in that: The training device comprises: an acquisition unit, configured to acquire training data, wherein the training data includes a training text, a main task instruction, and a first auxiliary task instruction, wherein the main task instruction includes a first task content of a main task, wherein the first task content includes determining a first entity word in the training text and an entity type of the first entity word, wherein the first entity word is a named entity, and wherein the first auxiliary task instruction includes a second task content of the first auxiliary task, wherein the second task content includes determining an entity type contained in the training text; an execution unit, configured to, in a process of training a pre-trained language model using the training data, cause the pre-trained language model to execute the main task on the training text according to the main task instruction to obtain a first execution result, and cause the pre-trained language model to execute the first auxiliary task on the training text according to the first auxiliary task instruction to obtain a second execution result; a determining unit, configured to determine a first difference between the first execution result and the first label of the main task; The determining unit is configured to determine a second difference between the second execution result and the second label of the first auxiliary task; An updating unit is used to update the parameters of the pre-trained language model based on the first difference and the second difference to obtain a named entity recognition model, wherein the named entity recognition model is used to perform named entity recognition on the text.

15. A named entity recognition device, characterized in that: The named entity recognition device comprises: An acquisition unit, used for acquiring the text to be recognized; The recognition unit is used to perform named entity recognition on the text to be recognized using a named entity recognition model to obtain a named entity recognition result, wherein the named entity recognition model is trained by the method described in any one of claims 1 to 9.

16. An electronic device, characterized in that: include: A processor and a memory, the memory being used to store computer program codes, the computer program codes comprising computer instructions, and when the processor executes the computer instructions, the electronic device executes the method according to any one of claims 1 to 9; When the processor executes the computer instructions, the electronic device may perform the method as claimed in any one of claims 10 to 13.

17. A computer-readable storage medium, characterized in that: The computer readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 1 to 9; When the program instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 10 to 13.

18. A computer program product, characterized in that The computer program product comprises a computer program or instructions; when the computer program or instructions are run on a computer, the computer is caused to execute the method according to any one of claims 1 to 9; When the computer program or instruction runs on a computer, the computer is caused to execute the method according to any one of claims 10 to 13.