Training method, device, equipment and storage medium for natural language processing model

By constructing training corpus pairs and training natural language processing models, the problem of insufficient accuracy in identifying pronouns and pronouns in the anaphora resolution task is solved, and the processing capabilities and functional practicability of the model are improved.

CN112001190BActive Publication Date: 2024-09-20BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010699284.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-20
Publication Date
2024-09-20
Estimated Expiration
2040-07-20

AI Technical Summary

Technical Problem

Existing natural language processing models have insufficient accuracy in identifying pronouns to refer to nouns in the coreference resolution task, which affects the results of machine translation and reading comprehension.

Method used

By constructing training corpus pairs based on a preset corpus, including positive samples and negative samples, the natural language processing model is trained so that it can learn to identify correct and incorrect referential relationships, and gradually improve the model's ability to handle referential resolution tasks.

Benefits of technology

It improves the natural language processing model's ability to handle coreference resolution tasks, enhances the function and practicality of the model, and ensures accurate analysis of pronoun reference relationships.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112001190B
    Figure CN112001190B
Patent Text Reader

Abstract

The present application discloses a training method, device, equipment and storage medium for a natural language processing model, and relates to the field of natural language processing based on artificial intelligence. The specific implementation scheme is: based on a preset corpus set, construct various training corpus pairs for the task of coreference resolution, each training corpus pair includes positive samples and negative samples; use each training corpus pair to train the natural language processing model so that it can learn the ability to identify the corresponding positive samples and negative samples; use the positive samples of each training corpus pair to train the natural language processing model so that it can learn the ability of coreference resolution tasks. The present application can realize the modeling of coreference resolution tasks by the natural language processing model, improve the processing ability of the natural language processing model for coreference resolution tasks, enrich the functions of the natural language processing model, and enhance the practicality of the natural language processing model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, in particular to the field of natural language processing based on artificial intelligence, and specifically to a training method, apparatus, device and storage medium for a natural language processing model. Background Art

[0002] In Natural Language Processing (NLP) tasks, there is a large demand for coreference resolution tasks.

[0003] For example, in reading comprehension, you need to know what noun each pronoun refers to in order to accurately and comprehensively understand the article; in machine translation, Turkish pronouns do not distinguish between male he and female she. If the meaning of the pronoun cannot be accurately parsed when translated into English, the machine translation effect will be seriously affected. How to better model the task of reference resolution and improve the ability of natural language processing models to handle reference resolution tasks is a technical problem that needs to be solved urgently. Summary of the invention

[0004] In order to solve the above problems, the present application provides a natural language processing model training, device, electronic device and storage medium.

[0005] According to one aspect of the present application, a method for training a natural language processing model is provided, wherein the method comprises:

[0006] Based on a preset corpus set, constructing various training corpus pairs for the coreference resolution task, each of the training corpus pairs including a positive sample and a negative sample;

[0007] Using each of the training corpus pairs, training the natural language processing model so that it learns the ability to recognize the corresponding positive samples and negative samples;

[0008] The natural language processing model is trained using positive samples of each training corpus pair to enable it to learn the ability of the coreference resolution task.

[0009] According to another aspect of the present application, a training device for a natural language processing model is provided, wherein the device comprises:

[0010] A construction module, used to construct various training corpus pairs for the reference resolution task based on a preset corpus set, wherein each training corpus pair includes a positive sample and a negative sample;

[0011] A first training module is used to train the natural language processing model using each of the training corpus pairs, so that the model can learn to recognize the corresponding positive samples and negative samples;

[0012] The second training module is used to use positive samples of each of the training corpus pairs to train the natural language processing model so that it can learn the ability of the coreference resolution task.

[0013] According to another aspect of the present application, there is provided an electronic device, comprising:

[0014] at least one processor; and

[0015] a memory communicatively connected to the at least one processor; wherein,

[0016] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described above.

[0017] According to yet another aspect of the present application, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method as described above.

[0018] According to yet another aspect of the present application, a computer program product is provided, comprising a computer program, wherein the computer program implements the above method when executed by a processor.

[0019] According to the technology of the present application, it is possible to implement modeling of the natural language processing model for the task of reference resolution, improve the processing capability of the natural language processing model for the task of reference resolution, enrich the functions of the natural language processing model, and enhance the practicality of the natural language processing model.

[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present application.

[0022] Figure 1 is a schematic diagram according to the first embodiment of the present application;

[0023] Figure 2 is a schematic diagram according to a second embodiment of the present application;

[0024] Figure 3 is an example diagram of a training corpus pair constructed in this embodiment;

[0025] Figure 4 This is a schematic diagram of the pre-training of the natural language processing model of this embodiment.

[0026] Figure 5is a schematic diagram according to a third embodiment of the present application;

[0027] Figure 6 is a schematic diagram according to a fourth embodiment of the present application;

[0028] Figure 7 It is a block diagram of an electronic device used to implement the above method in an embodiment of the present application. DETAILED DESCRIPTION

[0029] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0030] Figure 1 is a schematic diagram according to the first embodiment of the present application; Figure 1 As shown, this embodiment provides a training method for a natural language processing model, which may specifically include the following steps:

[0031] S101, constructing various training corpus pairs for the coreference resolution task based on a preset corpus set, wherein each training corpus pair includes a positive sample and a negative sample;

[0032] S102, using each training corpus pair to train a natural language processing model so that it can learn the ability to identify corresponding positive samples and negative samples;

[0033] S103. Using positive samples of each training corpus pair, train a natural language processing model to enable it to learn the ability of coreference resolution tasks.

[0034] The execution subject of the training method of the natural language processing model of this embodiment is the training method of the natural language processing model, and the training method of the natural language processing model can be a physical electronic device such as a computer or the like. Or it can also be an application integrated with software, which runs on a computer when in use to implement the training of the natural language processing model.

[0035] The purpose of this embodiment is to train a natural language processing model to perform a coreference resolution task. The coreference resolution task specifically refers to: when there is a pronoun in a sentence and there are at least two different nouns, how to identify which noun in the sentence the pronoun specifically refers to. The natural language processing model of this embodiment can be trained based on the Enhanced Language Representation with Informative Entities (ERNIE) model.

[0036] In this embodiment, the preset corpus is a collection of numerous corpora collected in advance. The language of the corpus can be the language scenario used by the natural language processing model to be trained for performing the coreference resolution task, such as English, Chinese, Japanese, Turkish, etc. For each language, the corresponding natural language processing model can be trained to perform the corresponding coreference resolution task.

[0037] In this embodiment, a training corpus pair for the coreference resolution task can be constructed based on each corpus in the preset corpus set. Each training corpus pair in this embodiment can include positive samples and negative samples. The positive sample includes the correct coreference relationship, while the negative sample includes the wrong coreference relationship. For example, each training corpus pair can include a positive sample and a negative sample, or can also include a positive sample and at least two negative samples, and the number of negative samples is specifically determined based on the number of nouns in the corresponding corpus. Or if each training corpus pair includes only one positive sample and one negative sample, then multiple training corpus pairs can also be generated based on a corpus in the corpus set. For example, if a certain corpus S includes three nouns a, b, c and a pronoun it, and it is known that the pronoun it refers to the noun c, then two training corpus pairs can be formed. The first training corpus pair can include it referring to c in the positive sample S; it refers to a in the negative sample S; and the second training corpus pair can include it referring to c in the positive sample S; it refers to b in the negative sample S. According to the above method, based on the corpus, countless training corpus pairs for the coreference resolution task can be constructed.

[0038] In this embodiment, the training of the natural language processing model is divided into two stages. In the first stage, each training corpus pair is used to train the natural language processing model so that it can learn to identify the corresponding positive samples and negative samples. The training in this stage is to first let the natural language processing model learn to identify positive samples and negative samples, and know what kind of reference relationship is correct and what kind of reference relationship is wrong. In this stage, a large number of training corpus pairs can be used to train the natural language processing model to have this recognition ability.

[0039] Based on the learning of the first stage, the natural language processing model has been adjusted to be able to identify which reference relations are correct and which reference relations are wrong. Next, in the training of the second stage, the learning difficulty is increased in a step-by-step manner, and the positive samples of each training corpus are used to train the natural language processing model so that it can learn the ability of the reference resolution task, that is, the language processing model can learn to identify which noun in the sentence the pronoun in the sentence refers to, and realize the ability to perform the reference resolution task. Based on the learning of the first stage, this process enables the natural language processing model to fine-tune parameters, carry out task-oriented and purposeful learning, so that it can master the ability to perform the reference resolution task. In the learning of the first stage of this embodiment, the natural language processing model can be based on the ERNIE model to complete the preliminary adjustment of the model parameters in the pre-training stage. In the learning of the second stage, the natural language processing model obtained by the first stage training can continue to use the positive samples of each training corpus to realize the ultimate adjustment of the parameters of the model in the fine-tuning stage, so that it can learn the ability of the reference resolution task.

[0040] The natural language processing model trained in this embodiment can be used in any scenario with a coreference resolution task. For example, in reading comprehension, it can understand the correct coreference relationship of each pronoun in a sentence, and assist in thoroughly understanding the entire text.

[0041] The training method of the natural language processing model of the present embodiment constructs various training corpus pairs for the coreference resolution task based on a preset corpus set, wherein each training corpus pair includes a positive sample and a negative sample; each training corpus pair is used to train the natural language processing model so that it can learn the ability to identify the corresponding positive samples and negative samples; the positive samples of each training corpus pair are used to train the natural language processing model so that it can learn the ability to perform the coreference resolution task, which can realize modeling of the coreference resolution task by the natural language processing model, improve the processing ability of the natural language processing model for the coreference resolution task, enrich the functions of the natural language processing model, and enhance the practicality of the natural language processing model.

[0042] Figure 2 is a schematic diagram according to the second embodiment of the present application; the training method of the natural language processing model of this embodiment, in the above Figure 1 Based on the technical solutions of the embodiments shown, the technical solutions of the present application are further described in more detail. Figure 2 As shown, the training method of the natural language processing model of this embodiment may specifically include the following steps:

[0043] S201, for each corpus in the preset corpus set, replace the target noun that does not appear for the first time in the corresponding corpus with a pronoun as training corpus;

[0044] It should be noted that the corpus collected in the corpus set in this embodiment uses nouns in its entirety and avoids the use of pronouns. In this way, it is very convenient to construct the training corpus pair for the reference resolution task of this embodiment based on such corpus. Specifically, according to the expression characteristics of the sentence, the pronoun in the sentence appears in a position that is not the first time it appears, so that it can refer to another noun that has already appeared. Therefore, in this embodiment, the target noun that does not appear for the first time can be replaced with a pronoun.

[0045] S202, obtaining other nouns from the training corpus;

[0046] S203, taking the training corpus and the referential relationship between the pronoun and the target noun as positive samples of the training corpus pair;

[0047] S204, using the training corpus and the referential relationship between the pronoun and other nouns as negative samples of the training corpus pair; a total of several training corpus pairs may be obtained;

[0048] Since the target noun is replaced by a pronoun in the above steps, the reference relationship between the pronoun and the target noun in the training corpus is a correct reference relationship, which is used as a positive sample. The reference relationship between the pronoun and other nouns in the training corpus is an incorrect reference relationship, which is used as a negative sample.

[0049] The above steps S201-S204 are Figure 1 An implementation of step S101 of the illustrated embodiment. This method can accurately and effectively construct numerous training corpus pairs for coreference resolution tasks, thereby facilitating learning of the recognition capabilities of positive and negative samples for the natural language processing model based on the constructed training corpus pairs.

[0050] For example, Figure 3 is an example diagram of the training corpus pair constructed in this embodiment. Figure 3As shown, for the corpus: Thetroph7 didn't fit into the suitcase because the suitcase was too small, the nouns in the sentence can be identified, and the noun the suitcase that does not appear for the first time can be replaced by the pronoun it, so that a training corpus can be obtained. Then the positive sample and negative sample of the training corpus pair can be constructed based on the training corpus. Based on the above process, it can be known that the it refers to the suitcase, so in the positive sample, the reference relationship of it referring to thesuitcase can be recorded, and in the negative sample, since the negative sample itself represents an erroneous sample, the reference relationship of it referring to other nouns other than the suitcase in the training corpus can be recorded, for example, in this embodiment, the negative sample can record that it refers to The troph7.

[0051] S205, inputting each training corpus pair into a natural language processing model, so that the natural language processing model learns to predict whether the reference relationship in the positive sample and the negative sample is correct;

[0052] Specifically, this step can be understood as using multi-task learning to enhance the modeling ability of the natural language processing model for the coreference resolution task after constructing the training corpus pairs for the coreference resolution task. For example, the coreference natural language processing model can be modeled as a binary classification task, and the constructed training corpus pairs are Sent[pronoun][Candidate pos ] and Sent[pronoun][Candidate neg ] is sent to the natural language processing model. pos The correct noun to which the pronoun refers, Candidate neg Indicates the wrong noun referred to by the pronoun. The optimization goal of the natural language processing model in this training process is to determine whether Candidate is the noun referred to by the pronoun, thereby achieving preliminary modeling of the reference resolution task.

[0053] For example, when inputting each training corpus pair into the natural language processing model, the referential relationship in the training corpus and the positive sample can be input as one piece of data. When inputting, each part of the content is input as a segment, and the pronouns and nouns in the referential relationship can be split into two segments. Similarly, the referential relationship in the training corpus and the negative sample is also input as one piece of data. For example, Figure 4 is a schematic diagram of the pre-training of the natural language processing model of this embodiment. Figure 4As shown in the figure, during training, the start character CLS is added to the front of each data input, and each segment is separated by the SEP character. The training process is to enable the natural language processing model to identify the correct reference relationship in the positive sample and the incorrect reference relationship in the negative sample.

[0054] S206, determine whether the prediction is correct; if it is wrong, execute step S207; otherwise, if it is correct, execute step S208;

[0055] It should be noted that when the natural language processing model predicts, it may misidentify the positive and negative samples, that is, the identification of the reference relationship in the positive sample is wrong, while the identification of the reference relationship in the negative sample is correct. In this case, the natural language processing model is considered to have made an incorrect prediction.

[0056] S207, adjusting the parameters of the natural language processing model so that the natural language processing model is adjusted in the direction of correctly predicting the referential relationship in the positive sample and the negative sample; returning to step S205 to continue training with the next training corpus;

[0057] S208, determining whether the prediction accuracy of the natural language processing model in the continuous preset number of rounds of training reaches a preset threshold; if not, returning to step S205 to continue training with the next training corpus; if so, determining preliminary parameters of the natural language processing model; and executing step S209;

[0058] The preset threshold can be set according to actual needs, for example, 80%, 90% or other percentages. When the accuracy reaches the preset threshold, it can be considered that the natural language processing model has basically met the requirements in the pre-training stage, and the training in the pre-training stage can be stopped at this time.

[0059] The above steps S205-S208 are Figure 1 An implementation of step S102 of the illustrated embodiment. This process occurs in the pre-training stage, and the parameters of the natural language processing model are preliminarily adjusted so that the natural language processing model can have the ability to identify positive and negative samples.

[0060] S209, masking the pronouns in the training corpus of the positive sample of each training corpus pair;

[0061] This step may specifically use the training corpus of the positive sample of each training corpus pair obtained in step S203. In this embodiment, a special character may be used for masking, such as the OPT character.

[0062] S210, inputting the pronoun-masked training corpus into a natural language processing model, so that the natural language processing model predicts the probability that the pronoun belongs to each noun in the training corpus;

[0063] In this embodiment, after the masked training corpus is input into the natural language processing model, the natural language processing model can predict the probability that the pronoun may be other nouns in the training corpus based on the context information of the masked pronoun in the training corpus.

[0064] S211, predicting the probability of the pronoun belonging to each noun in the training corpus and the target noun referred to by the pronoun identified in the positive sample based on the natural language processing model, and generating a target loss function;

[0065] For example, in this embodiment, generating the target loss function may specifically include the following steps:

[0066] (a) Based on the target noun referred to by the pronoun identified in the positive sample, obtain the probability that the natural language processing model predicts that the pronoun belongs to the target noun;

[0067] The target noun here means that it refers to the correct noun.

[0068] (b) predicting the probability of the pronoun belonging to the target noun based on the natural language processing model and constructing the first loss function;

[0069] (c) predicting the probability of the pronoun belonging to other nouns other than the target noun based on the natural language processing model, and constructing a second loss function;

[0070] The other nouns are the wrong nouns for it. Specifically, there may be one other noun, or two or more other nouns in a sentence.

[0071] (d) Generate a target loss function based on the first loss function and the second loss function.

[0072] For example, taking the above-mentioned example of The troph7 didn't fit into the suitcase because it was too small, where it refers to the suitcase as a positive sample, in this embodiment, c1 can be recorded as the correct target noun it refers to, c2 as the wrong other noun it refers to, and the sentence is recorded as s. Then the probability that the natural language processing model predicts that the pronoun belongs to the target noun can be expressed as p(c1|s), which is a conditional probability; similarly, the probability that the natural language processing model predicts that the pronoun belongs to other nouns other than the target noun can be expressed as p(c2|s). In actual applications, if there are other nouns c3, c4, etc. in a sentence, there may also be corresponding p(c3|s), p(c4|s), etc.

[0073] Correspondingly, the first loss function can be expressed as: L logloss=-log(p(c1|s)).

[0074] If there is only one other noun c2, then the second loss function can be expressed as:

[0075] L rankloss =alpha*max(0,log(p(c2|s))-log(p(c1|s))+beta)

[0076] Among them, alpha and beta are hyperparameters and can be set according to actual needs.

[0077] In addition, optionally, if there are other terms such as c3 and c4, then the second loss function can be expressed as:

[0078] L rankloss =alpha*max(0,log(p(c2|s),log(p(c3|s),log(p(c4|s),...)-log(p(c1|s))+beta)

[0079] The target loss function of this embodiment can be directly taken as the sum of the first loss function Lossloss and the second loss function Rankloss, that is, L = L logloss +L rankloss , as the optimization goal of the coreference resolution task, this can preserve the accuracy of the model's candidate predictions while allowing the model to notice the differences between different candidate items.

[0080] Alternatively, in practical applications, the target loss function can also be a linear or nonlinear superposition of two loss functions or a combination thereof using other mathematical methods.

[0081] S212, determine whether the target loss function converges; if not, execute step S213; if converged, execute step S214;

[0082] S213, adjusting the parameters of the natural language processing model based on the gradient descent method, and returning to step S209 to continue training using the training corpus of the next positive sample of the training corpus pair;

[0083] S214. Determine whether convergence has been achieved in consecutive preset rounds of training. If so, the training ends, the parameters of the natural language processing model are determined, and then the natural language processing model is determined and the training ends. If not, return to step S209 and continue training using the training corpus of the next training corpus pair's positive sample.

[0084] The continuous preset number of rounds in this embodiment may be 100 rounds, 200 rounds, or another number of rounds set according to actual needs.

[0085] Steps S209-S215 of this embodiment are as described above. Figure 1 An implementation of step S103 of the illustrated embodiment. This process occurs in the training phase of the fine-tuning phase, and based on the parameters of the natural language processing model that have been initially adjusted, the natural language processing model is continuously trained so that the natural language processing model learns to perform the coreference resolution task capability.

[0086] The training method of the natural language processing model of this embodiment can construct a training corpus pair for a semi-supervised coreference resolution task from a massive unsupervised corpus, which can effectively improve the model's modeling ability for the coreference resolution task. Further, in this embodiment, the coreference resolution task is modeled by a target loss function constructed by the first loss function and the second loss function, so that the model can predict which correct target noun the pronoun refers to while also paying attention to the differences between different other nouns, so that the model can better model the coreference resolution task, effectively improve the model's processing ability for the coreference resolution task, and can effectively enrich the functions of the natural language processing model and enhance the practicality of the natural language processing model.

[0087] Figure 5 is a schematic diagram according to the third embodiment of the present application; Figure 5 As shown, this embodiment provides a training device 500 for a natural language processing model, including:

[0088] A construction module 501 is used to construct various training corpus pairs for the coreference resolution task based on a preset corpus set, wherein each training corpus pair includes a positive sample and a negative sample;

[0089] A first training module 502 is used to train the natural language processing model using each training corpus pair so that it can learn the ability to identify corresponding positive samples and negative samples;

[0090] The second training module 503 is used to train the natural language processing model using positive samples of each training corpus pair, so that it can learn the ability of the coreference resolution task.

[0091] The training device 500 of the natural language processing model of this embodiment realizes the training of the natural language processing model by adopting the above-mentioned modules, and the implementation principle and technical effects are the same as those of the above-mentioned related method embodiments. For details, please refer to the records of the above-mentioned related method embodiments, which will not be repeated here.

[0092] Figure 6 is a schematic diagram according to the fourth embodiment of the present application; Figure 6 As shown, the training device 500 of the natural language processing model of this embodiment, in the above Figure 5Based on the technical method of the illustrated embodiment, the technical solution of the present application is further described in more detail.

[0093] like Figure 6 As shown, in the training device 500 of the natural language processing model of this embodiment, the construction module 501 includes:

[0094] A replacement unit 5011 is used to replace the target noun that does not appear for the first time in each corpus in the preset corpus set with a pronoun as training corpus;

[0095] An acquisition unit 5012, used for acquiring other nouns from the training corpus;

[0096] A setting unit 5013 is used to use the training corpus and the referential relationship between the pronoun and the target noun as positive samples of the training corpus pair;

[0097] The setting unit 5013 is further used to use the training corpus and the referential relationship between the pronoun and other nouns as negative samples of the training corpus pair.

[0098] Further optionally, if Figure 6 As shown, in the training device 500 for the natural language processing model of this embodiment, the first training module 502 includes:

[0099] The first prediction unit 5021 is used to input each training corpus pair into the natural language processing model, so that the natural language processing model learns to predict whether the reference relationship in the positive sample and the negative sample is correct;

[0100] The first adjustment unit 5022 is used to adjust the parameters of the natural language processing model when the prediction is wrong, so that the natural language processing model is adjusted in the direction of correctly predicting the reference relationship in the positive samples and the negative samples.

[0101] Further optionally, if Figure 6 As shown, in the training device 500 for the natural language processing model of this embodiment, the second training module 503 includes:

[0102] A masking unit 5031, used to mask the pronouns in the training corpus of the positive sample of each training corpus pair;

[0103] The second prediction unit 5032 is used to input the pronoun-masked training corpus into the natural language processing model, so that the natural language processing model predicts the probability that the pronoun belongs to each noun in the training corpus;

[0104] A generating unit 5033 is used to predict the probability of the pronoun belonging to each noun in the training corpus and the target noun referred to by the pronoun identified in the positive sample based on the natural language processing model, and generate a target loss function;

[0105] A detection unit 5034 is used to determine whether the target loss function converges;

[0106] The second adjustment unit 5035 is used to adjust the parameters of the natural language processing model based on the gradient descent method if convergence has not occurred.

[0107] Further optionally, the generating unit 5033 is used to:

[0108] Based on the target noun referred to by the pronoun identified in the positive sample, obtain the probability that the natural language processing model predicts that the pronoun belongs to the target noun;

[0109] Based on the natural language processing model, the probability of the pronoun belonging to the target noun is predicted, and the first loss function is constructed;

[0110] Based on the natural language processing model, the probability of the pronoun belonging to other nouns other than the target noun is predicted, and the second loss function is constructed;

[0111] Based on the first loss function and the second loss function, a target loss function is generated. …

[0112] The training device 500 of the natural language processing model of this embodiment realizes the training of the natural language processing model by adopting the above-mentioned modules, and the implementation principle and technical effects are the same as those of the above-mentioned related method embodiments. For details, please refer to the records of the above-mentioned related method embodiments, which will not be repeated here.

[0113] According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.

[0114] like Figure 7 , is a block diagram of an electronic device for implementing the above method of an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.

[0115] like Figure 7As shown, the electronic device includes: one or more processors 701, a memory 702, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 7 A processor 701 is taken as an example.

[0116] The memory 702 is a non-transitory computer-readable storage medium provided in the present application. The memory stores instructions executable by at least one processor to enable the at least one processor to perform the training method of the natural language processing model provided in the present application. The non-transitory computer-readable storage medium of the present application stores computer instructions, which are used to enable a computer to perform the training method of the natural language processing model provided in the present application.

[0117] The memory 702 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as the program instructions / modules corresponding to the training method of the natural language processing model in the embodiment of the present application (for example, the attached Figure 5 and attached Figure 6 The processor 701 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 702, that is, implements the training method of the natural language processing model in the above method embodiment.

[0118] The memory 702 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of an electronic device that implements a training method for a natural language processing model, etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 702 may optionally include a memory remotely disposed relative to the processor 701, and these remote memories may be connected to an electronic device that implements a training method for a natural language processing model via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0119] The electronic device implementing the training method of the natural language processing model may further include: an input device 703 and an output device 704. The processor 701, the memory 702, the input device 703 and the output device 704 may be connected via a bus or other means. Figure 7 The example of connecting through bus is taken in the following.

[0120] The input device 703 can receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device for implementing the training method of the natural language processing model, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a trackball, a joystick and other input devices. The output device 704 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display and a plasma display. In some embodiments, the display device may be a touch screen.

[0121] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0122] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.

[0123] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0124] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.

[0125] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.

[0126] According to the technical solution of the embodiment of the present application, by constructing various training corpus pairs for the coreference resolution task based on a preset corpus set, each training corpus pair includes a positive sample and a negative sample; using each training corpus pair to train a natural language processing model so that it can learn the ability to identify the corresponding positive samples and negative samples; using the positive samples of each training corpus pair to train the natural language processing model so that it can learn the ability to perform the coreference resolution task, the natural language processing model can be modeled for the coreference resolution task, the natural language processing model's processing ability for the coreference resolution task can be improved, the function of the natural language processing model can be enriched, and the practicality of the natural language processing model can be enhanced.

[0127] According to the technical solution of the embodiment of the present application, a training corpus pair for a semi-supervised coreference resolution task can be constructed from a massive unsupervised corpus, which can effectively improve the model's modeling ability for the coreference resolution task. Further, in this embodiment, the coreference resolution task is modeled by a target loss function constructed by the first loss function and the second loss function, so that the model can predict which correct target noun the pronoun refers to while also paying attention to the differences between different other nouns, so that the model can better model the coreference resolution task, effectively improve the model's processing ability for the coreference resolution task, and can effectively enrich the functions of the natural language processing model and enhance the practicality of the natural language processing model.

[0128] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.

[0129] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.

Claims

1. A method for training a natural language processing model, wherein: The method comprises: Based on a preset corpus set, constructing various training corpus pairs for the coreference resolution task, each of the training corpus pairs including a positive sample and a negative sample; In the pre-training stage, each of the training corpus pairs is used to train the natural language processing model so that it learns the ability to recognize the corresponding positive samples and negative samples; In the fine-tuning stage, the positive samples of each training corpus pair are used to train the natural language processing model so that it can learn the ability of the coreference resolution task; Among them, based on the preset corpus set, various training corpus pairs for the coreference resolution task are constructed, including: For each piece of corpus in the preset corpus set, replacing the target noun that does not appear for the first time in the corresponding corpus with a pronoun as training corpus; Obtaining other nouns from the training corpus; The training corpus and the referential relationship between the pronoun and the target noun are used as positive samples of the training corpus pair; The training corpus and the referential relationship between the pronoun and the other noun are used as negative samples of the training corpus pair; The positive samples of each training corpus pair are used to train the natural language processing model so that it can learn the ability of the coreference resolution task, including: Masking the pronouns in the training corpus of the positive sample of each training corpus pair; Inputting the training corpus after the pronouns are masked into the natural language processing model, so that the natural language processing model predicts the probability that the pronouns belong to each noun in the training corpus; Generate a target loss function based on the natural language processing model predicting the probability that the pronoun belongs to each noun in the training corpus and the target noun referred to by the pronoun identified in the positive sample; Determining whether the target loss function converges; If convergence has not occurred, the parameters of the natural language processing model are adjusted based on the gradient descent method.

2. The method according to claim 1, wherein: Using each of the training corpus pairs to train the natural language processing model so that it learns the ability to identify the corresponding positive samples and negative samples, including: Inputting each of the training corpus pairs into the natural language processing model, so that the natural language processing model learns to predict whether the reference relationship in the positive sample and the negative sample is correct; When the prediction is wrong, the parameters of the natural language processing model are adjusted so that the natural language processing model is adjusted in a direction of correctly predicting the referential relationship between the positive sample and the negative sample.

3. The method according to claim 1, wherein: The target loss function is generated based on the natural language processing model predicting the probability that the pronoun belongs to each noun in the training corpus and the target noun referred to by the pronoun identified in the positive sample, including: Based on the target noun referred to by the pronoun identified in the positive sample, obtaining the probability that the natural language processing model predicts that the pronoun belongs to the target noun; Predicting the probability that the pronoun belongs to the target noun based on the natural language processing model, and constructing a first loss function; Constructing a second loss function based on the natural language processing model to predict the probability that the pronoun belongs to other nouns other than the target noun; The target loss function is generated based on the first loss function and the second loss function.

4. A training device for a natural language processing model, wherein: The device comprises: A construction module, used to construct various training corpus pairs for the reference resolution task based on a preset corpus set, wherein each training corpus pair includes a positive sample and a negative sample; A first training module is used to train the natural language processing model using each of the training corpus pairs in a pre-training stage, so that the model can learn to recognize the corresponding positive samples and negative samples; A second training module is used to train the natural language processing model using positive samples of each training corpus pair in the fine-tuning stage, so that it can learn the ability of the coreference resolution task; Wherein, the building blocks include: A replacement unit, configured to replace, for each piece of corpus in the preset corpus set, a target noun that does not appear for the first time in the corresponding piece of corpus with a pronoun as training corpus; An acquisition unit, used for acquiring other nouns from the training corpus; A setting unit, configured to use the training corpus and the referential relationship between the pronoun and the target noun as positive samples of the training corpus pair; The setting unit is further used to use the training corpus and the referential relationship between the pronoun and the other noun as negative samples of the training corpus pair; Wherein, the second training module includes: A masking unit, used for masking the pronouns in the training corpus of the positive sample of each training corpus pair; A second prediction unit, configured to input the training corpus after the pronouns are masked into the natural language processing model, so that the natural language processing model predicts the probability that the pronouns belong to each noun in the training corpus; A generating unit, configured to predict the probability that the pronoun belongs to each noun in the training corpus and the target noun referred to by the pronoun identified in the positive sample based on the natural language processing model, and generate a target loss function; A detection unit, used to determine whether the target loss function converges; The second adjustment unit is used to adjust the parameters of the natural language processing model based on the gradient descent method if convergence has not occurred.

5. The device according to claim 4, wherein: The first training module includes: A first prediction unit, configured to input each of the training corpus pairs into the natural language processing model, so that the natural language processing model learns to predict whether the reference relationship in the positive sample and the negative sample is correct; The first adjustment unit is used to adjust the parameters of the natural language processing model when a prediction error occurs, so that the natural language processing model is adjusted in a direction of correctly predicting the reference relationship between the positive sample and the negative sample.

6. The device according to claim 4, wherein: The generating unit is used for: Based on the target noun referred to by the pronoun identified in the positive sample, obtaining the probability that the natural language processing model predicts that the pronoun belongs to the target noun; Predicting the probability that the pronoun belongs to the target noun based on the natural language processing model, and constructing a first loss function; Constructing a second loss function based on the natural language processing model to predict the probability that the pronoun belongs to other nouns other than the target noun; The target loss function is generated based on the first loss function and the second loss function.

7. An electronic device, wherein: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 3.

8. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 3.

9. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 3.