Text translation method, text translation model training method and device

By generating multiple candidate translations in the training phase of the diversity machine translation model, and adjusting parameters according to diversity and quality rewards, the problem of inconsistent translation generation in the training and application phases in the existing technology is solved, and the quality and diversity of translations are improved.

CN114781405BActive Publication Date: 2024-10-22ALIBABA (CHINA) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing diversity machine translation models use one-to-one training corpus in the training stage, resulting in one-to-many translation generation in the application stage, which affects the quality of the translation.

Method used

By generating multiple candidate translations during the model training phase, and adjusting model parameters based on diversity rewards and quality rewards, we ensure consistency between the training and testing phases and improve translation quality.

Benefits of technology

It improves the quality of the translations output by the text translation model, balances the diversity and quality of the translations, and ensures that the generated translations are more diverse and high-quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114781405B_ABST
    Figure CN114781405B_ABST
Patent Text Reader

Abstract

One or more embodiments of the present specification provide a text translation method, a training method and device for a text translation model, wherein the training method for the text translation model includes: for any sample original sentence in a training set, outputting K candidate translations corresponding to the sample original sentence through the text translation model to be trained, wherein K is a natural number greater than or equal to 2; the training set includes multiple sample original sentences; for any candidate translation among the K candidate translations, obtaining a diversity reward and a quality reward corresponding to the candidate translation; the diversity reward is used to measure the degree of diversity of the candidate translation; the quality reward is used to measure the translation quality of the candidate translation; according to the diversity rewards and quality rewards of the K candidate translations corresponding to each sample original sentence in the training set, respectively, determining a training objective function, and adjusting the model parameters of the text translation model based on the training objective function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present specification relate to the field of video processing technology, and more particularly to a text translation method, a text translation model training method and device. Background Art

[0002] In recent years, neural networks have made great progress and development, and have been applied to many fields and scenarios. Among them, neural networks are applied to perform translation tasks, namely neural machine translation (NMT). This neural machine translation can use neural networks to automatically complete the conversion between different human languages. It is an important research task in artificial intelligence natural language processing and is also a popular application on the Internet. Neural machine translation has great advantages in the accuracy and fluency of translation results, and has achieved remarkable results.

[0003] In the related art, neural machine translation can generate multiple translations that are consistent with the original meaning and have great differences based on an original text in some scenarios. This method can be called "diversity machine translation". The above-mentioned diversity translation can be performed based on the diversity machine translation model. However, during the training phase, the diversity machine translation model is trained with one-to-one training corpus, in which there is only one correct reference translation for each original text. The reference translation is the correct translation answer corresponding to the original text, which can usually be obtained by manual translation by professional translators based on the original text. This method of using one-to-one training corpus in the training phase and performing one-to-many translation generation in the model application phase will affect the quality of translation generation. Summary of the invention

[0004] In view of this, one or more embodiments of the present specification provide a text translation method, a text translation model training method and a device to improve the translation quality of diverse text translation.

[0005] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:

[0006] According to a first aspect of one or more embodiments of this specification, a method for training a text translation model is proposed, the method comprising:

[0007] For any sample original sentence in the training set, output K candidate translations corresponding to the sample original sentence through the text translation model to be trained, where K is a natural number greater than or equal to 2; the training set includes multiple sample original sentences;

[0008] For any candidate translation among the K candidate translations, obtain a diversity reward and a quality reward corresponding to the candidate translation; the diversity reward is used to measure the diversity degree of the candidate translation; the quality reward is used to measure the translation quality of the candidate translation;

[0009] A training objective function is determined according to the diversity rewards and quality rewards of the K candidate translations corresponding to each sample original sentence in the training set, and a model parameter of the text translation model is adjusted based on the training objective function.

[0010] According to a second aspect of one or more embodiments of this specification, a text translation method is proposed, the method comprising:

[0011] Input the original sentence to be translated into the text translation model;

[0012] The original sentence is translated by the text translation model to obtain K candidate translations output by the text translation model; the text translation model is obtained by any embodiment of this specification.

[0013] According to a third aspect of one or more embodiments of this specification, a training device for a text translation model is provided, the device comprising:

[0014] A translation output module is used to output K candidate translations corresponding to any sample original sentence in the training set through the text translation model to be trained, where K is a natural number greater than or equal to 2; the training set includes multiple sample original sentences;

[0015] A reward determination module, for obtaining, for any candidate translation among the K candidate translations, a diversity reward and a quality reward corresponding to the candidate translation; the diversity reward is used to measure the degree of diversity of the candidate translation; the quality reward is used to measure the translation quality of the candidate translation;

[0016] The parameter adjustment module is used to determine the training objective function according to the diversity rewards and quality rewards of the K candidate translations corresponding to each sample original sentence in the training set, and adjust the model parameters of the text translation model based on the training objective function.

[0017] According to a fourth aspect of one or more embodiments of this specification, a text translation device is provided, the device comprising:

[0018] This receiving module is used to input the original sentence to be translated into the text translation model;

[0019] A translation processing module is used to perform translation processing on the original sentence through the text translation model to obtain K candidate translations output by the text translation model; the text translation model is trained by the method described in any embodiment of this specification.

[0020] According to a fifth aspect of one or more embodiments of this specification, an electronic device is provided, the device comprising:

[0021] processor;

[0022] a memory for storing processor-executable instructions;

[0023] The processor implements the method described in any embodiment of this specification by running the executable instructions.

[0024] According to a sixth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the method described in any embodiment of the present specification is implemented.

[0025] The text translation method, text translation model training method and device described in the embodiments of this specification generate multiple candidate translations corresponding to the sample original sentence in the training stage of the model, and determine the training objective function according to the diversity reward and quality reward of the multiple candidate translations, so that multiple candidate translations participate in the parameter adjustment of the model in the model training stage, so that the text translation model is also in a one-to-many form in the training stage and the test stage, maintaining the consistency of training and testing, which helps to improve the quality of the translation output by the text translation model; and it can also be seen that in the model training process, the diversity reward and quality reward of the model are taken into account at the same time, and the diversity reward and quality reward are used to help the model adjust the generation of the translation in the framework of reinforcement learning, which helps to make the translation generated by the model more diverse and of higher quality, while taking into account and balancing the diversity and quality of the translation. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in one or more embodiments of the present disclosure or related technologies, the drawings required for use in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in one or more embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0027] Figure 1 is a flowchart of a method for training a text translation model provided by an exemplary embodiment;

[0028] Figure 2 It is a training framework principle of reinforcement learning provided by an exemplary embodiment;

[0029] Figure 3 A process for determining a diversity reward for candidate translations provided by an exemplary embodiment;

[0030] Figure 4 A process for determining a quality reward for a candidate translation is provided by an exemplary embodiment;

[0031] Figure 5 is a flowchart of a text translation method provided by an exemplary embodiment;

[0032] Figure 6 It is a structural schematic diagram of a training device for a text translation model provided by an exemplary embodiment;

[0033] Figure 7 is a structural schematic diagram of a text translation device provided by an exemplary embodiment;

[0034] Figure 8 It is a schematic structural diagram of an electronic device provided by an exemplary embodiment. DETAILED DESCRIPTION

[0035] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the attached claims.

[0036] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.

[0037] The embodiments of this specification provide a method for training a text translation model, in which a corresponding plurality of candidate translations can be generated after an original sentence is translated by the text translation model. Furthermore, the plurality of candidate translations can participate in constructing the objective function of the model training, so that in the training scenario of the model, there is also a one-to-many form of multiple translations of an original sentence, which is consistent with the one-to-many form of diverse translations in the model application process. This helps to improve the quality of the translations generated by the model and better balance the quality and diversity of the translations.

[0038] Figure 1 is a flowchart of a method for training a text translation model provided by an exemplary embodiment. Figure 1 As shown, the process may include the following processing:

[0039] In step 100, for any sample original sentence in the training set, the text translation model to be trained outputs K candidate translations corresponding to the sample original sentence, where K is a natural number greater than or equal to 2; the training set includes multiple sample original sentences.

[0040] In step 102, for any candidate translation among the K candidate translations, a diversity reward and a quality reward corresponding to the candidate translation are obtained; the diversity reward is used to measure the diversity degree of the candidate translation; and the quality reward is used to measure the translation quality of the candidate translation.

[0041] In step 104, a training objective function is determined according to the diversity rewards and quality rewards of the K candidate translations corresponding to the sample original sentences in the training set, and the model parameters of the text translation model are adjusted based on the training objective function.

[0042] The above process is described in detail as follows:

[0043] In this embodiment, the text translation model is used to generate a corresponding translation according to the original sentence, and the model can be an NMT model. Exemplarily, the NMT model can adopt an encoder-decoder framework. For example, the model can include an embedding layer embedding, a classification layer classifier, an encoder network encoder and a decoder network decoder. The network form of the encoder network and the decoder network includes but is not limited to structures such as a recursive neural network RNN, a convolutional neural network CNN and a self-attention network SAN.

[0044] This embodiment uses a reinforcement learning training framework to train the text translation model. Figure 2 The training framework principle of the reinforcement learning of this embodiment is illustrated. Figure 2As shown in the figure, the text translation model is equivalent to the "Agent" in the reinforcement learning framework. The text translation model generates K corresponding translations based on the original sentence to be translated. The processing is equivalent to the "action" performed by the Agent in the reinforcement learning framework. (n) The original sentence to be translated can be equivalent to the "state" in reinforcement learning. The "environment" in the reinforcement learning framework can calculate the reward that the agent can obtain based on the above K translations (reward calculation). The agent can adjust the processing of generating translations for subsequent original sentences based on the rewards obtained.

[0045] Next, we will combine Figure 1 The training method described in detail is based on Figure 2 The reinforcement learning framework shown is used to train a text translation model.

[0046] First, the training sample set for training the text translation model can be divided into multiple batches. In this embodiment, each batch is referred to as a training set. Each training set can include multiple original sentences to be translated. In this embodiment, the original sentences to be translated used in the training stage are referred to as "sample original sentences". For example, each training set can have 200 sample original sentences.

[0047] In step 100, for one of the training sets, a sample original sentence in the training set is input into the text translation model, and the text translation model can output K candidate translations corresponding to the sample original sentence. Since the text translation model of this embodiment is a model of diverse machine translation, in the training stage, the model can select and generate the top K candidate translations according to the ranking from high to low of the prediction probability, where K is a natural number greater than or equal to 2.

[0048] Exemplarily, assuming that the text translation model is applied to translate English into Chinese, and assuming that the sample original sentence is an English sentence, the corresponding generated K candidate translations in Chinese may include: "these two people look different", "these two people look very different", "these two people have few similarities in appearance", etc. That is, the meanings of the multiple candidate translations are consistent with the intention, but the expressions may have great differences. Among them, the generation of the K candidate translations can be carried out in a variety of ways, which are not limited in this embodiment. For example, the beam search algorithm can be used to generate the above K candidate translations.

[0049] Please refer to Figure 2 As shown, the K candidate translations generated by the above model can be expressed as follows: Among them, n means that the current sample original sentence is the nth sentence in the training set, x (n) That is, it represents the nth sample original sentence in the training set. It indicates that it is the kth candidate translation among the K candidate translations. In this embodiment, each sample original sentence in the training set can generate corresponding K candidate translations. For example, when each training set includes 200 sample original sentences, each sample original sentence can output K candidate translations corresponding to the sample original sentence through the text translation model.

[0050] In step 102, taking K candidate translations corresponding to a sample original sentence as an example: for any candidate translation among the K candidate translations, the diversity reward and quality reward corresponding to the candidate translation can be calculated. The diversity reward is used to measure the diversity of the candidate translation, and the quality reward is used to measure the translation quality of the candidate translation.

[0051] Specifically, in the training phase of the text translation model, the goal of the training is to make the K candidate translations generated by the model have as large a difference as possible. The diversity is used to indicate whether the difference between the candidate translation and other translations is significant. For example, taking the four candidate translations w1, w2, w3 and w4 as examples, if w1 is more different in expression than the other translations "w2, w3 and w4", it can be said that the diversity of the translation w1 is higher; otherwise, the diversity of the translation w1 is lower. Based on this, the present embodiment defines "diversity rewards", which are used to measure the degree of diversity of the candidate translations. For example, if a candidate translation is more different from other translations, that is, the diversity of the candidate translation is higher, correspondingly, the higher the diversity reward corresponding to the candidate translation is.

[0052] In this embodiment, a diversity reward for a candidate translation can be determined in the following manner: Figure 3 As shown, the Figure 3 The following is an example of the process of determining the diversity reward for candidate translations.

[0053] In step 300, the sub-matching degree between the candidate translation and any translation in the other translation sets is obtained respectively.

[0054] Among them, still combined Figure 2 For example, the sample original sentence x (n) After translation processing by the text translation model, the corresponding K candidate translations are obtained Assume that the current calculation is Corresponding diversity rewards.

[0055] Among them, the sample original sentence x (n) Also includes the corresponding reference translation y n , for example, the reference translation y nIt can be translated by professional translators based on the sample original sentence x (n) The correct translation answer obtained by manual translation, and the candidate translations mentioned above It is the translation generated by the text translation model.

[0056] For candidate translations For example, the other translation set may include at least one of the following: the sample original sentence x (n) Corresponding reference translation, and sample original sentence x (n) The corresponding K candidate translations except the candidate translation For example, Other candidate translations may include

[0057] In this step, candidate translations can be calculated The degree of match between a translation and any translation in the other translation sets may be referred to as a sub-match. The sub-match may be a measure of the difference between translations, and the sub-match may be calculated using the following indicators: Moving-Average Type-Token Ratio, BLEU, distinct indicators, etc.

[0058] For example, candidate translations can be calculated and candidate translations The sub-matching degree between BLEU Can also calculate candidate translations and candidate translations The sub-matching degree between BLEU And so on. That is, the candidate translations can be calculated separately With other translation collections In addition, it is also possible to calculate the sub-matching degree between any candidate translations in With reference translation n The sub-matching degree between .

[0059] In step 302, the matching degree between the candidate translation and other translation sets is obtained according to each of the sub-matching degrees.

[0060] In this step, the sub-matching degrees between the candidate translation currently being calculated and other translations can be synthesized on the basis of step 300 to obtain the matching degree between the candidate translation and other translation sets. That is, the matching degree is obtained by synthesizing the above-mentioned sub-matching degrees, for example, the matching degree can be obtained by weighted averaging the sub-matching degrees.

[0061] In step 304, a diversity reward corresponding to the candidate translation is determined based on the matching degree, such that the diversity reward is negatively correlated with the matching degree.

[0062] For example, as mentioned above, the diversity reward defined in this embodiment is used to measure the diversity of candidate translations. If the candidate translation is more different from other translations, the higher the diversity, the higher the diversity reward corresponding to the candidate translation. As for the matching degree, for example, the sub-matching degree between different translations mentioned above, if the sub-matching degree is higher, it means that the two translations are more similar and the difference is smaller. For example, if BLEU is used to measure the sub-matching degree between two translations, then the greater the difference between the two translations, the smaller the BLEU value. In order to be applied to the framework of reinforcement learning (reinforcement learning usually pursues higher "rewards"), this embodiment sets the diversity reward to be negatively correlated with the matching degree, that is, the lower the matching degree, the higher the diversity reward, so that it can meet the trend design that the greater the difference between the translations, the higher the diversity reward.

[0063] Based on the above Figure 3 The process shown in the figure, this embodiment provides an exemplary formula for diversity reward:

[0064]

[0065] As shown in the above formula (1), taking the BLEU indicator as an example, DR represents diversity reward, BLEU s Represents the sentence-level BLEU metric. Represents the candidate translation for the current calculation of diversity reward, y (n) Represents the reference translation corresponding to the sample original sentence. Indicates that among the K candidate translations corresponding to the sample original sentence, except for the current candidate translation The set of other candidate translations except . k represents the kth candidate translation among K candidate translations, and n represents that the sample original sentence corresponding to the current candidate translation is the nth training sample in the training set.

[0066] in, This means calculating candidate translations The matching degree between the reference translation y and other translation sets. (n) ,as well as For example, candidate translations can be calculated separately After the sub-matching degree between the candidate translation and any translation in the above translation set is obtained, these sub-matching degrees can be weighted averaged to obtain the matching degree. And, according to formula (1), if the candidate translation The higher the difference between the translations in the other translation sets, the smaller the BLEU match. The bigger it is.

[0067] On the other hand, during the training phase of the text translation model, the training goal for the translation quality is to make the quality of each candidate translation generated by the model as high as possible. In this embodiment, the quality reward (QualityRewards) is set to measure the translation quality of the candidate translation, so that the higher the translation quality, the higher the quality reward.

[0068] In this embodiment, the quality reward of a candidate translation can be determined in the following manner: Figure 4 As shown, FIG. 4 illustrates the process of determining the quality reward of the candidate translations.

[0069] In step 400, the candidate translation is reversely translated to obtain a reverse original sentence.

[0070] In this step, the candidate translation for the current quality reward calculation can be reverse translated. The "reverse translation" mentioned here means: assuming that the corresponding candidate translation (Chinese) is obtained by translating the sample original sentence (English), the reverse translation is to translate the candidate translation (Chinese) into the corresponding English original sentence, that is, the candidate translation obtained by translating from English to Chinese. The reverse translation is to translate from Chinese to English and then back to the corresponding English expression.

[0071] For example, the reverse translation may be performed by a pre-trained reverse translation model. In addition, in this embodiment, the sentence obtained by reverse translation of the candidate translation may be referred to as the reverse original sentence.

[0072] In step 402, based on the difference between the reverse original sentence and the sample original sentence, a quality reward corresponding to the candidate translation is obtained.

[0073] For example, if the reverse original sentence is more similar to the sample original sentence corresponding to the candidate translation and the difference is smaller, the quality reward obtained will be higher. Conversely, if the difference between the reverse original sentence and the sample original sentence is greater, the quality reward obtained will be lower.

[0074] Based on the above Figure 4 The process shown in this embodiment provides an exemplary formula for quality reward:

[0075]

[0076] As shown in the above formula (2), still taking the BLEU indicator as an example, QR represents diversity reward, BLEU s Represents the sentence-level BLEU metric. Representatives will be candidate translation The reverse original sentence obtained by reverse translation. (n) Representative candidate translation The corresponding sample original sentence. According to this formula, if With x (n) The smaller the difference, the better the candidate translation. The higher the translation quality, the higher the corresponding quality reward The higher too.

[0077] In addition to the above-mentioned BLEU indicator for calculating quality rewards, YiSi, COMET, BLEURT, etc. can also be used.

[0078] As mentioned above, a training set includes multiple sample original sentences, each of which can generate K corresponding candidate translations through the text translation model. For each candidate translation, Figure 3 and Figure 4 The diversity reward and quality reward corresponding to the candidate translation are generated in this way.

[0079] In step 104, the diversity bonus and quality bonus of each candidate translation obtained by the above calculation can be used to determine the objective function for training the text translation model. This is equivalent to that multiple candidate translations corresponding to each sample original sentence are all involved in the training of the text translation model, which is similar to forming a "one-to-many" form in the training stage.

[0080] In addition, it should be noted that the determination of the training objective function according to the diversity rewards and quality rewards of the K candidate translations corresponding to each sample original sentence in step 104 of this embodiment may involve both the diversity rewards and quality rewards of the K candidate translations in constructing the objective function, or may involve the diversity rewards and quality rewards of some of the K candidate translations in constructing the objective function, for example, selecting the rewards of the candidate translations with higher confidence levels for constructing the objective function, which is not limited in this embodiment and is included in the protection scope of this specification.

[0081] In addition, the determination of the training objective function according to the diversity reward and quality reward of the K candidate translations corresponding to each sample original sentence in the training set described in step 104 of the embodiment includes: in addition to the rewards of the K candidate translations or some of the candidate translations participating in the construction of the objective function, other information may also participate in the construction of the objective function. For example, the training objective function can be determined together with the reference translations corresponding to each sample original sentence in the training set, and the diversity reward and quality reward of the K candidate translations. That is, the basis parameters of this embodiment when constructing the objective function do not limit other parameters other than the reward of the candidate translation. In addition, since the translation quality of the reference translation is high, the reference translation is also involved in the construction of the objective function, which helps to improve the training effect of the text translation model. In the embodiments of this specification, the training objective function is determined according to the rewards of the reference translation and K candidate translations as an example.

[0082] In this embodiment, the training objective function may include two parts: a first objective item and a second objective item.

[0083] The first target item may be determined based on the reference translation corresponding to each sample original sentence in the training set. In the following example, the first target item is used to indicate the probability of obtaining the corresponding reference translation based on the sample original sentence.

[0084] For example, the following formula (3) illustrates the first target term:

[0085] First target item:

[0086] The first target item may be a training target based on maximum likelihood estimation, where N represents the number of sample original sentences included in the training set, and x (n) is the nth sample original sentence in the training set, y (n) is the sample original sentence x (n) The corresponding reference translation. θ is the model parameter of the text translation model. As shown in formula (3), according to the sample original sentence x (n) Get the corresponding reference translation y (n) The greater the probability, the smaller the first target item is, which is equivalent to the loss. Training the text translation model reduces the loss.

[0087] The second target item may be determined based on the diversity reward and quality reward of the K candidate translations corresponding to each sample original sentence in the training set. In the following example, the second target item is used to represent the probability of obtaining the corresponding candidate translation based on the sample original sentence.

[0088] This embodiment illustrates two methods for determining the second target item, which are not limited to the above in actual implementation:

[0089] Method 1: Please refer to formula (4):

[0090] Second target item:

[0091] in, The values ​​of are as follows:

[0092] If the candidate translation Diversity Awards Less than the diversity threshold γ d , or candidate translations Quality Rewards Less than the quality threshold γ q ,but The value is 0. Otherwise, The value is 1.

[0093] In addition, the meanings of other parameters in formula (4) can be referred to above. For example, N means that a training set includes N sample original sentences, K means that K candidate translations are generated, and x (n) Represents the nth sample original sentence in the training set.

[0094] According to the above formula (4), the present embodiment can select some candidate translations from the K candidate translations corresponding to each sample original sentence as target candidate translations according to the diversity reward and quality reward of each candidate translation, wherein the target candidate translation is a translation that meets the diversity and / or quality conditions; and then determine the second target item based on the probability of obtaining the target candidate translation from the sample original sentence.

[0095] For example, the above The condition that the value of satisfies is the candidate translation Diversity reward above or equal to diversity threshold γ d , and the quality reward is higher than or equal to the quality threshold γ q , when both of these are satisfied, the candidate translation As the target candidate translation, The value is 1. When the value is 1, can participate in the construction of the objective function. Otherwise, if the candidate translation Diversity rewards fall below a diversity threshold, or quality rewards fall below a quality threshold, The value is 0.

[0096] In addition to the above-mentioned diversity and / or quality conditions, other diversity and / or quality conditions may be set. For example, when the candidate translation Diversity reward above or equal to diversity threshold γ d, or, the quality reward is higher than or equal to the quality threshold γ q , that is, as long as one of the diversity reward and quality reward is higher than the corresponding threshold, the candidate translation can be This is also possible as a target candidate translation.

[0097] Method 2: Please refer to formula (5):

[0098] Second target item: R d (θ)+R q (θ)………………(5)

[0099] Among them, the above R d (θ) is the translation diversity risk value, R q (θ) is the translation quality risk value. The second target item “R d (θ)+R q (θ)”.

[0100] The above translation diversity risk value R d (θ) may be obtained by the diversity risk value of the candidate translations corresponding to each sample original sentence in the comprehensive training set. The diversity risk value of the candidate translation may be obtained based on the diversity reward of the candidate translation, satisfying: the higher the diversity reward of the candidate translation, the lower the conditional probability of generating the candidate translation based on the sample original sentence represented by the diversity risk value.

[0101] The R d The calculation of (θ) can refer to the following formula (6), wherein the meaning of each parameter in the formula is as mentioned above.

[0102]

[0103] According to formula (6), the candidate translation Diversity Awards The higher the candidate translation Diversity Value at Risk The smaller. It means that the diversity risk values ​​of each candidate translation corresponding to each sample original sentence in the training set are added together, and finally the translation diversity risk value R is obtained. d (θ).

[0104] Similarly, the above translation quality risk value R q (θ) can be obtained by the quality risk value of the candidate translation corresponding to each sample original sentence in the comprehensive training set. Among them, the quality risk value of the candidate translation can be obtained based on the quality reward of the candidate translation, satisfying: the higher the quality reward of the candidate translation, the lower the conditional probability of generating the candidate translation based on the sample original sentence represented by the quality risk value.

[0105] The R q The calculation of (θ) can refer to the following formula (7), wherein the meaning of each parameter in the formula is as mentioned above.

[0106]

[0107] According to formula (7), the candidate translation Quality Rewards The higher the candidate translation Quality risk value The smaller. It means that the quality risk values ​​of each candidate translation corresponding to each sample original sentence in the training set are added together, and finally the translation quality risk value R is obtained. q (θ).

[0108] On the basis of the above description of the first target item and the second target item, an objective function for training the text translation model may be determined based on the first target item and the second target item.

[0109] Objective function 1:

[0110]

[0111] Objective function 2:

[0112]

[0113] The above objective function 1 or objective function 2 can be used as a training objective function to update the model parameters of the text translation model.

[0114] It should be noted that the above objective function formulas (8) and (9) are only examples, and in actual implementation, they are not limited to the form of these objective functions. For example, classification loss functions such as classification error rate and mean square error can also be used.

[0115] In addition, according to the formula of the above objective function, it can be seen that a training set can be regarded as a batch. After the diversity reward and quality reward of each candidate translation corresponding to each sample original sentence in the training set are calculated, the rewards of these candidate translations in the training set are combined to calculate the objective function shown in the above formula (8) or (9), and the model parameters are updated once. Then, continue to perform the same processing on the next training set. For example, for each sample original sentence in the next training set, the text translation model outputs the corresponding K candidate translations, and the diversity reward and quality reward of each candidate translation are calculated respectively. The samples in the training set are combined to obtain the objective function and update the model parameters. This iteration is repeated many times until the model training end condition is met, and the model training is terminated.

[0116] The training method of the text translation model of the embodiment of the present specification generates multiple candidate translations corresponding to the sample original sentence in the training stage of the model, and determines the training objective function according to the diversity reward and quality reward of the multiple candidate translations, so that multiple candidate translations participate in the parameter adjustment of the model in the model training stage, so that the text translation model is also in a one-to-many form in the training stage and the test stage, maintaining the consistency of training and testing, which helps to improve the quality of the translation output by the text translation model; and it can also be seen that in the model training process, the diversity reward and quality reward of the model are taken into account at the same time, and the diversity reward and quality reward are used to help the model adjust the generation of the translation in the framework of reinforcement learning, which helps to make the translation generated by the model more diverse and of higher quality, while taking into account and balancing the diversity and quality of the translation.

[0117] Figure 5 FIG. 1 is a flowchart of a text translation method provided by an exemplary embodiment. In this embodiment, a trained text translation model can be used for translation. Figure 5 As shown, the process may include the following processing:

[0118] In step 500, an original sentence to be translated is input into a text translation model.

[0119] The text translation model is trained by the text translation model training method described in any embodiment of this specification.

[0120] In step 502, the original sentence is translated by the text translation model to obtain K candidate translations output by the text translation model.

[0121] Among them, the K candidate translations output by the text translation model may not be obtained at the same time. The K candidate translations may be output simultaneously or separately in different scenarios, and this embodiment does not limit this. For example, the text translation model has the ability to output K candidate translations simultaneously, but in some scenarios, the user may not need to see these K candidate translations at the same time, and some users only want to see one of the candidate translations that conforms to their own language habits. At this time, according to some restrictive conditions (for example, user characteristics), only some of the candidate translations corresponding to the conditions can be output.

[0122] For example, taking selection based on user characteristics as an example, the user characteristics may be the user's geographical location, such as "City A", "City B", etc. For users in City A, candidate translation Y1 may be output, and for users in City B, candidate translation Y2 may be output. However, in fact, the text translation model is capable of outputting K candidate translations at the same time, and the candidate translations Y1 and Y2 may be two of the K candidate translations. At this time, only some of the candidate translations are selectively output or displayed based on the user characteristics.

[0123] The text translation method of the embodiment of the present specification generates multiple candidate translations corresponding to the sample original sentence in the training phase, and the multiple candidate translations all participate in the parameter adjustment of the model, so that the text translation model is consistent in the training phase and the test phase, thereby improving the quality of the translation output by the text translation model; and in the model training process, the diversity reward and quality reward of the model are considered at the same time, and the diversity reward and quality reward are used to help the model adjust the generation of the translation, so that when the trained model is used to generate the translation, the diversity and quality of the translation are good.

[0124] Figure 6 An exemplary text translation model training device is provided, which can be used to implement the text translation model training method of any embodiment of this specification. Figure 6 As shown, the device may include: a translation output module 61, a reward determination module 62 and a parameter adjustment module 63.

[0125] The translation output module 61 is used to output K candidate translations corresponding to any sample original sentence in the training set through the text translation model to be trained, where K is a natural number greater than or equal to 2; the training set includes multiple sample original sentences.

[0126] The reward determination module 62 is used to obtain a diversity reward and a quality reward corresponding to any candidate translation among the K candidate translations; the diversity reward is used to measure the diversity degree of the candidate translation; and the quality reward is used to measure the translation quality of the candidate translation.

[0127] The parameter adjustment module 63 is used to determine the training objective function according to the diversity rewards and quality rewards of the K candidate translations corresponding to each sample original sentence in the training set, and adjust the model parameters of the text translation model based on the training objective function.

[0128] In one example, the reward determination module 62, when used to obtain the diversity reward and quality reward corresponding to the candidate translation, includes: respectively obtaining the sub-matching degree between the candidate translation and any translation in the other translation set, the other translation set including at least a part of the following: the reference translation corresponding to the sample original sentence, and the candidate translations other than the candidate translation in the K candidate translations; obtaining the matching degree between the candidate translation and the other translation sets according to each of the sub-matching degrees; and determining the diversity reward corresponding to the candidate translation based on the matching degree, so that the diversity reward is negatively correlated with the matching degree.

[0129] In one example, the reward determination module 62, when used to obtain the diversity reward and quality reward corresponding to the candidate translation, includes: reverse translating the candidate translation to obtain a reverse original sentence; and obtaining the quality reward corresponding to the candidate translation based on the difference between the reverse original sentence and the sample original sentence.

[0130] In one example, the parameter adjustment module 63, when used to determine the training objective function according to the diversity rewards and quality rewards of the K candidate translations corresponding to each sample original sentence in the training set, and adjust the model parameters of the text translation model based on the training objective function, includes: determining a first objective item according to the reference translations corresponding to each sample original sentence in the training set; determining a second objective item according to the diversity rewards and quality rewards of the K candidate translations corresponding to each sample original sentence in the training set; and determining the objective function for training the text translation model based on the first objective item and the second objective item.

[0131] In one example, the parameter adjustment module 63, when used to determine the second target item based on the diversity rewards and quality rewards of the K candidate translations corresponding to the sample original sentences in the training set, includes: selecting some candidate translations from the K candidate translations corresponding to the sample original sentences as target candidate translations based on the diversity rewards and quality rewards of the respective candidate translations, the target candidate translations being translations that meet the diversity and / or quality conditions; and determining the second target item based on the target candidate translations.

[0132] In one example, the parameter adjustment module 63, when used to select some candidate translations from K candidate translations corresponding to each sample original sentence as target candidate translations, includes: in response to the diversity reward of the candidate translation being higher than or equal to the diversity threshold, and the quality reward being higher than or equal to the quality threshold, taking the candidate translation as the target candidate translation; or, in response to the diversity reward of the candidate translation being higher than or equal to the diversity threshold, or the quality reward being higher than or equal to the quality threshold, taking the candidate translation as the target candidate translation.

[0133] In one example, the parameter adjustment module 63, when used to determine the second target item based on the diversity rewards and quality rewards of K candidate translations corresponding to each sample original sentence in the training set, includes: obtaining a translation diversity risk value by comprehensively analyzing the diversity risk values ​​of the candidate translations corresponding to each sample original sentence in the training set, the diversity risk value of the candidate translations being obtained based on the diversity rewards of the candidate translations, and the higher the diversity reward of the candidate translations, the lower the diversity risk value; obtaining a translation quality risk value by comprehensively analyzing the quality risk values ​​of the candidate translations corresponding to each sample original sentence in the training set, the quality risk value of the candidate translations being obtained based on the quality rewards of the candidate translations, and the higher the quality rewards of the candidate translations, the lower the quality risk value; and determining the second target item based on the translation diversity risk value and the translation quality risk value.

[0134] Figure 7 An exemplary text translation device is provided, which can be used to implement the text translation method of any embodiment of this specification. Figure 7 As shown, the device may include: a text receiving module 71 and a translation processing module 72.

[0135] The text receiving module 71 is used to input the original sentence to be translated into the text translation model.

[0136] The translation processing module 72 is used to perform translation processing on the original sentence through the text translation model to obtain K candidate translations output by the text translation model; the text translation model is trained by the text translation model training method described in any embodiment of this specification.

[0137] Figure 8 is a schematic structural diagram of an electronic device provided by an exemplary embodiment. Figure 8At the hardware level, the device includes a processor 802, an internal bus 804, a network interface 806, a memory 808, and a non-volatile memory 810, and may also include other hardware. One or more embodiments of this specification may be implemented based on software, such as the processor 802 reading the corresponding computer program from the non-volatile memory 810 into the memory 808 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but may also be hardware or logic devices.

[0138] The text translation device or text translation model training device of the embodiment of this specification can be applied to Figure 8 In the electronic device shown, the technical solution of this specification is implemented.

[0139] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.

[0140] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0141] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0142] The embodiments of this specification also provide a computer-readable storage medium on which computer instructions are stored. When the instructions are executed by a processor, the text translation method or the text translation model training method described in any embodiment of this specification is implemented.

[0143] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0144] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity or device including the element.

[0145] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0146] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0147] It should be understood that, although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0148] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.

Claims

1. A training method for a text translation model, characterized in that: The method comprises: For any sample original sentence in the training set, output K candidate translations corresponding to the sample original sentence through the text translation model to be trained, where K is a natural number greater than or equal to 2; the training set includes multiple sample original sentences; For any candidate translation among the K candidate translations, obtain a diversity reward and a quality reward corresponding to the candidate translation; the diversity reward is used to measure the diversity degree of the candidate translation; the quality reward is used to measure the translation quality of the candidate translation; A training objective function is determined according to the diversity rewards and quality rewards of the K candidate translations corresponding to each sample original sentence in the training set, and the model parameters of the text translation model are adjusted based on the training objective function.

2. The method according to claim 1, characterized in that The obtaining of the diversity reward and the quality reward corresponding to the candidate translations includes: Respectively obtaining a sub-matching degree between the candidate translation and any translation in a set of other translations, wherein the set of other translations includes at least a part of: a reference translation corresponding to the sample original sentence, and candidate translations other than the candidate translation in the K candidate translations; According to each of the sub-matching degrees, obtaining the matching degree between the candidate translation and the other translation sets; A diversity reward corresponding to the candidate translation is determined based on the matching degree, such that the diversity reward is negatively correlated with the matching degree.

3. The method according to claim 1, characterized in that The obtaining of the diversity reward and the quality reward corresponding to the candidate translations includes: Reversely translate the candidate translation to obtain a reverse original sentence; Based on the difference between the reverse original sentence and the sample original sentence, a quality reward corresponding to the candidate translation is obtained.

4. The method according to claim 1, characterized in that: The step of determining a training objective function according to the diversity rewards and quality rewards of the K candidate translations corresponding to the sample original sentences in the training set, and adjusting the model parameters of the text translation model based on the training objective function includes: Determining a first target item according to a reference translation corresponding to each sample original sentence in the training set; Determining a second target item according to the diversity rewards and quality rewards of the K candidate translations corresponding to the sample original sentences in the training set; Based on the first target term and the second target term, an objective function for training the text translation model is determined.

5. The method according to claim 4, characterized in that The determining of the second target item according to the diversity reward and the quality reward of the K candidate translations corresponding to each sample original sentence in the training set includes: According to the diversity reward and quality reward of each candidate translation, select some candidate translations from the K candidate translations corresponding to each sample original sentence as target candidate translations, wherein the target candidate translation is a translation that meets the diversity and / or quality conditions; A second target item is determined based on the target candidate translation.

6. The method according to claim 5, characterized in that The selecting of some candidate translations from the K candidate translations corresponding to the sample original sentences as target candidate translations includes: In response to a diversity reward of the candidate translation being higher than or equal to a diversity threshold, and a quality reward being higher than or equal to a quality threshold, taking the candidate translation as the target candidate translation; Alternatively, in response to a diversity reward of the candidate translation being higher than or equal to a diversity threshold, or a quality reward being higher than or equal to a quality threshold, the candidate translation is used as the target candidate translation.

7. The method according to claim 4, characterized in that The determining of the second target item according to the diversity reward and the quality reward of the K candidate translations corresponding to each sample original sentence in the training set includes: The diversity risk value of the candidate translations corresponding to the sample original sentences in the training set is synthesized to obtain the translation diversity risk value, wherein the diversity risk value of the candidate translation is obtained based on the diversity reward of the candidate translation, and the higher the diversity reward of the candidate translation, the lower the diversity risk value; The quality risk value of the candidate translation corresponding to each sample original sentence in the training set is synthesized to obtain a translation quality risk value, wherein the quality risk value of the candidate translation is obtained based on the quality reward of the candidate translation, and the higher the quality reward of the candidate translation, the lower the quality risk value; The second target item is determined according to the translation diversity risk value and the translation quality risk value.

8. A text translation method, characterized in that: The method comprises: Input the original sentence to be translated into the text translation model; The text translation model is used to perform translation processing on the original sentence to obtain K candidate translations output by the text translation model; the text translation model is trained by any one of the methods described in claims 1 to 7.

9. A training device for a text translation model, characterized in that: The device comprises: A translation output module is used to output K candidate translations corresponding to any sample original sentence in the training set through the text translation model to be trained, where K is a natural number greater than or equal to 2; the training set includes multiple sample original sentences; A reward determination module, for obtaining, for any candidate translation among the K candidate translations, a diversity reward and a quality reward corresponding to the candidate translation; the diversity reward is used to measure the degree of diversity of the candidate translation; the quality reward is used to measure the translation quality of the candidate translation; The parameter adjustment module is used to determine the training objective function according to the diversity rewards and quality rewards of the K candidate translations corresponding to each sample original sentence in the training set, and adjust the model parameters of the text translation model based on the training objective function.

10. A text translation device, characterized in that: The device comprises: A text receiving module, used for inputting the original sentence to be translated into the text translation model; A translation processing module is used to perform translation processing on the original sentence through the text translation model to obtain K candidate translations output by the text translation model; the text translation model is trained by any one of the methods described in claims 1 to 7.

11. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 8 by running the executable instructions.

12. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the instruction is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.