Translation method, model training method, device, terminal and storage medium
By inputting the prefix source sentence and the target translation sentence from the previous time step into the translation model, and using encoding and attention modules to generate a more stable target translation sentence, the problem of easy modification of translation results in machine simultaneous interpretation is solved, and the stability and quality of translation are improved.
Patent Information
- Application Number
- CN202111574305.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-21
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2041-12-21
AI Technical Summary
In machine simultaneous interpretation, existing technologies are prone to modifying translation results when dealing with incomplete sentences, leading to decreased stability and user experience.
By inputting the prefix source sentence and the target translation sentence received in chronological order into the translation model, the encoding module and attention module are used to splice and associate them to generate a more stable target translation sentence, reducing the need to modify the translated text.
It improves the stability and quality of translation, reduces the deviation of translation results, and does not increase the model structure or decoding time.
Smart Images

Figure CN114444520B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of artificial intelligence, and in particular, to a translation method, a model training method, an apparatus, a terminal and a storage medium. BACKGROUND
[0002] Generally, machine simultaneous translation refers to converting the content of a speaker into text in real time by using speech recognition technology, then translating the text into a target language by using machine translation, and finally displaying the translated text on the screen or playing the result through speech synthesis in the form of voice translation. An important aspect of machine simultaneous translation is to ensure the synchronization of translation. Here, synchronization refers to the fact that the input is substantially synchronized with the output of the translation result. In order to ensure the synchronization of translation, the speaker speaks a certain number of words to be translated at time a, and the machine translates the corresponding translated text A. However, in common cases, the multiple words to be translated spoken by the speaker at time a are not a complete sentence, and the speaker may continue to output the remaining words to be translated of the complete sentence at time b. When the machine translation translates the complete sentence at time b, the translated text A that has been output is often modified, resulting in a decrease in translation stability and affecting the user experience. If the complete sentence is not spoken in two times but in three times or more, each translation may modify the translated text that has been translated before, further affecting the user experience. SUMMARY
[0003] The present disclosure provides a translation method, a model training method, an apparatus, a terminal and a storage medium.
[0004] According to a first aspect of the present disclosure, a translation method is provided, which comprises:
[0005] inputting the m-1th target translated sentence corresponding to the mth prefix source sentence and the m-1th prefix source sentence received in time sequence into the translation model to obtain the mth target translated sentence corresponding to the mth prefix source sentence; wherein the mth prefix source sentence is a sentence formed by connecting the first word to be translated to the kth word to be translated in the complete source sentence, the k is a positive integer greater than or equal to 2, the number of words to be translated contained in the mth prefix source sentence is greater than the number of words to be translated contained in the m-1th prefix source sentence, and is less than the number of words to be translated contained in the m+1th prefix source sentence; and the m is a positive integer not less than 2.
[0006] In some embodiments, the method further comprises:
[0007] inputting the first prefix source sentence and a preset translated sentence received in time sequence into the trained translation model to obtain the first target translated sentence corresponding to the first prefix source sentence; wherein the first prefix source sentence is a sentence formed by connecting the first word to be translated to the qth word to be translated in the complete source sentence, and the q is a positive integer less than the k.
[0008] In some embodiments, the inputting the m-1th target translation sentence corresponding to the mth prefix source sentence and the m-1th prefix source sentence into the translation model to obtain the mth target translation sentence corresponding to the mth prefix source sentence comprises:
[0009] splicing the word to be translated in the mth prefix source sentence and the target translation word in the m-1th target translation sentence to obtain an mth spliced vector;
[0010] inputting the mth spliced vector into an encoding module of the translation model to obtain a first vector;
[0011] associating the word to be translated vector and the target translation word vector in the first vector to obtain a second vector; wherein the word to be translated vector is a word vector corresponding to the word to be translated in the mth prefix source sentence, and the target translation word vector is a word vector corresponding to the target translation word in the m-1th target translation sentence;
[0012] inputting the second vector into a decoder of the translation model to obtain the mth target translation sentence.
[0013] In some embodiments, the associating the word to be translated vector and the target translation word vector in the first vector to obtain the second vector comprises:
[0014] allocating attention probabilities to the word to be translated vector and the target translation word vector of the first vector respectively through an attention module of the translation model;
[0015] weighting and summing the word to be translated vector and the allocated attention probability, and weighting and summing the target translation word vector and the allocated attention probability to obtain the second vector.
[0016] According to a second aspect of the present disclosure, a model training method is provided, which comprises:
[0017] training a translation model by taking the n th prefix source sentence and the n-1th target translation sentence as input data and taking the n th target translation sentence as a label;
[0018] wherein the n th prefix source sentence is a sentence formed by connecting the first word to be translated to the e th word to be translated in the source sentence of the training set, e is a positive integer greater than or equal to 2, the n th prefix source sentence contains more words to be translated than the n-1th prefix source sentence, and less words to be translated than the n+1th prefix source sentence, and n is a positive integer not less than 2.
[0019] In some embodiments, the input data further comprises:
[0020] The first prefix source sentence and the preset translation sentence; wherein the first prefix source sentence is a sentence formed by connecting the first to the xth to-be-translated word in the source sentence of the training set, and x is a positive integer less than e.
[0021] In some embodiments, the method further comprises:
[0022] inputting the nth prefix source sentence into a preset model to obtain a first probability sequence of a to-be-output translation word corresponding to a to-be-translated word in the nth prefix source sentence;
[0023] In response to the translation of the first to-be-translated word in the nth prefix source sentence, determining that the to-be-output translation word pointed to by the maximum probability in the first probability sequence is a first target translation word corresponding to the first to-be-translated word;
[0024] In response to the translation of the ith to-be-translated word in the nth prefix source sentence, determining an ith target translation word corresponding to the ith to-be-translated word in the nth prefix source sentence according to an (i-1)th target translation word corresponding to an (i-1)th to-be-translated word in the nth prefix source sentence and an (i-1)th target translation word of an (n-1)th target translation sentence; wherein i is a positive integer not less than 2;
[0025] connecting the output target translation words corresponding to the to-be-translated words in the nth prefix source sentence to obtain the nth target translation sentence.
[0026] In some embodiments, the determining of the ith target translation word corresponding to the ith to-be-translated word in the nth prefix source sentence according to the (i-1)th target translation word corresponding to the (i-1)th to-be-translated word in the nth prefix source sentence and the (i-1)th target translation word of the (n-1)th target translation sentence comprises:
[0027] if the (i-1)th target translation word in the nth prefix source sentence is the same as the (i-1)th target translation word of the (n-1)th target translation sentence, increasing the probability of the to-be-output translation word corresponding to the (i-1)th target translation word in the (n-1)th target translation sentence in the first probability sequence to obtain a second probability sequence of the to-be-output translation word;
[0028] determining that the to-be-output translation word pointed to by the maximum probability in the second probability sequence is the ith target translation word of the nth prefix source sentence.
[0029] In some embodiments, the increasing of the probability of the to-be-output translation word corresponding to the ith target word in the (n-1)th target translation sentence in the first probability sequence to obtain the second probability sequence of the to-be-output translation word comprises:
[0030] determining an ith target translation word of a to-be-translated word in the (n-1)th target translation sentence that aligns with the ith to-be-translated word in the nth prefix source sentence.
[0031] determining a preset probability sequence according to the i-th target translation word in the n-1-th target translation sentence; wherein, a probability of the i-th to-be-output word in the preset probability sequence corresponding to the i-th target word in the n-1-th target translation sentence is 1, and a probability of the i-th to-be-output word not corresponding to the i-th target word in the n-1-th target translation sentence is 0;
[0032] performing weighted summation on the first probability sequence and the preset probability sequence to obtain the second probability sequence;
[0033] wherein, a sum of the first weight corresponding to the first probability sequence and the second weight corresponding to the preset sequence is equal to 1.
[0034] In some embodiments, the determining the i-th target translation word corresponding to the i-1-th to-be-translated word in the n-th prefix source sentence according to the i-1-th target translation word corresponding to the i-1-th to-be-translated word in the n-th prefix source sentence and the i-1-th target translation word in the n-1-th target translation sentence comprises:
[0035] if the i-1-th target translation word in the n-th prefix source sentence is different from the i-1-th target translation word in the n-1-th target translation sentence, determining that the to-be-output translation word pointed to by the maximum probability in the first probability sequence is the i-th target translation word of the n-th prefix source sentence.
[0036] In some embodiments, the method further comprises:
[0037] obtaining a complete translation sentence corresponding to the source sentence in the training set;
[0038] selecting a translation word corresponding to the to-be-translated word in the n-th prefix source sentence in the complete translation sentence to obtain the n-th target translation sentence.
[0039] In some embodiments, the training the translation model by taking the n-th prefix source sentence and the n-1-th target translation sentence as input data and taking the n-th target translation sentence as a label comprises:
[0040] concatenating the to-be-translated word in the n-th prefix source sentence and the target translation word in the n-1-th target translation sentence to obtain an n-th concatenated vector;
[0041] inputting the n-th concatenated vector into an encoding module of the translation model to obtain a first vector;
[0042] associating a to-be-translated word vector in the first vector and a target translation word vector to obtain a second vector; wherein, the to-be-translated word vector is a word vector corresponding to the to-be-translated word in the m-th prefix source sentence, and the target translation word vector is a word vector corresponding to the target translation word in the m-1-th target translation sentence.
[0043] inputting the second vector into a decoder of the translation model to obtain a translation result corresponding to the nth prefix source sentence;
[0044] updating parameters of the translation model according to the translation result and the label.
[0045] In some embodiments, the associating the word to be translated in the nth prefix source sentence with the (n-1)th target translation word to obtain a second vector comprises:
[0046] allocating, by an attention module of the translation model, an attention probability to the word vector to be translated and the target translation word vector of the first vector, respectively;
[0047] performing weighted summation on the word vector to be translated and the allocated attention probability, and performing weighted summation on the target translation word vector and the allocated attention probability to obtain the second vector.
[0048] According to a third aspect of the embodiments of the present disclosure, a translation device is provided, which comprises:
[0049] The first translation module is configured to input an (m-1)th target translation sentence corresponding to an mth prefix source sentence and an (m-1)th prefix source sentence received in time sequence into the translation model to obtain an mth target translation sentence corresponding to the mth prefix source sentence, wherein the mth prefix source sentence is a sentence formed by connecting the first word to be translated to the kth word to be translated in the complete source sentence, the k is a positive integer greater than or equal to 2, the number of words to be translated contained in the mth prefix source sentence is greater than the number of words to be translated contained in the (m-1)th prefix source sentence, and is less than the number of words to be translated contained in an (m+1)th prefix source sentence, and the m is a positive integer not less than 2.
[0050] In some embodiments, the device further comprises:
[0051] The second translation module is configured to input a first prefix source sentence and a preset translation sentence received in time sequence into the trained translation model to obtain a first target translation sentence corresponding to the first prefix source sentence, wherein the first prefix source sentence is a sentence formed by connecting the first word to be translated to the qth word to be translated in the complete source sentence to be translated, and the q is a positive integer less than the k.
[0052] In some embodiments, the first translation module is further configured to:
[0053] splicing the word to be translated in the mth prefix source sentence and the target translation word in the (m-1)th target translation sentence to obtain an mth splicing vector;
[0054] inputting the mth spliced vector into an encoding module of the translation model to obtain a first vector;
[0055] associating a to-be-translated word vector in the first vector and a target translated word vector to obtain a second vector; the to-be-translated word vector is a word vector corresponding to a to-be-translated word in the mth prefix source sentence, and the target translated word vector is a word vector corresponding to a target translated word in the m-1th target translated sentence;
[0056] inputting the second vector into a decoder of the translation model to obtain the mth target translated sentence.
[0057] In some embodiments, the first translation module is further configured to:
[0058] assigning, by an attention module of the translation model, an attention probability to the to-be-translated word vector and the target translated word vector of the first vector, respectively;
[0059] performing weighted summation on the to-be-translated word vector and the assigned attention probability, and performing weighted summation on the target translated word vector and the assigned attention probability to obtain the second vector.
[0060] According to a fourth aspect of the present disclosure, a model training device is provided, and the device comprises:
[0061] a training module configured to train a translation model by taking the n th prefix source sentence and the n-1th target translated sentence as input data and taking the n th target translated sentence as a label;
[0062] wherein the n th prefix source sentence is a sentence formed by connecting the first to-be-translated word to the e th to-be-translated word in the training set, e is a positive integer greater than or equal to 2, the n th prefix source sentence contains more to-be-translated words than the n-1th prefix source sentence, and less to-be-translated words than the n+1th prefix source sentence, and n is a positive integer not less than 2.
[0063] In some embodiments, the device further comprises:
[0064] a first obtaining module configured to input the n th prefix source sentence into a preset model to obtain a first probability sequence of a to-be-output translated word corresponding to a to-be-translated word in the n th prefix source sentence;
[0065] In response to the translation of the first to-be-translated word in the n th prefix source sentence, determining that the to-be-output translated word pointed to by the maximum probability in the first probability sequence is a first target translated word corresponding to the first to-be-translated word;
[0066] determining, in response to the translation of the (i-1)th word to be translated in the nth prefix source sentence, the ith target word corresponding to the ith word to be translated in the nth prefix source sentence according to the (i-1)th target word corresponding to the (i-1)th word to be translated in the nth prefix source sentence and the (i-1)th target word in the (n-1)th target translated sentence, wherein the i is a positive integer not less than 2;
[0067] connecting the target words output corresponding to the words to be translated in the nth prefix source sentence to obtain the nth target translated sentence.
[0068] In some embodiments, the first obtaining module is further configured to:
[0069] if the (i-1)th target word in the nth prefix source sentence is different from the (i-1)th target word in the (n-1)th target translated sentence, determining that the target word to be output corresponding to the maximum probability in the first probability sequence is the ith target word of the nth prefix source sentence.
[0070] determining that the target word to be output corresponding to the maximum probability in the second probability sequence is the ith target word of the nth prefix source sentence.
[0071] In some embodiments, the first obtaining module is further configured to:
[0072] determining the ith target word in the (n-1)th target translated sentence that aligns with the ith word to be translated in the nth prefix source sentence;
[0073] determining a preset probability sequence according to the ith target word in the (n-1)th target translated sentence, wherein a probability of the ith target word to be output corresponding to the ith target word in the (n-1)th target translated sentence in the preset probability sequence is 1, and a probability of the ith target word to be output not corresponding to the ith target word in the (n-1)th target translated sentence in the preset probability sequence is 0;
[0074] performing weighted summation on the first probability sequence and the preset probability sequence to obtain the second probability sequence;
[0075] wherein a sum of a first weight corresponding to the first probability sequence and a second weight corresponding to the preset sequence is equal to 1.
[0076] In some embodiments, the first obtaining module is further configured to:
[0077] if the (i-1)th target word in the nth prefix source sentence is different from the (i-1)th target word in the (n-1)th target translated sentence, determining that the target word to be output corresponding to the maximum probability in the first probability sequence is the ith target word of the nth prefix source sentence.
[0078] In some embodiments, the apparatus further includes:
[0079] a second obtaining module, configured to obtain a complete translation sentence corresponding to the source sentence in the training set;
[0080] select a translation word in the complete translation sentence corresponding to the to-be-translated word in the nth prefix source sentence, to obtain the nth target translation sentence.
[0081] According to a fifth aspect of the present disclosure, a terminal is provided, comprising:
[0082] a processor;
[0083] a memory for storing processor-executable instructions;
[0084] The processor is configured to implement the method steps of the first aspect or the second aspect.
[0085] According to a sixth aspect of the present disclosure, a computer-readable storage medium is provided, which stores a computer program, when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the method steps of the first aspect or the second aspect.
[0086] The technical solutions provided by the embodiments of the present disclosure can include the following beneficial effects:
[0087] As can be seen from the above embodiments, the present disclosure encourages the translation model to generate the mth target translation sentence based on the (m-1)th target translation sentence by inputting the mth prefix source sentence and the (m-1)th target translation sentence corresponding to the (m-1)th prefix source sentence into the trained translation model, thereby reducing the modification of the (m-1)th target translation sentence that has been translated and improving the translation stability. Moreover, the translation method of the present disclosure for reducing the amount of translation modification by modifying the input data does not change the model structure and almost does not increase the decoding time of the translation model. Furthermore, the training process and the translation process of the translation model are both based on the new input data composed of the mth prefix source sentence and the (m-1)th target translation sentence to obtain the mth target translation sentence, which ensures the consistency of the translation model training process and the translation process, and is conducive to reducing the deviation of the translation result.
[0088] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0089] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present disclosure and, together with the specification, serve to explain the principles of the present disclosure.
[0090] Figure 1 is a flow chart of a translation method according to an example embodiment;
[0091] Figure 2 is a flow chart of a model training method according to an example embodiment;
[0092] Figure 3 is a structural schematic diagram of a translation apparatus according to an example embodiment;
[0093] Figure 4 is a structural schematic diagram of a training apparatus according to an example embodiment;
[0094] Figure 5 is a structural block diagram of a terminal according to an example embodiment. DETAILED DESCRIPTION
[0095] The example embodiments will be described in detail herein with reference to the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following example embodiments do not represent all implementations consistent with the present disclosure. Instead, they are merely examples of apparatuses consistent with some aspects of the present disclosure as detailed in the appended claims.
[0096] The application scenario of the embodiments of the present disclosure is: in machine simultaneous interpretation, the output form of the target language is text. For example: real-time captioning task. The application scenario of the embodiments of the present disclosure includes but is not limited to: converting the speaking content of a speaker into text displayed on the screen, i.e. speech-to-text scenario. Or, converting the text content input in a natural speech of a speaker into text in another natural speech, i.e. text-to-text scenario. Because the output is text, a new translation with higher quality can be obtained by allowing a small amount of modification to the previously translated translation.
[0097] Before the technical solutions of the present disclosure are further described in detail, the following terms and terms involved in the embodiments of the present disclosure are described, and the following terms and terms involved in the embodiments of the present disclosure are applicable to the following explanations.
[0098] 1) Source sentence, a sentence in a certain natural language input to the translation model before translation.
[0099] 2) Translation word, a word contained in the source sentence. Generally, a source sentence contains at least one translation word.
[0100] 3) Target translation sentence, a sentence output in another natural language (also referred to as target language) after the translation model performs language conversion on part or all of the translation words in the source sentence.
[0101] 4) target translation words, target translation words contained in a target translation sentence. Generally, a target translation sentence contains at least one target translation word.
[0102] 5) to-be-output translation words, a plurality of preset words selected by the translation model before a target translation word is output as a translation of a to-be-translated word in a source sentence. The to-be-output translation words include the target translation word.
[0103] Figure 1 A flowchart of a translation method is shown. As shown in Figure 1 The first aspect of the present disclosure provides a translation method, which comprises:
[0104] inputting the m-1th target translation sentence corresponding to the mth prefix source sentence and the (m-1)th prefix source sentence received in time sequence into the trained translation model to obtain the mth target translation sentence corresponding to the mth prefix source sentence; wherein the mth prefix source sentence is a sentence formed by connecting the first to-be-translated word to the kth to-be-translated word in the complete source sentence, the k is a positive integer greater than or equal to 2, the number of to-be-translated words contained in the mth prefix source sentence is greater than the number of to-be-translated words contained in the (m-1)th prefix source sentence, and is less than the number of to-be-translated words contained in the (m+1)th prefix source sentence; and the m is a positive integer not less than 2.
[0105] In some embodiments, the translation method comprises:
[0106] Step S110: inputting the first prefix source sentence and the preset translation sentence received in time sequence into the trained translation model to obtain the first target translation sentence corresponding to the first prefix source sentence; wherein the first prefix source sentence is a sentence formed by connecting the first to-be-translated word to the qth to-be-translated word in the complete source sentence to be translated, and the q is a positive integer not less than 1.
[0107] Step S120: inputting the mth prefix source sentence and the m-1th target translation sentence corresponding to the (m-1)th prefix source sentence received in time sequence into the trained translation model to obtain the mth target translation sentence corresponding to the mth prefix source sentence; wherein the mth prefix source sentence is a sentence formed by connecting the first to-be-translated word to the kth to-be-translated word in the complete source sentence, the k is a positive integer greater than the q, the number of to-be-translated words contained in the mth prefix source sentence is greater than the number of to-be-translated words contained in the (m-1)th prefix source sentence, and is less than the number of to-be-translated words contained in the (m+1)th prefix source sentence; and the m is a positive integer not less than 2.
[0108] In steps S110 and S120, generally, the source sentence is a complete sentence. The prefix source sentence is a part of, or the entire, source sentence. For example, the source sentence is “We are friends”, the first prefix source sentence can be “We”, the second prefix source sentence can be “We are”, and the third prefix source sentence can be “We are friends”. At this time, the first and second prefix source sentences are parts of the source sentence, and the third prefix source sentence is the source sentence.
[0109] The target translation is a translation of the corresponding prefix source sentence. For example, the first prefix source sentence is translated to obtain the first target translation, the second prefix source sentence is translated to obtain the second target translation, and so on.
[0110] The preset translation can select a special token without specific meaning to reduce the influence on the translation process. For example, the Chinese translation into English can be none.
[0111] The prefix source sentence received at the later time contains more words to be translated than the prefix source sentence received at the previous time, that is, the mth prefix source sentence contains the (m-1)th prefix source sentence. For example, the source sentence is “We are friends”, and if the prefix source sentence received at the previous time is the second prefix source sentence, that is, “We are”, then the prefix source sentence received at the next time is the third prefix source sentence, that is, “We are friends”. Therefore, each time a prefix source sentence is translated, it is retranslated from the first word to be translated of the source sentence. Since the mth prefix source sentence has a more complete context than the (m-1)th prefix source sentence, this retranslation method can generate a higher quality translation in a more complete context.
[0112] In the embodiments of the present disclosure, when the mth prefix source sentence is translated, not only the mth prefix source sentence is input into the trained translation model, but also the (m-1)th target translation obtained by translation is input, so as to encourage the model to translate based on the (m-1)th target translation and reduce the modification of the (m-1)th target translation output, thereby improving the translation stability.
[0113] For example, the source sentence is “We have more market share than any other company”.
[0114] If the first prefix source sentence is "We have more market share" and the second prefix source sentence is "We have more market share than any other company", the first target translation sentence translated by the translation model is "We have a lot of market share". If only the second prefix source sentence is input into the translation model when the second prefix source sentence is translated, the second target translation sentence is likely to be "Our market share is more than any company", and the first target translation sentence is modified. In the embodiment of the present disclosure, the second prefix source sentence and the first target translation sentence are input into the translation model, and the second target translation sentence is "We have a lot of market share, more than any other company". At this time, the mth target translation sentence is accurate, and the (m-1)th target translation sentence does not need to be modified. This translation method takes into account the translation quality and translation stability.
[0115] Machine translation in the embodiment of the present disclosure refers to neural machine translation (NMT). The translation model is a neural network (NN) model, also known as an artificial neural network (ANN).
[0116] Non-limitingly, the translation model includes an encoding module, an attention module, and a decoding module. The encoding module encodes the word vector of the source sentence to obtain an encoded vector, and the decoder decodes the encoded vector into the target language. The attention module can set the weight when encoding the word vector, and consider the influence of the to-be-output translation word on the current decoding vector during the decoding process, so as to ensure the translation performance.
[0117] The translation method of the embodiment of the present disclosure for reducing the amount of translation modification by modifying the input data does not change the structure of the translation model and almost does not increase the decoding time of the translation model.
[0118] Non-limitingly, the translation model can be an LSTM (Long Short-Term Memory network) structure or a Transformer structure. The translation model is not limited thereto.
[0119] In some embodiments, the inputting of the first prefix source sentence and the preset translation sentence in time sequence into the trained translation model to obtain the first target translation sentence corresponding to the first prefix source sentence comprises: splicing the first prefix source sentence and the preset translation sentence to obtain a first spliced vector;
[0120] inputting the first spliced vector into the translation model to obtain the first target translation sentence.
[0121] In some embodiments, the inputting the mth prefix source sentence and the (m-1)th target translation sentence corresponding to the (m-1)th prefix source sentence into the translation model to obtain the mth target translation sentence corresponding to the mth prefix source sentence comprises:
[0122] splicing the mth prefix source sentence and the (m-1)th target translation sentence to obtain an mth spliced vector;
[0123] inputting the mth spliced vector into the translation model to obtain the mth target translation sentence.
[0124] In other some optional embodiments, the inputting the mth prefix source sentence and the (m-1)th target translation sentence corresponding to the (m-1)th prefix source sentence into the translation model to obtain the mth target translation sentence corresponding to the mth prefix source sentence comprises:
[0125] splicing the to-be-translated word in the mth prefix source sentence and the target translation word in the (m-1)th target translation sentence to obtain an mth spliced vector;
[0126] inputting the mth spliced vector into an encoding module of the translation model to obtain a first vector;
[0127] associating a to-be-translated word vector and a target translation word vector in the first vector to obtain a second vector; wherein the to-be-translated word vector is a word vector corresponding to a to-be-translated word in the mth prefix source sentence, and the target translation word vector is a word vector corresponding to a target translation word in the (m-1)th target translation sentence;
[0128] inputting the second vector into a decoder of the translation model to obtain the mth target translation sentence.
[0129] In actual application, since the data input into the translation model includes the current prefix source sentence (corresponding to the mth prefix source sentence, denoted as s m ) and the target translation sentence (corresponding to the (m-1)th target translation sentence, denoted as t m-1 ) corresponding to the last prefix source sentence (corresponding to the (m-1)th prefix source sentence), the encoding module encodes s m and t m-1 at the same time, that is, the first vector obtained by the encoding module already contains the information of the target translation words corresponding to the first m-1 to-be-translated words. Associating the to-be-translated word in the mth prefix source sentence with the (m-1)th target translation word can guide and encourage the model to produce new translation on the basis of the (m-1)th target translation sentence, thereby reducing the number of modifications to the last target translation.
[0130] In some other optional embodiments, the associating the to-be-translated word vector in the first vector and the target translated word vector to obtain a second vector comprises:
[0131] The attention module of the translation model respectively assigns an attention probability to the to-be-translated word vector and the target translated word vector in the first vector;
[0132] The second vector is obtained by weighted summation of the to-be-translated word vector and the assigned attention probability, and weighted summation of the target translated word vector and the assigned attention probability.
[0133] The attention probability assigned by the attention module can increase the probability of the to-be-output translated word in the to-be-output translated word vector aligning with the m-1th target translated sentence, thereby encouraging the translation model to translate based on the m-1th target translated sentence. For example, the m-1th prefix source sentence is “a b c”, the m-1th target translated sentence is “A B C”, and the mth prefix source sentence is “a b c d”. When translating the to-be-translated word “b” in “a b c d”, the attention probability assigned by the attention module can increase the probability of “B” in the to-be-output translated word vector, thereby associating “b” with “B” and encouraging the translation model to output the target translated word corresponding to “b” as “B”. All to-be-translated words in the mth prefix source sentence that align with the m-1th prefix source sentence can be translated in this way.
[0134] If the first vector is represented by h j , where h j is the to-be-translated word vector corresponding to the jth to-be-translated word in the mth prefix source sentence, or the target translated word vector corresponding to the jth target translated word; and a ij represents the assigned attention probability, a ij represents the attention probability of the jth to-be-translated word vector or target translated word vector when the decoder outputs the ith target translated word. The second vector obtained by weighted summation of the to-be-translated word vector and the assigned attention probability, and weighted summation of the target translated word vector and the assigned attention probability can be represented as , where Lx is the length of the mth prefix source sentence.
[0135] In a specific example, the translation model is used for machine simultaneous interpretation, and each prefix source sentence is obtained in the form of streaming input. That is, the first prefix source sentence is received as “I” in time sequence, the second prefix source sentence is “I like”, and the third prefix source sentence is “I like China”… When translating the first prefix source sentence, the first prefix source sentence and <none>The first spliced vector is obtained, the first spliced vector is input into the translation model to obtain the first target translation sentence "I". Then, the second prefix source sentence is translated. At this time, the second prefix source sentence and the first target translation sentence are spliced to obtain new input, that is, the second spliced vector, and then the second spliced vector is input into the translation model to obtain the second target translation sentence "I like". In this way, the last prefix source sentence is translated to obtain the target translation sentence "I like China".
[0136] The second aspect of the present disclosure provides a model training method, which comprises:
[0137] The translation model is trained by taking the nth prefix source sentence and the (n-1)th target translation sentence as input data and taking the nth target translation sentence as a label.
[0138] The nth prefix source sentence is a sentence formed by connecting the first to e-th to-be-translated words in the source sentence of the training set, e is a positive integer greater than or equal to 2, the to-be-translated words contained in the nth prefix source sentence are more than the to-be-translated words contained in the (n-1)th prefix source sentence, and less than the to-be-translated words contained in the (n+1)th prefix source sentence, and n is a positive integer not less than 2.
[0139] In actual application, the prefix source sentence can be obtained by selecting a preset proportion of to-be-translated words in the source sentence of the training set from the first to-be-translated word.
[0140] The preset proportion is the proportion of all to-be-translated words in the source sentence. The preset proportion can be 5%, 10%, 15%, 20%, 30% or 35%, but is not limited thereto.
[0141] In some embodiments, the input data further comprises:
[0142] The first prefix source sentence and the preset translation sentence, wherein the first prefix source sentence is a sentence formed by connecting the first to x-th to-be-translated words in the source sentence of the training set, and x is a positive integer less than e.
[0143] The first prefix source sentence can be a sentence formed by connecting the first to x-th to-be-translated words in the source sentence, the second prefix source sentence can be a sentence formed by connecting the first to x+1-th to-be-translated words, and so on.
[0144] The nth prefix source sentence contains the (n-1)th prefix source sentence.
[0145] The target translation sentence is a translation sentence after the corresponding prefix source sentence is translated. For example, the first prefix source sentence is translated to obtain the first target translation sentence, the second prefix source sentence is translated to obtain the second target translation sentence, and so on.
[0146] The preset translation sentence can be represented by special characters (tokens). Taking Chinese translation into English as an example, the preset translation sentence can be none.
[0147] In some embodiments, the proportion of the same target translation words in the first target translation word to the (n-1)th target translation word of the nth target translation sentence and in the (n-1)th target translation sentence is greater than or equal to a preset threshold.
[0148] The preset threshold can be 60%, 70%, 80%, or 100%, but is not limited thereto.
[0149] The greater the proportion of the same target translation words in the first target translation word to the (n-1)th target translation word of the nth target translation sentence and in the (n-1)th target translation sentence in the data of the training set, the higher the similarity of the translation sentence formed by the first (n-1) target translation words of the nth target translation sentence and the (n-1)th target translation sentence, which is more conducive to training the translation model to translate based on the (n-1)th target translation sentence, and thus is more conducive to reducing the modification of the (n-1)th target translation sentence and improving the training effect.
[0150] For example, the source sentence is "a b c d e", and the target translation sentence corresponding to the source sentence is "A B C D E". The second prefix source sentence is "a b", and the second target translation sentence is "A B". When translating the third prefix source sentence, if the to-be-translated word b can be translated into B or B0, and the third target translation sentence is "A B0 C", only A in the first two target translation words is the same as A in the second target translation sentence, and the proportion of the same target translation words is 1 / (1+1)=50%. When the third target translation sentence is "A B C", A in the first two target translation words is the same as A in the second target translation sentence, and B is the same as B, and the proportion of the same target translation words is 2 / (1+1)=100%. At this time, the third target translation sentence A B C is more conducive to training.
[0151] When translating the nth prefix source sentence, not only the nth prefix source sentence is input into the translation model, but also the (n-1)th target translation sentence is input, so as to encourage the model to translate based on the (n-1)th target translation sentence and reduce the modification of the output (n-1)th target translation sentence. This training method is conducive to increasing the stability of the translated translation model.
[0152] Furthermore, the training process and the translation process of the translation model are both based on the new input data composed of the mth prefix source sentence and the (m-1)th target translation sentence to obtain the mth target translation sentence, which ensures the consistency of the training process and the translation process of the translation model and is conducive to reducing the deviation of the translation result.
[0153] In some optional embodiments, the translation model is trained by taking the n th prefix source sentence and the (n-1) th target translation sentence as input data, and taking the n th target translation sentence as a label, including:
[0154] The n th prefix source sentence and the (n-1) th target translation sentence are spliced to obtain an n th spliced vector.
[0155] The translation model is trained by taking the n th spliced vector as the input data and taking the n th target translation sentence as the label.
[0156] In other optional embodiments, the method further includes:
[0157] The n th prefix source sentence is input into a preset model to obtain a first probability sequence of a to-be-output translation word corresponding to a to-be-translated word in the n th prefix source sentence.
[0158] In response to translation of a first to-be-translated word in the n th prefix source sentence, a first target translation word corresponding to the first to-be-translated word is determined as a to-be-output translation word pointed to by a maximum probability in the first probability sequence.
[0159] In response to translation of an i th to-be-translated word in the n th prefix source sentence, an i th target translation word corresponding to the i th to-be-translated word in the n th prefix source sentence is determined according to an (i-1) th target translation word corresponding to an (i-1) th to-be-translated word in the n th prefix source sentence and an (i-1) th target translation word of the (n-1) th target translation sentence, where i is a positive integer not less than 2.
[0160] The target translation words output corresponding to the to-be-translated words in the n th prefix source sentence are connected to obtain the n th target translation sentence.
[0161] In some embodiments, as shown in FIG. 2, Figure 2 the method includes:
[0162] In step S210, the n th prefix source sentence is input into a preset model to obtain a first probability sequence of a to-be-output translation word corresponding to a to-be-translated word in the n th prefix source sentence.
[0163] In step S220, in response to translation of a first to-be-translated word in the n th prefix source sentence, a first target translation word corresponding to the first to-be-translated word is determined as a to-be-output translation word pointed to by a maximum probability in the first probability sequence.
[0164] Step S230, in response to the translation of the i-th word to be translated in the n-th prefix source sentence, determining an i-th target translated word corresponding to an i-th word to be translated in the n-th prefix sentence according to an (i-1)-th target translated word corresponding to an (i-1)-th word to be translated in the n-th prefix source sentence and an (i-1)-th target translated word of the (n-1)-th target translated sentence; wherein the i is a positive integer not less than 2;
[0165] Step S240, connecting the target translated words corresponding to the words to be translated in the n-th prefix source sentence to obtain the n-th target translated sentence.
[0166] Step S250, training a translation model by taking the n-th prefix source sentence and the (n-1)-th target translated sentence as input data and taking the n-th target translated sentence as a label.
[0167] The steps S210 to S240 are a process of obtaining a target translated sentence, i.e., a process of preparing a training set.
[0168] In the embodiments of the present disclosure, the preset model is also a neural network translation model. For example, the preset model can be an LSTM structure or a Transformer structure, but is not limited thereto.
[0169] When the prefix source sentence is translated by using the preset model, the i-th target translated word corresponding to the i-th word to be translated in the n-th prefix sentence is determined according to the (i-1)-th target translated word corresponding to the (i-1)-th word to be translated in the n-th prefix source sentence and the (i-1)-th target translated word of the (n-1)-th target translated sentence, which is conducive to ensuring the translation quality and increasing the number of target translated words in the n-th target translated sentence that are the same as those in the (n-1)-th target translated sentence and reducing the modification of the (n-1)-th target translated sentence.
[0170] For example, if the (i-1)-th target translated word in the n-th prefix source sentence is different from the (i-1)-th target translated word of the (n-1)-th target translated sentence, it indicates that after the n-th prefix source sentence is input, the (i-1)-th target translated word corresponding to the (i-1)-th word to be translated needs to be changed to be more accurate, and at this time, it is not suitable to encourage the preset model to continue translating on the basis of the (n-1)-th target translated sentence. Conversely, if the (i-1)-th target translated word in the n-th prefix source sentence is the same as the (i-1)-th target translated word of the (n-1)-th target translated sentence, it indicates that after the n-th prefix source sentence is input, the target translated words corresponding to the first word to be translated to the (i-1)-th word to be translated are translated and expressed accurately enough, and the preset model can be encouraged to continue translating on the basis of the (n-1)-th target translated sentence, and then when the i-th word to be translated is translated, the target translated word corresponding to the i-th word to be translated in the (n-1)-th target translated sentence is selected from the output translated words as much as possible.
[0171] For the n-1 prefix source sentence does not have the to-be-translated word, that is, for the n prefix source sentence added to-be-translated word, the corresponding target translation word can be obtained according to the translation method of the first to-be-translated word. For example: the n-1 prefix source sentence contains p to-be-translated words, and the n prefix source sentence contains p+s to-be-translated words. In response to the translation of the p+s to-be-translated word, it is determined that the to-be-output translation word pointed to by the maximum probability in the first probability sequence is the p+s target translation word; wherein p is a positive integer greater than or equal to 1, and s is a positive integer greater than or equal to 1.
[0172] In other optional embodiments, the n prefix source sentence is determined according to the i-1 target translation word corresponding to the i-1 to-be-translated word in the n-1 prefix source sentence, and the i-1 target translation word in the n-1 target translation sentence, including:
[0173] If the i-1 target translation word in the n prefix source sentence is the same as the i-1 target translation word in the n-1 target translation sentence, the probability of the to-be-output translation word corresponding to the i target translation word in the n-1 target translation sentence in the first probability sequence is increased to obtain the second probability sequence of the to-be-output translation word.
[0174] It is determined that the to-be-output translation word pointed to by the maximum probability in the second probability sequence is the i target translation word of the n prefix source sentence.
[0175] In practical applications, if the i-1 target translation word in the n prefix source sentence is the same as the i-1 target translation word in the n-1 target translation sentence, it indicates that after inputting the n prefix source sentence, the target translation words corresponding to the first to-be-translated word to the i-1 to-be-translated word are translated accurately enough, and the preset model can be encouraged to continue translation based on the n-1 target translation sentence. At this time, the translation of the i to-be-translated word can be intervened so that the target translation word corresponding to the i to-be-translated word in the n-1 target translation sentence is selected from the to-be-output translation word as much as possible when the i to-be-translated word is translated, and the modification of the n-1 target translation sentence is reduced.
[0176] In other optional embodiments, the n prefix source sentence is determined according to the i-1 target translation word corresponding to the i-1 to-be-translated word in the n-1 prefix source sentence, and the i-1 target translation word in the n-1 target translation sentence, including:
[0177] Determine the i target translation word in the n-1 target translation sentence that aligns with the i to-be-translated word in the n prefix source sentence;
[0178] determine a preset probability sequence according to the i th target translation word in the n-1 th target translation sentence; wherein, the probability of the i th to-be-output word aligned with the i th target word in the n-1 th target translation sentence in the preset probability sequence is 1, and the probability of the i th to-be-output word not aligned with the i th target word in the n-1 th target translation sentence is 0;
[0179] perform weighted summation on the first probability sequence and the preset probability sequence to obtain the second probability sequence; wherein, the sum of the first weight corresponding to the first probability sequence and the second weight corresponding to the preset sequence is equal to 1.
[0180] In the embodiment of the present disclosure, when the i th to-be-translated word of the n th prefix source sentence is translated, the first probability sequence of the to-be-output translation word generated by the preset model is denoted as p now (y i ), and y i represents the i th to-be-output translation word; the preset probability sequence is denoted as δ (y i ), wherein the preset probability sequence is a one-hot probability sequence, that is, the probability of the position of the i th target translation word y i of the n-1 th prefix source sentence is 1, and the probability of the rest is 0. When the probability sequence δ (y i ) and p now (y i ) are weighted and summed, the probability of the i th to-be-output word aligned with the i th target word in the n-1 th target translation sentence in the first probability sequence is increased, thereby encouraging the translation of the n th prefix source sentence based on the n-1 th target translation sentence.
[0181] For example, the source sentence is "abcde", and the target translation sentence corresponding to the source sentence is "ABCDE". The 3 rd prefix source sentence is "abc", and the 3 rd target translation sentence is "ABC". The 4 th prefix source sentence is "abcd". When the 3 rd to-be-translated word "c" in the 4 th prefix source sentence is translated, it is determined whether the target translation word corresponding to the 2 nd to-be-translated word "b" in the 4 th prefix source sentence is the same as the target translation word "B" in the 3 rd target translation sentence. If not, no intervention is needed for the translation of the 3 rd to-be-translated word "c" in the 4 th prefix source sentence. If yes, the translation of the 3 rd to-be-translated word "c" is intervened, and the preset model is encouraged to translate the 3 rd prefix source sentence based on the 2 nd target translation sentence. The specific intervention process generally includes: increasing the probability of C in the plurality of to-be-output translation words generated by the preset model to encourage the selection of C as the target translation word of the to-be-translated word c in the 4 th prefix source sentence.
[0182] Without limitation, the second probability sequence obtained after the intervention is: p new (y i ) = (1-β)·p now (y i )+β·δ(y i ), where β is a hyper-parameter that controls the degree of intervention. In fact, this intervention is to increase the probability of the model selecting the word corresponding to the last target translation sentence, in this way, the preset model is encouraged to select the target translation as much as possible in the last target translation sentence, so as to reduce the modification amount of the newly generated target translation compared with the existing target translation.
[0183] In some other optional embodiments, the determining the i th target translation word corresponding to the i th to-be-translated word in the n th prefix source sentence according to the i th-1 target translation word corresponding to the i th-1 to-be-translated word in the n th prefix source sentence and the i th-1 target translation word in the n th-1 target translation sentence comprises:
[0184] If the i th-1 target translation word in the n th prefix source sentence is different from the i th-1 target translation word in the n th-1 target translation sentence, it is determined that the to-be-output translation word pointed to by the maximum probability in the first probability sequence is the i th target translation word of the n th prefix source sentence.
[0185] If the i th-1 target translation word in the n th prefix source sentence is different from the i th-1 target translation word in the n th-1 target translation sentence, it indicates that after inputting the n th prefix source sentence, the i th-1 target translation word corresponding to the i th-1 to-be-translated word needs to be changed to be more accurate in expression due to the n th prefix source sentence having a more complete sentence. At this time, it is not suitable to encourage the preset model to continue translation based on the n th-1 target translation sentence, and there is no need to intervene in the translation of the i th to-be-translated word.
[0186] In some other optional embodiments, the method further comprises:
[0187] obtaining a complete translation corresponding to the source sentence in the training set;
[0188] selecting a translation word corresponding to the to-be-translated word in the n th prefix source sentence in the complete translation to obtain the n th target translation.
[0189] In the embodiments of the present disclosure, the complete translation is a target translation corresponding to the source sentence.
[0190] In addition to obtaining the target translation sentence by using the preset model, the corresponding target translation word can be directly selected from the complete translation sentence to obtain the target translation sentence. For example, if the source sentence is "ab c d" and the complete translation sentence is "A B C D", the target translation word corresponding to the to-be-translated word "a" is "A", the target translation word corresponding to the to-be-translated word "b" is "B", and so on. If the first prefix source sentence is "a", the first target translation sentence is "A", if the second prefix source sentence is "ab", the second target translation sentence is "A B", if the third prefix source sentence is "abc", the third target translation sentence is "AB C". In this way, the required training data can be obtained more quickly.
[0191] In some other optional embodiments, the training of the translation model by taking the n th prefix source sentence and the n-1 th target translation sentence as input data and taking the n th target translation sentence as a label comprises:
[0192] splicing the to-be-translated word in the n th prefix source sentence and the target translation word in the n-1 th target translation sentence to obtain an n th spliced vector;
[0193] inputting the n th spliced vector into an encoding module of the translation model to obtain a first vector;
[0194] associating the to-be-translated word vector and the target translation word vector in the first vector to obtain a second vector; wherein the to-be-translated word vector is a word vector corresponding to the to-be-translated word in the m th prefix source sentence, and the target translation word vector is a word vector corresponding to the target translation word in the m-1 th target translation sentence;
[0195] inputting the second vector into a decoder of the translation model to obtain a translation result corresponding to the n th prefix source sentence;
[0196] updating the parameters of the translation model according to the translation result and the label.
[0197] In actual application, since the data input into the translation model includes the current prefix source sentence (corresponding to the n th prefix source sentence, denoted as s n ) and the target translation sentence corresponding to the last prefix source sentence (corresponding to the n-1 th prefix source sentence, denoted as t n-1 ), the encoding module encodes s n and t n-1 at the same time, that is, the first vector obtained by the encoding module already contains the information of the target translation word corresponding to the first n-1 to-be-translated words. Associating the to-be-translated word in the n th prefix source sentence with the n-1 th target translation word can guide and encourage the model to generate new translation on the basis of the n-1 th target translation, thereby reducing the number of modifications to the previous target translation.
[0198] In some other optional embodiments, the association of the first vector of the to-be-translated word vector and the target translated word vector to obtain the second vector comprises:
[0199] The attention module of the translation model assigns an attention probability to the to-be-translated word vector and the target translated word vector of the first vector, respectively;
[0200] The to-be-translated word vector and the assigned attention probability are weighted and summed, and the target translated word vector and the assigned attention probability are weighted and summed to obtain the second vector.
[0201] The attention probability assigned by the attention module can increase the probability of the target translated word aligned with the m-1th target translated sentence in the to-be-output translated word generated by the decoding module, thereby encouraging the translation model to translate based on the m-1th target translated sentence.
[0202] In a specific example, the training method of the model comprises: preparation of training data and a training process of the translation model. Wherein, the training data preparation has two methods.
[0203] The first method is: selecting to-be-translated words in the source sentence (denoted by source, abbreviated as s) according to a preset proportion to obtain a prefix source sentence, and selecting target translated words in the complete translated sentence (denoted by target, abbreviated as t) corresponding to the source sentence according to the proportion to obtain target translated sentences corresponding to the corresponding prefix source sentence. In this way, triple training data (s n ,t n-1 ,t n ) is obtained, wherein s n is the n th prefix source sentence, tn is the n th target translated sentence, and t n-1 is the n-1th target translated sentence. t0 is a special character: <none>.
[0204] The second method is to obtain the target translation by biased decoding. First, select the words to be translated in the source sentence according to a preset proportion to obtain a prefix source sentence s n . Then, the sn is decoded by a preset model to obtain the corresponding target translation t n . Then, the target translation and the prefix source sentence are combined to form a triple training data: (s n , t n-1 , t n ), and t0 is also recorded as a special character: <none>.
[0205] The biased decoding in the second method is roughly as follows: inputting the nth prefix source sentence into a preset model to obtain a first probability sequence of the to-be-output translated word corresponding to the to-be-translated word in the nth prefix source sentence; in response to the translation of the first to-be-translated word in the nth prefix source sentence, determining that the to-be-output translated word with the maximum probability in the first probability sequence is the first target translated word corresponding to the first to-be-translated word.
[0206] In response to the translation of the i-th to-be-translated word in the nth prefix source sentence, if the (i-1)-th target translated word in the nth prefix source sentence is the same as the (i-1)-th target translated word in the (n-1)-th target translated sentence, increasing the probability of the to-be-output translated word corresponding to the i-th target translated word in the (n-1)-th target translated sentence in the first probability sequence to obtain a second probability sequence of the to-be-output translated word; determining that the to-be-output translated word with the maximum probability in the second probability sequence is the i-th target translated word of the nth prefix source sentence; wherein the i is a positive integer not less than 2; and connecting the output target translated words corresponding to the to-be-translated words in the nth prefix source sentence to obtain the nth target translated sentence.
[0207] If the (i-1)-th target translated word in the nth prefix source sentence is not the same as the (i-1)-th target translated word in the (n-1)-th target translated sentence, determining that the to-be-output translated word with the maximum probability in the first probability sequence is the i-th target translated word of the nth prefix source sentence.
[0208] Through the above two methods, I obtain a large amount of triple data containing the previous target sentence. The first method can quickly obtain a large amount of data, and the second method can obtain triple data with less modification of the (n-1)-th target translated sentence. The triple training data obtained by the second method is more conducive to training a translation model with high translation stability.
[0209] In the training process of the translation model, unlike the scheme of training the model using (s n ,t n ) binary tuple training data, the embodiments of the present disclosure train the model using the above constructed triple training data (s n ,t n-1 ,t n ), wherein the (s n ,t n-1) An overall input is obtained by splicing: s n + <esp>+t n-1 The label is the remaining t n For typical training data, the encoding module of the translation model will process s... n The information is encoded to guide the translation model in generating the corresponding target translation. In the scenario of this embodiment, the given input is the current s n And the last time s n-1 Corresponding translation t n-1 Therefore, the encoder will process (s) n ,t n-1 The information encoding means that the information provided by the encoding module already contains t. n In, and with t n-1 The target word information (also known as target prefix information) is aligned, and the target prefix information is associated with the current sn through an attention module. This guides and encourages the translation model to generate new target sentences based on the target prefix information, thereby reducing the dependence on t. n-1 The number of modifications. In summary, in this embodiment of the disclosure, only the training process and the form of the input need to be modified, without changing the structure of the translation model, and the decoding time is almost not increased. Moreover, the triple training data obtained through biased decoding can better help the translation model generate the nth target translation sentence with less modification to the (n-1)th target translation sentence.
[0210] A third aspect of this disclosure provides a translation apparatus, such as... Figure 3 As shown, the device 300 includes:
[0211] The first translation module 320 is used to input the m-th prefix source sentence and the (m-1)-th target translation sentence corresponding to the (m-1)-th prefix source sentence into the translation model to obtain the m-th target translation sentence corresponding to the m-th prefix source sentence; wherein, the m-th prefix source sentence is the sentence formed by connecting the first word to the k-th word to be translated in the complete source sentence, where k is a positive integer greater than or equal to 2, and the number of words to be translated contained in the m-th prefix source sentence is greater than the number of words to be translated contained in the (m-1)-th prefix source sentence and less than the number of words to be translated contained in the (m+1)-th prefix source sentence; where m is a positive integer not less than 2.
[0212] In some embodiments, such as Figure 3 As shown, the device 300 further includes:
[0213] The second translation module 310 is configured to input a first prefix source sentence and a preset translation sentence received in time sequence into the trained translation model to obtain a first target translation sentence corresponding to the first prefix source sentence, wherein the first prefix source sentence is a sentence formed by connecting a first to-be-translated word to a qth to-be-translated word in a complete source sentence to be translated, and q is a positive integer less than k.
[0214] In some other optional embodiments, the first translation module is further configured to:
[0215] splicing the to-be-translated word in the mth prefix source sentence and the target translation word in the m-1th target translation sentence to obtain an mth splicing vector;
[0216] inputting the mth splicing vector into the encoding module of the translation model to obtain a first vector;
[0217] associating the to-be-translated word vector and the target translation word vector in the vector to obtain a second vector, wherein the to-be-translated word vector is a word vector corresponding to the to-be-translated word in the mth prefix source sentence, and the target translation word vector is a word vector corresponding to the target translation word in the m-1th target translation sentence;
[0218] inputting the second vector into the decoder of the translation model to obtain the mth target translation sentence.
[0219] In some other optional embodiments, the first translation module is further configured to:
[0220] allocating attention probabilities to the to-be-translated word vector and the target translation word vector of the first vector through the attention module of the translation model;
[0221] weighting and summing the to-be-translated word first vector and the allocated attention probabilities, and weighting and summing the target translation word vector and the allocated attention probabilities to obtain the second vector.
[0222] The fourth aspect of the present disclosure provides a model training device, as shown in the following Figure 4 The device 400 includes:
[0223] The training module 430 is configured to train a translation model by taking the nth prefix source sentence and the n-1th target translation sentence as input data and taking the nth target translation sentence as a label.
[0224] The nth prefix source sentence is a sentence formed by connecting a first to-be-translated word to an e-th to-be-translated word in a training set, e is a positive integer greater than or equal to 2, the to-be-translated words contained in the nth prefix source sentence are more than the to-be-translated words contained in the n-1th prefix source sentence, and less than the to-be-translated words contained in the n+1th prefix source sentence, and n is a positive integer not less than 2.
[0225] In some embodiments, the input data further comprises: a first prefix source sentence and a preset translation sentence; wherein the first prefix source sentence is a sentence formed by connecting the first to xth to-be-translated words in the source sentence of the training set, and x is a positive integer less than e.
[0226] In other optional embodiments, as shown in Figure 4 The apparatus further comprises:
[0227] The first obtaining module 410 is configured to input the nth prefix source sentence into a preset model to obtain a first probability sequence of a to-be-output translation word corresponding to a to-be-translated word in the nth prefix source sentence.
[0228] In response to the translation of the first to-be-translated word in the nth prefix source sentence, the first probability sequence is determined, and the to-be-output translation word pointed to by the maximum probability in the first probability sequence is determined as the first target translation word corresponding to the first to-be-translated word.
[0229] In response to the translation of the ith to-be-translated word in the nth prefix source sentence, the ith target translation word corresponding to the ith to-be-translated word in the nth prefix source sentence is determined according to the (i-1)th target translation word corresponding to the (i-1)th to-be-translated word in the nth prefix source sentence and the (i-1)th target translation word of the (n-1)th target translation sentence; wherein i is a positive integer not less than 2.
[0230] The target translation words output by the to-be-translated words in the nth prefix source sentence are connected to obtain the nth target translation sentence.
[0231] In other optional embodiments, the first obtaining module is further configured to:
[0232] If the (i-1)th target translation word in the nth prefix source sentence is the same as the (i-1)th target translation word of the (n-1)th target translation sentence, the probability of the to-be-output translation word corresponding to the ith target translation word in the (n-1)th target translation sentence in the first probability sequence is increased to obtain a second probability sequence of the to-be-output translation word.
[0233] The to-be-output translation word pointed to by the maximum probability in the second probability sequence is determined as the ith target translation word of the nth prefix source sentence.
[0234] In other optional embodiments, the first obtaining module is further configured to:
[0235] The ith target translation word of the to-be-translated word in the (n-1)th target translation sentence that aligns with the ith to-be-translated word in the nth prefix source sentence is determined.
[0236] determine a preset probability sequence according to the i th target translated word in the n-1 th target translated sentence; wherein a probability of an i th to-be-output word aligned with the i th target word in the n-1 th target translated sentence in the preset probability sequence is 1, and a probability of an i th to-be-output word not aligned with the i th target word in the n-1 th target translated sentence in the preset probability sequence is 0;
[0237] perform weighted summation on the first probability sequence and the preset probability sequence to obtain the second probability sequence;
[0238] wherein a sum of a first weight corresponding to the first probability sequence and a second weight corresponding to the preset sequence is equal to 1.
[0239] In other optional embodiments, the first obtaining module is further configured to:
[0240] if the i-1 th target translated word in the n th prefix source sentence is different from the i-1 th target translated word in the n-1 th target translated sentence, determine that the to-be-output translated word to which the maximum probability in the first probability sequence points is the i th target translated word of the n th prefix source sentence.
[0241] In other optional embodiments, the apparatus further comprises:
[0242] The second obtaining module 420 is configured to obtain a complete translated sentence corresponding to a source sentence in the training set.
[0243] select a translated word in the complete translated sentence corresponding to the to-be-translated word in the n th prefix source sentence to obtain the n th target translated sentence.
[0244] In other optional embodiments, the training module is further configured to:
[0245] splice the to-be-translated word in the n th prefix source sentence and the target translated word in the n-1 th target translated sentence to obtain an n th spliced vector;
[0246] input the n th spliced vector into an encoding module of the translation model to obtain a first vector;
[0247] associate a to-be-translated word vector in the first vector and a target translated word vector to obtain a second vector; wherein the to-be-translated word vector is a word vector corresponding to the to-be-translated word in the m th prefix source sentence, and the target translated word vector is a word vector corresponding to the target translated word in the m-1 th target translated sentence;
[0248] input the second vector into a decoder of the translation model to obtain a translation result corresponding to the n th prefix source sentence;
[0249] update parameters of the translation model according to the translation result and the label.
[0250] In some other optional embodiments, the training module is further configured to:
[0251] assign, by an attention module of the translation model, an attention probability to each of the to-be-translated word vector and the target translated word vector;
[0252] perform weighted summation on the to-be-translated word vector and the assigned attention probability, and perform weighted summation on the target translated word vector and the assigned attention probability, to obtain the second vector.
[0253] A fifth aspect of the present disclosure provides an electronic device, comprising:
[0254] a processor;
[0255] a memory for storing processor-executable instructions;
[0256] The processor is configured to implement the method steps of the first aspect or the second aspect.
[0257] A sixth aspect of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method steps of the first aspect or the second aspect.
[0258] In exemplary embodiments, a plurality of modules in a printing device, etc. can be implemented by one or more central processing units (CPUs), graphics processing units (GPUs), baseband processors (BPs), application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic elements, for executing the foregoing methods.
[0259] Figure 5 is a block diagram of an electronic device 800 according to an exemplary embodiment. The device 800 can be a mobile phone, a computer, a digital broadcasting terminal, a message transmitter, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc., for example.
[0260] Referring to Figure 5 The device 800 can include one or more of the following components: a processing component 802, a memory 804, a power supply component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.
[0261] The processing component 802 usually controls overall operations of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 can include one or more processors 820 to execute instructions to complete all or part of steps of the above-described methods. In addition, the processing component 802 can include one or more modules to facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0262] The memory 804 is configured to store various types of data to support operations of the device 800. Examples of these data include instructions for any application or method operating on the device 800, contact data, phonebook data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage devices or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0263] The power supply component 806 supplies electric power for various components of the device 800. The power supply component 806 can include a power supply management system, one or more power supplies, and other components associated with generating, managing and distributing electric power for the device 800.
[0264] The multimedia component 808 includes a screen providing an output interface between the device 800 and a user. In some embodiments, the screen can include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors for sensing a touch, a slide and a gesture on the touch panel. The touch sensor can not only sense a boundary of a touching or a sliding action, but also detect duration and pressure related to the touching or sliding action. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operation mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data.
[0265] The audio component 810 is configured to output and / or input an audio signal. For example, the audio component 810 includes a microphone (MIC) configured to receive an external audio signal when the device 800 is in an operation mode, such as a call mode, a recording mode and a voice recognition mode. The received audio signal can be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, the audio component 810 further includes a speaker for outputting an audio signal.
[0266] The I / O interface 812 provides an interface between the processing component 802 and peripheral interface modules, such as a keypad, a click wheel, buttons and the like. The buttons can include, but are not limited to, a home button, a volume button, a start button and a lock button.
[0267] The sensor component 814 includes one or more sensors for providing status assessments of various aspects of the device 800. For example, the sensor component 814 can detect an open / closed position of the device 800, relative positioning of components, such as a display and a keypad of the device 800, a change of position of the device 800 or a component of the device 800, presence or absence of user contact with the device 800, a change in orientation of the device 800 or acceleration / deceleration of the device 800, and a temperature change of the device 800, among a plethora of other examples. The sensor component 814 can include an orientation sensor, an acceleration sensor, a proximity sensor, a gesture sensor, a gravity sensor, a biometric sensor, a temperature sensor, a humidity sensor, and an illuminance sensor, among a plethora of other examples.
[0268] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 can access a wireless network based on a communication standard, such as WiFi, 4G, or 5G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate close proximity communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technology.
[0269] In an exemplary embodiment, the device 800 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components, for performing the above-described methods.
[0270] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions, such as the memory 804 including instructions, is also provided, which can be executed by the processor 820 of the device 800 to complete the above-described methods. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disc, and an optical data storage device, etc.
[0271] The methods disclosed in several method embodiments of the present disclosure can be combined arbitrarily without conflict, to obtain new method embodiments.
[0272] The features disclosed in several device embodiments of the present disclosure can be combined arbitrarily without conflict, to obtain new product embodiments.
[0273] The features disclosed in several method or device embodiments of the present disclosure can be combined arbitrarily without conflict, to obtain new method embodiments or product embodiments.
[0274] Other embodiments of the present disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the aspects of the present disclosure disclosed herein. It is intended that the present disclosure cover any and all variations of the present disclosure included within the spirit and scope of the basic underlying principles disclosed and such variations are to be considered as falling within the purview of the exemplary embodiments. It is intended that the specification and examples be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.
[0275] It should be understood that the present disclosure is not limited to the precise construction that has been described above and shown in the accompanying drawings, and that various modifications and changes can be made by those skilled in the art without departing from the scope of the present disclosure. The scope of the present disclosure is limited only by the appended claims.< / esp> < / none> < / none> < / none>
Claims
1. A translation method, characterized in that, The method includes: The m-th prefix source sentence and the (m-1)-th target translation sentence corresponding to the (m-1)-th prefix source sentence, received in chronological order, are input into the translation model to obtain the m-th target translation sentence corresponding to the m-th prefix source sentence. The m-th prefix source sentence is the sentence formed by connecting the first word to the k-th word in the complete source sentence, where k is a positive integer greater than or equal to 2, and the number of words to be translated in the m-th prefix source sentence is greater than the number of words to be translated in the (m-1)-th prefix source sentence but less than the number of words to be translated in the (m+1)-th prefix source sentence; where m is a positive integer not less than 2. The step of inputting the m-th prefix source sentence and the (m-1)-th target translation sentence corresponding to the (m-1)-th prefix source sentence, received in chronological order, into the translation model to obtain the m-th target translation sentence corresponding to the m-th prefix source sentence includes: By concatenating the word to be translated in the m-th prefix source sentence and the target word in the (m-1)-th target translation sentence, the m-th concatenation vector is obtained; The m-th concatenated vector is input into the encoding module of the translation model to obtain the first vector; By associating the word vector to be translated and the target word vector in the first vector, a second vector is obtained; wherein, the word vector to be translated is the word vector corresponding to the word to be translated in the m-th prefix source sentence, and the target word vector is the word vector corresponding to the target word in the (m-1)-th target translation sentence; The second vector is input into the decoder of the translation model to obtain the m-th target translation.
2. The method according to claim 1, characterized in that, The method further includes: The first prefix source sentence and the preset translation sentence, received in chronological order, are input into the trained translation model to obtain the first target translation sentence corresponding to the first prefix source sentence; wherein, the first prefix source sentence is the sentence formed by connecting the first word to be translated to the qth word to be translated in the complete source sentence, and q is a positive integer less than k.
3. The method according to claim 1, characterized in that, The second vector is obtained by associating the word vector to be translated and the target word vector in the first vector, including: The attention module of the translation model assigns attention probabilities to the word vector to be translated and the target word vector of the first vector, respectively. The second vector is obtained by weighted summation of the word vector to be translated and the assigned attention probability, and by weighted summation of the target word vector and the assigned attention probability.
4. A model training method, characterized in that, The method includes: The translation model is trained using the nth prefix source sentence and the (n-1)th target translation sentence as input data, and the nth target translation sentence as the label. Wherein, the nth prefix source sentence is the sentence formed by connecting the first word to be translated to the eth word to be translated in the source sentences of the training set, where e is a positive integer greater than or equal to 2, and the nth prefix source sentence contains more words to be translated than the (n-1)th prefix source sentence contains, but less words to be translated than the (n+1)th prefix source sentence contains, where n is a positive integer not less than 2; The process of training a translation model using the nth prefix source sentence and the (n-1)th target translation sentence as input data, and the nth target translation sentence as the label, includes: By concatenating the word to be translated in the nth prefix source sentence and the target word in the (n-1)th target translation sentence, the nth concatenation vector is obtained; The nth concatenated vector is input into the encoding module of the translation model to obtain the first vector; By associating the word vector to be translated and the target word vector in the first vector, a second vector is obtained; wherein, the word vector to be translated is the word vector corresponding to the word to be translated in the nth prefix source sentence, and the target word vector is the word vector corresponding to the target word in the (n-1)th target translation sentence; The second vector is input into the decoder of the translation model to obtain the translation result corresponding to the nth prefix source sentence; The parameters of the translation model are updated based on the translated result and the label.
5. The method according to claim 4, characterized in that, The input data also includes: The first prefix source sentence and the preset translation sentence; wherein, the first prefix source sentence is the sentence formed by connecting the first word to be translated to the xth word in the source sentences of the training set, and x is a positive integer less than e.
6. The method according to claim 4, characterized in that, The method further includes: The nth prefix source sentence is input into the preset model to obtain the first probability sequence of the output translation words corresponding to the translation words in the nth prefix source sentence; In response to the translation of the first word to be translated in the nth prefix source sentence, the word to be output with the highest probability in the first probability sequence is determined to be the first target word corresponding to the first word to be translated; In response to the translation of the ith word to be translated in the nth prefix source sentence, the ith target translation word corresponding to the (i-1)th word to be translated in the nth prefix source sentence is determined based on the (i-1)th target translation word corresponding to the (i-1)th word to be translated in the nth prefix source sentence and the (i-1)th target translation word of the (n-1)th target translation sentence; where i is a positive integer not less than 2; Connect the target translation word corresponding to the word to be translated in the nth prefix source sentence to obtain the nth target translation sentence.
7. The method according to claim 6, characterized in that, The step of determining the i-th target translation word corresponding to the i-th word in the n-th prefix source sentence based on the i-1-th target translation word corresponding to the i-th word to be translated in the n-th prefix source sentence and the i-1-th target translation word in the n-1-th target translation sentence includes: If the (i-1)th target translation word in the nth prefix source sentence is the same as the (i-1)th target translation word in the (n-1)th target translation sentence, increase the probability of the output translation word corresponding to the ith target translation word in the (n-1)th target translation sentence in the first probability sequence to obtain the second probability sequence of the output translation word; In the second probability sequence, the term to be translated that points to the highest probability is determined to be the i-th target term of the n-th prefix source sentence.
8. The method according to claim 7, characterized in that, The step of increasing the probability of the target word to be output in the first probability sequence corresponding to the i-th target word in the (n-1)-th target translation sentence to obtain the second probability sequence of the target word to be output includes: In the (n-1)th target translation sentence, determine the i-th target translation word that is aligned with the i-th word to be translated in the n-th prefix source sentence; Based on the i-th target word in the (n-1)-th target translation sentence, a preset probability sequence is determined; wherein, in the preset probability sequence, the probability that the i-th output word is aligned with the i-th target word in the (n-1)-th target translation sentence is 1, and the probability that the i-th output word is not aligned with the i-th target word in the (n-1)-th target translation sentence is 0; The second probability sequence is obtained by weighted summation of the first probability sequence and the preset probability sequence; Wherein, the sum of the first weight corresponding to the first probability sequence and the second weight corresponding to the preset probability sequence is equal to 1.
9. The method according to claim 6, characterized in that, The step of determining the i-th target translation word corresponding to the i-th word in the n-th prefix source sentence based on the i-1-th target translation word corresponding to the i-th word to be translated in the n-th prefix source sentence and the i-1-th target translation word in the n-1-th target translation sentence includes: If the (i-1)th target translation word in the nth prefix source sentence is different from the (i-1)th target translation word in the (n-1)th target translation sentence, then the output translation word pointed to by the highest probability in the first probability sequence is determined to be the i-th target translation word of the nth prefix source sentence.
10. The method according to claim 4, characterized in that, The method further includes: Obtain the complete translated sentences corresponding to the source sentences in the training set; Select the word in the complete translated sentence that corresponds to the word to be translated in the nth prefix source sentence to obtain the nth target translated sentence.
11. The method according to claim 4, characterized in that, The second vector is obtained by associating the word vector to be translated and the target word vector in the first vector, including: The attention module of the translation model assigns attention probabilities to the word vector to be translated and the target word vector of the first vector, respectively. The second vector is obtained by weighted summation of the word vector to be translated and the assigned attention probability, and by weighted summation of the target word vector and the assigned attention probability.
12. A translation device, characterized in that, The device includes: The first translation module is used to input the m-th prefix source sentence and the (m-1)-th target translation sentence corresponding to the (m-1)-th prefix source sentence, received in chronological order, into the translation model to obtain the m-th target translation sentence corresponding to the m-th prefix source sentence; wherein, the m-th prefix source sentence is a sentence formed by connecting the first word to the k-th word to be translated in the complete source sentence, where k is a positive integer greater than or equal to 2, and the number of words to be translated contained in the m-th prefix source sentence is greater than the number of words to be translated contained in the (m-1)-th prefix source sentence, but less than the number of words to be translated contained in the (m+1)-th prefix source sentence; where m is a positive integer not less than 2; The first translation module is further configured to concatenate the word to be translated in the m-th prefix source sentence and the target word in the (m-1)-th target translation sentence to obtain the m-th concatenation vector; input the m-th concatenation vector into the encoding module of the translation model to obtain a first vector; associate the word vector to be translated and the target word vector in the first vector to obtain a second vector; wherein the word vector to be translated is the word vector corresponding to the word to be translated in the m-th prefix source sentence, and the target word vector is the word vector corresponding to the target word in the (m-1)-th target translation sentence; input the second vector into the decoder of the translation model to obtain the m-th target translation sentence.
13. The apparatus according to claim 12, characterized in that, The device further includes: The second translation module is used to input the first prefix source sentence and the preset translation sentence received in chronological order into the trained translation model to obtain the first target translation sentence corresponding to the first prefix source sentence; wherein, the first prefix source sentence is a sentence formed by connecting the first word to be translated to the qth word in the complete source sentence to be translated, and q is a positive integer less than k.
14. The apparatus according to claim 12, characterized in that, The first translation module is also used for: The attention module of the translation model assigns attention probabilities to the word vector to be translated and the target word vector of the first vector, respectively. The second vector is obtained by weighted summation of the word vector to be translated and the assigned attention probability, and by weighted summation of the target word vector and the assigned attention probability.
15. A model training device, characterized in that, The device includes: The training module is used to train the translation model using the nth prefix source sentence and the (n-1)th target translation sentence as input data, and the nth target translation sentence as the label. Wherein, the nth prefix source sentence is the sentence formed by connecting the first word to the eth word to be translated in the training set, where e is a positive integer greater than or equal to 2, and the nth prefix source sentence contains more words to be translated than the (n-1)th prefix source sentence, but less words to be translated than the (n+1)th prefix source sentence, where n is a positive integer not less than 2; The training module is further configured to concatenate the word to be translated in the nth prefix source sentence and the target word in the (n-1)th target translation sentence to obtain the nth concatenation vector; input the nth concatenation vector into the encoding module of the translation model to obtain a first vector; associate the word to be translated vector and the target word vector in the first vector to obtain a second vector; wherein the word to be translated vector is the word vector corresponding to the word to be translated in the nth prefix source sentence, and the target word vector is the word vector corresponding to the target word in the (n-1)th target translation sentence; input the second vector into the decoder of the translation model to obtain the translation result corresponding to the nth prefix source sentence; and update the parameters of the translation model according to the translation result and the label.
16. The apparatus according to claim 15, characterized in that, The device further includes: The first acquisition module is used to input the nth prefix source sentence into the preset model to obtain the first probability sequence of the output translation word corresponding to the word to be translated in the nth prefix source sentence; In response to the translation of the first word to be translated in the nth prefix source sentence, the word to be output with the highest probability in the first probability sequence is determined to be the first target word corresponding to the first word to be translated; In response to the translation of the ith word to be translated in the nth prefix source sentence, the ith target translation word corresponding to the (i-1)th word to be translated in the nth prefix source sentence is determined based on the (i-1)th target translation word corresponding to the (i-1)th word to be translated in the nth prefix source sentence and the (i-1)th target translation word of the (n-1)th target translation sentence; where i is a positive integer not less than 2; Connect the target translation word corresponding to the word to be translated in the nth prefix source sentence to obtain the nth target translation sentence.
17. The apparatus according to claim 16, characterized in that, The acquisition module is also used for: If the (i-1)th target translation word in the nth prefix source sentence is the same as the (i-1)th target translation word in the (n-1)th target translation sentence, increase the probability of the output translation word corresponding to the ith target translation word in the (n-1)th target translation sentence in the first probability sequence to obtain the second probability sequence of the output translation word; In the second probability sequence, the term to be translated that points to the highest probability is determined to be the i-th target term of the n-th prefix source sentence.
18. The apparatus according to claim 17, characterized in that, The acquisition module is also used for: In the (n-1)th target translation sentence, determine the i-th target translation word that is aligned with the i-th word to be translated in the n-th prefix source sentence; Based on the i-th target word in the (n-1)-th target translation sentence, a preset probability sequence is determined; wherein, in the preset probability sequence, the probability that the i-th output word is aligned with the i-th target word in the (n-1)-th target translation sentence is 1, and the probability that the i-th output word is not aligned with the i-th target word in the (n-1)-th target translation sentence is 0; The second probability sequence is obtained by weighted summation of the first probability sequence and the preset probability sequence; Wherein, the sum of the first weight corresponding to the first probability sequence and the second weight corresponding to the preset probability sequence is equal to 1.
19. The apparatus according to claim 16, characterized in that, The acquisition module is also used for: If the (i-1)th target translation word in the nth prefix source sentence is different from the (i-1)th target translation word in the (n-1)th target translation sentence, then the output translation word pointed to by the highest probability in the first probability sequence is determined to be the i-th target translation word of the nth prefix source sentence.
20. The apparatus according to claim 15, characterized in that, The device further includes: The second acquisition module is used to acquire the complete translated sentences corresponding to the source sentences in the training set; Select the word in the complete translated sentence that corresponds to the word to be translated in the nth prefix source sentence to obtain the nth target translated sentence.
21. A terminal, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to: execute the method steps of any one of claims 1 to 3, or execute the method steps of any one of claims 4 to 11, when implemented.
22. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the method steps of any one of claims 1 to 3, or the method steps of any one of claims 4 to 11, when implemented.
Citation Information
Patent Citations
Translation method and device based on machine translation model, equipment and storage medium
CN110457713A
Statement translation method and device, electronic equipment and storage medium
CN111832322A