Training method and device and computer readable storage medium
By training the translation direction recognition model, accurately identifying the translation direction in parallel corpus, the problem of low recognition accuracy in the prior art is solved, and the training effect of the translation quality evaluation model is improved.
Patent Information
- Application Number
- CN202310628938.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-30
- Publication Date
- 2024-12-03
AI Technical Summary
It is difficult for the prior art to accurately identify sentence pairs consistent with the translation direction of the translation model in a large number of parallel corpuses, which affects the accuracy of the translation quality evaluation model.
By training the translation direction recognition model, input the native text of the source language into the translation model to obtain the translated text of the target language, and use these texts as training samples to adjust the model parameters to distinguish the native text from the translated text, and then identify the consistent translation direction of the translation direction Corpus pairs generate labels used to train translation quality evaluation models.
The accuracy and efficiency of identifying corpus pairs consistent with the translation direction of the translation model from a large number of corpus is improved, and the training effect of the translation quality evaluation model is enhanced.
Smart Images

Figure CN119067132A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of machine translation and artificial intelligence technology, and in particular to a training method, device and computer-readable storage medium. Background Art
[0002] In the development and actual application of machine translation systems, it is necessary to evaluate the performance and translation quality of the trained translation model. Therefore, in recent years, some researchers have proposed some translation quality evaluation methods that do not rely on reference translations, and specifically use the term "Quality Estimation" to refer to such methods.
[0003] The existing quality assessment methods mainly rely on manual translation quality scoring, generating annotated data, and training the translation quality assessment model to make the model output a translation quality score that is close to the manually generated one. Since the annotated data for manual scoring is small in scale and difficult to obtain, some researchers have proposed using large-scale parallel corpora to automatically generate training data with pseudo labels to train the translation quality assessment model. Summary of the invention
[0004] The inventors found that the commonly used parallel corpora usually contain texts with two translation directions. For example, the parallel corpora are composed of sentence pairs whose source language is English and artificially generated Chinese translations, and whose source language is Chinese and artificially generated English translations, and the translation direction information of the sentence pairs in the training set is usually missing. The translation direction of the translation model is certain, and it is necessary to use sentence pairs that are consistent with the translation direction of the translation model to improve the accuracy of the translation quality assessment of the translation model. Therefore, how to identify sentence pairs that are consistent with the translation direction of the translation model in a large amount of parallel corpora is a problem that needs to be studied and solved.
[0005] A technical problem to be solved by the present disclosure is: how to identify corpus pairs in the corpus that are consistent with the translation direction of the translation model, so as to improve the recognition accuracy and efficiency.
[0006] According to some embodiments of the present disclosure, a training method is provided, comprising: inputting a native text of a source language into a translation model to obtain a translated text of a target language; using the native text of the target language and the translated text of the target language as first training samples; inputting each first training sample into a translation direction recognition model to obtain a classification result of each first training sample; and adjusting the parameters of the translation direction recognition model according to the classification result of each first training sample so that the translation direction recognition model distinguishes between the native text and the translated text of the target language.
[0007] In some embodiments, the classification results of each first training sample include the predicted probability that each first training sample belongs to the native text of the target language. According to the classification results of each first training sample, adjusting the parameters of the translation direction recognition model includes: determining a loss function based on the difference between the true probability distribution of the native text and the translated text of the target language in the first training sample and the predicted probability distribution of the native text and the translated text of the target language in the first training sample, wherein the true probability distribution of the native text and the translated text in the target language in the first training sample is determined according to the label of each first training sample; and adjusting the parameters of the translation direction recognition model according to the loss function.
[0008] In some embodiments, the native text of the source language is input into the translation model to obtain the translated text of the target language, including: when the source language and the target language are a preset similar language pair, in each self-attention layer of the encoding end of the translation model, for each word in the native text of the source language, the self-attention weight of each word in a preset window centered on the word relative to the word is determined; based on the self-attention weight of each word in the preset window centered on the word relative to the word, the self-attention encoding of the word is determined; and based on the self-attention encoding of each word in the native text of the source language, the translated text of the target language is determined.
[0009] In some embodiments, for each word in the native text of the source language, determining the self-attention weights of each word in a preset window centered on the word relative to the word includes: in each self-attention layer at the encoding end of the translation model, for each word in the native text of the source language, determining the query vector of the word according to the query weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer, and determining the key vector of the word according to the key weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer; for each word in the native text of the source language, determining the self-attention weights of each word in the preset window centered on the word relative to the word according to the query vector of the word and the key vectors of each word in the preset window centered on the word.
[0010] In some embodiments, the native text of the source language is input into the translation model to obtain the translated text of the target language, including: when the source language and the target language do not belong to a preset similar language pair, in each self-attention layer of the encoding end of the translation model, for any word in the native text of the source language, determining the self-attention weight of each word relative to the word; determining the self-attention encoding of the word according to the self-attention weight of each word relative to the word; and determining the translated text of the target language according to the self-attention encoding of each word in the native text of the source language.
[0011] In some embodiments, for any word in the native text of the source language, determining the self-attention weight of each word relative to the word includes: in each self-attention layer at the encoding end of the translation model, for any word in the native text of the source language, determining the query vector of the word according to the query weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer, and determining the key vector of the word according to the key weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer; for any word in the native text of the source language, determining the self-attention weight of each word relative to the word according to the query vector of the word and the key vector of each word.
[0012] In some embodiments, the method further includes: obtaining parallel corpora, wherein each group of parallel corpora includes: a first corpus pair and a second corpus pair, and the translation directions of the first corpus pair and the second corpus pair are opposite; using a trained translation direction recognition model, determining a corpus pair in the first corpus pair and the second corpus pair whose translation direction is consistent with the translation model.
[0013] In some embodiments, the method further includes: using the corpus pair in the first corpus pair and the second corpus pair that is consistent with the translation direction of the translation model as a reference corpus pair, and generating a set of second training samples based on the reference corpus pair, wherein the set of second training samples includes: the translated text in the target language corresponding to the native text in the source language in the reference corpus pair, the native text in the target language, and a translation quality label; and using the set of second training samples to train the translation quality assessment model.
[0014] In some embodiments, inputting a parallel corpus pair into a trained translation direction recognition model to determine which corpus pair in the first corpus pair and the second corpus pair has a translation direction consistent with the translation model includes: inputting a first target language text in the first corpus pair into the trained translation direction recognition model to determine whether the first target language text belongs to the native text or the translated text; inputting a second target language text in the first corpus pair into the trained translation direction recognition model to determine whether the second target language text belongs to the native text or the translated text; when the first target language text belongs to the translated text, determining that the translation direction of the first corpus pair is consistent with that of the translation model; when the second target language text belongs to the translated text, determining that the translation direction of the second corpus pair is consistent with that of the translation model.
[0015] In some embodiments, generating a set of second training samples based on a reference corpus pair includes: inputting the native text of the source language in the reference corpus pair into a translation model to obtain a corresponding translated text in the target language; and generating a quality label based on a comparison of the native text of the target language and the translated text of the target language in the reference corpus pair.
[0016] In some embodiments, the quality label includes: a sentence-level quality score of the translated text in the target language and a quality label for each word.
[0017] In some embodiments, training the translation quality assessment model using the set of second training samples includes: pre-training the translation quality assessment model using the set of second training samples; and fine-tuning the translation quality assessment model using manually annotated translation quality assessment data, wherein the translation quality assessment data includes translated text in the target language, native text in the target language, and manually annotated quality labels.
[0018] In some embodiments, the method further includes: pre-training a translation direction recognition model using monolingual corpus, wherein the translation direction recognition model is a text classifier.
[0019] In some embodiments, the method further includes: inputting the source language native text in the test data into the translation model to obtain the output target language translated text; inputting the target language native text and the target language translated text in the test data into the trained translation quality assessment model to obtain quality assessment information.
[0020] According to some other embodiments of the present disclosure, a training device is provided, including: a first acquisition module, used to input native text of a source language into a translation model to obtain a translated text of a target language; a generation module, used to use the native text of the target language and the translated text of the target language as first training samples; a second acquisition module, used to input each first training sample into a translation direction recognition model to obtain a classification result of each first training sample; and an adjustment module, used to adjust the parameters of the translation direction recognition model according to the classification result of each first training sample, so that the translation direction recognition model distinguishes between the native text and the translated text of the target language.
[0021] According to some further embodiments of the present disclosure, a training device is provided, comprising: a processor; and a memory coupled to the processor, for storing instructions, wherein when the instructions are executed by the processor, the processor executes a training method as described in any of the aforementioned embodiments.
[0022] According to some further embodiments of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, wherein the program, when executed by a processor, implements the training method of any of the aforementioned embodiments.
[0023] The present disclosure proposes a translation direction recognition model. In the process of training the translation direction recognition model, the native text of the source language is first translated using the translation model to obtain the translated text of the target language. Then, the native text of the target language and the translated text of the target language are input into the translation direction recognition model as the first training samples to obtain the classification results of each first training sample. Then, according to the classification results of each first training sample, the parameters of the translation direction recognition model are adjusted. The translation direction recognition model after training can distinguish between the native text and the translated text of the target language. In this way, the target language text in the corpus can be input into the translation direction recognition model to identify it as the native text or the translated text, thereby identifying the translation direction. The translation direction recognition model can more accurately and quickly identify corpus pairs that are consistent with the translation direction of the translation model from a large amount of corpus.
[0024] Other features and advantages of the present disclosure will become apparent from the following detailed description of exemplary embodiments of the present disclosure with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0026] Figure 1 A flowchart illustrating a training method according to some embodiments of the present disclosure is shown.
[0027] Figure 2 A schematic diagram showing the architecture of a system according to some embodiments of the present disclosure.
[0028] Figure 3 A flowchart diagram showing the training methods of other embodiments of the present disclosure is shown.
[0029] Figure 4 A schematic diagram showing the structure of a training device according to some embodiments of the present disclosure.
[0030] Figure 5 Schematic diagrams showing the structures of training devices according to other embodiments of the present disclosure.
[0031] Figure 6 A schematic diagram showing the structure of training devices according to some other embodiments of the present disclosure. DETAILED DESCRIPTION
[0032] The technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The following description of at least one exemplary embodiment is actually only illustrative and is by no means intended to limit the present disclosure and its application or use. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0033] This disclosure proposes a training method that can be used to train a translation direction recognition model. Figures 1 to 3 Give a description.
[0034] Figure 1 Flowcharts of some embodiments of the training method disclosed herein. Figure 1 As shown, the method of this embodiment includes: steps S102-108.
[0035] In step S102, the native text in the source language is input into the translation model to obtain the translated text in the target language.
[0036] The corpus used to train the translation direction recognition model can include monolingual data in the source language and the target language, as the native text of the source language and the native text of the target language respectively. The native texts of the two languages do not need to correspond one to one in terms of content, so a larger monolingual corpus can be used as training data to improve the training effect.
[0037] The translation model can be a model for subsequent translation quality assessment. Any translation model can be applied to the method of the present disclosure. For example, the translation model can adopt a neural machine translation model. More specifically, for example, the translation model adopts a Transformer structure. The translated text can also be called a translationese text, that is, a text obtained through translation. This text usually presents different linguistic features from the native text of the language. For example, the translation model is an English-Chinese machine translation system, which translates the English native text into Chinese text, that is, Chinese translationese text. Figure 2 As shown, the native text in the source language is input into the translation model, and the translated text in the target language is output.
[0038] In step S104, the native text in the target language and the translated text in the target language are used as first training samples.
[0039] The first training sample set includes a plurality of first training samples, namely, a plurality of native texts in the target language and a plurality of translated texts in the target language. Each first training sample also has a corresponding label, for example, 1 represents the native text and 0 represents the translated text.
[0040] For example, taking English-Chinese translation as an example, we first randomly select 1 million Chinese and English native texts from the WMT (Workshop on Machine Translation) monolingual corpus, and use the translation model to obtain 1 million Chinese translation texts, which together with the 1 million Chinese native texts form the first training sample set. Figure 2 As shown, the translation direction recognition model is trained using the native text of the target language and the translated text of the target language.
[0041] In step S106, each first training sample is input into a translation direction recognition model to obtain a classification result of each first training sample.
[0042] The translation direction identification model is used to identify whether a text belongs to the native text of the target language or the translated text, and then determine the translation direction. For example, the classification result of each first training sample includes the predicted probability that each first training sample belongs to the native text of the target language, or the predicted probability that each first training sample belongs to the translated text of the target language. The classification result of each first training sample may also include: each first training sample is the native text or the translated text of the target language.
[0043] In some embodiments, the translation direction recognition model is a text classifier. For example, the translation direction recognition model is a text classifier based on BERT (Bidirectional Encoder Representations from Transformers) or RoBERTa, but is not limited to the examples given.
[0044] In step S108, the parameters of the translation direction identification model are adjusted according to the classification results of each first training sample, so that the translation direction identification model can distinguish between the native text and the translated text in the target language.
[0045] In some embodiments, a loss function is determined based on the difference between the true probability distribution of the native text and the translated text in the target language in the first training sample and the predicted probability distribution of the native text and the translated text in the target language in the first training sample, and the parameters of the translation direction recognition model are adjusted based on the loss function. The greater the difference between the true probability distribution and the predicted probability, the greater the loss function value. The true probability distribution of the native text and the translated text in the target language in the first training sample is determined based on the labels of each first training sample.
[0046] For example, during each training iteration, the above method is used to determine the loss function, and the parameters of the translation direction recognition model are adjusted according to the loss function, and the process is repeated until the preset convergence condition is reached. The specific process of adjusting the parameters can refer to the prior art, for example, using methods such as gradient descent, etc., which are not limited to the examples given. For example, the preset convergence condition is that the loss function value reaches a minimum or threshold, reaches a preset number of iterations, etc., which are not limited to the examples given.
[0047] For example, the loss function is cross entropy loss, which can be expressed by the following formula.
[0048]
[0049] N represents the total number of first training samples, y i represents the label of the first training sample of the i-th class, for example, the positive class (native text in the target language) is 1, the negative class (translated text in the target language) is 0, and p i represents the predicted probability of the i-th native text in the target language belonging to the first training sample.
[0050] In some embodiments, the translation direction recognition model is pre-trained using monolingual corpus, and then the parameters of the translation direction recognition model are fine-tuned using each first training sample. In this way, the existing corpus can be directly used for pre-training, thereby improving the training efficiency.
[0051] After research, the inventors found that for language pairs with large differences in cultural background, the content of the native text itself is quite different. For example, in English-Chinese, directly using the translated text of the target language obtained by the translation model and the native text of the target language as the first training sample to train the translation direction recognition model can achieve good training results, and the translation direction recognition model has high accuracy.
[0052] For example, the translation model adopts a Transformer structure, including an encoding end and a decoding end. The encoding end includes one or more self-attention layers. In some embodiments, when the source language and the target language do not belong to a preset similar language pair, in each self-attention layer of the encoding end of the translation model, for any word in the native text of the source language, the self-attention weight of each word relative to the word is determined; based on the self-attention weight of each word relative to the word, the self-attention encoding of the word is determined; based on the self-attention encoding of each word in the native text of the source language, the translated text of the target language is determined.
[0053] Furthermore, in some embodiments, for any word in the native text of the source language, the query vector of the word is determined according to the query weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer, and the key vector of the word is determined according to the key weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer; for any word in the native text of the source language, the self-attention weight of each word relative to the word is determined according to the query vector of the word and the key vector of each word.
[0054] Further, in some embodiments, for each word in the native text of the source language, the value vector of the word is determined according to the value weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer. Further, for any word in the native text of the source language, the value vector of each word is weighted and summed according to the self-attention weight of each word relative to the word to determine the self-attention code of the word.
[0055] The query weight matrix, key weight matrix, and value weight matrix are adjustable parameters in the self-attention layer. After encoding the original text of the source language through the encoding end, it is input into the decoding end to obtain the translated text of the target language.
[0056] After research, the inventor found that for language pairs with small differences in cultural background, such as English-German, the accuracy of recognition based solely on text content features is low. Therefore, it is proposed to use language style features to improve recognition accuracy. Compared with the native text, the translated translation text often presents a single syntactic structure, is influenced by the source language, and has language style characteristics of "word-by-word translation". Therefore, it is proposed to limit the scope of self-attention at the encoding end of the translation model in the process of using the translation model to translate the native text of the source language into the translation text of the target language.
[0057] In some embodiments, when the source language and the target language are a preset similar language pair, in each self-attention layer of the encoding end of the translation model, for each word in the native text of the source language, the self-attention weights of each word within a preset window centered on the word relative to the word are determined; based on the self-attention weights of each word within the preset window centered on the word relative to the word, the self-attention encoding of the word is determined; and based on the self-attention encoding of each word in the native text of the source language, the translated text of the target language is determined.
[0058] Furthermore, in some embodiments, in each self-attention layer at the encoding end of the translation model, for any word in the native text of the source language, the query vector of the word is determined according to the query weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer, and the key vector of the word is determined according to the key weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer; for any word in the native text of the source language, the self-attention weight of each word relative to the word is determined according to the query vector of the word and the key vector of each word.
[0059] For example, set win=3, modify the calculation method of the self-attention weight of each layer of the encoder, and determine the self-attention weight according to the following formula.
[0060]
[0061] ψ i,j Represents the attention weight between the i-th word and the j-th word in the native text of the source language. If it exceeds the preset window, the weight is set to negative infinity. In this case, the translation model can generate a translation text in the target language with more "translation-accented" language style characteristics. The translation text of the generated target language and the native text are used as training data to train the translation direction recognition model. The translation direction recognition model can learn more information about the differences in language style characteristics and has a higher accuracy in the task of distinguishing between native text and translation-accented text in language pairs with smaller cultural background differences (for example, English-German).
[0062] The above embodiment proposes a translation direction recognition model. In the process of training the translation direction recognition model, the native text of the source language is first translated using the translation model to obtain the translated text of the target language. Then, the native text of the target language and the translated text of the target language are input into the translation direction recognition model as the first training samples to obtain the classification results of each first training sample. Then, according to the classification results of each first training sample, the parameters of the translation direction recognition model are adjusted. The translation direction recognition model after training can distinguish between the native text and the translated text of the target language. In this way, the target language text in the corpus can be input into the translation direction recognition model to identify it as the native text or the translated text, thereby identifying the translation direction. The translation direction recognition model can more accurately and quickly identify corpus pairs that are consistent with the translation direction of the translation model from a large amount of corpus.
[0063] Combine the following Figure 3 Describe the application process of the translation direction recognition model.
[0064] Figure 3 Flow charts of other embodiments of the training method disclosed herein. Figure 3As shown, the method of this embodiment includes: steps S302-310.
[0065] In step S302, a parallel corpus is obtained.
[0066] Each set of parallel corpora includes: a first corpus pair and a second corpus pair, and the translation directions of the first corpus pair and the second corpus pair are opposite. For example, the first corpus pair is a Chinese-English sentence pair, and the second corpus pair is an English-Chinese sentence pair.
[0067] In step S304, the trained translation direction identification model is used to determine a corpus pair in the first corpus pair and the second corpus pair that has a translation direction consistent with the translation model.
[0068] In some embodiments, the first target language text in the first corpus pair is input into a trained translation direction recognition model to determine whether the first target language text is a native text or a translated text; the second target language text in the first corpus pair is input into a trained translation direction recognition model to determine whether the second target language text is a native text or a translated text; if the first target language text is a translated text, it is determined that the translation direction of the first corpus pair is consistent with that of the translation model; if the second target language text is a translated text, it is determined that the translation direction of the second corpus pair is consistent with that of the translation model. Figure 2 As shown, the translation direction of each sentence pair in the parallel corpus is identified through the translation direction identification model, and the corpus pairs consistent with the translation direction of the translation model are obtained.
[0069] In step S306, the corpus pair in the first corpus pair and the second corpus pair that is consistent with the translation direction of the translation model is used as a reference corpus pair, and a set of second training samples is generated according to the reference corpus pair.
[0070] For example, the set of second training samples includes: a translation text in a target language corresponding to a native text in a source language in a reference corpus pair, the native text in the target language, and a translation quality label.
[0071] like Figure 2 As shown, in some embodiments, the native text of the source language in the reference corpus pair is input into the translation model to obtain the corresponding translated text in the target language; and a quality label is generated based on the comparison between the native text of the target language and the translated text of the target language in the reference corpus pair.
[0072] For example, the quality label includes: the sentence-level quality score of the target language translation text and the quality label of each word. The sentence-level quality score can be a value between 0.0 and 1.0, and the larger the value, the worse the translation quality. The quality label of each word can be expressed as l i∈{OK,BAD}, set the value representing the gap before the first word, after the last word, and between each word. For example, the value representing the gap is [GAP], and the corresponding quality label is set. You can also use {OK,BAD} to indicate whether there is a missing translation at the corresponding position. The existing automatic evaluation index algorithm can be used to generate the quality label, which will not be repeated here.
[0073] In step S308, the translation quality assessment model is trained using the set of second training samples.
[0074] In some embodiments, the native text of the target language and the corresponding translated text in the set of the second training samples are input into the translation quality assessment model to obtain the sentence-level predicted quality score and the predicted probability that each word of the translated text (which may include a value indicating the interval [GAP]) belongs to the positive class (for example, the quality label is OK). According to the difference between the sentence-level predicted quality score and the sentence-level quality score in the quality label, a first sub-loss function is determined, according to the predicted probability that each word belongs to the positive class and the quality label of each word in the quality label, a second sub-loss function is determined, and according to the first sub-loss function and the second sub-loss function, the parameters of the translation quality assessment model are adjusted.
[0075] For example, the first sub-loss function is the mean square loss, which can be determined using the following formula.
[0076]
[0077] N represents the total number of second training samples (the native text in the target language and the corresponding translated text are taken together as a second training sample), y i represents the sentence-level quality score in the quality label of the i-th translation text, represents the sentence-level prediction quality score of the i-th translated text.
[0078] For example, the second sub-loss function is the cross entropy loss, which can be determined using the following formula.
[0079]
[0080] N represents the total number of second training samples, y ij represents the quality label of the jth word in the i-th translation text, the positive class (quality label is OK) is 1, the negative class (quality label is BAD) is 0, p ij Represents the predicted probability that the jth word belongs to the positive class.
[0081] Algorithms such as gradient descent can be used to adjust the parameters of the translation quality assessment model, which will not be described in detail here.
[0082] like Figure 2As shown, in some embodiments, the translation quality assessment model is pre-trained using the set of second training samples; the translation quality assessment model is fine-tuned using manually annotated translation quality assessment data, wherein the translation quality assessment data includes the translation text in the target language, the native text in the target language, and manually annotated quality labels. This can further improve the accuracy of the translation quality assessment model.
[0083] The translation quality assessment model may adopt an existing model, such as an XLM-R model, but is not limited to the examples given.
[0084] In step S310, the quality of the translation model is evaluated using a translation quality evaluation model.
[0085] The translation quality assessment model can be applied to downstream tasks such as online testing of machine translation systems, computer-assisted translation, and quality monitoring in interactive machine translation, and is not limited to the examples given. In some embodiments, the native text in the source language in the test data is input into the translation model to obtain the output translation text in the target language; the native text in the target language and the translation text in the target language in the test data are input into the trained translation quality assessment model to obtain quality assessment information.
[0086] The translation quality assessment model can be used to assess the translation model used in the aforementioned embodiment, and can also be used to assess other translation models.
[0087] The method of the embodiment of the present disclosure applies the method of distinguishing the translation direction of parallel corpora to the training or pre-training of the translation quality assessment model, and proposes to screen the parallel corpora that are consistent with the translation direction of the translation to be evaluated, which can optimize the training or pre-training process of the translation quality assessment model. The method of the embodiment of the present disclosure proposes a method for automatically generating data using monolingual corpora and existing translation models to train a translation direction recognition model. The translation direction recognition model constructed based on the monolingual pre-training model can utilize the difference information of the native text content of different languages and can achieve a higher accuracy rate. For language pairs with relatively similar text content (such as English-German), by limiting the scope of the self-attention module in the encoder of the existing translation model, a text with more "translation accent" language style characteristics is generated, so that the translation direction recognition model can make more use of the difference information of the language style of the native text of different languages to achieve a higher recognition accuracy rate.
[0088] The present disclosure also provides a training device, Figure 4 Give a description.
[0089] Figure 4 Figure 1 is a structural diagram of some embodiments of the training device disclosed herein. Figure 4As shown, the device 40 of this embodiment includes: a first acquisition module 410 , a generation module 420 , a second acquisition module 430 , and an adjustment module 440 .
[0090] The first acquisition module 410 is used to input the native text in the source language into the translation model to obtain the translated text in the target language.
[0091] In some embodiments, when the source language and the target language are a preset similar language pair, in each self-attention layer of the encoding end of the translation model, for each word in the native text of the source language, the self-attention weights of each word within a preset window centered on the word relative to the word are determined; based on the self-attention weights of each word within the preset window centered on the word relative to the word, the self-attention encoding of the word is determined; and based on the self-attention encoding of each word in the native text of the source language, the translated text of the target language is determined.
[0092] In some embodiments, for each word in the native text of the source language, determining the self-attention weights of each word in a preset window centered on the word relative to the word includes: in each self-attention layer at the encoding end of the translation model, for each word in the native text of the source language, determining the query vector of the word according to the query weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer, and determining the key vector of the word according to the key weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer; for each word in the native text of the source language, determining the self-attention weights of each word in the preset window centered on the word relative to the word according to the query vector of the word and the key vectors of each word in the preset window centered on the word.
[0093] In some embodiments, when the source language and the target language do not belong to a preset similar language pair, in each self-attention layer of the encoding end of the translation model, for any word in the native text of the source language, the self-attention weight of each word relative to the word is determined; based on the self-attention weight of each word relative to the word, the self-attention encoding of the word is determined; and based on the self-attention encoding of each word in the native text of the source language, the translated text of the target language is determined.
[0094] In some embodiments, for any word in the native text of the source language, determining the self-attention weight of each word relative to the word includes: in each self-attention layer at the encoding end of the translation model, for any word in the native text of the source language, determining the query vector of the word according to the query weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer, and determining the key vector of the word according to the key weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer; for any word in the native text of the source language, determining the self-attention weight of each word relative to the word according to the query vector of the word and the key vector of each word.
[0095] The generating module 420 is used to use the native text in the target language and the translated text in the target language as the first training samples.
[0096] The second acquisition module 430 is used to input each first training sample into the translation direction recognition model to obtain a classification result of each first training sample.
[0097] The adjustment module 440 is used to adjust the parameters of the translation direction identification model according to the classification results of each first training sample, so that the translation direction identification model can distinguish between the native text and the translated text in the target language.
[0098] In some embodiments, the translation direction identification model is pre-trained using monolingual corpus, wherein the translation direction identification model is a text classifier.
[0099] In some embodiments, the classification results of each first training sample include the predicted probability that each first training sample belongs to the native text of the target language. The adjustment module 440 is used to determine the loss function based on the difference between the actual probability distribution of the native text and the translated text of the target language in the first training sample and the predicted probability distribution of the native text and the translated text of the target language in the first training sample, wherein the actual probability distribution of the native text and the translated text in the target language in the first training sample is determined according to the label of each first training sample; and the parameters of the translation direction recognition model are adjusted according to the loss function.
[0100] In some embodiments, the device 40 also includes: an identification module 450, which is used to obtain parallel corpora, wherein each group of parallel corpora includes: a first corpus pair and a second corpus pair, and the translation directions of the first corpus pair and the second corpus pair are opposite; using a trained translation direction identification model, determine the corpus pair in the first corpus pair and the second corpus pair whose translation direction is consistent with the translation model.
[0101] In some embodiments, the recognition module 450 is used to input the first target language text in the first corpus pair into the trained translation direction recognition model to determine whether the first target language text belongs to the native text or the translated text; input the second target language text in the first corpus pair into the trained translation direction recognition model to determine whether the second target language text belongs to the native text or the translated text; when the first target language text belongs to the translated text, determine that the translation directions of the first corpus pair and the translation model are consistent; when the second target language text belongs to the translated text, determine that the translation directions of the second corpus pair and the translation model are consistent.
[0102] In some embodiments, the quality assessment module 460 is used to use the corpus pair in the first corpus pair and the second corpus pair that is consistent with the translation direction of the translation model as a reference corpus pair, and generate a set of second training samples based on the reference corpus pair, wherein the set of second training samples includes: the translated text in the target language corresponding to the native text in the source language in the reference corpus pair, the native text in the target language, and a translation quality label; and use the set of second training samples to train the translation quality assessment model.
[0103] In some embodiments, the quality assessment module 460 is used to input the native text of the source language in the reference corpus pair into the translation model to obtain the corresponding translated text in the target language; and generate a quality label based on the comparison of the native text of the target language and the translated text of the target language in the reference corpus pair.
[0104] In some embodiments, the quality label includes: a sentence-level quality score of the translated text in the target language and a quality label for each word.
[0105] In some embodiments, the quality assessment module 460 is used to pre-train the translation quality assessment model using a set of second training samples; and fine-tune the translation quality assessment model using manually annotated translation quality assessment data, wherein the translation quality assessment data includes the translated text in the target language, the native text in the target language, and manually annotated quality labels.
[0106] In some embodiments, the quality assessment module 460 is also used to input the source language native text in the test data into the translation model to obtain the output target language translated text; input the target language native text and the target language translated text in the test data into the trained translation quality assessment model to obtain quality assessment information.
[0107] The training device in the embodiments of the present disclosure can be implemented by various computing devices or computer systems. Figure 5 as well as Figure 5 Give a description.
[0108] Figure 5Figure 1 is a structural diagram of some embodiments of the training device disclosed herein. Figure 5 As shown, the device 50 of this embodiment includes: a memory 510 and a processor 520 coupled to the memory 510, and the processor 520 is configured to execute the training method in any of some embodiments of the present disclosure based on the instructions stored in the memory 510.
[0109] The memory 510 may include, for example, a system memory, a fixed non-volatile storage medium, etc. The system memory may store, for example, an operating system, an application program, a boot loader, a database, and other programs.
[0110] Figure 6 FIG. 2 is a structural diagram of some other embodiments of the training device disclosed in the present invention. Figure 6 As shown, the device 60 of this embodiment includes: a memory 610 and a processor 620, which are similar to the memory 510 and the processor 520 respectively. It can also include an input and output interface 630, a network interface 640, a storage interface 650, etc. These interfaces 630, 640, 650 and the memory 610 and the processor 620 can be connected, for example, through a bus 660. Among them, the input and output interface 630 provides a connection interface for input and output devices such as a display, a mouse, a keyboard, and a touch screen. The network interface 640 provides a connection interface for various networked devices, for example, it can be connected to a database server or a cloud storage server. The storage interface 650 provides a connection interface for external storage devices such as SD cards and USB flash drives.
[0111] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable non-transient storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0112] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1A device that provides the functions specified in a block or multiple blocks.
[0113] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0114] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0115] The above are only preferred embodiments of the present disclosure and are not intended to limit the present disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure should be included in the protection scope of the present disclosure.
Claims
1. A training method comprising: Input the original text in the source language into the translation model to obtain the translated text in the target language; Using the native text in the target language and the translated text in the target language as first training samples; Inputting each first training sample into a translation direction recognition model to obtain a classification result of each first training sample; According to the classification results of each first training sample, the parameters of the translation direction identification model are adjusted so that the translation direction identification model can distinguish between the native text and the translated text in the target language.
2. The training method according to claim 1, wherein: The classification results of each first training sample include a predicted probability that each first training sample belongs to the native text of the target language, and adjusting the parameters of the translation direction recognition model according to the classification results of each first training sample includes: determining a loss function according to a difference between a true probability distribution of the native text and the translated text in the target language in the first training sample and a predicted probability distribution of the native text and the translated text in the target language in the first training sample, wherein the true probability distribution of the native text and the translated text in the target language in the first training sample is determined according to labels of each first training sample; According to the loss function, the parameters of the translation direction recognition model are adjusted.
3. The training method according to claim 1, wherein: The step of inputting the native text of the source language into the translation model to obtain the translated text of the target language comprises: when the source language and the target language are a preset similar language pair, In each self-attention layer of the encoding end of the translation model, for each word in the native text of the source language, a self-attention weight of each word within a preset window centered on the word relative to the word is determined; Determine the self-attention encoding of the word according to the self-attention weights of each word in a preset window centered on the word relative to the word; The translated text in the target language is determined according to the self-attention encoding of each word in the native text in the source language.
4. The training method according to claim 3, wherein: For each word in the native text of the source language, determining the self-attention weights of each word in a preset window centered on the word relative to the word includes: In each self-attention layer of the encoding end of the translation model, for each word in the native text of the source language, a query vector of the word is determined according to a query weight matrix corresponding to the self-attention layer and an input vector of the word input into the self-attention layer, and a key vector of the word is determined according to a key weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer; For each word in the native text of the source language, the self-attention weights of each word in the preset window centered on the word relative to the word are determined according to the query vector of the word and the key vectors of each word in the preset window centered on the word.
5. The training method according to claim 1, wherein: The step of inputting the native text of the source language into the translation model to obtain the translated text of the target language includes: when the source language and the target language do not belong to a preset similar language pair, In each self-attention layer of the encoding end of the translation model, for any word in the native text of the source language, determine a self-attention weight of each word relative to the word; Determine the self-attention encoding of each word based on the self-attention weight of the word relative to the word; The translated text in the target language is determined according to the self-attention encoding of each word in the native text in the source language.
6. The training method according to claim 5, wherein: For any word in the native text of the source language, determining the self-attention weight of each word relative to the word includes: In each self-attention layer of the encoding end of the translation model, for any word in the native text of the source language, a query vector of the word is determined according to a query weight matrix corresponding to the self-attention layer and an input vector of the word input into the self-attention layer, and a key vector of the word is determined according to a key weight matrix corresponding to the self-attention layer and the input vector of the word input into the self-attention layer; For any word in the native text of the source language, the self-attention weight of each word relative to the word is determined according to the query vector of the word and the key vector of each word.
7. The training method according to claim 1, further comprising: Acquire parallel corpora, wherein each set of parallel corpora includes: a first corpus pair and a second corpus pair, wherein the translation directions of the first corpus pair and the second corpus pair are opposite; The trained translation direction recognition model is used to determine a corpus pair in the first corpus pair and the second corpus pair that is consistent with the translation direction of the translation model.
8. The training method according to claim 7, further comprising: The corpus pair in the first corpus pair and the second corpus pair that is consistent with the translation direction of the translation model is used as a reference corpus pair, and a set of second training samples is generated according to the reference corpus pair, wherein the set of second training samples includes: a translation text in a target language corresponding to the native text in the source language in the reference corpus pair, the native text in the target language, and a translation quality label; The translation quality assessment model is trained using the set of the second training samples.
9. The training method according to claim 7, wherein: The step of inputting the parallel corpus pair into the trained translation direction recognition model and determining the corpus pair in the first corpus pair and the second corpus pair that has the same translation direction as the translation model comprises: Inputting the first target language text in the first corpus pair into the trained translation direction recognition model to determine whether the first target language text is a native text or a translated text; Inputting the second target language text in the first corpus pair into the trained translation direction recognition model to determine whether the second target language text is a native text or a translated text; In the case where the first target language text is a translation text, determining that the translation direction of the first corpus pair is consistent with that of the translation model; In the case where the second target language text is a translation text, it is determined that the translation direction of the second corpus pair is consistent with that of the translation model.
10. The training method according to claim 8, wherein: Generating a set of second training samples according to the reference corpus includes: Inputting the original text in the source language of the reference corpus pair into the translation model to obtain the corresponding translated text in the target language; A quality label is generated based on a comparison between the native text in the target language and the translated text in the target language in the reference corpus pair.
11. The training method according to claim 8, wherein: The quality label includes: a sentence-level quality score of the translation text in the target language and a quality label for each word.
12. The training method according to claim 5, wherein: The step of training the translation quality assessment model using the set of the second training samples includes: Pre-training the translation quality assessment model using the set of the second training samples; The translation quality assessment model is fine-tuned using manually annotated translation quality assessment data, wherein the translation quality assessment data includes a translated text in a target language, a native text in the target language, and manually annotated quality labels.
13. The training method according to any one of claims 1 to 12, further comprising: The translation direction identification model is pre-trained using monolingual corpus, wherein the translation direction identification model is a text classifier.
14. The training method according to claim 5, further comprising: Inputting the source language native text in the test data into the translation model to obtain the output target language translated text; The target language native text and the target language translated text in the test data are input into the trained translation quality assessment model to obtain quality assessment information.
15. A training device comprising: A first acquisition module is used to input the native text in the source language into the translation model to obtain the translated text in the target language; A generating module, configured to use the native text in the target language and the translated text in the target language as first training samples; A second acquisition module is used to input each first training sample into the translation direction recognition model to obtain a classification result of each first training sample; The adjustment module is used to adjust the parameters of the translation direction identification model according to the classification results of each first training sample, so that the translation direction identification model can distinguish the native text and the translated text of the target language.
16. A training device comprising: processor; as well as A memory coupled to the processor, for storing instructions, wherein when the instructions are executed by the processor, the processor performs the training method according to any one of claims 1 to 14.
17. A computer-readable storage medium having a computer program stored thereon, wherein: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 14 are implemented.
