Multilingual machine translation method, device, electronic device and storage medium
By pre-training multilingual parallel sentence pairs and introducing a cross-attention mechanism and an adaptive shared separation layer, the problem of poor generalization performance of multilingual machine translation models is solved, and the translation effect and semantic alignment relationship of low-resource languages are improved.
Patent Information
- Application Number
- CN202110697871.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-23
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2041-06-23
AI Technical Summary
Existing multilingual machine translation models have poor generalization performance, especially for low-resource languages, and cannot effectively capture the unified representation of semantics between different languages.
Pre-training is carried out with the goal of obtaining unified encoding results by encoding multi-language parallel sentence pairs, building a multi-language translation model based on the pre-trained encoder, and introducing a cross-attention mechanism and adaptive shared separation layer into the model to optimize the translation model to improve generalization performance.
It improves the generalization performance of multi-language machine translation models, improves the semantic alignment relationship between different languages, improves the translation effect of low-resource languages, and solves the problems of language conflicts and parameter sharing.
Smart Images

Figure CN113239710B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a multilingual machine translation method, device, electronic device and storage medium. Background Art
[0002] With the accumulation of large-scale parallel corpora, the continuous improvement of computing power and the widespread application of Transformer, machine translation technology has been gradually applied in people's daily lives. With the popularization of Internet applications and the development of globalization, in order to enable machine translation to quickly expand to multilingual translation, multilingual machine translation technology has received widespread attention.
[0003] Existing multilingual machine translation technology achieves unified modeling of multiple languages through parameter sharing, so that the same model supports translation between multiple languages. However, this modeling method cannot guarantee that sentences in different languages will have similar sentence representations, resulting in poor generalization performance of multilingual machine translation models, and poor translation results for low-resource languages. Summary of the invention
[0004] The present invention provides a multilingual machine translation method, device, electronic device and storage medium, which are used to solve the defect of poor generalization performance in the prior art and improve the generalization performance of the multilingual machine translation model.
[0005] The present invention provides a multilingual machine translation method, comprising:
[0006] Determine the source language text to be translated;
[0007] Inputting the source language text into a multilingual translation model to obtain a target language text output by the multilingual translation model;
[0008] The multilingual translation model is constructed based on a pre-trained encoder, and the pre-trained encoder is trained with the goal of encoding multilingual parallel sentence pairs to obtain a unified encoding result.
[0009] According to a multilingual machine translation method provided by the present invention, the pre-trained encoder is determined based on the following steps:
[0010] A pre-trained translation model is trained with the goal of translating multi-language parallel sentence pairs to obtain a unified translation result, and the encoder therein is used as the pre-trained encoder.
[0011] According to a multilingual machine translation method provided by the present invention, the encoder and decoder of the pre-trained translation model are connected through a pooling layer.
[0012] According to a multilingual machine translation method provided by the present invention, the multilingual translation model is determined based on the following steps:
[0013] Based on the pre-trained encoder, determining an initial network; the encoder and decoder of the initial network are connected through a cross attention mechanism;
[0014] The initial network is trained to obtain the multilingual translation model.
[0015] According to a multilingual machine translation method provided by the present invention, the training of the initial network to obtain the multilingual translation model includes:
[0016] Inputting a sample text in a single language into the initial network to obtain translation texts in multiple languages output by the initial network;
[0017] Based on the sample text in the single language and the translated texts in the multiple languages, the initial network is trained to obtain the multilingual translation model.
[0018] According to a multilingual machine translation method provided by the present invention, the multilingual translation model includes an adaptive shared separation layer, and the adaptive shared separation layer is used to select language shared parameters or language independent parameters for machine translation based on the upper layer output.
[0019] According to a multilingual machine translation method provided by the present invention, the multilingual translation model further includes a translation execution layer, and one of the adaptive shared separation layers is arranged between every two translation execution layers.
[0020] The present invention also provides a multilingual machine translation device, comprising:
[0021] A determination module, used for determining the source language text to be translated;
[0022] A translation module, used for inputting the source language text into a multilingual translation model to obtain a target language text output by the multilingual translation model;
[0023] The multilingual translation model is constructed based on a pre-trained encoder, and the pre-trained encoder is trained with the goal of encoding multilingual parallel sentence pairs to obtain a unified encoding result.
[0024] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the multilingual machine translation methods described above are implemented.
[0025] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the multilingual machine translation methods described above are implemented.
[0026] The multilingual machine translation method, device, electronic device and storage medium provided by the present invention perform pre-training with the goal of encoding multilingual parallel sentence pairs to obtain a unified encoding result, so that the pre-trained encoder can learn the unified semantic representation of sentences in different languages, and then obtain a multilingual translation model based on the pre-trained encoder, so that the machine translation model can learn the semantic alignment relationship more easily, thereby improving the multilingual machine translation effect and improving the generalization performance of the multilingual machine translation model. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0028] Figure 1 It is a flowchart of the multilingual machine translation method provided by the present invention;
[0029] Figure 2 This is one of the flow charts of the multilingual translation model training method provided by the present invention;
[0030] Figure 3 is a schematic diagram of the network structure of the pre-trained translation model provided by the present invention;
[0031] Figure 4 This is the second flow chart of the multilingual translation model training method provided by the present invention;
[0032] Figure 5 It is a schematic diagram of the process of the multilingual knowledge distillation method provided by the present invention;
[0033] Figure 6 is a schematic diagram of the network structure of the multilingual translation model provided by the present invention;
[0034] Figure 7 It is a schematic diagram of the structure of the multilingual machine translation device provided by the present invention;
[0035] Figure 8 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0037] Most current machine translation systems use parallel corpora to learn the mapping relationship between languages end-to-end, making the translation task a completely data-driven task. When the number of parallel sentence pairs in the translation task is relatively abundant, the quality of the translation model is high, but when the sentence pair data of the translation task is limited, the quality of the machine translation model is greatly limited. With the popularization of Internet applications and the development of globalization, in order to enable machine translation to quickly expand to multi-language translation and improve modeling efficiency, multi-language machine translation technology has received widespread attention.
[0038] However, for machine translation models, independent modeling cannot capture the problem of the same semantics in different language forms. Multilingual machine translation hopes to narrow the semantic distance between different language expressions by training multiple translation tasks simultaneously. Depending on the number of languages supported by the encoder and the number of languages supported by the decoder, multilingual machine translation can be divided into Many-to-One, One-to-Many and Many-to-Many modes.
[0039] Among them, Many-to-One means translating multiple languages into one language, One-to-Many means translating one language into multiple languages, and Many-to-Many means supporting translation between multiple languages. Many-to-One is usually used in many-to-one machine translation tasks, and hybrid modeling is achieved by sharing parameters on the decoder side; in the One-to-Many model structure, multiple languages share a common encoder and independent decoders, and are usually used in one-to-many translation tasks; in the Many-to-Many model structure, multiple languages not only share an encoder but also a decoder, and are usually used in many-to-many translation tasks, using one model to solve multiple translation tasks at the same time.
[0040] It can be seen that the existing multilingual machine translation realizes that one model supports translation of multiple languages at the same time through parameter sharing (shared encoder or shared decoder). By adding language labels to the encoder and decoder, the translation direction can be controlled. However, this modeling method cannot guarantee that sentences in different languages will have similar sentence representations, which leads to poor generalization performance of the multilingual machine translation model and poor translation effect for low-resource languages. With the progress of globalization, multilingual machine translation technology can alleviate cross-language communication barriers, so exploring and finding better multilingual translation modeling solutions has important practical significance.
[0041] In this regard, an embodiment of the present invention provides a multilingual machine translation method. Figure 1 is a flow chart of the multilingual machine translation method provided by the present invention, such as Figure 1 As shown, the method includes:
[0042] Step 110, determining the source language text to be translated;
[0043] Step 120, inputting the source language text into the multilingual translation model to obtain the target language text output by the multilingual translation model;
[0044] Among them, the multilingual translation model is built based on a pre-trained encoder, which is trained with the goal of encoding multilingual parallel sentence pairs to obtain a unified encoding result.
[0045] Here, the source language text is the text to be translated, the language used in the source language text is the source language, the language used in the text after translation is the target language, and the corresponding translation result is the target language text. The source language text here can be directly input by the user, or obtained by performing speech recognition on the collected audio, or by performing OCR (Optical Character Recognition) on the image obtained by image acquisition devices such as scanners, mobile phones, and cameras. The source language text can be a sentence or a combination of multiple sentences, which is not specifically limited in the embodiments of the present invention.
[0046] The multilingual translation model can realize the task of mutual translation between multiple languages. After the source language text is input into the multilingual translation model, the multilingual translation model can translate the source language text and output the translated target language text.
[0047] Considering that the existing multilingual machine translation model realizes unified modeling of multiple languages through parameter sharing, it lacks modeling of different language representations of the same semantics, resulting in poor generalization performance of the multilingual machine translation model. To address this problem, the embodiment of the present invention performs pre-training with the goal of encoding multilingual parallel sentence pairs to obtain a unified encoding result, obtains a pre-trained encoder, and constructs a multilingual translation model based on the pre-trained encoder.
[0048] Here, language parallel sentence pairs are sentence pairs that use multiple different languages to express the same semantics, for example, "I like learning" and "I like learning". During the training process of the pre-trained encoder, the encoding results of sentences with the same semantics in multiple different languages will tend to be consistent, and ultimately a unified encoding result that is independent of the language will be obtained, so that the pre-trained encoder can learn the unified semantic representation of sentences in different languages and narrow the semantic space distance between different languages. On this basis, a multilingual translation model is constructed based on the pre-trained encoder, so that the multilingual translation model can learn the intrinsic semantic connection between different languages without paying attention to the language itself, thereby improving the multilingual machine translation effect and the generalization performance of the multilingual machine translation model.
[0049] The method provided by the embodiment of the present invention performs pre-training with the goal of encoding multi-language parallel sentence pairs to obtain a unified encoding result, so that the pre-trained encoder can learn a unified semantic representation of sentences in different languages, and then obtain a multi-language translation model based on the pre-trained encoder, so that the machine translation model can learn the semantic alignment relationship more easily, thereby improving the multi-language machine translation effect and improving the generalization performance of the multi-language machine translation model.
[0050] Based on any of the above embodiments, the pre-trained encoder is determined based on the following steps:
[0051] A pre-trained translation model is trained with the goal of translating multi-language parallel sentence pairs to obtain a unified translation result, and the encoder therein is used as the pre-trained encoder.
[0052] Specifically, taking the model structure Transformer model and its deformation model commonly used in machine translation as an example, the model used for translation can generally be divided into two parts: an encoder and a decoder, wherein the encoder is used to undertake the encoding task of the source language text, such as the pre-trained encoder involved in step 120 of the embodiment of the present invention.
[0053] In order to obtain a pre-trained encoder, the embodiment of the present invention first uses multi-language parallel sentence pairs as training corpus, and aims to translate multi-language parallel sentence pairs to obtain a unified translation result, and trains the initial pre-trained model, and when the training converges, the pre-trained translation model can be obtained. Here, the initial pre-trained model is an encoder-decoder structure.
[0054] It is understandable that due to the characteristics of multilingual translation, multiple sentence pairs in multilingual parallel sentence pairs express the same meaning; when the initial pre-training model training converges, that is, the decoder outputs the same translation results of multilingual parallel sentence pairs, since the decoder can only decode based on the output information of the encoder during the training process, it can be explained that the encoder at this time has learned that the encoding representations of the same semantics in different languages are the same, and the encoder at this time can be used as a pre-training encoder.
[0055] By training with the goal of unifying translation results, the goal of obtaining unified encoding results can be achieved, so that the pre-trained encoder obtained in this way can narrow the semantic space distance between different languages and improve the multilingual machine translation effect.
[0056] Based on any of the above embodiments, the encoder and decoder of the pre-trained translation model are connected through a pooling layer.
[0057] Specifically, in order to learn a unified semantic representation of multiple languages, the embodiment of the present invention removes the attention mechanism between the encoder and the decoder in the conventional encoder-decoder model structure during pre-training using the encoder-decoder model structure, and adds a pooling layer to the output layer of the encoder, so that the encoder and the decoder are connected through the pooling layer. Here, the embodiment of the present invention does not specifically limit the type of the pooling layer, for example, it can be a maximum pooling layer, an average pooling layer, etc.
[0058] The encoder and decoder exchange information only through the output of the pooling layer, so that the decoder can complete the decoding process only by relying on the text encoding result output by the encoder through the pooling layer. The training goal of the unified translation result forces the encoder to learn the unified semantic representation of input sentences in different languages, thereby improving the learning ability of the pre-trained encoder for the unified semantic representation of sentences in different languages. Based on any of the above embodiments, Figure 2 is one of the flow charts of the multilingual translation model training method provided by the present invention, such as Figure 2 As shown, the multilingual translation model is determined based on the following steps:
[0059] Step 210, determining an initial network based on the pre-trained encoder; the encoder and decoder of the initial network are connected via a cross attention mechanism;
[0060] Step 220: training the initial network to obtain a multilingual translation model.
[0061] Specifically, after obtaining the pre-trained encoder, the multilingual translation model can be obtained in the following way: first, the encoder of the initial network is initialized using the pre-trained encoder to obtain the initialized initial network, thereby maximizing the benefits of the pre-training method; in addition, in order for the network to better learn features during the training process and thus improve the translation effect, the encoder and decoder of the initial network can be connected through a cross-attention mechanism; on this basis, the initial network is trained based on multilingual parallel sentences, and the network parameters are further optimized to finally obtain a multilingual translation model, thereby enabling the multilingual translation model to achieve better translation effects.
[0062] Here, step 210 may be to replace the encoder with a pre-trained encoder on the existing network architecture to obtain the initial network, or may be to directly adaptively change the encoder and decoder of the pre-trained translation model to obtain the initial network, which is not specifically limited in the embodiment of the present invention.
[0063] Based on any of the above embodiments, Figure 3 is a schematic diagram of the network structure of the pre-trained translation model provided by the present invention, such as Figure 3 As shown in the figure, the pre-trained translation model structure is based on the Transformer structure, with corresponding changes: the attention mechanism between the encoder and the decoder is removed, and a Max-Pooling layer is added to the output of the encoder to obtain the semantic representation of the encoder, so that the encoder and the decoder only exchange information through the output of the Max-Pooling layer.
[0064] In addition, the pre-trained translation model can be trained in the following manner: first, multi-language parallel sentence pairs are input into the initial pre-trained model, and the initial pre-trained model is trained with the goal of translating the multi-language parallel sentence pairs to obtain a unified translation result. When the training converges, the pre-trained translation model can be obtained. Furthermore, considering that when processing multi-language data, in order to distinguish the translation direction, it is necessary to add language tags to the parallel sentence pairs. The usual practice is to add language tags to both the encoder and the decoder. However, in the embodiment of the present invention, in order to enable the encoder to obtain a unified semantic representation that is independent of language, no language tags are added to the encoder, and only the language tag of the target language is added to the decoder. For example, in Figure 3 In the example, Chinese needs to be translated into English, that is, "I am from China"->" <en>I am from China", you can add the English language tag to the decoder.
[0065] After training to obtain the pre-trained translation model, the encoder of the pre-trained translation model can be used as the pre-trained encoder, and then the initial network is determined based on the pre-trained encoder: the encoder of the initial network is initialized using the pre-trained encoder; the decoder of the initial network is initialized using the decoder of the pre-trained translation model; the Max-Pooling layer of the encoder is removed; and a cross-attention mechanism is added between the encoder and the decoder for connection. Then, the initial network is trained based on multi-language parallel sentences, so that a multi-language translation model can be obtained.
[0066] It should be noted that, in response to the problem that existing multilingual machine translation models are unable to handle expressions of the same semantics in different languages, an embodiment of the present invention proposes a multilingual semantic unified representation pre-training scheme, which models expressions of the same semantics in different languages through an end-to-end learning mechanism, learns unified semantic representations of different languages, and shortens the semantic distance between expressions of the same language in different languages, thereby enabling the machine translation model to learn semantic alignment relationships more easily, thereby improving the multilingual machine translation effect.
[0067] Based on any of the above embodiments, Figure 4 FIG. 2 is a flow chart of the multilingual translation model training method provided by the present invention. Figure 4 As shown, step 220 includes:
[0068] Step 221, inputting a sample text in a single language into the initial network to obtain translation texts in multiple languages output by the initial network;
[0069] Step 222: Based on the sample text in a single language and the translated texts in multiple languages, an initial network is trained to obtain a multi-language translation model.
[0070] Specifically, considering that the existing multilingual hybrid modeling can improve the effect of low-resource machine translation due to the mutual promotion of languages, in the hybrid modeling scenario, due to data sampling problems, the limited parameters of the translation model can only be allocated to the low-resource language, resulting in insufficient training of low-resource languages. In addition, there are relatively few parallel sentence pairs in low-resource languages and there are problems in collecting them, resulting in unsatisfactory translation effects and low usability.
[0071] In this regard, an embodiment of the present invention introduces multilingual knowledge distillation technology for low-resource languages. That is, in the process of training the initial network, the initial network itself is optimized by using the data generated by the initial network itself. On the one hand, the sentence pair level of low-resource languages can be improved, and on the other hand, the learning difficulty of the machine translation model can be reduced, thereby improving the machine translation effect.
[0072] After determining the initial network, the embodiment of the present invention first inputs a sample text in a single language into the initial network to obtain translated texts in multiple languages output by the initial network to achieve data enhancement, and then uses the translated texts in multiple languages generated by the initial network as training samples, and uses the corresponding sample texts in a single language as target labels of the training samples to train the initial network, thereby obtaining a multilingual translation model.
[0073] It is understandable that since the initial network is determined based on the pre-trained encoder and has the characteristic of unified representation of multi-language semantic sentence pairs, the translated texts in multiple languages generated by the initial network have similar semantic representations, which can significantly narrow the distance between the semantics of low-resource languages and rich-resource languages, and thus facilitate the translation effect of low-resource languages. On this basis, multi-language knowledge distillation can be achieved through the initial network, which can reduce the resource requirements of the machine translation model for scarce languages and can effectively solve the resource scarcity problem of low-resource languages.
[0074] It should be noted that the multilingual knowledge distillation technology provided in the embodiment of the present invention can expand the number of scarce resource sentence pairs and improve the translation effect of low-resource languages, but it is also applicable to high-resource languages and can achieve similar effects. Therefore, the embodiment of the present invention does not specifically limit the type of language used for the sample text of a single language, and it can be any language.
[0075] Based on any of the above embodiments, Figure 5 is a flow chart of the multilingual knowledge distillation method provided by the present invention, such as Figure 5 As shown, in the process of training the initial network, the embodiment of the present invention inputs a sample text of a single language into the initial network, and then uses the data generated by the initial network itself to optimize the initial network itself, thereby finally obtaining a multilingual translation model with better translation effect. Figure 5 In the example, the sample text in a single language is "I am from China". Correspondingly, the data generated by inputting "I am from China" into the initial network is the translated text in multiple languages.
[0076] Furthermore, the specific process of the multilingual knowledge distillation method is as follows:
[0077] 1. In the process of training the initial network, the translation ability of the initial network is used to translate a single language into other languages;
[0078] 2. Since the initial network is built based on the pre-trained encoder, the semantics of multiple languages in step 1 have similar representations;
[0079] 3. Based on the translation texts in multiple languages generated in step 1, it is used to optimize the initial network currently being trained;
[0080] 4. Repeat the above steps until the initial network converges, that is, the text output by the initial network is consistent with the sample text of a single language. At this time, a multilingual translation model can be obtained.
[0081] It should be noted that, in order to solve the problem of poor machine translation effect of existing scarce resources, the embodiment of the present invention uses online multilingual knowledge distillation technology under the framework of multilingual machine translation model. This technology can generate same-semantic sentence pairs using the multilingual semantic unified representation framework, effectively improving the level of parallel sentence pairs of scarce resources, and through multilingual unified representation, the model learns how to transfer linguistic knowledge from rich resource languages, thereby improving the machine translation effect in low-resource scenarios. At the same time, the use of multilingual knowledge distillation technology can also reduce the difficulty of multilingual machine translation learning.
[0082] Based on any of the above embodiments, the multi-language translation model includes an adaptive shared separation layer, and the adaptive shared separation layer is used to select language shared parameters or language independent parameters for machine translation based on the output of the upper layer.
[0083] Specifically, considering that when existing multilingual machine translation uses the same model to model the translation of multiple language pairs at the same time, the usual practice is to fully share parameters. This approach ignores the differences between languages, resulting in the widespread existence of model language conflicts or parameter conflicts in multilingual machine translation models, which in turn leads to the fact that in some scenarios, the effect of multilingual machine translation models is even worse than independent modeling, such as in One-to-Many scenarios. At present, the solution to parameter conflicts is usually to separate some parameters as language-independent parameters. Although this approach can alleviate the parameter conflict problem, it also weakens the significance of mutual promotion of languages in multilingual mixed modeling.
[0084] In order to solve the above problems, an embodiment of the present invention proposes an adaptive parameter sharing mechanism, that is, an adaptive shared separation layer is set in the multilingual translation model, where the adaptive shared separation layer can be set to one or more, and can be set in the encoder or decoder of the multilingual translation model, or can be set in the encoder and decoder of the multilingual translation model respectively. The adaptive shared separation layer is inserted into the multilingual translation model in a cascade form, and can adaptively determine whether to select language shared parameters for machine translation or language independent parameters for machine translation based on the data output by the upper layer, that is, the data input into the adaptive shared separation layer. The language shared parameters here are the parameters shared by all languages, and the language independent parameters are the different parameters used for different languages. Both parameters are pre-set.
[0085] The method provided by the embodiment of the present invention realizes adaptive selection of language shared parameters or language independent parameters by setting an adaptive shared separation layer in the multilingual translation model, so that the multilingual machine translation model can dynamically decide whether to share parameters when facing different languages, different sentences, and different vocabularies, thereby effectively solving the language conflict phenomenon existing in the multilingual machine translation model and improving the overall effect of multilingual machine translation.
[0086] Based on any of the above embodiments, the multi-language translation model further includes a translation execution layer, and an adaptive shared separation layer is arranged between every two translation execution layers.
[0087] Specifically, in order to enable the translation execution layer to adaptively select independent parameters or shared parameters, and to enable each translation execution layer to maintain its original structure, an adaptive shared separation layer is set between every two translation execution layers in an embodiment of the present invention. Here, the translation execution layer is a network layer used to perform machine translation tasks. It can be understood that the corresponding translation execution layer will be different depending on the different neural networks used in the multilingual translation model. For example, the multilingual translation model uses a Transformer network, and the translation execution layer corresponds to the Self-Attention layer, the Feed-Forward layer, etc.
[0088] In the multilingual translation model thus formed, most of the network layer parameters used to perform machine translation tasks can be adaptively selected according to the input source language text, which greatly improves the flexibility of the multilingual translation model when translating into different languages, thereby improving the overall effect of multilingual machine translation.
[0089] Based on any of the above embodiments, the adaptive shared separation layer can be represented by an adaptive selection module and a language parameter module, wherein the language parameter module includes a language independent parameter module and a language shared parameter module.
[0090] Among them, the adaptive selection module is used to determine whether to select language-shared parameters or language-independent parameters according to the upper-layer output, which can be specifically expressed as a binary classification model or a gate threshold module.
[0091] For example, Figure 6 It is a schematic diagram of the network structure of the multilingual translation model provided by the present invention. The encoder and decoder modules of the model are mainly modified based on the Transformer structure. The adaptive shared separation layer is the CLSR in the figure, the adaptive selection module is the Gate module between the input and output in the figure, the language independent parameter module is the Language Specific in the figure, and the language shared parameter module is the Shared in the figure.
[0092] like Figure 6 As shown in the figure, CLSR is set between the Self-Attention layer and the Feed-Forward layer, between the Self-Attention layer and the Cross-Attention layer, and between the Cross-Attention layer and the Feed-Forward layer. When the multi-translation model passes through the language-independent parameter module, it means that the parameters independent of each language are selected for machine translation; when the translation model passes through the language-shared parameter module, it means that the parameters shared by all languages are selected for machine translation. For example, in Figure 6 In the language-specific parameter module Language Specific shown, each language has a corresponding independent parameter, such as Chinese zh, English en, and French fr.
[0093] CLSR can implement an adaptive parameter sharing mechanism for language and sentence through the Gate module. Each token in the encoder and decoder corresponds to an adaptive Gate module. For different languages and different tokens, the Gate module is used to determine which parameters the model uses. The Gate module g(.) is composed of a two-layer feed-forward network G(.). In order to make the Gate module close to 0 or 1 during training to determine whether the parameters are shared or separated, Gaussian noise N(0,1) is added to the Gate module. The calculation formula of the Gate module is as follows:
[0094] G(z l )=Relu(z l W1+b)w2,
[0095] Where σ(.) is the sigmoid function, α(t) is the increasing function of time, and as the training continues, the Gaussian noise gradually increases; l It is the intermediate representation of the token input of the l-th layer network, W1, b and w2 are the model training parameters, and learn whether to share parameters and how many parameters to share.
[0096] After learning, the Gate module will decide how to dynamically share parameters for different languages and sentences. During the prediction process, the learned Gate parameters are used to dynamically decide whether the prediction process uses shared parameters or independent parameters. The process is as follows:
[0097] 1) After the source language text is tokenized, it is input into the Embedding layer of the multilingual translation model, and then sent to the Transformer encoder of the multilingual translation model;
[0098] 2) After passing through the Self-Attention module in the encoder, CLSR is used to calculate the output of the Gate module based on the implicit state of each token in the source language text, and decide whether to use language-shared parameters or language-independent parameters.
[0099] 3) Then after passing through the Feed-Forward Layer in the encoder, it enters the next Transformer layer and executes in a loop;
[0100] 4) The Tansformer decoder is similar to the encoder. CLSR exists between the Self-Attention module and the Cross-Attention module, and between the Cross-Attention module and the Feed-Forward Layer.
[0101] 5) After passing through the Transformer decoder, the output is obtained through the softmax layer.
[0102] It should be noted that, in view of the common language conflict phenomenon in existing multilingual machine translation models, the embodiment of the present invention proposes an adaptive parameter sharing separation mechanism based on a threshold module. Through the learning of Gate parameters, the multilingual translation model uses shared parameters when it is necessary to use information shared between languages, and uses language independent parameters when it is necessary to avoid language conflicts, thereby achieving a balance between the number of languages and model parameters. In addition, the use of a parameter-based threshold module to control parameter sharing can not only optimize the parameter model end-to-end, but also can decide how many parameters to share without relying on manual experience, thereby achieving a complete end-to-end optimization effect.
[0103] Finally, it should be noted that the present invention uses technologies such as deep learning, machine translation, multilingual hybrid modeling, multilingual semantic unified representation pre-training scheme, adaptive multilingual parameter sharing mechanism and multilingual knowledge distillation, and utilizes massive multilingual parallel sentence pairs to learn the intrinsic connections between languages, so as to achieve the purpose of comprehensively optimizing the multilingual machine translation model, so that multilingual machine translation can learn the semantic alignment relationship of multiple languages, overcome language conflicts, and improve the effect of low-resource machine translation.
[0104] The multilingual machine translation device provided by the present invention is described below. The multilingual machine translation device described below and the multilingual machine translation method described above can be referred to each other.
[0105] Figure 7 is a schematic diagram of the structure of the multilingual machine translation device provided by the present invention. Figure 7 As shown, the device comprises:
[0106] A determination module 710, for determining a source language text to be translated;
[0107] The translation module 720 is used to input the source language text into the multilingual translation model to obtain the target language text output by the multilingual translation model;
[0108] Among them, the multilingual translation model is built based on a pre-trained encoder, which is trained with the goal of encoding multilingual parallel sentence pairs to obtain a unified encoding result.
[0109] The device provided by the embodiment of the present invention performs pre-training with the goal of encoding multi-language parallel sentence pairs to obtain a unified encoding result, so that the pre-trained encoder can learn a unified semantic representation of sentences in different languages, and then obtain a multi-language translation model based on the pre-trained encoder, so that the machine translation model can learn the semantic alignment relationship more easily, thereby improving the multi-language machine translation effect and improving the generalization performance of the multi-language machine translation model.
[0110] Based on any of the above embodiments, the pre-trained encoder is determined based on the following steps:
[0111] A pre-trained translation model is trained with the goal of translating multi-language parallel sentence pairs to obtain a unified translation result, and the encoder therein is used as the pre-trained encoder.
[0112] Based on any of the above embodiments, the encoder and decoder of the pre-trained translation model are connected through a pooling layer.
[0113] Based on any of the above embodiments, the multilingual translation model is determined based on the following steps:
[0114] Based on the pre-trained encoder, determine the initial network; the encoder and decoder of the initial network are connected through a cross-attention mechanism;
[0115] The initial network is trained to obtain a multilingual translation model.
[0116] Based on any of the above embodiments, the initial network is trained to obtain a multilingual translation model, including:
[0117] Input a sample text in a single language into the initial network to obtain translated texts in multiple languages output by the initial network;
[0118] Based on sample texts in a single language and translated texts in multiple languages, the initial network is trained to obtain a multilingual translation model.
[0119] Based on any of the above embodiments, the multi-language translation model includes an adaptive shared separation layer, and the adaptive shared separation layer is used to select language shared parameters or language independent parameters for machine translation based on the output of the upper layer.
[0120] Based on any of the above embodiments, the multi-language translation model further includes a translation execution layer, and an adaptive shared separation layer is arranged between every two translation execution layers.
[0121] Figure 8 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 8 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication interface 820 and the memory 830 communicate with each other through the communication bus 840. The processor 810 may call the logic instructions in the memory 830 to execute the multilingual machine translation method, which includes: determining the source language text to be translated; inputting the source language text into the multilingual translation model to obtain the target language text output by the multilingual translation model; wherein the multilingual translation model is constructed based on a pre-trained encoder, and the pre-trained encoder is trained with the goal of encoding multilingual parallel sentence pairs to obtain a unified encoding result.
[0122] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0123] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the multilingual machine translation method provided by the above methods, and the method includes: determining a source language text to be translated; inputting the source language text into a multilingual translation model to obtain a target language text output by the multilingual translation model; wherein the multilingual translation model is constructed based on a pre-trained encoder, and the pre-trained encoder is trained with the goal of encoding multilingual parallel sentence pairs to obtain a unified encoding result.
[0124] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the multilingual machine translation method provided above, the method comprising: determining a source language text to be translated; inputting the source language text into a multilingual translation model to obtain a target language text output by the multilingual translation model; wherein the multilingual translation model is constructed based on a pre-trained encoder, and the pre-trained encoder is trained with the goal of encoding multilingual parallel sentence pairs to obtain a unified encoding result.
[0125] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0126] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0127] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.< / en>
Claims
1. A multilingual machine translation method, characterized in that: include: Determine the source language text to be translated; Inputting the source language text into a multilingual translation model to obtain a target language text output by the multilingual translation model; The multilingual translation model is constructed based on a pre-trained encoder, which is trained to encode multilingual parallel sentence pairs to obtain a unified encoding result; the multilingual parallel sentence pairs are sentence pairs that use multiple different languages to express the same semantics; The pre-trained encoder is determined based on the following steps: A pre-trained translation model is trained with the goal of translating multi-language parallel sentence pairs to obtain a unified translation result, and the encoder in the pre-trained translation model is used as the pre-trained encoder; the encoder and decoder of the pre-trained translation model are connected through a pooling layer; The multilingual translation model also includes an adaptive shared separation layer, which is used to select language shared parameters or language independent parameters for machine translation based on the upper layer output; the adaptive shared separation layer is constructed based on the Gate module; the multilingual translation model also includes a translation execution layer, and one adaptive shared separation layer is set between every two translation execution layers.
2. The multilingual machine translation method according to claim 1, characterized in that: The multilingual translation model is determined based on the following steps: Based on the pre-trained encoder, determining an initial network; the encoder and decoder of the initial network are connected through a cross attention mechanism; The initial network is trained to obtain the multilingual translation model.
3. The multilingual machine translation method according to claim 2, characterized in that: The step of training the initial network to obtain the multilingual translation model includes: Inputting a sample text in a single language into the initial network to obtain translation texts in multiple languages output by the initial network; The initial network is trained based on the sample text in the single language and the translated texts in the multiple languages to obtain the multilingual translation model.
4. A multilingual machine translation device, characterized in that: include: A determination module, used for determining the source language text to be translated; A translation module, used for inputting the source language text into a multilingual translation model to obtain a target language text output by the multilingual translation model; The multilingual translation model is constructed based on a pre-trained encoder, which is trained to encode multilingual parallel sentence pairs to obtain a unified encoding result; the multilingual parallel sentence pairs are sentence pairs that use multiple different languages to express the same semantics; The pre-trained encoder is determined based on the following steps: A pre-trained translation model is trained with the goal of translating multi-language parallel sentence pairs to obtain a unified translation result, and the encoder in the pre-trained translation model is used as the pre-trained encoder; the encoder and decoder of the pre-trained translation model are connected through a pooling layer; The multilingual translation model also includes an adaptive shared separation layer, which is used to select language shared parameters or language independent parameters for machine translation based on the upper layer output; the adaptive shared separation layer is constructed based on the Gate module; the multilingual translation model also includes a translation execution layer, and one adaptive shared separation layer is set between every two translation execution layers.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the multi-language machine translation method according to any one of claims 1 to 3 are implemented.
6. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the multilingual machine translation method according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Machine translation method, training method, corresponding device and electronic equipment
CN110956045A
