Machine translation method and device based on imitation learning, and terminal equipment

By combining imitation learning methods with decoders from autoregressive and non-autoregressive models, erroneous words are removed, missing words are filled in, and placeholders are replaced. This solves the speed and accuracy problems in traditional machine translation and achieves efficient parallel translation.

CN116151277BActive Publication Date: 2026-05-08SICHUAN LAN-BRIDGE INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SICHUAN LAN-BRIDGE INFORMATION TECHNOLOGY CO LTD
Filing Date
2023-02-16
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

Traditional machine translation methods cannot balance the translation efficiency of non-autoregressive models with the translation accuracy of autoregressive models, resulting in slow decoding speed and low translation quality.

Method used

We employ a machine translation method based on imitation learning. By combining a deletion classifier decoder, an insertion classifier decoder, and a word classifier decoder with autoregressive and non-autoregressive models, we first delete erroneous words, fill in missing word positions, and replace placeholders with correct words to generate the final translation.

Benefits of technology

While ensuring the quality of the translation, parallel accelerated translation was achieved, significantly improving the translation speed. The quality of the translation was comparable to that of the autoregressive model and superior to that of the non-autoregressive model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116151277B_ABST
    Figure CN116151277B_ABST
Patent Text Reader

Abstract

The application is suitable for the technical field of machine translation, and provides a machine translation method and device based on imitation learning and terminal equipment, the method comprising: inputting a to-be-translated original text into a non-autoregressive model to obtain a first initial translation; when the first initial translation passes through a deletion classification decoder, deleting an error word in the first initial translation, and outputting a second initial translation; when the second initial translation passes through an insertion classification decoder, using a placeholder to fill a missing word position in the second initial translation, and outputting a third initial translation; and when the third initial translation passes through a word classification decoder, replacing the placeholder with a correct word, and outputting a final translation. The application combines the advantages of autoregressive models and non-autoregressive models, and can realize parallel acceleration while ensuring the quality of the translation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine translation technology, and in particular to a machine translation method, apparatus, and terminal device based on imitation learning. Background Technology

[0002] Currently, machine translation tasks often employ sequence neural networks (SNNNs) with autoregressive generation models. Whether based on recurrent neural networks (RNNs) or multi-head self-attention networks (Transformers), these models generate translations word by word. That is, to generate the next word, the previous word must be input into the model. While this results in high translation accuracy, the dependence of each subsequent word on the preceding one leads to a relatively slow decoding speed for autoregressive models (AT models).

[0003] Typically, to improve the slow decoding speed of autoregressive models, a non-autoregressive model, i.e., the NAT model, is used to generate the entire translation in parallel. However, although this method improves the decoding speed, the quality of the generated translation is not as good as that of translation methods based on autoregressive models. Summary of the Invention

[0004] The main objective of this invention is to propose a machine translation method, apparatus, and terminal device based on imitation learning, which solves the problem that traditional machine translation cannot simultaneously achieve the translation efficiency of non-autoregressive models and the translation accuracy of autoregressive models.

[0005] To achieve the above objectives, the first aspect of the present invention provides 1. a machine translation method based on imitation learning, characterized in that it includes:

[0006] Input the original text to be translated into a non-autoregressive model to obtain the first initial translation;

[0007] When the first initial translation is processed by the deletion classification decoder, erroneous words in the first initial translation are deleted, and the second initial translation is output.

[0008] When the second initial translation is passed through the insertion classification decoder, placeholders are used to fill in the missing word positions in the second initial translation, and the third initial translation is output.

[0009] When the third initial translation is processed by the word classification decoder, the placeholders are replaced with the correct words, and the final translation is output.

[0010] In conjunction with the first aspect of the present invention, in the first embodiment of the present invention, before inputting the original text to be translated into a non-autoregressive model to obtain the first initial translation, the following steps are included:

[0011] Obtain the translated original text and the corresponding reference translation;

[0012] Using the translated original text and the reference translation as training data, a basic translation model is trained to obtain the deletion classification decoder, the insertion classification decoder, and the word classification decoder.

[0013] In conjunction with the first embodiment of the first aspect of the present invention, in the second embodiment of the present invention, when the translated original text and the reference translation are used as training data, the translated original text and the reference translation are converted into original text-translation pairs.

[0014] In conjunction with the first embodiment of the first aspect of the present invention, in the third embodiment of the present invention, the translated original text and the reference translation are used as training data to train a basic translation model, obtaining a deletion classification decoder, the insertion classification decoder, and the word classification decoder, including:

[0015] A baseline translation model is obtained by training a non-autoregressive model.

[0016] The baseline translation model is used to translate the original text to be translated, generating a baseline translation;

[0017] The baseline translation and the reference translation are processed by the edit distance algorithm to construct the classifier data of the deletion classification decoder, the classifier data of the insertion classification decoder, and the classifier data of the word classification decoder;

[0018] The baseline translation model is trained using the classifier data of the deletion classifier, the insertion classifier, and the word classifier based on the imitation learning algorithm, to obtain the deletion classifier, the insertion classifier, and the word classifier.

[0019] In conjunction with the third embodiment of the first aspect of the present invention, in the fourth embodiment of the present invention, the baseline translation and the reference translation are processed by an edit distance algorithm, including:

[0020] The shortest distance from the baseline translation to the reference translation is calculated using an edit distance algorithm.

[0021] In conjunction with the fourth embodiment of the first aspect of the present invention, in the fifth embodiment of the present invention, constructing the classifier data for deleting the classifier decoder and the classifier data for inserting the classifier decoder includes:

[0022] The classifier data for the deletion classifier and the classifier data for the insertion classifier are constructed based on the shortest distance.

[0023] In conjunction with the fourth embodiment of the first aspect of the present invention, in the sixth embodiment of the present invention, the classifier data for constructing the word classification decoder includes:

[0024] When the shortest distance is available, classifier data for the word classification decoder is constructed based on the word replacements from the baseline translation to the reference translation.

[0025] A second aspect of the present invention provides a machine translation apparatus based on imitation learning, comprising:

[0026] The initial translation module is used to input the original text to be translated into a non-autoregressive model to obtain the first initial translation;

[0027] The first decoding module is used to delete erroneous words in the first initial translation and output the second initial translation when the first initial translation passes through the deletion classification decoder.

[0028] The second decoding module is used to fill in the missing word positions in the second initial translation with placeholders and output the third initial translation when the second initial translation passes through the insertion classification decoder.

[0029] The third decoding module is used to replace the placeholders with the correct words when the third initial translation passes through the word classification decoder, and output the final translation.

[0030] A third aspect of the present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method provided in the first aspect above.

[0031] A fourth aspect of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method provided in the first aspect above.

[0032] This invention provides a machine translation method based on imitation learning. By deleting the classification decoder, inserting the classification decoder, and the word classification decoder, it combines the advantages of autoregressive and non-autoregressive models, achieving parallel acceleration while ensuring translation quality. Attached Figure Description

[0033] Figure 1 This is a schematic diagram illustrating the implementation process of the machine translation method based on imitation learning provided in an embodiment of the present invention.

[0034] Figure 2 This is a schematic diagram illustrating the decoder operation process provided in an embodiment of the present invention;

[0035] Figure 3 This is a schematic diagram of the composition structure of a machine translation device based on imitation learning provided in an embodiment of the present invention.

[0036] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0037] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0038] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0039] In this document, suffixes such as "module," "part," or "unit" used to denote elements are used only for the purpose of illustrative purposes and do not have any specific meaning in themselves. Therefore, "module" and "part" can be used interchangeably.

[0040] like Figure 1 As shown, this embodiment of the invention provides a machine translation method based on imitation learning, including but not limited to the following steps:

[0041] S101. Input the original text to be translated into the non-autoregressive model to obtain the first initial translation.

[0042] In step S101 above, obtaining the first initial translation through a non-autoregressive model is a parallel decoding method, which has a fast decoding speed and translation efficiency, but the translation accuracy of the generated first initial translation is not high.

[0043] In practical applications, when translating using a non-autoregressive model, the Encoder predicts the number of words in the translation corresponding to each word in the source text, and copies the words in the source text several times to input them into the Decoder, thereby decoding in parallel and generating all the translations at once.

[0044] S102. When the first initial translation passes through the deletion classification decoder, the erroneous words in the first initial translation are deleted, and the second initial translation is output.

[0045] In step S102 above, the deletion classification decoder is used to delete erroneous words in the first initial translation. The deletion classification decoder is trained using the baseline translation and reference translation as training data in the following steps. The training objective is to identify erroneous words in the process from the baseline translation to the reference translation.

[0046] S103. When the second initial translation passes through the insertion classification decoder, placeholders are used to fill in the missing word positions in the second initial translation, and the third initial translation is output.

[0047] In step S103 above, the insertion classification decoder is used to fill in the missing positions in the first initial translation after the deletion classification decoder has deleted words, that is, the missing word positions in the second initial translation. In this embodiment of the invention, such a translation with missing words is recorded as the third initial translation. Furthermore, the insertion classification decoder is trained using the baseline translation and the reference translation as training data in the following steps. The training objective is to identify the word count difference between the baseline translation and the reference translation.

[0048] It should be noted that the missing word positions in the second initial translation do not correspond one-to-one with the word positions to be filled in this step S103. For example, when there is one missing word position in the second initial translation, the word position to be filled in this step S103 is not limited to one.

[0049] S104. When the third initial translation passes through the word classification decoder, the placeholder is replaced with the correct word, and the final translation is output.

[0050] In step S104 above, the word classification decoder is used to fill in the missing words in the third initial translation. The word classification decoder is trained using the baseline translation and reference translation as training data in the following steps. The training objective is to learn the word editing process from the baseline translation to the reference translation.

[0051] like Figure 2 As shown, the embodiments of the present invention also describe in detail the working process of the deletion classification decoder, the insertion classification decoder and the word classification decoder. It is assumed that the original text to be translated is "the cat is sitting on the mat". According to the above step S101, a poor quality translation is generated based on the non-autoregressive model, namely the first initial translation, which is "catsitmat".

[0052] In the first initial translation, “sit” is an incorrect word. In this embodiment of the invention, the deletion classification decoder can identify and delete this incorrect word. Therefore, according to the above step S102, the second initial translation is obtained as “catmat”.

[0053] In the second initial translation, there is one missing word position, but it is four word positions missing compared to the correct translation. Therefore, a classification decoder is inserted to fill in the missing words using four placeholders, generating the third initial translation: "[PLH]cat[PLH][PLH][PLH]mat".

[0054] Finally, the third initial translation is processed by a word classification decoder, which fills in the placeholders with the correct words. The final translation is generated as: "acatsatonthemat".

[0055] In this embodiment of the invention, the deletion classification decoder, the insertion classification decoder, and the word classification decoder are pre-trained classifiers. Therefore, before step S101 above, the following steps are included:

[0056] Obtain the translated original text and the corresponding reference translation;

[0057] Using the translated original text and the reference translation as training data, a basic translation model is trained to obtain the deletion classification decoder, the insertion classification decoder, and the word classification decoder.

[0058] Specifically, when using the translated original text and the reference translation as training data, the translated original text and the reference translation are converted into original text-translation pairs.

[0059] It should be noted that the reference translation is the correct translation of the original text, which can be obtained by human translation or by a highly accurate autoregressive model.

[0060] This invention also describes the training process of the deletion classification decoder, the insertion classification decoder, and the word classification decoder. Specifically, the implementation methods for training the basic translation model using the translated source text and the reference translation as training data to obtain the deletion classification decoder, the insertion classification decoder, and the word classification decoder include:

[0061] A baseline translation model is obtained by training a non-autoregressive model.

[0062] The baseline translation model is used to translate the translated source text to generate a baseline translation;

[0063] The baseline translation and the reference translation are processed by the edit distance algorithm to construct the classifier data of the deletion classification decoder, the classifier data of the insertion classification decoder, and the classifier data of the word classification decoder;

[0064] The baseline translation model is trained using the classifier data of the deletion classifier decoder, the insertion classifier decoder, and the word classifier decoder based on the imitation learning algorithm, thereby obtaining the deletion classifier decoder, the insertion classifier decoder, and the word classifier decoder.

[0065] It should be noted that the baseline translation model is the traditional translation model trained based on a non-autoregressive model, and its training process is not limited in this embodiment of the invention.

[0066] The baseline translation and the reference translation are processed using an edit distance algorithm, including:

[0067] The shortest distance from the baseline translation to the reference translation is calculated using an edit distance algorithm.

[0068] The classifier data, which is the training data used to train each classifier decoder, includes the detailed implementation of its construction, namely, constructing the classifier data for deleting the classifier decoder and the classifier data for inserting the classifier decoder.

[0069] The classifier data for the deletion classifier and the classifier data for the insertion classifier are constructed based on the shortest distance.

[0070] Furthermore, the classifier data used to construct the word classification decoder includes:

[0071] When the shortest distance is available, classifier data for the word classification decoder is constructed based on the word replacements from the baseline translation to the reference translation.

[0072] In the above steps, when the shortest distance is obtained, the word changes from the baseline translation to the reference translation will be obtained. For example, if the words in the baseline translation are A+B+C+D and the words in the reference translation are A+B+E+F+G, then the word change is CD→EFG and the word count change is 4→2→5.

[0073] In other words, the optimal editing strategy for the baseline translation to the reference is...

[0074] 1. Delete "C" and "D".

[0075] 2. Insert “E”, “F”, and “G” in the corresponding positions respectively;

[0076] Based on this, in this embodiment of the invention, the classifier data for the deletion classification decoder is constructed according to the shortest distance. This actually involves constructing the words to be deleted from the baseline translation, and using these words, along with the baseline translation, as the classifier data for the deletion classification decoder, i.e., the training data for the deletion classification decoder. Similarly, the classifier data for the insertion classification decoder is constructed according to the shortest distance. This actually involves constructing the placeholders and their positions to be inserted from the baseline translation to the reference translation, and using these placeholders, along with the deleted baseline translation, as the classifier data for the insertion classification decoder, i.e., the training data for the insertion classification decoder. Finally, the classifier data for the word classification decoder is constructed based on the word replacements from the baseline translation to the reference translation. This actually involves constructing the correct word lexical changes, and using these changes, along with the baseline translation after inserting placeholders, as the classifier data for the word classification decoder, i.e., the training data for the word classification decoder.

[0077] Therefore, the above steps allow each classifier to learn the entire process from poor-quality translations to edited reference translations.

[0078] This invention also compares the provided machine translation method based on imitation learning with traditional autoregressive and non-autoregressive models:

[0079] First, let's analyze and compare based on computational complexity:

[0080] Autoregressive model: For a translation process of length N, N decoder operations are required to generate a translation of N words, with an algorithm complexity of O(N).

[0081] Non-autoregressive model: For a translation process of length N, only one decoding is needed to generate a translation of length N, and the algorithm complexity is O(1);

[0082] The machine translation method based on imitation learning provided in this embodiment of the invention: For a translation process with a translation length of N, only 4 decoding steps are required to generate a translation of length N, and the algorithm complexity is O(1);

[0083] In practical applications, N is generally much greater than 4. Therefore, the machine translation method based on imitation learning provided in this embodiment of the invention has a significant speed advantage over the autoregressive model, but is slightly inferior to the non-autoregressive model.

[0084] Then, an analysis and comparison were conducted based on the translation quality:

[0085] Tests were conducted on Traditional Chinese-English, Simplified Chinese-English, and English-German datasets. The final translation quality was comparable to that of the autoregressive model, and on average, it was 4 BLEU values ​​higher than that of the non-autoregressive model.

[0086] In addition to the advantages mentioned above, the model used in the machine translation method based on imitation learning provided in this embodiment of the invention can be used for post-editing of translators' translations or other machine-translated translations after training, which ordinary autoregressive models cannot do.

[0087] like Figure 3 As shown, this embodiment of the invention also provides a machine translation device 30 based on imitation learning, comprising:

[0088] The initial translation module 31 is used to input the original text to be translated into a non-autoregressive model to obtain the first initial translation;

[0089] The first decoding module 32 is used to delete erroneous words in the first initial translation and output the second initial translation when the first initial translation passes through the deletion classification decoder;

[0090] The second decoding module 33 is used to fill in the missing word positions in the second initial translation with placeholders and output the third initial translation when the second initial translation passes through the insertion classification decoder.

[0091] The third decoding module 34 is used to replace the placeholders with the correct words and output the final translation when the third initial translation passes through the word classification decoder.

[0092] This invention also provides a terminal device including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the various steps of the machine translation method described in the above embodiments.

[0093] This invention also provides a storage medium, which is a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the various steps of the machine translation method described in the above embodiments.

[0094] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the foregoing embodiments have described the present invention in detail, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A machine translation method based on imitation learning, characterized in that, include: Input the original text to be translated into a non-autoregressive model to obtain the first initial translation; When the first initial translation is processed by the deletion classification decoder, erroneous words in the first initial translation are deleted, and the second initial translation is output. When the second initial translation is passed through the insertion classification decoder, placeholders are used to fill in the missing word positions in the second initial translation, and the third initial translation is output. When the third initial translation is processed by the word classification decoder, the placeholders are replaced with the correct words, and the final translation is output. Before inputting the original text to be translated into the non-autoregressive model to obtain the first initial translation, the following steps are included: Obtain the translated original text and the corresponding reference translation; Using the translated original text and the reference translation as training data, a basic translation model is trained to obtain the deletion classification decoder, the insertion classification decoder, and the word classification decoder. Using the translated original text and the reference translation as training data, a basic translation model is trained to obtain a deletion classification decoder, an insertion classification decoder, and a word classification decoder, including: A baseline translation model is obtained by training a non-autoregressive model. The baseline translation model is used to translate the original text to be translated, generating a baseline translation; The baseline translation and the reference translation are processed by the edit distance algorithm to construct the classifier data of the deletion classification decoder, the classifier data of the insertion classification decoder, and the classifier data of the word classification decoder; The baseline translation model is trained using the classifier data of the deletion classifier decoder, the insertion classifier decoder, and the word classifier decoder based on the imitation learning algorithm, thereby obtaining the deletion classifier decoder, the insertion classifier decoder, and the word classifier decoder.

2. The machine translation method based on imitation learning as described in claim 1, characterized in that, When using the translated original text and the reference translation as training data, the translated original text and the reference translation are converted into original-translation pairs.

3. The machine translation method based on imitation learning as described in claim 1, characterized in that, The baseline translation and the reference translation are processed using an edit distance algorithm, including: The shortest distance from the baseline translation to the reference translation is calculated using an edit distance algorithm.

4. The machine translation method based on imitation learning as described in claim 3, characterized in that, Constructing the classifier data for the deletion classifier decoder and the classifier data for the insertion classifier decoder includes: The classifier data for the deletion classifier and the classifier data for the insertion classifier are constructed based on the shortest distance.

5. The machine translation method based on imitation learning as described in claim 3, characterized in that, The classifier data for constructing the word classification decoder includes: When the shortest distance is available, classifier data for the word classification decoder is constructed based on the word replacements from the baseline translation to the reference translation.

6. A machine translation device based on imitation learning, characterized in that, include: The initial translation module is used to input the original text to be translated into a non-autoregressive model to obtain the first initial translation; The first decoding module is used to delete erroneous words in the first initial translation and output the second initial translation when the first initial translation passes through the deletion classification decoder. The second decoding module is used to fill in the missing word positions in the second initial translation with placeholders and output the third initial translation when the second initial translation passes through the insertion classification decoder. The third decoding module is used to replace the placeholders with the correct words when the third initial translation passes through the word classification decoder, and output the final translation; Before inputting the original text to be translated into the non-autoregressive model to obtain the first initial translation, the following steps are included: Obtain the translated original text and the corresponding reference translation; Using the translated original text and the reference translation as training data, a basic translation model is trained to obtain the deletion classification decoder, the insertion classification decoder, and the word classification decoder. Using the translated original text and the reference translation as training data, a basic translation model is trained to obtain a deletion classification decoder, an insertion classification decoder, and a word classification decoder, including: A baseline translation model is obtained by training a non-autoregressive model. The baseline translation model is used to translate the original text to be translated, generating a baseline translation; The baseline translation and the reference translation are processed by the edit distance algorithm to construct the classifier data of the deletion classification decoder, the classifier data of the insertion classification decoder, and the classifier data of the word classification decoder; The baseline translation model is trained using the classifier data of the deletion classifier decoder, the insertion classifier decoder, and the word classifier decoder based on the imitation learning algorithm, thereby obtaining the deletion classifier decoder, the insertion classifier decoder, and the word classifier decoder.

7. A terminal device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it implements the steps of the machine translation method based on imitation learning as described in any one of claims 1 to 5.

8. A storage medium, said storage medium being a computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements each step of the machine translation method based on imitation learning as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Correction term pair automatic positioning method and device, electronic equipment and storage medium

    CN111985254A

  • Translation method and device, readable medium and electronic equipment

    CN115409044A