Translation model training method and device, translation method and device
By determining the target affinity between translation tasks in a multilingual translation model and performing clustering, a target task cluster is constructed and a target translation model is trained. This solves the problem of reduced accuracy caused by the mutual influence of languages in multilingual translation models and achieves higher translation accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INST OF AUTOMATION CHINESE ACAD OF SCI
- Filing Date
- 2022-07-06
- Publication Date
- 2026-05-08
AI Technical Summary
In existing technologies, building a unified multilingual translation model for all languages can lead to mutual interference between different languages, reducing the translation quality of the multilingual translation model. How to improve the accuracy of multilingual translation is an important issue that urgently needs to be addressed.
By determining the target affinity between any two translation tasks, clustering is performed based on the target affinity to obtain multiple target task clusters, and the target translation model is trained based on the training data of each target task cluster.
It improves the accuracy of multilingual translation, makes full use of knowledge transfer between different translation tasks, and enhances the translation performance of the target translation model.
Smart Images

Figure CN115358245B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, and in particular to a method and apparatus for training a translation model, as well as a translation method and apparatus. Background Technology
[0002] With the development of deep learning technology, machine translation has become a hot topic in the field of natural language processing. Its goal is to use computer technology to automatically translate text from one language into text in other languages. Neural network-based machine translation methods have achieved significant improvements over traditional statistical machine translation methods. By expanding the language data at the source or target end, neural network machine translation models can directly model the mapping relationship between one set of languages and another, handling translations between multiple languages within the same model, thereby improving the efficiency of application deployment.
[0003] In related technologies, research on multilingual translation typically involves building a unified multilingual translation model for all languages to be translated. In this approach, the multilingual translation model supports translation for all languages.
[0004] However, with thousands of languages in the world, building a unified multilingual translation model for all languages would lead to mutual interference between different languages, thereby reducing the translation quality of the multilingual translation model. Therefore, improving the accuracy of multilingual translation is a crucial issue that the industry urgently needs to address. Summary of the Invention
[0005] In view of the problems existing in the prior art, the present invention provides a training method and apparatus for a translation model, and a translation method and apparatus.
[0006] This invention provides a method for training a translation model, comprising:
[0007] Obtain training data and preset translation models for M translation tasks, where M is greater than 1;
[0008] For the training data of any two translation tasks in the M translation tasks and the preset translation model, determine the target affinity between the two translation tasks. The target affinity is obtained by training the preset model on the two translation tasks.
[0009] Based on the target affinity described above, the translation tasks are clustered to obtain multiple target task clusters;
[0010] Based on the training data of each translation task in each of the target task clusters, the target translation model corresponding to each target task cluster is trained.
[0011] Optionally, determining the target affinity between any two translation tasks based on the training data and preset translation model of any two of the M translation tasks includes:
[0012] Input the training data of the first translation task from any two translation tasks into the preset translation model to obtain the first loss function value of the preset translation model for the first translation task at time t;
[0013] The preset translation model is updated based on the training data of the second translation task in any two of the translation tasks. The training data of the first translation task is input into the updated preset translation model to obtain the second loss function value of the updated preset translation model for the first translation task at time t+1.
[0014] Calculate the difference between the first loss function value and the second loss function value to determine the affinity between the first translation task and the second translation task at time t;
[0015] When the preset translation model reaches the convergence condition, the target affinity is determined based on the affinity between the first translation task and the second translation task at all times.
[0016] Optionally, based on the affinity of each target, the translation tasks are clustered to obtain multiple target task clusters, including:
[0017] Based on the target affinity of each of the above, an auxiliary translation task is determined for each of the translation tasks, wherein the target affinity between the auxiliary translation task and the translation task is greater than 0;
[0018] Clustering is performed on each of the translation tasks and the corresponding auxiliary translation tasks to obtain M initial task clusters;
[0019] Clustering is performed on each of the initial task clusters to obtain multiple target task clusters.
[0020] Optionally, the step of clustering each of the initial task clusters to obtain multiple target task clusters includes:
[0021] For any two initial task clusters among the M initial task clusters, calculate the overall affinity between the two initial task clusters.
[0022] The two initial task clusters with the highest overall affinity are clustered repeatedly until a preset stopping condition is met, resulting in multiple target task clusters.
[0023] Optionally, training the target translation model corresponding to each target task cluster based on the training data of each translation task in each target task cluster includes:
[0024] The training data of each translation task and auxiliary translation task in each target task cluster are sampled using a preset sampling rule to obtain the sampled training data corresponding to each target task cluster.
[0025] The sampled training data corresponding to each of the target task clusters is input into the target translation model corresponding to each of the target task clusters for training until the training stops.
[0026] The present invention also provides a translation method, comprising:
[0027] Obtain at least one text to be translated;
[0028] The text to be translated is input into the target translation model corresponding to the text to be translated, and the multilingual translation result output by the target translation model is obtained;
[0029] The target translation model is obtained by training the translation model using the same training method.
[0030] The present invention also provides a training apparatus for a translation model, comprising:
[0031] The first acquisition module is used to acquire training data and preset translation models for M translation tasks, where M is greater than 1;
[0032] The determination module is used to determine the target affinity between any two translation tasks and a preset translation model, given the training data of any two translation tasks among the M translation tasks. The target affinity is obtained by training the preset model on the two translation tasks.
[0033] The processing module is used to cluster the translation tasks based on the target affinity to obtain multiple target task clusters;
[0034] The training module is used to train the target translation model corresponding to each target task cluster based on the training data of each translation task in each target task cluster.
[0035] The present invention also provides a translation device, comprising:
[0036] The second acquisition module is used to acquire at least one text to be translated;
[0037] The input module is used to input the text to be translated into the target translation model corresponding to the text to be translated, and to obtain the multilingual translation result output by the target translation model;
[0038] The target translation model is obtained by training the translation model using the same training method.
[0039] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a training method or a translation method of any of the translation models described above.
[0040] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a training method or a translation method for any of the translation models described above.
[0041] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements a training method or a translation method for any of the translation models described above.
[0042] The translation model training method provided by this invention, by determining the target affinity between any two translation tasks, can reflect the degree to which the two translation tasks influence the accuracy of the translation results of the preset translation model. This allows for the clustering of translation tasks that promote the translation results of the preset translation model, resulting in target task clusters. Based on the training data of each translation task within each target task cluster, the target translation model corresponding to each target task cluster is trained, thereby improving the accuracy of the target translation model in multilingual translation scenarios. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0044] Figure 1 This is one of the flowcharts illustrating the training method for the translation model provided by this invention;
[0045] Figure 2 This is the second flowchart illustrating the training method for the translation model provided by this invention;
[0046] Figure 3 This is a flowchart illustrating the translation method provided by the present invention;
[0047] Figure 4 This is a schematic diagram of the structure of the training device for the translation model provided by the present invention;
[0048] Figure 5This is a schematic diagram of the translation device provided by the present invention;
[0049] Figure 6 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0050] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0051] To facilitate a clearer understanding of the various embodiments of this application, some relevant background knowledge will be introduced as follows.
[0052] Machine translation is a hot topic in the field of natural language processing. Its goal is to use computer technology to automatically translate text from one language into text in other languages. In recent years, with the development of deep learning technology, neural network-based machine translation methods have achieved significant improvements compared to traditional statistical machine translation methods. Multilingual machine translation methods use neural network machine translation models. By expanding the source / target language data, they can directly model the mapping relationship between one set of languages and another, handling translations between multiple languages within the same model, thereby improving the efficiency of application deployment.
[0053] However, there are thousands of languages in the world, with over one hundred spoken by more than ten million people. Building a unified multilingual machine translation for all languages would cause mutual interference between different languages, thereby reducing translation quality.
[0054] In multilingual translation scenarios, a simple approach to improve translation quality is to categorize different languages into different categories and build a multilingual translation system for each category.
[0055] The key challenge of this approach is determining which languages should be clustered into one group and which should belong to different groups. Most current work clusters languages using latent representations (such as word embeddings of language labels, or the corresponding representation of each language in a multilingual knowledge base) or linguistic prior information (such as using language family relationships or the degree of word overlap between different languages). However, this approach cannot describe the language differences arising from different training data distributions (e.g., two languages belonging to the medical and spoken language domains, even if their linguistic relationships are similar, will still have different representations in the model). Furthermore, it cannot handle "multi-language to multi-language" translation (e.g., when translating between Chinese, English, Japanese, and French, if Chinese and Japanese are grouped into one cluster and English and French into another, then translation between Chinese-English and Chinese-French language pairs becomes impossible).
[0056] In summary, in order to improve the accuracy of multilingual translation in multilingual translation scenarios, this invention provides a training method and apparatus for a translation model, as well as a translation method and apparatus.
[0057] The following is combined Figure 1 The training method for the translation model provided by this invention will be described in detail. Figure 1 This is one of the flowcharts illustrating the training method for the translation model provided by this invention. See [link / reference]. Figure 1 As shown, the method includes steps 101-104, wherein:
[0058] Step 101: Obtain training data and preset translation models for M translation tasks, where M is greater than 1.
[0059] First, it should be noted that the subject of this invention can be any electronic device with the function of training a translation model, such as any kind of smartphone, smartwatch, desktop computer, laptop, etc.
[0060] In multilingual translation scenarios, building a unified multilingual translation model for all languages can cause mutual interference between different languages, thereby reducing the translation quality of the multilingual translation model.
[0061] To improve the accuracy of multilingual translation, in this embodiment of the invention, it is first necessary to obtain training data for M translation tasks and a preset translation model.
[0062] Specifically, a translation task refers to the task of translating a text into a target language. For example, a translation task can be Chinese to English, Chinese to Japanese, or English to Chinese.
[0063] The preset translation model is a multilingual machine translation model, such as a multilingual machine translation model based on recurrent neural networks, a multilingual machine translation model based on self-attention mechanisms, etc. This invention does not limit the structural type of the preset translation model.
[0064] Step 102: For the training data and preset translation model of any two translation tasks among the M translation tasks, determine the target affinity between the two translation tasks. The target affinity is obtained by training the preset model based on the two translation tasks.
[0065] Specifically, after obtaining the training data for M translation tasks and the preset translation model, randomly sample any two translation tasks from the M translation tasks and obtain the training data for each of the two translation tasks.
[0066] Based on the training data of any two translation tasks and the preset translation model, the target affinity between any two translation tasks can be determined. Target affinity is used to reflect the degree to which any two translation tasks influence the accuracy of the preset translation model's translation results.
[0067] In other words, if the target affinity between translation task 1 and translation task 2 is high, it means that the two translation tasks have a positive effect on the translation results of the preset translation model. For example, if the preset translation model is trained using translation task 1, the accuracy of the preset translation model for translation task 2 will be improved, indicating that the two translation tasks have a positive effect on the translation results of the preset translation model.
[0068] Step 103: Based on the target affinity of each, the translation tasks are clustered to obtain multiple target task clusters.
[0069] Specifically, after determining the target affinity between each pair of translation tasks in the M translation tasks, it is necessary to cluster the translation tasks based on the target affinity to obtain multiple target task clusters. Each target task cluster includes multiple translation tasks and the training data of each translation task.
[0070] Step 104: Based on the training data of each translation task in each target task cluster, train the target translation model corresponding to each target task cluster.
[0071] Specifically, after obtaining multiple target task clusters, a target translation model needs to be constructed for each target task cluster. That is, each target task cluster corresponds to a target translation model. The target translation model is a multilingual machine translation model, such as a multilingual machine translation model based on recurrent neural networks, a multilingual machine translation model based on self-attention mechanism (such as the Transformer model), etc. This invention does not limit the structural type of the target translation model.
[0072] Based on the training data of each translation task in each target task cluster, the target translation model corresponding to each target task cluster is trained, thereby improving the accuracy of the target translation model in multilingual translation scenarios.
[0073] The translation model training method provided by this invention, by determining the target affinity between any two translation tasks, can reflect the degree to which the two translation tasks influence the accuracy of the translation results of the preset translation model. This allows for the clustering of translation tasks that promote the translation results of the preset translation model, resulting in target task clusters. Based on the training data of each translation task within each target task cluster, the target translation model corresponding to each target task cluster is trained, thereby improving the accuracy of the target translation model in multilingual translation scenarios.
[0074] Optionally, in one possible implementation of this invention, determining the target affinity between any two translation tasks based on the training data and preset translation model of any two of the M translation tasks can be achieved through the following steps, specifically including steps 1)-4):
[0075] Step 1) Input the training data of the first translation task from any two translation tasks into the preset translation model to obtain the first loss function value of the preset translation model for the first translation task at time t;
[0076] Step 2) Update the preset translation model based on the training data of the second translation task in any two translation tasks, input the training data of the first translation task into the updated preset translation model, and obtain the second loss function value of the updated preset translation model for the first translation task at time t+1.
[0077] Step 3) Calculate the difference between the first loss function value and the second loss function value to determine the affinity between the first translation task and the second translation task at time t;
[0078] Step 4) If the preset translation model reaches the convergence condition, determine the target affinity based on the affinity between the first translation task and the second translation task at all times.
[0079] Specifically, the first step is to consider the first translation task τ in any two translation tasks. i (For example, Chinese to English) training data is input into a preset translation model to obtain the preset translation model for τ. i The value of the first loss function at the current time (e.g., time t) can be specifically represented by the following formula (1):
[0080] L1 = -log P(y|x,M) t (1)
[0081] Where L1 represents the first loss function value; x represents the language text to be translated in the first translation task; y represents the target language text in the first translation task; M t This represents the preset translation model at time t.
[0082] After obtaining the first loss function value, based on the second translation task τ j The training data is used to update the preset translation model, that is, using τ j The training data is used to train the preset translation model step by step (only one step) to obtain the preset translation model M at time t+1. t+1 Specifically, it can be expressed by the following formula (2):
[0083] M t+1 =update(M t (2)
[0084] Then the training data from the first translation task is input into the updated preset translation model M. t+1 The updated preset translation model's second loss function value for the first translation task at time t+1 is obtained, which can be specifically expressed by the following formula (3):
[0085] L2 = -log P(y|x,M) t+1 (3)
[0086] Where L2 represents the value of the second loss function; x represents the language text to be translated in the first translation task; y represents the target language text in the first translation task; M t+1 This represents the preset translation model at time t+1.
[0087] After obtaining the first loss function value and the second loss function value, the difference between the first loss function value and the second loss function value can be calculated to determine the affinity between the first translation task and the second translation task at time t. Specifically, it can be expressed by the following formula (4):
[0088]
[0089] in, This represents the affinity of the second translation task to the first translation task at time t. It should be noted that in the above formula (4), a lower loss function value indicates a higher accuracy rate of the preset translation model. A value greater than 0 indicates that the translation has been processed by the preset translation model and passed through τ. j After training and updating the training data, τ i The input of training data into the updated preset translation model reduces the loss function value of the updated preset translation model, thus demonstrating that for τ i In terms of τ j It has a positive effect on the translation results of the preset translation model.
[0090] Due to the use of τ i τ j The training process for a pre-defined translation model typically involves tens of thousands to hundreds of thousands of iterative training steps, therefore τ i With τ j As the pre-defined translation model is iteratively trained, many affinity parameters will be calculated. Therefore, once the pre-defined translation model reaches convergence, it is necessary to base the calculation on τ. i and τ j The affinity between them at all times determines τ i and τ j The affinity between the targets.
[0091] Specifically, if the preset translation model reaches the convergence condition, τ can be... i and τ j The affinity between them at all times is averaged to obtain τ. i and τ j The target affinity between them can be specifically expressed by the following formula (5):
[0092]
[0093] Among them, Z j→i Represents τ j For τ i Target affinity.
[0094] In the above implementation, the target affinity between any two translation tasks is quantified by the loss function value of the preset translation model. This reflects the degree to which any two translation tasks influence the accuracy of the preset translation model's translation results. Furthermore, the translation tasks that promote the translation results of the preset translation model can be clustered to fully utilize the knowledge transfer between different translation tasks and improve the accuracy of the target translation model in multilingual translation.
[0095] Optionally, in one possible implementation of the present invention, the step of clustering the translation tasks based on the affinity of each target to obtain multiple target task clusters can be achieved through the following steps, specifically including steps a)-c):
[0096] Step a) Based on the target affinity of each of the above, determine the auxiliary translation task corresponding to each of the translation tasks, wherein the target affinity between the auxiliary translation task and the translation task is greater than 0;
[0097] Step b) Cluster the translation tasks and the corresponding auxiliary translation tasks to obtain M initial task clusters;
[0098] Step c) Cluster the initial task clusters to obtain multiple target task clusters.
[0099] In this embodiment, after determining the target affinity between each pair of M translation tasks, it is necessary to cluster the translation tasks based on the target affinity to obtain multiple target task clusters.
[0100] Specifically, firstly, based on the target affinity, we need to find a translation task with a target affinity greater than 0 for each of the M translation tasks as the corresponding auxiliary translation task.
[0101] Then, each translation task and its corresponding auxiliary translation task are clustered to obtain M initial task clusters.
[0102] It should be noted that each translation task initially corresponds to a task cluster. Therefore, M translation tasks have M task clusters, which can be represented by the following formula (6):
[0103] C = {c1, c2, ..., c} M} (6)
[0104] Where C represents the set of task clusters; c1 represents the task cluster corresponding to the first translation task in the set of task clusters; c2 represents the task cluster corresponding to the second translation task in the set of task clusters; c M This represents the task cluster corresponding to the Mth translation task in the task cluster set.
[0105] Accordingly, the set of auxiliary translation tasks corresponding to the M translation tasks can be represented by the following formula (7):
[0106] G = {g1, g2, ..., g} M} (7)
[0107] Where G represents the set of translation assistance tasks; g1 represents the translation assistance task corresponding to the first translation task in the set; g2 represents the translation assistance task corresponding to the second translation task in the set; g M This represents the auxiliary translation task corresponding to the Mth translation task in the set of auxiliary translation tasks.
[0108] For the k-th initial task cluster among the M initial task clusters, this initial task cluster includes the k-th translation task among the M translation tasks and all auxiliary translation tasks corresponding to the k-th translation task. Specifically, all auxiliary translation tasks corresponding to the k-th translation task can be represented by the following formula (8):
[0109]
[0110] After obtaining M initial task clusters, clustering is performed on each initial task cluster to obtain multiple target task clusters.
[0111] In the above implementation, by utilizing the target affinity between each translation task, the translation tasks are clustered to obtain M initial task clusters. This ensures that the translation tasks in each initial task cluster have high target affinity with all corresponding auxiliary translation tasks. As a result, the target translation model can be trained by making full use of the translation tasks and the corresponding auxiliary translation tasks, thereby improving the accuracy of the target translation model in multilingual translation.
[0112] Optionally, in one possible implementation of the present invention, the clustering of each initial task cluster to obtain multiple target task clusters can be achieved through the following steps, specifically including steps [1]-[2]:
[0113] Step [1]: For any two initial task clusters among the M initial task clusters, calculate the overall affinity between the two initial task clusters;
[0114] Step [2]: Repeatedly cluster the two initial task clusters with the highest overall affinity until a preset stopping condition is reached to obtain multiple target task clusters.
[0115] Specifically, the overall affinity between any two initial task clusters in the M initial task clusters refers to the target affinity between any two translation tasks in any two initial task clusters, plus the sum of the target affinity of all auxiliary translation tasks in the two initial task clusters, which can be expressed by the following formula (9):
[0116]
[0117] Wherein, S(c k ,g k ) represents the overall affinity after merging any two initial task clusters.
[0118] After calculating the overall affinity between any two initial task clusters, the two initial task clusters with the highest overall affinity are clustered in a loop.
[0119] It should be noted that when clustering any two initial task clusters (for example, when clustering initial task cluster p1 and initial task cluster p2), the auxiliary translation tasks corresponding to p1 and p2 also need to be clustered to ensure that when clustering the two initial task clusters, there is a one-to-one correspondence between the translation task set P in each initial task cluster and the auxiliary translation task set Q in each initial task cluster.
[0120] When clustering any two initial task clusters, the translation tasks in each initial task cluster must satisfy the first clustering rule. Specifically, the first clustering rule can be expressed by the following formula (10):
[0121]
[0122] The auxiliary translation tasks corresponding to each translation task in each initial task cluster need to satisfy the second clustering rule for clustering. Specifically, the second clustering rule can be expressed by the following formula (11):
[0123]
[0124] In this embodiment, the two initial task clusters with the highest overall affinity are repeatedly clustered until a preset stopping condition is met to obtain multiple target task clusters. This means that multiple target task clusters are obtained by repeatedly clustering the two initial task clusters with the highest overall affinity until no two initial task clusters can be clustered to further improve the overall affinity.
[0125] In other words, the loop clusters the two initial task clusters with the highest overall affinity. Under the preset stopping condition, for any two initial task clusters p1 and p2, and their corresponding q1 and q2, the following relationship is satisfied, which can be expressed by formula (12):
[0126]
[0127] in, S(p1,q1) represents the overall affinity after clustering any two initial task clusters p1 and p2; S(p2,q2) represents the affinity of the initial task cluster p1; and S(p2,q2) represents the affinity of the initial task cluster p2.
[0128] In the above implementation, the two initial task clusters with the highest overall affinity are clustered in a loop. When a preset stopping condition is met, each translation task that promotes the translation results of the preset translation model can be clustered to obtain target task clusters. Based on the training data of each translation task in each target task cluster, the target translation model corresponding to each target task cluster is trained, thereby improving the accuracy of the target translation model in multilingual translation scenarios.
[0129] Optionally, in one possible implementation of the present invention, the step of training the target translation model corresponding to each of the target task clusters based on the training data of each translation task in each target task cluster can be achieved in the following way, specifically including steps [a]-[b]:
[0130] Step [a]: Use preset sampling rules to sample the training data of each translation task and auxiliary translation task in each target task cluster to obtain the sampled training data corresponding to each target task cluster;
[0131] Step [b]: Input the sampled training data corresponding to each target task cluster into the target translation model corresponding to each target task cluster for training until the training stop condition is met.
[0132] In this embodiment, when training the target translation model corresponding to each target task cluster, it is necessary to use a preset sampling rule to sample the training data of each translation task and auxiliary translation task in each target task cluster.
[0133] Specifically, a dynamic data sampler is constructed for each target task cluster to sample each translation task and auxiliary task in each target task cluster, thereby obtaining the sampled training data corresponding to each target task cluster.
[0134] In practical applications, the sampler initialization method is not limited, such as uniform sampling, proportional sampling, temperature-based sampling, etc. Here, temperature-based sampling is used to sample the training data of each translation task and auxiliary translation task in each target task cluster, which can be expressed by the following formula (13):
[0135]
[0136] in, q represents the sampled training data corresponding to each target task cluster; τ q represents the proportion of training data for the τ-th translation task to the total training data for all translation tasks; π The value represents the proportion of training data for the π-th translation assistance task to the total training data for all translation assistance tasks; ρ represents the temperature sampling parameter; |D τ | represents the amount of training data for the translation task τ; |D π | indicates the amount of training data for the assisted translation task π.
[0137] In this embodiment, during the training of the target translation model, the training data of each translation task and auxiliary translation task in each target task cluster needs to be sampled dynamically, and the sampled training data corresponding to each target task cluster is input into the target translation model corresponding to each target task cluster for training until the training stop condition is reached.
[0138] The dynamic data sampler gradually increases the sampling probability of translation tasks in each target task cluster and gradually decreases the sampling probability of auxiliary translation tasks. This can be expressed by the following formula (14):
[0139]
[0140] Where E represents the number of training iterations of the current target translation model; λ represents the hyperparameter used to control the decay rate of the sampling probability.
[0141] In the above implementation, by sampling the training data of each translation task and auxiliary translation task in each target task cluster using preset sampling rules, the target translation model can focus more on the performance of the translation tasks in each target task cluster. For the auxiliary translation tasks, it can only utilize their advantageous translation knowledge without excessive optimization of the performance of the auxiliary translation tasks, thereby improving the efficiency of training each target translation model. At the same time, based on the training data of each translation task in each target task cluster, the target translation model corresponding to each target task cluster is trained, thereby improving the accuracy of the target translation model in multilingual translation scenarios.
[0142] Figure 2 This is the second flowchart illustrating the training method for the translation model provided by this invention. See also... Figure 2 As shown, the method includes steps 201-210, wherein:
[0143] Step 201: Obtain training data and preset translation models for M translation tasks, where M is greater than 1.
[0144] Step 202: Input the training data of the first translation task from any two translation tasks into the preset translation model to obtain the first loss function value of the preset translation model for the first translation task at time t.
[0145] Step 203: Update the preset translation model based on the training data of the second translation task in any two translation tasks. Input the training data of the first translation task into the updated preset translation model to obtain the second loss function value of the updated preset translation model for the first translation task at time t+1.
[0146] Step 204: Calculate the difference between the first loss function value and the second loss function value to determine the affinity between the first translation task and the second translation task at time t.
[0147] Step 205: If the preset translation model reaches the convergence condition, determine the target affinity based on the affinity between the first translation task and the second translation task at all times.
[0148] Step 206: Based on the target affinity, determine the auxiliary translation task corresponding to each translation task, wherein the target affinity between the auxiliary translation task and the translation task is greater than 0.
[0149] Step 207: Cluster the translation tasks and the corresponding auxiliary translation tasks to obtain M initial task clusters.
[0150] Step 208: For any two initial task clusters among the M initial task clusters, calculate the overall affinity between the two initial task clusters.
[0151] Step 209: Repeatedly cluster the two initial task clusters with the highest overall affinity until the preset stopping condition is met, resulting in multiple target task clusters.
[0152] Step 210: Use preset sampling rules to sample the training data of each translation task and auxiliary translation task in each target task cluster to obtain the sampled training data corresponding to each target task cluster.
[0153] Step 211: Input the sampled training data corresponding to each target task cluster into the target translation model corresponding to each target task cluster for training until the training stops.
[0154] Figure 3 This is a flowchart illustrating the translation method provided by the present invention. See also: Figure 3 As shown, the method includes steps 301-302, wherein:
[0155] Step 301: Obtain at least one text to be translated.
[0156] For example, the text to be translated is Chinese text.
[0157] Step 302: Input the text to be translated into the target translation model corresponding to the text to be translated, and obtain the multilingual translation result output by the target translation model;
[0158] In this embodiment, the target translation model is trained using the same method as the translation model, and the target translation model corresponds to the text to be translated.
[0159] For example, for Chinese text to be translated, the corresponding target translation model can support Chinese to English, Chinese to Japanese, and Chinese to French.
[0160] By inputting the Chinese text to be translated into the target translation model corresponding to the Chinese text, we can obtain the translation results of "English", "Japanese" and "French" output by the target translation model.
[0161] The translation method provided by this invention uses a target translation model to translate the text to be translated, which can improve the accuracy of translating the text to be translated in multilingual translation scenarios.
[0162] The training apparatus for the translation model provided by the present invention will be described below. The training apparatus for the translation model described below can be referred to in correspondence with the training method for the translation model described above. Figure 4 This is a schematic diagram of the structure of the training device for the translation model provided by the present invention, as shown below. Figure 4 As shown, the training device 400 for the translation model includes: a first acquisition module 401, a determination module 402, a processing module 403, and a training module 404, wherein:
[0163] The first acquisition module 401 is used to acquire training data and preset translation models for M translation tasks, where M is greater than 1;
[0164] The determination module 402 is used to determine the target affinity between any two translation tasks and a preset translation model for any two translation tasks among the M translation tasks. The target affinity is obtained by training the preset model based on the any two translation tasks.
[0165] The processing module 403 is used to cluster the translation tasks based on the target affinity of each task to obtain multiple target task clusters.
[0166] The training module 404 is used to train the target translation model corresponding to each target task cluster based on the training data of each translation task in each target task cluster.
[0167] The translation model training device provided by this invention can reflect the degree to which any two translation tasks influence the accuracy of the translation results of the preset translation model by determining the target affinity between them. This allows for the clustering of translation tasks that promote the translation results of the preset translation model, resulting in target task clusters. Based on the training data of each translation task in each target task cluster, the target translation model corresponding to each target task cluster is trained, thereby improving the accuracy of the target translation model in multilingual translation scenarios.
[0168] Optionally, module 402 is further configured to:
[0169] Input the training data of the first translation task from any two translation tasks into the preset translation model to obtain the first loss function value of the preset translation model for the first translation task at time t;
[0170] The preset translation model is updated based on the training data of the second translation task in any two of the translation tasks. The training data of the first translation task is input into the updated preset translation model to obtain the second loss function value of the updated preset translation model for the first translation task at time t+1.
[0171] Calculate the difference between the first loss function value and the second loss function value to determine the affinity between the first translation task and the second translation task at time t;
[0172] When the preset translation model reaches the convergence condition, the target affinity is determined based on the affinity between the first translation task and the second translation task at all times.
[0173] Optionally, the processing module 403 is further configured to:
[0174] Based on the target affinity of each of the above, an auxiliary translation task is determined for each of the translation tasks, wherein the target affinity between the auxiliary translation task and the translation task is greater than 0;
[0175] Clustering is performed on each of the translation tasks and the corresponding auxiliary translation tasks to obtain M initial task clusters;
[0176] Clustering is performed on each of the initial task clusters to obtain multiple target task clusters.
[0177] Optionally, the processing module 403 is further configured to:
[0178] For any two initial task clusters among the M initial task clusters, calculate the overall affinity between the two initial task clusters.
[0179] The two initial task clusters with the highest overall affinity are clustered repeatedly until a preset stopping condition is met, resulting in multiple target task clusters.
[0180] Optionally, training module 404 is further used for:
[0181] The training data of each translation task and auxiliary translation task in each target task cluster are sampled using a preset sampling rule to obtain the sampled training data corresponding to each target task cluster.
[0182] The sampled training data corresponding to each of the target task clusters is input into the target translation model corresponding to each of the target task clusters for training until the training stops.
[0183] Figure 5 This is a schematic diagram of the translation device provided by the present invention, as shown below. Figure 5 As shown, the translation device 500 includes: a second acquisition module 501 and an input module 502, wherein:
[0184] The second acquisition module 501 is used to acquire at least one text to be translated;
[0185] Input module 502 is used to input the text to be translated into the target translation model corresponding to the text to be translated, and to obtain the multilingual translation result output by the target translation model;
[0186] The target translation model is obtained by training the translation model using the same training method.
[0187] The translation device provided by this invention uses a target translation model to translate the text to be translated, which can improve the accuracy of translating the text to be translated in multilingual translation scenarios.
[0188] Figure 6 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 6As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630, and a communication bus 640, wherein the processor 610, the communication interface 620, and the memory 630 communicate with each other through the communication bus 640. The processor 610 can call logical instructions in the memory 630 to execute a translation model training method. This method includes: acquiring training data for M translation tasks and a preset translation model, where M is greater than 1; for any two translation tasks among the M translation tasks and the preset translation model, determining the target affinity between the two translation tasks, wherein the target affinity is obtained by training the preset model based on the two translation tasks; clustering the translation tasks based on the target affinity to obtain multiple target task clusters; and training the target translation model corresponding to each target task cluster based on the training data of each translation task in each target task cluster.
[0189] Alternatively, a translation method may be performed, comprising: acquiring at least one text to be translated; inputting the text to be translated into a target translation model corresponding to the text to be translated, and obtaining a multilingual translation result output by the target translation model; wherein the target translation model is trained using a translation model training method.
[0190] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0191] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the training method for the translation model provided by the above methods. The method includes: acquiring training data for M translation tasks and a preset translation model, where M is greater than 1; determining the target affinity between any two translation tasks and the preset translation model, wherein the target affinity is obtained by training the preset model based on the two translation tasks; clustering the translation tasks based on the target affinity to obtain multiple target task clusters; and training the target translation model corresponding to each target task cluster based on the training data of each translation task in each target task cluster.
[0192] Alternatively, a translation method may be performed, comprising: acquiring at least one text to be translated; inputting the text to be translated into a target translation model corresponding to the text to be translated, and obtaining a multilingual translation result output by the target translation model; wherein the target translation model is trained using a translation model training method.
[0193] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements a method for training the translation model provided by the above methods. The method includes: acquiring training data for M translation tasks and a preset translation model, where M is greater than 1; for any two translation tasks among the M translation tasks and the preset translation model, determining the target affinity between the two translation tasks, wherein the target affinity is obtained by training the preset model based on the two translation tasks; clustering the translation tasks based on the target affinity to obtain multiple target task clusters; and training the target translation model corresponding to each target task cluster based on the training data of each translation task within each target task cluster.
[0194] Alternatively, a translation method may be performed, comprising: acquiring at least one text to be translated; inputting the text to be translated into a target translation model corresponding to the text to be translated, and obtaining a multilingual translation result output by the target translation model; wherein the target translation model is trained using a translation model training method.
[0195] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0196] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0197] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for training a translation model, characterized in that, include: Obtain training data and preset translation models for M translation tasks, where M is greater than 1; For the training data of any two translation tasks in the M translation tasks and the preset translation model, determine the target affinity between the two translation tasks. The target affinity is obtained by training the preset translation model on the two translation tasks. Based on the target affinity described above, the translation tasks are clustered to obtain multiple target task clusters; Based on the training data of each translation task in each of the target task clusters, the target translation model corresponding to each target task cluster is trained; The determination of target affinity between any two translation tasks, given the training data and preset translation model for any two of the M translation tasks, includes: Input the training data of the first translation task from any two translation tasks into the preset translation model to obtain the first loss function value of the preset translation model for the first translation task at time t; The preset translation model is updated based on the training data of the second translation task in any two of the translation tasks. The training data of the first translation task is input into the updated preset translation model to obtain the second loss function value of the updated preset translation model for the first translation task at time t+1. Calculate the difference between the first loss function value and the second loss function value to determine the affinity between the first translation task and the second translation task at time t; When the preset translation model reaches the convergence condition, the target affinity is determined based on the affinity between the first translation task and the second translation task at all times.
2. The training method for the translation model according to claim 1, characterized in that, Based on the target affinity of each target, the translation tasks are clustered to obtain multiple target task clusters, including: Based on the target affinity of each of the above, an auxiliary translation task is determined for each of the translation tasks, wherein the target affinity between the auxiliary translation task and the translation task is greater than 0; Clustering is performed on each of the translation tasks and the corresponding auxiliary translation tasks to obtain M initial task clusters; Clustering is performed on each of the initial task clusters to obtain multiple target task clusters.
3. The training method for the translation model according to claim 2, characterized in that, The process of clustering each of the initial task clusters to obtain multiple target task clusters includes: For any two initial task clusters among the M initial task clusters, calculate the overall affinity between the two initial task clusters. The two initial task clusters with the highest overall affinity are clustered repeatedly until a preset stopping condition is met, resulting in multiple target task clusters.
4. The training method for the translation model according to claim 1, characterized in that, The step of training the target translation model corresponding to each target task cluster based on the training data of each translation task in each target task cluster includes: The training data of each translation task and auxiliary translation task in each target task cluster are sampled using a preset sampling rule to obtain the sampled training data corresponding to each target task cluster. The sampled training data corresponding to each of the target task clusters is input into the target translation model corresponding to each of the target task clusters for training until the training stops.
5. A translation method, characterized in that, include: Obtain at least one text to be translated; The text to be translated is input into the target translation model corresponding to the text to be translated, and the multilingual translation result output by the target translation model is obtained; The target translation model is obtained by training the translation model according to any one of claims 1-4.
6. A training device for a translation model, characterized in that, include: The first acquisition module is used to acquire training data and preset translation models for M translation tasks, where M is greater than 1; The determination module is used to determine the target affinity between any two translation tasks and a preset translation model, given the training data of any two translation tasks among the M translation tasks. The target affinity is obtained by training the preset translation model on the two translation tasks. The processing module is used to cluster the translation tasks based on the target affinity to obtain multiple target task clusters; The training module is used to train the target translation model corresponding to each target task cluster based on the training data of each translation task in each target task cluster. The determination of target affinity between any two translation tasks, given the training data and preset translation model for any two of the M translation tasks, includes: Input the training data of the first translation task from any two translation tasks into the preset translation model to obtain the first loss function value of the preset translation model for the first translation task at time t; The preset translation model is updated based on the training data of the second translation task in any two of the translation tasks. The training data of the first translation task is input into the updated preset translation model to obtain the second loss function value of the updated preset translation model for the first translation task at time t+1. Calculate the difference between the first loss function value and the second loss function value to determine the affinity between the first translation task and the second translation task at time t; When the preset translation model reaches the convergence condition, the target affinity is determined based on the affinity between the first translation task and the second translation task at all times.
7. A translation method, characterized in that, include: The second acquisition module is used to acquire at least one text to be translated; The input module is used to input the text to be translated into the target translation model corresponding to the text to be translated, and to obtain the multilingual translation result output by the target translation model; The target translation model is obtained by training the translation model according to any one of claims 1-4.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the training method of the translation model as described in any one of claims 1 to 4, or the translation method as described in claim 5.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the training method of the translation model as described in any one of claims 1 to 4, or the translation method as described in claim 5.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the training method of the translation model as described in any one of claims 1 to 4, or the translation method as described in claim 5.