Translation method, device, computer equipment and storage medium

By encoding and jointly decoding the target source sentence and the initial translation sentence in machine translation to generate sentence adjustment operations, the problem of low translation accuracy in the existing technology is solved and higher translation accuracy is achieved.

CN110263348BActive Publication Date: 2024-09-13TENCENT TECHNOLOGY (SHENZHEN) CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910168264.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-03-06
Publication Date
2024-09-13
Estimated Expiration
2039-03-06

AI Technical Summary

Technical Problem

Among the existing machine translation methods, the translation accuracy based on the Encoder-Decoder framework is low, and it is difficult to effectively improve the accuracy of translation.

Method used

By obtaining the target source sentence and the initial translation sentence, using the trained machine learning model to encode and jointly decode them, generate a sequence of sentence adjustment operations, and then adjust the initial translation sentence to improve the accuracy of translation.

Benefits of technology

By combining the semantic information of the source sentence and the initial translation sentence, a highly accurate sentence adjustment operation is generated, which significantly improves the accuracy of translation and improves the quality of translation results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110263348B
    Figure CN110263348B
Patent Text Reader

Abstract

The present invention relates to a translation method, apparatus, computer equipment and storage medium, the method comprising: obtaining a target source sentence and an initial translation sentence obtained by translating the target source sentence; encoding the target source sentence and the initial translation sentence using a trained machine learning model to obtain a first encoding vector sequence corresponding to the target source sentence and a second encoding vector sequence corresponding to the initial translation sentence; jointly decoding the first encoding vector sequence and the second encoding vector sequence using the machine learning model to obtain a sentence adjustment operation sequence; sentence adjustment is performed on the initial translation sentence according to the sentence adjustment operation sequence to obtain a target translation sentence corresponding to the target source sentence. The above method can improve translation accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine learning, and in particular to a translation method, apparatus, computer device and storage medium. Background Art

[0002] Machine translation refers to the translation of a natural language text into another natural language text by computer to achieve conversion between texts in different languages. With the development of information technology, the demand for translation is increasing. At present, translation can be performed based on the Encoder-Decoder framework, in which the encoding model encodes the input target source sentence to obtain a sequence of encoding vectors, and the decoding model decodes the encoding vector sequence to obtain the target sentence. However, in the above framework, the accuracy of the target sentence translated is low. Summary of the invention

[0003] Based on this, it is necessary to provide a translation method, apparatus, computer device and storage medium to address the problem of low accuracy of target sentences translated using traditional machine models.

[0004] A translation method, the method comprising: obtaining a target source sentence and an initial translation sentence obtained by translating the target source sentence; encoding the target source sentence and the initial translation sentence using a trained machine learning model to obtain a first encoding vector sequence corresponding to the target source sentence and a second encoding vector sequence corresponding to the initial translation sentence; jointly decoding the first encoding vector sequence and the second encoding vector sequence using the machine learning model to obtain a sentence adjustment operation sequence; sentence adjustment is performed on the initial translation sentence according to the sentence adjustment operation sequence to obtain a target translation sentence corresponding to the target source sentence.

[0005] A translation device, the device comprising: a source sentence and an initial translation sentence acquisition module, used to acquire a target source sentence and an initial translation sentence obtained by translating the target source sentence; an encoding module, used to encode the target source sentence and the initial translation sentence using a trained machine learning model to obtain a first encoding vector sequence corresponding to the target source sentence and a second encoding vector sequence corresponding to the initial translation sentence; a decoding module, used to jointly decode the first encoding vector sequence and the second encoding vector sequence using the machine learning model to obtain a sentence adjustment operation sequence; and an adjustment module, used to perform sentence adjustment on the initial translation sentence according to the sentence adjustment operation sequence to obtain a target translation sentence corresponding to the target source sentence.

[0006] In some embodiments, the machine learning model includes an operation decoding model and a word decoding model, and the decoding module includes: an operation obtaining unit, which is used to use the operation decoding model to jointly decode the first encoding vector sequence and the second encoding vector sequence to obtain the candidate operation decoding result at the current moment, and determine the current sentence adjustment operation corresponding to the current moment according to the candidate operation decoding result at the current moment; a word obtaining unit, which is used to use the word decoding model to decode according to the candidate operation decoding result at the current moment to obtain the target word corresponding to the current moment; the adjustment module is used to: perform sentence adjustment on the initial translation sentence according to the sentence adjustment operations corresponding to each moment and the target word, and obtain the target translation sentence corresponding to the target source sentence.

[0007] In some embodiments, the operation obtaining unit includes: a first coefficient obtaining subunit, which is used to determine, for each first coding vector of the first coding vector sequence, a first attention allocation weight coefficient relative to the target word to be output at the current moment; a second coefficient obtaining subunit, which is used to determine, for each second coding vector of the second coding vector sequence, a second attention allocation weight coefficient relative to the target word to be output at the current moment; a joint vector obtaining subunit, which is used to calculate the joint vector according to the first coding vector sequence and the corresponding first attention allocation weight coefficient, the second coding vector sequence and the corresponding second attention allocation weight coefficient; an operation decoding result obtaining subunit, which is used for the operation decoding model to decode the joint vector using the word vector of the target word output by the word decoding model at the previous moment to obtain the candidate operation decoding result at the current moment.

[0008] In some embodiments, the candidate operation decoding results include the selection rates corresponding to each candidate sentence adjustment operation, and the word obtaining unit includes: a target operation vector obtaining subunit, used to calculate the target operation vector based on the operation vectors and selection rates corresponding to each candidate sentence adjustment operation, or to determine the current sentence adjustment operation based on the selection rates corresponding to each candidate sentence adjustment operation, and use the operation vector corresponding to the current sentence adjustment operation as the target operation vector; a word obtaining subunit, used to input the target operation vector into the word decoding model, and decode to obtain the target word corresponding to the current moment.

[0009] In some embodiments, the word acquisition subunit is used to: input the target operation vector, the hidden state vector of the operation decoding model at the current moment, and the hidden state vector of the word decoding model at the previous moment into the word decoding model, and decode to obtain the target word corresponding to the current moment.

[0010] In some embodiments, the training module of the machine learning model includes: a training sample acquisition unit, which is used to acquire training samples in a training sample set, wherein the training samples include a sample source sentence, an initial sample translation sentence obtained by performing an initial translation on the sample source sentence, a sample sentence adjustment operation sequence for performing sentence adjustment on the initial sample translation sentence, and an adjustment word corresponding to each sentence adjustment operation in the sample sentence adjustment operation sequence; a coding vector sequence acquisition unit, which is used to input the sample source sentence and the initial sample translation sentence in the training sample into the machine learning model for encoding, and obtain a third coding vector sequence corresponding to the sample source sentence and a fourth coding vector sequence corresponding to the initial sample translation sentence; a prediction operation and word acquisition unit, which is used to jointly decode the third coding vector sequence and the fourth coding vector sequence using the machine learning model, and obtain a prediction operation sequence and prediction words corresponding to each prediction operation in the prediction operation sequence; an updating unit, which is used to update the parameters in the machine learning model according to the difference between the prediction operation sequence and the sample sentence adjustment operation sequence, and the difference between the adjustment word and the prediction word; and a returning unit, which is used to return to the step of acquiring the training samples in the training sample set to continue model training until the training convergence condition is met to obtain a trained machine learning model.

[0011] In some embodiments, the machine learning model includes a first encoding model and a second encoding model, and the encoding module is used to: input the target source sentence into the first encoding model for encoding to obtain a first encoding vector sequence corresponding to the target source sentence, and input the initial translation sentence into the second encoding model for encoding to obtain a second encoding vector sequence corresponding to the initial translation sentence.

[0012] In some embodiments, the source sentence and initial translation sentence acquisition module is used to: acquire a target source sentence to be translated; input the target source sentence into a machine translation model, and translate to obtain an initial translation sentence corresponding to the target source sentence.

[0013] A computer device comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the above-mentioned translation method.

[0014] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the steps of the above-mentioned translation method.

[0015] The above-mentioned translation method, device, computer equipment and storage medium, after obtaining the target source sentence and the initial translation sentence obtained by initial translation of the target source sentence, further encode the target source sentence and the initial translation sentence using a machine learning model, obtain the corresponding encoding vector sequence and jointly decode the encoding vector sequence, obtain the operation sequence for adjusting the initial translation sentence, and perform sentence adjustment on the initial translation sentence. By jointly decoding the encoding vector sequence of the initial translation sentence and the source sentence, it is possible to obtain a sentence adjustment operation for sentence adjustment of the initial translation sentence in combination with the semantic information of the source sentence and the initial translation sentence, and the sentence adjustment operation has high accuracy, so the target translation sentence obtained by adjusting the initial translation sentence according to the sentence adjustment operation has high accuracy, thereby improving the accuracy of the translation. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 A diagram of an application environment of a translation method provided in some embodiments;

[0017] Figure 2 A flowchart of a translation method in some embodiments;

[0018] Figure 3 A schematic diagram of the structure of a machine learning model in some embodiments;

[0019] Figure 4A A flowchart of an operation decoding model in some embodiments jointly decoding a first coding vector sequence and a second coding vector sequence to obtain a candidate operation decoding result at a current moment;

[0020] Figure 4B A schematic diagram of the structure of a machine learning model in some embodiments;

[0021] Figure 5 A flowchart of the training steps of a machine learning model in some embodiments;

[0022] Figure 6 A flowchart of a translation method in some embodiments;

[0023] Figure 7 A schematic diagram of using a machine learning model to adjust a sentence and obtain a target translation sentence in some embodiments;

[0024] Figure 8 is a structural block diagram of a translation device in some embodiments;

[0025] Fig. 9 is a structural block diagram of a training module in some embodiments;

[0026] Fig.10 A block diagram of the internal structure of a computer device in some embodiments. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0028] It is understood that the terms "first", "second", etc. used in this application may be used herein to describe various elements, but unless otherwise specified, these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of this application, a first encoding vector sequence may be referred to as a second encoding vector sequence, and similarly, a second encoding vector sequence may be referred to as a first encoding vector sequence.

[0029] Figure 1 FIG. 1 is an application environment diagram of the translation method provided in some embodiments, such as Figure 1 As shown, in the application environment, a terminal 110 and a server 120 are included, and the translation method is applied to a translation system. The terminal 110 can obtain a target source sentence, and send the target source sentence to the server 120. The server 120 obtains an initial translation sentence according to the target source sentence translation, and then executes the translation method of the embodiment of the present application to obtain a target translation sentence, and returns the target translation sentence to the terminal 110. The terminal 110 can also execute the translation method after obtaining the target source sentence to obtain the target translation sentence. It can be understood that the server 120 can also obtain the initial translation sentence and the target source sentence by other means. For example, the initial translation sentence can be obtained by preliminary translation by humans, and the terminal 110 can send the initial translation sentence and the target source sentence to the server 120.

[0030] The server 120 may be an independent physical server or a server cluster composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud servers, cloud databases, cloud storage, and CDN. The terminal 110 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal 110 and the server 120 may be connected via a communication connection such as a network, and the present invention does not limit this.

[0031] like Figure 2 As shown, in some embodiments, a translation method is proposed. This embodiment mainly applies this method to the above Figure 1 The server 120 in FIG. 1 is used as an example. Specifically, the following steps may be included:

[0032] Step S202: acquiring a target source sentence and an initial translation sentence obtained by translating the target source sentence.

[0033] Specifically, the target source sentence is a sentence to be translated. A target source sentence may include multiple words. The language of the target source sentence may be determined according to actual needs, for example, the target source sentence may be a Chinese sentence or a Japanese sentence. The initial translation sentence is a translation sentence obtained by performing an initial translation of the target source sentence. The initial translation sentence may be manually translated or automatically translated by a machine such as a server. For example, a pre-trained machine translation model may be used to translate the target source sentence to obtain an initial translation sentence.

[0034] In some embodiments, the target source sentence may be segmented to obtain a word sequence composed of each word. The initial translation sentence may also be segmented to obtain a word sequence composed of each word. The word segmentation method may be a dictionary-based or statistical-based word segmentation method. For example, assuming that the target source sentence is "Today is Sunday", the word sequence obtained by the word segmentation is "Today / is / Sunday".

[0035] In some embodiments, the target source sentence and the initial translation sentence can be directly obtained, and the target source sentence and the initial translation sentence can be segmented to obtain corresponding word sequences. The computer device can also receive word sequences generated by other computer devices based on the target source sentence and the initial translation sentence.

[0036] In some embodiments, obtaining a target source sentence and translating the target source sentence to obtain an initial translation sentence includes: obtaining a target source sentence to be translated; inputting the target source sentence into a machine translation model, and translating to obtain an initial translation sentence corresponding to the target source sentence. The machine translation model can be any translation model, for example, it can be a translation model corresponding to Google Translate or a machine translation model obtained by self-training. After obtaining the target source sentence to be translated, the target source sentence is input into the machine translation model, so that the initial translation sentence corresponding to the target source sentence can be translated.

[0037] Step S204, using the trained machine learning model to encode the target source sentence and the initial translation sentence to obtain a first encoding vector sequence corresponding to the target source sentence and a second encoding vector sequence corresponding to the initial translation sentence.

[0038] Specifically, the encoding can convert the input sentence into a vector. The encoding vector sequence refers to a vector sequence composed of encoding vectors obtained by encoding each word of the sentence. Each word of the word sequence corresponding to the sentence can be semantically encoded to extract the semantic features of each word, convert each word into a vector representation, and splice the vector representation corresponding to each word to obtain the encoding vector sequence. The trained machine learning model can be a learning model based on the Encoder-Decoder (encoding model-decoding model) structure. The machine learning model of the Encoder-Decoder structure can convert input data into another data output. In this framework, the encoder converts the input into a vector, and the decoder decodes the vector to generate output data. The encoding model and the decoding model can use the same type of neural network model, or different types of neural network models. For example, the encoder can be a CNN (Convolutional Neural Networks, Convolutional Neural Networks) model, or the encoder uses an RNN (Recurrent Neural Networks) model, and the decoder uses an RNN model. The machine learning model is pre-trained. Before translating based on the trained machine learning model, it is necessary to train the machine learning model through training data to determine the model parameters so that it can establish a mapping from input data to output data. When training the model, a supervised learning method can be used. For any training data, the output data is known, so the model parameters can be adjusted according to the predicted output data corresponding to the training data and the actual output data to obtain a machine learning model that meets the model convergence conditions.

[0039] In some embodiments, the machine learning model may be an RNN model, and each transition block of the RNN model may include a linear transformation enhanced GRU (LinearTransformationenhancedGRU) and multiple transition GRUs (TransitionGRU) after the linear transformation enhanced GRU. GRU refers to a gated recurrent unit (GatedRecurrentUnit).

[0040] In some embodiments, the target source sentence can be segmented to obtain a word sequence of the target source sentence. The word sequence can be converted into a word vector sequence through word embedding processing, and the word vector sequence is input into the hidden layer of the trained machine learning model. The encoder in the machine learning model performs semantic encoding processing on the word vector sequence corresponding to the target source sentence to obtain a first encoding vector sequence. Among them, a first encoding vector in the first encoding vector sequence can correspond to a word in the word sequence of the target source sentence. It can be understood that the initial translation sentence can also be encoded with reference to the encoding method of the target source sentence to obtain a second encoding vector sequence, which will not be repeated here.

[0041] In some embodiments, the word sequence of the target source sentence and the word sequence of the initial translation sentence can be input into the input layer of the encoder in the machine learning model, and semantic encoding processing is performed through each hidden layer in the encoder of the machine learning model to obtain a vector sequence output by the hidden layer as a first encoding vector sequence and a second encoding vector sequence. Among them, the hidden layer is a term in the neural network model, which is an intermediate layer relative to the input layer and the output layer. The hidden layer includes model parameters obtained by training the neural network model. Here, the hidden layer of the encoder is an intermediate layer relative to the input layer of the encoder and the output layer of the encoder. The hidden layer of the encoder may include multiple neural network layers.

[0042] In some embodiments, the encoding model may be a recurrent neural network model, in which the encoding vector generated at the current moment is determined based on the current word vector and the encoding vector generated at the previous moment. The formula is as follows: j =E(b j-1 , x j ), where bj represents the encoding vector corresponding to the jth word in the word sequence, b j-1 represents the encoding vector corresponding to the j-1th word in the sentence, x j Represents the word vector of the jth word in the word sequence, and E represents the mapping function corresponding to the encoding model.

[0043] In some embodiments, the machine learning model includes a first encoding model and a second encoding model. The target source sentence and the initial translation sentence are encoded using the trained machine learning model to obtain a first encoding vector sequence corresponding to the target source sentence and a second encoding vector sequence corresponding to the initial translation sentence, which includes: inputting the target source sentence into the first encoding model for encoding to obtain a first encoding vector sequence corresponding to the target source sentence, and inputting the initial translation sentence into the second encoding model for encoding to obtain a second encoding vector sequence corresponding to the initial translation sentence.

[0044] Among them, the first encoding model and the second encoding model refer to different encoding models. The first encoding model and the second encoding model can be encoding models in a translation model. For example, the first encoding model is an encoding model in a translation model that translates a sentence represented in a language corresponding to a target source sentence into a sentence represented in a language corresponding to an initial translation sentence, and the second encoding model is an encoding model in a translation model that translates a sentence represented in a language corresponding to an initial translation sentence into a sentence represented in a language corresponding to a target source sentence. To give a practical example, assuming that the source sentence is a sentence represented in Chinese and the initial translation sentence is a sentence represented in English, the first encoding model is an encoding model in a translation model that translates Chinese into English, and the second encoding model is an encoding model in a translation model that translates English into Chinese. After obtaining the target source sentence and the initial translation sentence, the target source sentence is input into the first encoding model to obtain a first encoding vector sequence, and the initial translation sentence is input into the second encoding model to obtain a second encoding vector sequence.

[0045] Step S206: Use the machine learning model to jointly decode the first encoding vector sequence and the second encoding vector sequence to obtain a statement adjustment operation sequence.

[0046] Specifically, decoding is the process of converting a vector into the data output obtained by the desired conversion. Joint decoding means that when decoding, decoding is performed in combination with the first coding vector sequence and the second coding vector sequence. For example, the vectors of the first coding vector sequence and the second coding vector sequence are weighted summed to obtain a joint vector. The statement adjustment operation sequence includes one or more statement adjustment operations. The statement adjustment operation is used to adjust the statement. The types of statement adjustment operations in the statement adjustment operation sequence may include one or more of keep, delete, replace and insert. Keeping means keeping the words in the statement unchanged, deleting means deleting the words in the statement, replacing means replacing the words in the statement with other words, and inserting means inserting words in the statement. After obtaining the first coding vector sequence and the second coding vector sequence, the decoding model of the machine learning model can be used to decode the first coding vector sequence and the second coding vector sequence to obtain a statement adjustment operation sequence.

[0047] In some embodiments, when performing joint decoding, the decoding model may be a recurrent neural network model. In the recurrent neural network decoding model, the decoding result generated at the current moment is determined based on the input and the decoding result at the previous moment. It can be expressed as follows: j =G(f j-1 , a j ), where fj represents the decoding result corresponding to the jth moment, f j-1 represents the decoding result corresponding to the j-1th moment, a jrepresents the vector input to the hidden layer of the decoder at the jth moment, and G represents the mapping function corresponding to the decoding model.

[0048] In some embodiments, when performing joint decoding, a first attention allocation weight coefficient corresponding to each first coding vector at the current moment can be generated based on the attention mechanism, an attention allocation weight coefficient corresponding to the second coding vector can be generated based on the attention mechanism, and the first coding vector of the first coding vector sequence is weighted and summed based on the first attention weight coefficient to obtain the first attention vector, and the second coding vector of the second coding vector sequence is weighted and summed based on the second attention weight coefficient to obtain the second attention vector. A joint vector is calculated based on the first attention vector and the second attention vector, and the joint vector is used as the vector of the hidden layer input into the decoding model at the current moment.

[0049] Step S208, adjusting the initial translation sentence according to the sentence adjustment operation sequence to obtain a target translation sentence corresponding to the target source sentence.

[0050] Specifically, after obtaining the sentence adjustment operation sequence, the initial translation sentence is adjusted in sequence according to the sentence adjustment operations in the sentence adjustment operation sequence, that is, the words at each position of the initial translation sentence are adjusted in sequence according to the order of the sentence adjustment operations in the sentence adjustment operation sequence. After obtaining the first sentence adjustment operation, the adjustment can be performed according to the first sentence adjustment operation to obtain the adjusted intermediate translation sentence. After obtaining the second sentence adjustment operation, the initial translation sentence is adjusted according to the second sentence adjustment operation to obtain the adjusted intermediate translation sentence. The above steps are repeated until the sentence adjustment operations in the sentence adjustment operation sequence are all completed to obtain the target translation sentence. When performing the sentence adjustment operation, the word position after the word adjusted according to the previous sentence adjustment operation can be used as the current position to be adjusted by the current sentence adjustment operation. For the keep sentence adjustment operation, the word corresponding to the current position in the initial translation sentence is kept; for the replace sentence adjustment operation, the word corresponding to the current position in the initial translation sentence is replaced by other words; for the delete sentence adjustment operation, the word corresponding to the current position is deleted; for the insert sentence adjustment operation, a new word is inserted in front of the word corresponding to the current position. For example, the first sentence adjustment operation adjusts the position before the first word in the initial translation sentence, and the sentence adjustment operation after the first sentence adjustment operation adjusts the position after the latest adjusted word.

[0051] For example, suppose the initial translation sentence is "Today is Friday", the operations in the obtained sentence adjustment operation sequence are "keep", "insert", "keep", "delete", and the word corresponding to the insert operation is "is", then the target translation sentence is "Today is Friday". Suppose the initial translation sentence is "This flower is beautiful", the operations in the obtained operation sequence are "keep", "replace", "keep", "keep", and the word corresponding to the replace operation is "flower", then the target translation sentence is "This flower is beautiful".

[0052] In some embodiments, after obtaining the sentence adjustment operation sequence, the initial translation sentence and the target translation sentence can be processed so that the initial translation sentence and the target translation sentence are respectively the same length as the sentence adjustment operation sequence, so as to facilitate understanding of what adjustments have been made to the sentence. For example, a placeholder can be used to replace the space in the sentence. The adding position of the placeholder can be determined according to the operation type of the sentence adjustment operation sequence. In particular, for the "insert" operation, a placeholder can be added after the words at the corresponding position of the initial translation sentence, and for the "delete" operation, a placeholder can be added at the corresponding position of the target translation sentence. For example, assuming that the "delete" operation is the third operation, a placeholder is added after the second word of the target translation sentence, so that the "delete" operation corresponds to the third word in the target translation sentence to which the placeholder is added, which means that the third word in the initial translation sentence has been deleted.

[0053] The above translation method, after obtaining the target source sentence and the initial translation sentence obtained by translating the target source sentence, further encodes the target source sentence and the initial translation sentence using a machine learning model, obtains a corresponding encoding vector sequence and jointly decodes the encoding vector sequence, obtains an operation sequence for adjusting the initial translation sentence, and performs sentence adjustment on the initial translation sentence. By jointly decoding the encoding vector sequence of the initial translation sentence and the source sentence, a sentence adjustment operation for adjusting the initial translation sentence can be obtained in combination with the semantic information of the source sentence and the initial translation sentence, and the sentence adjustment operation has high accuracy. Therefore, the target translation sentence obtained by adjusting the initial translation sentence according to the sentence adjustment operation has high accuracy, thereby improving the accuracy of the translation.

[0054] The translation method provided by the embodiment of the present invention can be applied to translation scenarios, such as simultaneous interpretation. The process of human language translation usually includes a preliminary translation to obtain a translation draft, and the translation draft is continuously polished according to the translation draft and the original text to obtain the final translation. For translation scenarios with relatively high real-time requirements such as simultaneous interpretation, if the translation is performed by humans, it is difficult to have time to polish the translation due to the short translation time, so the translated sentences may have errors. The translation method provided by the embodiment of the present invention, after obtaining the initial translation, obtains the operation and words for the translation to polish the translation, which is equivalent to simulating the process of human translation to obtain the translation. Among them, the initial translation sentence can be translated by the simultaneous interpreter on the scene, and the source sentence issued by the speaker can be collected by using a voice collection tool, and the source sentence of the speaker collected is used as the target source sentence. According to the target source sentence and the initial translation sentence, the translation method provided by the embodiment of the present invention is implemented to obtain the target translation sentence, and the target translation sentence can be displayed on the screen, or the target translation sentence can be played. In this way, since the simultaneous interpreter understands the speaking scenario, such as the technical background of the current speaker, the theme of the meeting, etc., the initial translation sentence obtained by translation is flexibly adjusted according to the current scenario. Even if the simultaneous interpreter omits some information about the speaker or there are translation errors, the translation method provided by the embodiment of the present invention can be used to correct them. Therefore, the target source sentence finally obtained not only fits the current speaking context, but also can accurately express the meaning conveyed by the target source sentence.

[0055] The translation method provided by the embodiment of the present invention not only relies on the initial translation sentence to obtain the sentence adjustment operation in the process of polishing the translation, but introduces the target source sentence, which is equivalent to using the target source sentence as additional reference information, and modifying the initial translation sentence information by comparing the semantic information conveyed by the target source sentence and the initial translation sentence, so that the translation accuracy is high. For example, assuming that the method provided by the embodiment of the present invention is not adopted, the initial translation sentence is obtained by translating with a commonly used translation model, and the translation quality is evaluated by the BELU (Bilingual Evaluation Understudy) translation quality evaluation method, then the BELU score is 62.49 points. The method provided by the embodiment of the present invention is used to polish the initial translation sentence, obtain the target translation sentence, and use the BELU translation quality evaluation method to evaluate the translation quality, then the BELU score is 71.16 points. Among them, BELU is a text evaluation algorithm, which is used to evaluate the correspondence between machine translation and professional manual translation. The core idea is that the closer the machine translation is to professional manual translation, the better the quality is. The score obtained by the bleu algorithm can be used as one of the indicators of machine translation quality.

[0056] In some embodiments, the machine learning model includes an operation decoding model and a word decoding model. The machine learning model is used to jointly decode the first coding vector sequence and the second coding vector sequence to obtain a sentence adjustment operation sequence, including: the operation decoding model jointly decodes the first coding vector sequence and the second coding vector sequence to obtain a candidate operation decoding result at the current moment, and determines the current sentence adjustment operation corresponding to the current moment according to the candidate operation decoding result at the current moment; the word decoding model decodes according to the candidate operation decoding result at the current moment to obtain a target word corresponding to the current moment; sentence adjustment is performed on the initial translation sentence according to the sentence adjustment operation sequence to obtain a target translation sentence corresponding to the target source sentence, including: sentence adjustment is performed on the initial translation sentence according to the sentence adjustment operations corresponding to each moment and the target word to obtain a target translation sentence corresponding to the target source sentence.

[0057] Specifically, the operation decoding model is used to determine the sentence adjustment operation, and the word decoding model is used to determine the words corresponding to the sentence adjustment operation. The candidate operation decoding result is the decoding result corresponding to each candidate operation, which can be used to determine the target operation at the current moment. For example, the candidate operation decoding result can be the probability corresponding to each candidate operation. After obtaining the probability of each candidate operation, the operation with the highest probability can be selected as the target sentence adjustment operation (also called the current sentence adjustment operation) at the current moment according to the probability corresponding to the candidate operation, for example, a beam search method or a greedy algorithm is used to take the operation with the highest probability as the current sentence adjustment operation. After obtaining the candidate operation decoding result at the current moment, the word decoding model performs word decoding based on the candidate operation decoding result at the current moment, obtains the probability of each word in each word list at the current moment, and can select the word with the highest probability as the target word, for example, a beam search method or a greedy method is used to take the word with the highest probability as the target word. The sentence adjustment operation at each moment constitutes a sentence adjustment operation sequence. When performing sentence adjustment, the initial translation sentence is adjusted according to the sentence adjustment operation at the same moment and the target word.

[0058] The target word output by the word decoding model at the current moment corresponds to the type of the current sentence adjustment operation. For example, for the delete operation, the word output by the word decoding model is empty. For the keep operation, the word output by the word decoding model is the same as the word corresponding to the initial translation sentence. For the replace operation, a word different from the word corresponding to the initial translation sentence is generated. For the insert operation, there is no restriction on whether the corresponding word is the same as the word corresponding to the initial translation sentence. In order to make the word obtained by the word decoding model correspond to the type of the current sentence adjustment operation, when performing model training, if the operation type does not correspond to the corresponding word, the model loss value is increased so that the word obtained by the trained word decoding model corresponds to the operation type of the corresponding sentence adjustment operation.

[0059] like Figure 3 As shown, it is a model architecture diagram of the machine learning model in some embodiments, including an encoding model and a decoding model. The encoding model may include a first encoding model and a second encoding model, and the decoding model includes an operation decoding model and a word decoding model. The first encoding model encodes the target source sentence to obtain a first encoding vector sequence, and the second encoding model encodes the initial translation sentence to obtain a second encoding vector sequence. The first encoding vector sequence and the second encoding vector sequence are input into the operation decoding model to obtain the candidate operation decoding result at the current moment, and the target sentence adjustment operation is obtained according to the candidate operation decoding result, and the candidate operation decoding result is input into the word decoding model. The word decoding model decodes the candidate operation decoding result to obtain the target word at the current moment.

[0060] In some embodiments, the candidate operation decoding results include the selection rates corresponding to each candidate sentence adjustment operation. The word decoding model decodes according to the candidate operation decoding results at the current moment to obtain the target word corresponding to the current moment, including: calculating the target operation vector according to the operation vectors and the selection rates corresponding to each candidate sentence adjustment operation, or determining the current sentence adjustment operation according to the selection rates corresponding to each candidate sentence adjustment operation, and using the operation vector corresponding to the current sentence adjustment operation as the target operation vector; inputting the target operation vector into the word decoding model, and decoding to obtain the target word corresponding to the current moment.

[0061] Specifically, the selection rate represents the possibility of each candidate statement adjustment operation being selected as the current statement adjustment operation corresponding to the current moment, and the operation vector refers to the vector representation corresponding to the operation. For example, the candidate operation decoding result can be the probability distribution corresponding to the candidate statement adjustment operation. To give a practical example, the candidate operation decoding result can be: the probabilities corresponding to the replacement operation, the retention operation, the deletion operation, and the insertion operation are 0.1, 0.3, 0.5, and 0.1, respectively. After obtaining the selection rate corresponding to the candidate statement adjustment operation, the operation vector corresponding to each candidate statement operation can be obtained, and the selection rate is multiplied by the corresponding operation vector to obtain the multiplied vector, and the vectors obtained after the multiplication of each candidate operation are added to obtain the target operation vector. Of course, the operation vector corresponding to the current statement adjustment operation can also be directly used as the target operation vector.

[0062] For example, the candidate operation decoding results can be: the probabilities of replacement, retention, deletion and insertion are 0.1, 0.3, 0.5 and 0.1 respectively. Assuming that the vectors corresponding to replacement, retention, deletion and insertion are c1, c2, c3 and c4 respectively, the target operation vector can be 0.1*c1+0.3*c2+0.5*c3+0.1*c4.

[0063] In some embodiments, the target operation vector, the hidden state vector of the operation decoding model at the current moment, and the hidden state vector of the word decoding model at the previous moment can be input into the word decoding model to decode the target word corresponding to the current moment.

[0064] Among them, the hidden state vector is the vector of the hidden layer output, which represents the hidden state of the model. When decoding to obtain the target word corresponding to the current moment, the data input to the word decoding model includes the target operation vector, the hidden state vector of the operation decoding model at the current moment, and the hidden state vector of the word decoding model at the previous moment. The word decoding model decodes to obtain the decoding hidden state vector corresponding to the current moment, performs a linear transformation on the decoding hidden state vector at the current moment, obtains the probability of each candidate word at the current moment, and can use the candidate word with the highest probability as the word output at the current moment. The function for obtaining the probability can use the softmax function.

[0065] In the above embodiment, the machine learning model is divided into two parts, namely, operation and words, for decoding. The target words are decoded based on the constraints of the operation decoding results obtained by decoding, which can improve the accuracy of the obtained words and make the decoded target words correspond to the operations. Furthermore, adjusting the sentences according to the output operations and words also facilitates understanding of the logic of sentence polishing by the machine, and improves the interpretability of the machine translation process. Moreover, when training the model, this machine learning model can adjust the parameters of the model according to the difference between the predicted operations and the actual operations, and the difference between the predicted words and the actual words, so that the adjustment of the model parameters is more targeted.

[0066] Among them, the decoding model can perform multiple decoding until the conditions for terminating decoding are met, for example, the decoding is stopped when the word obtained is a translation stop symbol. It can be understood that the above-mentioned "current moment" refers to the moment corresponding to the generation of the current encoding vector for the encoding model, and refers to the moment when the current output data is obtained by decoding for the decoding model, and the previous moment is relative to the current moment. For example, when the decoding model needs to generate the i-th word, the moment corresponding to the generation of the i-th word is the current moment, and the moment corresponding to the generation of the i-1-th word is the previous moment. When the decoding model is to generate the i+1-th word, the moment corresponding to the generation of the i+1-th word is the current moment, and the moment corresponding to the generation of the i-th word is the previous moment. When the encoding model is to generate the c-th encoding vector, the moment corresponding to the generation of the c-1-th encoding vector is the previous moment. When the encoding model generates the c+1-th encoding vector, the moment corresponding to the generation of the c+1-th encoding vector is the current moment, and the moment corresponding to the generation of the c-1-th encoding vector is the previous moment. When the encoding model generates the c+1-th encoding vector, the moment corresponding to the generation of the c+1-th encoding vector is the current moment, and the moment corresponding to the generation of the c-1-th encoding vector is the previous moment. When decoding is performed for the first time, the output data corresponding to the previous moment may be a value set based on experience or a randomly generated initial value.

[0067] In some embodiments, when generating a sentence adjustment operation at the current moment, the word vector of the target word output at the previous moment is obtained, and the first encoding vector sequence and the second encoding vector sequence are jointly decoded according to the word vector of the target word at the previous moment to obtain the candidate operation decoding result at the current moment, and then the target word output at the current moment is determined according to the candidate operation decoding result. In this way, the sentence adjustment operation at the current moment integrates the semantic information of the target word output at the previous moment, so that the target translation sentence finally generated can be more coherent and richer in information.

[0068] In some embodiments, Figure 4A As shown, the operation decoding model jointly decodes the first coding vector sequence and the second coding vector sequence, and obtains the candidate operation decoding results at the current moment including:

[0069] Step S402: for each first encoding vector of the first encoding vector sequence, determine the first attention allocation weight coefficient relative to the target word to be output at the current moment.

[0070] Specifically, the decoding model is a model based on the attention mechanism, the attention model (AttentionModel), which is used to determine the influence of each coding vector in the input coding vector sequence on the words output by the decoding model at the current moment. The attention allocation weight coefficient represents the influence of the coding vector on the words to be output at the current moment. The attention allocation weight coefficient is positively correlated with the influence. The larger the attention allocation weight coefficient corresponding to the coding vector, the greater its influence on the words to be output at the current moment, and the coding vector is more critical to the words to be output at the current moment. On the contrary, the smaller the attention allocation weight coefficient corresponding to the coding vector, the weaker the influence of the coding vector on the words to be output at the current moment, indicating that the coding vector is not so critical. The first coding vector sequence can be input into the attention model corresponding to the decoding model to obtain the attention allocation weight coefficients corresponding to each coding vector in the coding vector sequence.

[0071] In some embodiments, for each first encoding vector of the first encoding vector sequence, the first attention allocation weight coefficient relative to the target word to be output at the current moment can be calculated based on the hidden state vector output by the word decoding model at the previous moment. The weight coefficient can be obtained by attention calculation with reference to the following formula: e i,j =ATT(s i-1 ,h j ), where i refers to the i-th moment, j refers to the j-th vector in the encoding vector sequence, and α i,j Refers to the attention allocation weight coefficient corresponding to the jth encoding vector in the encoding vector sequence at the i-th moment. ATT represents the attention function, S i-1 is the hidden state vector output by the word decoding model at the previous moment, h j represents the jth encoding vector.

[0072] Step S404: for each second encoding vector of the second encoding vector sequence, determine the second attention allocation weight coefficient relative to the target word to be output at the current moment.

[0073] Specifically, the second attention allocation weight coefficient corresponding to each coding vector in the second coding vector sequence can be obtained by referring to the step of obtaining the first attention allocation weight coefficient in step S402, and replacing the first coding vector with the second coding vector. For example, for each second coding vector in the second coding vector sequence, the second attention allocation weight coefficient relative to the target word to be output at the current moment can be calculated according to the hidden state vector output by the word decoding model at the previous moment, and the details are not repeated here.

[0074] Step S406, calculate the joint vector according to the first coding vector sequence and the first attention allocation weight coefficient, the second coding vector sequence and the corresponding second attention allocation weight coefficient.

[0075] Specifically, the joint vector is obtained by combining the first coding vector sequence and the first attention allocation weight coefficient, the second coding vector sequence and the corresponding second attention allocation weight coefficient. For example, the first coding sequence of the first coding vector sequence can be multiplied by the corresponding first attention allocation weight coefficient, and the vectors obtained by multiplication are added to obtain the first attention vector. The second coding sequence of the second coding vector sequence can be multiplied by the corresponding second attention allocation weight coefficient, and the vectors obtained by multiplication are added to obtain the second attention vector. The first attention vector and the second attention vector are combined to obtain a joint vector, wherein the first weighted weight corresponding to the first attention vector and the second weighted weight corresponding to the second attention vector can be obtained, and the first attention vector and the second attention vector are weightedly added according to the weighted weights to obtain a joint vector. Among them, the first weighted weight and the second weighted weight can be preset. For example, the first weighted weight can be set to 0.6 and the second weighted weight can be set to 0.2. The corresponding weight model can also be added to calculate the weighted weight. For example, assuming that the attention allocation weight coefficient at the current moment is expressed as α i,j ={α1,α2,…,α J}. The encoding vector sequence can be expressed as H = {h1,h2,…,h J}, the attention vector can be calculated using the following formula: Assuming that the first attention vector is represented as attention_1, the second attention vector is represented as attention_2, the first weighted weight is w, and the second weighted weight is 1-w, the joint vector can be expressed as w*attention_1+(1-w)*attention_2.

[0076] Step S408, the operation decoding model uses the word vector of the target word output by the word decoding model at the previous moment to decode the joint vector to obtain the candidate operation decoding result at the current moment.

[0077] In the embodiment of the present invention, when joint decoding is performed, the attention allocation weight coefficients of the first coding vector and the second coding vector relative to the target word to be output at the current moment are determined, so that the candidate operation decoding result output at the current moment can contain the information in the coding vector that is more important to the word at the current moment, and reduce the impact of the translation error of the initial translation sentence. For example, for the second coding vector corresponding to the translation error in the initial translation sentence, if there is a semantic error, its correlation with the hidden state vector output by the word decoding model at the previous moment is relatively low, so the obtained attention allocation weight coefficient is small, and when performing weighted summation, the influence on the obtained joint vector is small, thereby reducing the influence of the semantic information of the wrong place in the initial translation sentence on the decoding result.

[0078] In some embodiments, after obtaining the joint vector, the joint vector and the word vector of the target word output by the word decoding model at the previous moment can be input into the word decoding model to obtain the candidate operation decoding result at the current moment. Decoding the joint vector with reference to the word vector of the template word output at the previous moment can make the target translation sentence generated finally more coherent and richer in information, and, through the attention mechanism processing, the candidate operation decoding result output at the current moment can contain more important information in the encoding vector for the word at the current moment.

[0079] In some embodiments, the operation decoding model uses the word vector of the target word output by the word decoding model at the previous moment to decode the joint vector, and the candidate operation decoding result at the current moment is obtained, which includes: the word vector of the target word output by the word decoding model at the previous moment, the joint vector, and the hidden state vector of the operation decoding model at the previous moment are input into the operation decoding model to obtain the candidate operation decoding result at the current moment. By using the hidden state vector of the operation decoding model at the previous moment, the model state corresponding to the sentence adjustment operation at the previous moment is referenced, and by using the word vector of the target word output by the word decoding model at the previous moment, the word obtained by the sentence adjustment operation at the previous moment is referenced, so that the target translation sentence finally generated can be more coherent, and thus the sentence adjustment operation obtained can be more accurate.

[0080] like Figure 4BAs shown, it is a model architecture diagram of a machine learning model in some embodiments, including an encoding model and a decoding model. The encoding model may include a first encoding model and a second encoding model, and the decoding model includes an operation decoding model and a word decoding model. The operation decoding model is a model based on the attention mechanism. The attention model can be used as a part of the word operation decoding model. The two attention models can be used to obtain a joint vector, and the joint vector is input into the operation decoding hidden layer of the operation decoding model. Among them, the first attention model is used to determine the first attention allocation weight coefficient of the first encoding vector relative to the target word to be output at the current moment according to the hidden state vector output by the word decoding model at the previous moment, multiply the first encoding sequence of the first encoding vector sequence by the corresponding first attention allocation weight coefficient, and add the multiplied vectors to obtain the first attention vector. The second attention model is used to determine the second attention allocation weight coefficient of the second encoding vector relative to the target word to be output at the current moment according to the hidden state vector output by the word decoding model at the previous moment, multiply the second encoding sequence of the second encoding vector sequence by the corresponding second attention allocation weight coefficient, and add the multiplied vectors to obtain the second attention vector. After the first attention vector and the second attention vector are combined to obtain the joint vector, the operation decoding model decodes according to the joint vector, the word vector of the target word output by the word decoding model at the previous moment, and the hidden state vector of the operation decoding model at the previous moment to obtain the candidate operation decoding result at the current moment. The word decoding model decodes according to the target operation vector, the hidden state vector of the operation decoding model at the current moment, and the hidden state vector of the word decoding model at the previous moment to obtain the target word corresponding to the current moment.

[0081] In some embodiments, Figure 5 As shown, the training steps of the machine learning model include:

[0082] Step S502: obtaining training samples from a training sample set, wherein the training samples include a sample source sentence, an initial sample translation sentence obtained by initially translating the sample source sentence, a sample sentence adjustment operation sequence for adjusting the initial sample translation sentence, and adjustment words corresponding to each sentence adjustment operation in the sample sentence adjustment operation sequence.

[0083] Specifically, the sample set is a set of training samples used for model training. The number of training samples in the sample set can be set as needed, for example, it can be 100,000. A training sample includes a sample source sentence, an initial sample translation sentence obtained by performing an initial translation on the sample source sentence, a sample sentence adjustment operation sequence for adjusting the initial sample translation sentence, and an adjustment word corresponding to each sentence adjustment operation in the sample sentence adjustment operation sequence. The sample source sentence is a source sentence in the training sample, and the initial sample translation sentence is a translation sentence obtained by performing an initial translation on the sample source sentence. After the initial sample translation sentence is adjusted, a target sample translation sentence that accurately translates the sample source sentence can be obtained. The sample sentence adjustment operation sequence is an operation sequence composed of sentence adjustment operations for adjusting the initial sample translation sentence to obtain a target sample translation sentence, and may also include one or more of replacement, retention, deletion, and insertion. The sample sentence adjustment operation sequence for adjusting the initial sample translation sentence to the target sample translation sentence can be obtained using the minimum edit distance algorithm (MinimumEditDistance). For example, Chinese sentences and the corresponding initially translated English sentences, i.e., initial sample translation sentences, can be collected, and the English sentences can be further modified to obtain target sample translation sentences that accurately translate the Chinese sentences, and sample sentence adjustment operations and corresponding words that modify the initial sample translation sentences to target sample translation sentences can be obtained. Each sample sentence adjustment operation forms a sample sentence adjustment operation sequence in the order of operation. For a practical example, assuming that the sample source sentence is "Who are you", the initial sample translation sentence is "who is you", and the target sample translation sentence is "who are you", then the operations of the sample sentence adjustment operation sequence are keep operation, replace operation, and keep operation, and the adjustment words corresponding to each operation are who, are, and you, respectively. For the delete operation, the corresponding adjustment word is empty.

[0084] The training samples in the sample set can be collected manually or translated using a machine translation model. The translation results are used as the initial sample translation sentences. The initial sample translation sentences are manually modified to obtain target sample translation sentences. The sample sentence adjustment operation sequence and the adjustment words corresponding to each sentence adjustment operation in the sample sentence adjustment operation sequence are obtained based on the target sample translation sentences and the initial sample translation sentences. For example, the machine translation results in the training data of the ape (Automatic Post-Editing) task can be used as the initial sample translation sentence. It is also possible to obtain bilingual corpora, use one of the bilingual corpora as a sample source sentence, and the other as a target sample translation sentence. The sample source sentence is input into a pre-trained translation model for translation, and the obtained sentence is used as the initial sample translation sentence. The Ape task refers to a task that further adjusts the machine translated text to improve the translation quality of the machine translated text.

[0085] Step S504: input the sample source sentence and the initial sample translation sentence in the training sample into the machine learning model for encoding, and obtain a third encoding vector sequence corresponding to the sample source sentence and a fourth encoding vector sequence corresponding to the initial sample translation sentence.

[0086] Specifically, when performing model training, the sample source sentences and initial sample translation sentences in the training samples are input into the machine learning model for encoding to obtain a third encoding vector sequence corresponding to the sample source sentences and a fourth encoding vector sequence corresponding to the initial sample translation sentences.

[0087] Step S506: Use the machine learning model to jointly decode the third coding vector sequence and the fourth coding vector sequence to obtain a prediction operation sequence and prediction words corresponding to each prediction operation in the prediction operation sequence.

[0088] Specifically, after obtaining the third coding vector sequence and the fourth coding vector sequence, joint decoding is performed with reference to the third coding vector sequence and the fourth coding vector sequence to obtain the predicted operation and the predicted words corresponding to the predicted operation. It can be understood that for steps S504 and 506 in the model training process of the machine learning model, reference can be made to the description of steps S204 and S206 in the use process of the machine learning model, with the difference that the machine learning model parameters in steps S204 and S206 are the model parameters obtained after training, while S504 and S506 are the model parameters obtained during the training process.

[0089] Step S508, update the parameters in the machine learning model according to the difference between the predicted operation sequence and the sample statement adjustment operation sequence, and the difference between the adjustment words and the predicted words, return to the step of obtaining the training samples in the training sample set to continue model training until the training convergence conditions are met to obtain a trained machine learning model.

[0090] Specifically, the model parameters can be adjusted in the direction of reducing the difference between the prediction operation sequence and the sample sentence adjustment operation sequence, and the difference between the adjustment words and the prediction words. In this way, through continuous model training, the training is stopped until the training convergence condition is reached, and the machine learning model is trained. The training convergence condition can be that the model loss value calculated based on the difference between the prediction operation sequence and the sample sentence adjustment operation sequence, and the difference between the adjustment words and the prediction words is less than a preset threshold.

[0091] In some embodiments, during the model training phase, the model loss value is calculated based on the difference between the probability distribution corresponding to the predicted operation sequence output by the machine learning model and the output probability distribution of the sample sentence adjustment operation sequence, as well as the difference between the probability distribution of the predicted words and the adjusted words of the predicted output. For example, assuming that there are 4 candidate sentence operations, the output value of the hidden layer of the operation decoding model can be mapped to a 4-dimensional vector, and then activated, for example, using the softmax function to obtain the corresponding probability of each candidate sentence adjustment operation as the probability distribution corresponding to the predicted operation sequence. The output value words of the hidden layer of the word decoding model are mapped to a vector of the same size as the number of words in the vocabulary, and then activated, for example, using the softmax function to obtain the corresponding probability of each word. The cross entropy between the probability distribution of the predicted operation sequence and the probability distribution of the actual sample sentence adjustment operation sequence is calculated, and the cross entropy between the probability distribution of the predicted words and the actual probability distribution of the adjustment words is calculated. The two cross entropies are added as the model loss value, and the model parameters are updated in the direction of decreasing the model loss value. The model parameters of the word decoding model are updated according to the cross entropy between the probability distribution of the predicted words and the actual probability distribution of the adjustment words. The model parameters of the operation decoding model are updated according to the cross entropy between the probability distribution of the predicted words and the actual probability distribution of the adjustment words, as well as the cross entropy between the probability distribution of the predicted operations and the probability distribution of the actual sample sentence adjustment operation sequence.

[0092] In order to make the words obtained by the word decoding model correspond to the type of the current sentence adjustment operation, when the model is trained, if the operation type does not correspond to the corresponding word, the model loss value is increased so that the words obtained by the trained word decoding model correspond to the operation type of the corresponding sentence adjustment operation. For example, when the model is trained, if the sample sentence adjustment operation is to maintain, assuming that the predicted adjustment operation is to maintain, when the predicted word is inconsistent with the adjusted word, the loss value can be increased according to the similarity between the predicted word and the adjusted word vector, and the smaller the similarity, the greater the increased loss value.

[0093] like Figure 6 As shown, in a specific embodiment, the translation method includes the following steps:

[0094] Step S602: Obtain a target source sentence, and translate the target source sentence to obtain an initial translation sentence.

[0095] Step S604: Encode the target source sentence using the trained machine learning model to obtain a first encoding vector sequence corresponding to the target source sentence.

[0096] Step S606: Encode the initial translation sentence using the trained machine learning model to obtain a second encoding vector sequence corresponding to the initial translation sentence.

[0097] Step S608: The operation decoding model jointly decodes the first coding vector sequence and the second coding vector sequence to obtain the candidate operation decoding result at the current moment, and determines the current statement adjustment operation corresponding to the current moment according to the candidate operation decoding result at the current moment.

[0098] Step S610, the word decoding model decodes according to the candidate operation decoding result at the current moment to obtain the target word corresponding to the current moment.

[0099] Step S612: adjusting the initial translation sentence according to the sentence adjustment operation sequence and the target words corresponding to each moment, to obtain a target translation sentence corresponding to the target source sentence.

[0100] See also Figure 7, is a schematic diagram of using a machine learning model to adjust a sentence in some embodiments to obtain a target translation sentence. Among them, the first hidden layer is the hidden layer of the operation decoding model, the second hidden layer is the hidden layer of the word decoding model, y1, y2, and y3 refer to the word vectors of the target words output at the first moment, the second moment, and the third moment respectively, y0 is the initial word vector, which can be preset, and EOS represents a stop symbol. When EOS is obtained, decoding is stopped. After obtaining the target source sentence and the initial translation sentence obtained by translating the target source sentence, the target source sentence is input into the first encoding model, and the first encoding model encodes the target source sentence to obtain the first encoding vector sequence corresponding to the target source sentence. The initial translation sentence is input into the second encoding model, and the second encoding model encodes the initial translation sentence to obtain the second encoding vector sequence corresponding to the initial translation sentence. The first coding vector sequence and the second coding vector sequence are input into the attention model to obtain the joint vector corresponding to the current moment. The word vector of the target word output by the word decoding model at the previous moment, the joint vector, and the hidden state vector of the operation decoding model are input into the first hidden layer to obtain the probability distribution (i.e., selection rate) of each candidate operation at the current moment. The operation vector calculation layer uses the operation vector of the candidate operation with the highest probability as the target operation vector. The action acquisition layer can use the operation corresponding to the target operation vector as the current statement adjustment operation at the current moment. Among them, the action acquisition layer can also input the target operation vector into the second hidden layer. By Figure 7 It can be seen that the vectors input to the first hidden layer include: the word vector of the target word output by the word decoding model at the previous moment, the joint vector, and the hidden state vector of the operation decoding model at the previous moment; the vectors input to the second hidden layer include: the target operation vector, the hidden state vector of the operation decoding model at the current moment, and the hidden state vector of the word decoding model at the previous moment.

[0101] like Figure 8 As shown, in some embodiments, a translation device is provided, which can be integrated in the above-mentioned server 120, and can specifically include a source sentence and initial translation sentence acquisition module 802, an encoding module 804, a decoding module 806 and an adjustment module 808.

[0102] The source sentence and initial translation sentence acquisition module 802 is used to acquire a target source sentence and an initial translation sentence obtained by translating the target source sentence.

[0103] The encoding module 804 is used to encode the target source sentence and the initial translation sentence using the trained machine learning model to obtain a first encoding vector sequence corresponding to the target source sentence and a second encoding vector sequence corresponding to the initial translation sentence.

[0104] The decoding module 806 is used to jointly decode the first encoding vector sequence and the second encoding vector sequence using a machine learning model to obtain a statement adjustment operation sequence.

[0105] The adjustment module 808 is used to perform sentence adjustment on the initial translation sentence according to the sentence adjustment operation sequence to obtain a target translation sentence corresponding to the target source sentence.

[0106] In some embodiments, the machine learning model includes an operation decoding model and a word decoding model, and the decoding module 806 includes:

[0107] The operation obtaining unit is used to jointly decode the first coding vector sequence and the second coding vector sequence using the operation decoding model to obtain the candidate operation decoding result at the current moment, and determine the current statement adjustment operation corresponding to the current moment according to the candidate operation decoding result at the current moment.

[0108] The word obtaining unit is used to use the word decoding model to decode according to the candidate operation decoding result at the current moment to obtain the target word corresponding to the current moment.

[0109] The adjustment module 808 is used to adjust the initial translation sentence according to the sentence adjustment operations corresponding to each moment and the target words to obtain a target translation sentence corresponding to the target source sentence.

[0110] In some embodiments, operating the obtaining unit includes:

[0111] The first coefficient obtaining subunit is used to determine, for each first encoding vector of the first encoding vector sequence, a first attention allocation weight coefficient relative to a target word to be output at a current moment.

[0112] The second coefficient obtaining subunit is used to determine, for each second encoding vector of the second encoding vector sequence, a second attention allocation weight coefficient relative to the target word to be output at the current moment.

[0113] The joint vector obtaining subunit is used to calculate the joint vector based on the first coding vector sequence and the corresponding first attention allocation weight coefficient, the second coding vector sequence and the corresponding second attention allocation weight coefficient.

[0114] The operation decoding result obtaining subunit is used for the operation decoding model to decode the joint vector using the word vector of the target word output by the word decoding model at the previous moment to obtain the candidate operation decoding result at the current moment.

[0115] In some embodiments, the candidate operation decoding result includes the selection rate corresponding to each candidate sentence adjustment operation, and the word obtaining unit includes:

[0116] The target operation vector obtaining subunit is used to calculate the target operation vector based on the operation vectors corresponding to each candidate statement adjustment operation and the selection rate, or to determine the current statement adjustment operation based on the selection rate corresponding to each candidate statement adjustment operation, and use the operation vector corresponding to the current statement adjustment operation as the target operation vector.

[0117] The word acquisition subunit is used to input the target operation vector into the word decoding model to decode and obtain the target word corresponding to the current moment.

[0118] In some embodiments, the word acquisition subunit is used to: input the target operation vector, the hidden state vector of the operation decoding model at the current moment, and the hidden state vector of the word decoding model at the previous moment into the word decoding model, and decode to obtain the target word corresponding to the current moment.

[0119] like Fig. 9 As shown, in some embodiments, the training module of the machine learning model includes:

[0120] The training sample acquisition unit 902 is used to acquire training samples from the training sample set, where the training samples include a sample source sentence, an initial sample translation sentence obtained by initially translating the sample source sentence, a sample sentence adjustment operation sequence for adjusting the initial sample translation sentence, and adjustment words corresponding to each sentence adjustment operation in the sample sentence adjustment operation sequence.

[0121] The encoding vector sequence obtaining unit 904 is used to input the sample source sentence and the initial sample translation sentence in the training sample into the machine learning model for encoding, and obtain a third encoding vector sequence corresponding to the sample source sentence and a fourth encoding vector sequence corresponding to the initial sample translation sentence.

[0122] The predicted operation and word obtaining unit 906 is used to jointly decode the third coding vector sequence and the fourth coding vector sequence using a machine learning model to obtain a predicted operation sequence and predicted words corresponding to each predicted operation in the predicted operation sequence.

[0123] The updating unit 908 is used to update the parameters in the machine learning model according to the difference between the predicted operation sequence and the sample sentence adjustment operation sequence, and the difference between the adjustment words and the predicted words.

[0124] The return unit 910 is used to return to the step of obtaining the training samples in the training sample set to continue the model training until the training convergence condition is met to obtain the trained machine learning model.

[0125] In some embodiments, the machine learning model includes a first encoding model and a second encoding model, and the encoding module 804 is used to: input the target source sentence into the first encoding model for encoding to obtain a first encoding vector sequence corresponding to the target source sentence, and input the initial translation sentence into the second encoding model for encoding to obtain a second encoding vector sequence corresponding to the initial translation sentence.

[0126] In some embodiments, the source sentence and initial translation sentence acquisition module 802 is used to: acquire a target source sentence to be translated; input the target source sentence into a machine translation model, and translate to obtain an initial translation sentence corresponding to the target source sentence.

[0127] Fig.10 The internal structure diagram of the computer device in some embodiments is shown. The computer device can be specifically Figure 1 The server 120 in FIG. Fig.10 As shown, the computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program, which, when executed by the processor, enables the processor to implement the translation method. The internal memory may also store a computer program, which, when executed by the processor, enables the processor to execute the translation method.

[0128] Those skilled in the art will understand that Fig.10 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0129] In some embodiments, the translation device provided by the present application can be implemented in the form of a computer program, which can be used in Fig.10 The computer device shown in the figure is run. The memory of the computer device can store various program modules constituting the translation device, such as: Figure 8 The source sentence and the initial translation sentence acquisition module 802, the encoding module 804, the decoding module 806 and the adjustment module 808 are shown. The computer program composed of various program modules enables the processor to execute the steps of the translation method of each embodiment of the present application described in this specification.

[0130] For example, Fig.10 The computer device shown can be Figure 8The source sentence and initial translation sentence acquisition module 802 in the translation device shown acquires the target source sentence and the initial translation sentence obtained by translating the target source sentence. The target source sentence and the initial translation sentence are encoded by the encoding module 804 using the trained machine learning model to obtain a first encoding vector sequence corresponding to the target source sentence and a second encoding vector sequence corresponding to the initial translation sentence. The first encoding vector sequence and the second encoding vector sequence are jointly decoded by the decoding module using the machine learning model to obtain a sentence adjustment operation sequence. The initial translation sentence is sentence adjusted by the adjustment module 808 according to the sentence adjustment operation sequence to obtain a target translation sentence corresponding to the target source sentence.

[0131] In some embodiments, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above-mentioned translation method. The steps of the translation method here may be the steps of the translation method in the above-mentioned various embodiments.

[0132] In some embodiments, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the processor executes the steps of the above-mentioned translation method. The steps of the translation method here can be the steps in the translation method of each of the above-mentioned embodiments.

[0133] It should be understood that, although each step in the flow chart of each embodiment of the present invention is shown in sequence according to the indication of the arrow, these steps are not necessarily performed in sequence according to the order indicated by the arrow. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in each embodiment may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these sub-steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of other steps or sub-steps or stages of other steps.

[0134] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0135] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0136] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A translation method, comprising: Acquire a target source sentence and an initial translation sentence obtained by translating the target source sentence; Encoding the target source sentence and the initial translation sentence using the trained machine learning model to obtain a first encoding vector sequence corresponding to the target source sentence and a second encoding vector sequence corresponding to the initial translation sentence; For each first encoding vector of the first encoding vector sequence, determining a first attention allocation weight coefficient relative to a target word to be output at a current moment; For each second encoding vector of the second encoding vector sequence, determining a second attention allocation weight coefficient relative to the target word to be output at the current moment; Calculate a joint vector according to the first coding vector sequence and the corresponding first attention allocation weight coefficient, the second coding vector sequence and the corresponding second attention allocation weight coefficient; The operation decoding model included in the machine learning model decodes the joint vector using the word vector of the target word output by the word decoding model included in the machine learning model at a previous moment to obtain a candidate operation decoding result at a current moment; The operation decoding model determines the current statement adjustment operation corresponding to the current moment according to the candidate operation decoding result at the current moment; The word decoding model decodes the candidate operation decoding result at the current moment to obtain the target word corresponding to the current moment; The initial translation sentence is sentence adjusted according to the sentence adjustment operations corresponding to each moment and the target words to obtain a target translation sentence corresponding to the target source sentence.

2. The method according to claim 1, characterized in that The operation decoding model included in the machine learning model uses the word vector of the target word output by the word decoding model included in the machine learning model at the previous moment to decode the joint vector, and obtain the candidate operation decoding result at the current moment includes: The operation decoding model included in the machine learning model inputs the word vector of the target word output by the word decoding model at the previous moment, the joint vector and the hidden state vector of the operation decoding model at the previous moment into the operation decoding model to obtain the candidate operation decoding result at the current moment.

3. The method according to claim 1, characterized in that The candidate operation decoding result includes the selection rate corresponding to each candidate sentence adjustment operation. The word decoding model decodes according to the candidate operation decoding result at the current moment, and obtains the target word corresponding to the current moment, including: Calculating a target operation vector according to the operation vectors and selection rates corresponding to the candidate sentence adjustment operations, or determining a current sentence adjustment operation according to the selection rates corresponding to the candidate sentence adjustment operations, and using the operation vector corresponding to the current sentence adjustment operation as the target operation vector; The target operation vector is input into the word decoding model, and the target word corresponding to the current moment is obtained by decoding.

4. The method according to claim 3, characterized in that The step of inputting the target operation vector into the word decoding model and decoding to obtain the target word corresponding to the current moment includes: The target operation vector, the hidden state vector of the operation decoding model at the current moment, and the hidden state vector of the word decoding model at the previous moment are input into the word decoding model to decode and obtain the target word corresponding to the current moment.

5. The method according to claim 1, characterized in that The training steps of the machine learning model include: Acquire training samples from a training sample set, wherein the training samples include a sample source sentence, an initial sample translation sentence obtained by initially translating the sample source sentence, a sample sentence adjustment operation sequence for performing sentence adjustment on the initial sample translation sentence, and adjustment words corresponding to each sentence adjustment operation in the sample sentence adjustment operation sequence; Inputting the sample source sentence in the training sample and the initial sample translation sentence into the machine learning model for encoding, to obtain a third encoding vector sequence corresponding to the sample source sentence and a fourth encoding vector sequence corresponding to the initial sample translation sentence; Using the machine learning model to jointly decode the third encoding vector sequence and the fourth encoding vector sequence to obtain a prediction operation sequence and prediction words corresponding to each prediction operation in the prediction operation sequence; The parameters in the machine learning model are updated according to the difference between the predicted operation sequence and the sample sentence adjustment operation sequence, and the difference between the adjusted words and the predicted words, and the step of obtaining the training samples in the training sample set is returned to continue the model training until the training convergence condition is met to obtain the trained machine learning model.

6. The method according to claim 1, characterized in that The machine learning model includes a first encoding model and a second encoding model, and the target source sentence and the initial translation sentence are encoded using the trained machine learning model to obtain a first encoding vector sequence corresponding to the target source sentence and a second encoding vector sequence corresponding to the initial translation sentence, including: The target source sentence is input into the first encoding model for encoding to obtain a first encoding vector sequence corresponding to the target source sentence, and the initial translation sentence is input into the second encoding model for encoding to obtain a second encoding vector sequence corresponding to the initial translation sentence.

7. The method according to claim 1, characterized in that The acquiring of the target source sentence and the initial translation sentence obtained by translating the target source sentence include: Obtain the target source sentence to be translated; The target source sentence is input into a machine translation model, and translated to obtain an initial translation sentence corresponding to the target source sentence.

8. A translation device, comprising: A source sentence and initial translation sentence acquisition module, used to acquire a target source sentence and an initial translation sentence obtained by translating the target source sentence; An encoding module, used to encode the target source sentence and the initial translation sentence using a trained machine learning model to obtain a first encoding vector sequence corresponding to the target source sentence and a second encoding vector sequence corresponding to the initial translation sentence; A decoding module, comprising an operation obtaining unit and a decoding obtaining unit, wherein the operation obtaining unit comprises a first coefficient obtaining sub-unit, a second coefficient obtaining sub-unit, a joint vector obtaining sub-unit and an operation decoding result obtaining sub-unit; A first coefficient obtaining subunit is used to determine, for each first encoding vector of the first encoding vector sequence, a first attention allocation weight coefficient relative to a target word to be output at a current moment; A second coefficient obtaining subunit is used to determine, for each second encoding vector of the second encoding vector sequence, a second attention allocation weight coefficient relative to the target word to be output at the current moment; A joint vector obtaining subunit, configured to calculate a joint vector according to the first coding vector sequence and the corresponding first attention allocation weight coefficient, the second coding vector sequence and the corresponding second attention allocation weight coefficient; The operation decoding result obtaining subunit is used to decode the joint vector by using the word vector of the target word output by the word decoding model included in the machine learning model at the previous moment, through the operation decoding model included in the machine learning model, to obtain the candidate operation decoding result at the current moment; determine the current sentence adjustment operation corresponding to the current moment according to the candidate operation decoding result at the current moment; A word obtaining unit, used to use the word decoding model to decode according to the candidate operation decoding result at the current moment, to obtain the target word corresponding to the current moment; The adjustment module is used to perform sentence adjustment on the initial translation sentence according to the sentence adjustment operation corresponding to each moment and the target words to obtain a target translation sentence corresponding to the target source sentence.

9. The device according to claim 8, characterized in that The operation decoding result obtaining subunit is also used to input the word vector of the target word output by the word decoding model at the previous moment, the joint vector and the hidden state vector of the operation decoding model at the previous moment into the operation decoding model through the operation decoding model included in the machine learning model to obtain the candidate operation decoding result at the current moment.

10. The device according to claim 8, characterized in that The candidate operation decoding result includes the selection rate corresponding to each candidate sentence adjustment operation, and the word obtaining unit includes: a target operation vector obtaining subunit, configured to calculate the target operation vector according to the operation vectors corresponding to the respective candidate statement adjustment operations and the selection rates, or to determine the current statement adjustment operation according to the selection rates corresponding to the respective candidate statement adjustment operations, and to use the operation vector corresponding to the current statement adjustment operation as the target operation vector; The word obtaining subunit is used to input the target operation vector into the word decoding model to decode and obtain the target word corresponding to the current moment.

11. The device according to claim 10, characterized in that The word acquisition subunit is also used to input the target operation vector, the hidden state vector of the operation decoding model at the current moment, and the hidden state vector of the word decoding model at the previous moment into the word decoding model to decode and obtain the target word corresponding to the current moment.

12. The device according to claim 8, characterized in that The device also includes a training module, which includes: a training sample acquisition unit, configured to acquire training samples from a training sample set, wherein the training samples include a sample source sentence, an initial sample translation sentence obtained by initially translating the sample source sentence, a sample sentence adjustment operation sequence for performing sentence adjustment on the initial sample translation sentence, and adjustment words corresponding to each sentence adjustment operation in the sample sentence adjustment operation sequence; A coding vector sequence obtaining unit, used for inputting the sample source sentence in the training sample and the initial sample translation sentence into the machine learning model for encoding, to obtain a third coding vector sequence corresponding to the sample source sentence and a fourth coding vector sequence corresponding to the initial sample translation sentence; A prediction operation and word obtaining unit, configured to jointly decode the third encoding vector sequence and the fourth encoding vector sequence using the machine learning model to obtain a prediction operation sequence and prediction words corresponding to each prediction operation in the prediction operation sequence; An updating unit, configured to update parameters in the machine learning model according to a difference between the predicted operation sequence and the sample sentence adjustment operation sequence, and a difference between the adjustment words and the predicted words; The returning unit is used to return to the step of obtaining the training samples in the training sample set to continue the model training until the training convergence condition is met to obtain the trained machine learning model.

13. The device according to claim 8, characterized in that The machine learning model includes a first encoding model and a second encoding model. The encoding module is also used to input the target source sentence into the first encoding model for encoding to obtain a first encoding vector sequence corresponding to the target source sentence, and input the initial translation sentence into the second encoding model for encoding to obtain a second encoding vector sequence corresponding to the initial translation sentence.

14. The device according to claim 8, characterized in that The source sentence and initial translation sentence acquisition module is also used to acquire a target source sentence to be translated; input the target source sentence into a machine translation model, and translate to obtain an initial translation sentence corresponding to the target source sentence.

15. A computer device, characterized in that: The invention comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the translation method according to any one of claims 1 to 7.

16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the steps of the translation method according to any one of claims 1 to 7.