Translation Model Training Method, Device, and Medium

By replacing some words in the sentence to be translated as synonyms of the target language in bilingual parallel corpus, the first translation model is trained, and the problems of poor translation accuracy and resource overhead in rare languages are solved, and efficient accuracy and resource savings of multilingual translation are achieved.

CN113609873BActive Publication Date: 2025-08-01TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110090073.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-22
Publication Date
2025-08-01
Estimated Expiration
2041-01-22

AI Technical Summary

Technical Problem

The existing machine translation model has poor translation accuracy in rare languages, complex training and deployment processes, and high resource overhead.

Method used

By replacing some words in the sentence to be translated as synonyms of the target language in a bilingual parallel corpus, the first translation model is trained until the convergence conditions are met, the target language is randomly sampled and multiple iterative training is performed to build a model suitable for multilingual translation.

Benefits of technology

The accuracy of the translation model for various languages is improved, especially the translation ability of rare languages, and the overhead of training and deployment resources is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113609873B_ABST
    Figure CN113609873B_ABST
Patent Text Reader

Abstract

The present application provides a method, apparatus and medium for training a translation model, relating to the field of artificial intelligence technologies, and particularly to natural language processing technologies. The method for training the translation model can improve the accuracy of the output of the trained translation model. In the method for training the translation model, some words in the sentence to be translated are replaced with synonyms corresponding to a language different from the language of the sentence to be translated, and different languages are input into the translation model at one time, so that the translation model can learn the relationships between multiple languages at one time, improve the training effect of the translation model, and thus improve the output accuracy of the translation model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, in particular to natural language processing technology, and provides a translation model training method, device and medium. Background Art

[0002] Machine translation enables communication between people without being restricted by language, and can promote exchanges in various aspects such as economy and culture among countries and regions.

[0003] Currently, there are two common approaches to machine translation. The first is to implement machine translation using a one-to-one translation model, where a separate translation model is trained for each translation from one language to another. The second is to combine bilingual parallel corpora in multiple languages to train a single translation model, using this model to share parameters for translation between multiple languages.

[0004] The second approach can simplify the number of models used for translation. However, because the training process actually involves learning the relationships between any two languages separately, the training method is essentially the same as the first approach. As a result, the performance of the trained model in each language is closely related to the amount of bilingual parallel corpus data. If the corresponding corpus for a certain language is relatively small, the trained translation model will produce less accurate translation results when translating that language. Summary of the Invention

[0005] The embodiments of the present application provide a translation model training method, device, and medium for improving the accuracy of translation results.

[0006] In one aspect, a translation model training method is provided, comprising:

[0007] Acquire multiple types of bilingual parallel corpora, wherein each type of bilingual parallel corpora includes at least one bilingual sentence pair, and each bilingual sentence pair is two sentences corresponding to each other and belonging to two different languages;

[0008] For each bilingual sentence pair in each type of bilingual parallel corpus, the following operations are performed to obtain updated multi-type bilingual parallel corpora: replacing some words in a sentence to be translated in a bilingual sentence pair in a type of bilingual parallel corpus with synonyms in a target language, where the target language is different from the language associated with the sentence to be translated in the bilingual sentence pair;

[0009] Based on the updated multi-category bilingual parallel corpus, the first translation model is trained until the first translation model meets a first model convergence condition, thereby obtaining a trained first translation model.

[0010] In one aspect, an embodiment of the present application provides a translation model training method, comprising:

[0011] Select the target bilingual parallel corpus from multiple types of bilingual parallel corpora;

[0012] Use the target bilingual parallel corpus to retrain the trained first translation model obtained by the translation model training method described above until the trained first translation model meets the second model convergence condition, and obtain the trained second translation model.

[0013] On the one hand, an embodiment of the present application provides a translation method, including:

[0014] In response to a translation request operation for a target text, obtain a translation result through the trained first translation model, where the trained first translation model is obtained by the translation model training method described above.

[0015] On the one hand, an embodiment of the present application provides a translation model training device, including:

[0016] A corpus acquisition module, configured to acquire multiple types of bilingual parallel corpora, where each type of bilingual parallel corpus includes at least one bilingual sentence pair, and each bilingual sentence pair is two sentences that correspond to each other and belong to two different languages;

[0017] A corpus replacement module, configured to perform the following operations for each bilingual sentence pair in each type of bilingual parallel corpus respectively to obtain the updated multiple types of bilingual parallel corpora: replace some words of the sentence to be translated in a bilingual sentence pair in a type of bilingual parallel corpus with synonyms in the target language, and the languages associated with the sentence to be translated in a bilingual sentence pair are different;

[0018] A model training module, configured to train the first translation model based on the updated multiple types of bilingual parallel corpora until the first translation model meets the first model convergence condition, and obtain the trained first translation model.

[0019] In a possible embodiment, the corpus replacement module is specifically configured to:

[0020] Randomly sample the target language from the first language set, the second language set, and the third language set, where the first language set includes languages that belong to the same language family as the language associated with the sentence to be translated in the bilingual sentence pair, the second language set includes languages that belong to the same language family as the language associated with the sentence to be translated in the bilingual sentence pair, and the third language set includes languages in the languages associated with the multiple types of bilingual parallel corpora other than the language associated with the sentence to be translated in the bilingual sentence pair;

[0021] Replace some words of the sentence to be translated in a bilingual sentence pair in a class of bilingual parallel corpora with synonyms corresponding to the target language.

[0022] In a possible embodiment, the corpus replacement module is specifically configured to:

[0023] Randomly sample the target language from the first language set, the second language set, and the third language set respectively according to the sampling probabilities corresponding to the first language set, the second language set, and the third language set, where the sampling probability corresponding to the first language set is greater than the sampling probability corresponding to the second language set, and the sampling probability corresponding to the second language set is greater than the sampling probability corresponding to the third language set.

[0024] In a possible embodiment, the model training module is specifically configured to:

[0025] Based on the updated multi-class bilingual parallel corpus, perform multiple iterative trainings on the first translation model, where each iterative training process includes the following operations:

[0026] For each updated bilingual sentence pair in the updated multi-class bilingual parallel corpus, perform the following operations respectively:

[0027] Convert the two sentences in an updated bilingual sentence pair into a first vector and a second vector respectively;

[0028] Input the first vector into the first translation model to obtain a third vector;

[0029] Determine a loss value based on the third vector and the second vector;

[0030] Adjust the parameters of the first translation model based on the obtained loss value.

[0031] In a possible embodiment, the model training module is specifically configured to:

[0032] Obtain the first language identifier associated with the sentence to be translated in the updated bilingual sentence pair, and the second language identifier associated with the sample translation sentence in the updated bilingual sentence pair;

[0033] Input the first language identifier, the second language identifier, and the first vector into the first translation model to obtain a third vector, where the third vector is used to obtain the translation result corresponding to the second language identifier.

[0034] On the one hand, an embodiment of the present application provides a translation model training device, including:

[0035] A corpus selection module, configured to select target bilingual parallel corpus from multiple types of bilingual parallel corpora;

[0036] A model training module, which uses the target bilingual parallel corpus to retrain the trained first translation model obtained by the translation model training method described above until the trained first translation model meets the second model convergence condition, and obtains a trained second translation model.

[0037] On the one hand, an embodiment of the present application provides a translation device, including:

[0038] A translation response module, configured to respond to a translation request operation for a target text;

[0039] A translation obtaining module, configured to obtain a translation result through the trained first translation model, where the trained first translation model is obtained by any translation model training method.

[0040] In a possible embodiment, the translation response module is further configured to respond to a selection operation for the target text;

[0041] The translation obtaining module is specifically configured to detect a language identifier corresponding to the target text and display multiple languages;

[0042] The translation response module is specifically configured to obtain a language identifier corresponding to a selected specified language in response to a language selection operation for the multiple languages;

[0043] The translation obtaining module is specifically configured to input the language identifier corresponding to the target text, the language identifier corresponding to the specified language, and the target text into the trained first translation model to obtain a translation result in the specified language.

[0044] An embodiment of the present application provides a computer device, including:

[0045] At least one processor, and

[0046] A memory communicatively connected to the at least one processor;

[0047] Wherein, the memory stores instructions executable by the at least one processor, and the at least one processor realizes the translation model training method, translation model training method or translation method described above by executing the instructions stored in the memory.

[0048] An embodiment of the present application provides a computer storage medium storing computer instructions, which, when running on a computer, cause the computer to execute the translation model training method, the translation model training method, or the translation method as described above.

[0049] Since the embodiment of the present application adopts the above technical solution, it has at least the following technical effects:

[0050] In the embodiment of the present application, some words in the sentence to be translated are replaced with the target language to update multiple types of bilingual parallel languages. This is equivalent to introducing some words in other languages into the sentence to be translated. When training the first translation model based on the sentence to be translated, the first translation model can simultaneously learn the relationships between multiple languages, narrow the distance between different languages, improve the overall training effect of the first translation model, enhance the translation ability of the first translation model for each language, and thus improve the accuracy of the output of the first translation model. Moreover, since some words in the target language can be used to replace the bilingual parallel languages, rare languages can be used for replacement, thereby constructing more parallel corpora related to rare languages and enhancing the translation ability of the first translation model for rare languages. Also, during training, there is no need to train models for each language separately, reducing the training cost of the model. And, the first translation model in the embodiment of the present application can be used to translate multiple languages. Therefore, during actual translation, only one model needs to be deployed, thus reducing the resource cost during actual translation. Description of the Drawings

[0051] Figure 1A It is the first application scenario diagram of a translation model training method provided by an embodiment of the present application;

[0052] Figure 1B It is the application scenario of a translation model training method provided by an embodiment of the present application Figure 2 ;

[0053] Figure 1C is Figure 1B the structural schematic diagram of each device in

[0054] Figure 2 It is the flowchart of a translation model method provided by an embodiment of the present application;

[0055] Figure 3 It is the process example diagram of the first translation model outputting a translation result provided by an embodiment of the present application;

[0056] Figure 4 It is the structural schematic diagram of the transformer model provided by an embodiment of the present application;

[0057] Figure 5Flowchart of a translation model training method provided by an embodiment of the present application;

[0058] Figure 6 Flowchart of a translation training method provided by an embodiment of the present application;

[0059] Figure 7 Process example diagram of a translation target text provided by an embodiment of the present application;

[0060] Figure 8 Provided by an embodiment of the present application Figure 1A Interaction schematic diagram between the terminal and the second server in

[0061] Figure 9 Structural schematic diagram of a translation model training device provided by an embodiment of the present application;

[0062] Figure 10 Structural schematic diagram of a translation model training device provided by an embodiment of the present application;

[0063] Figure 11 Structural schematic diagram of a translation device provided by an embodiment of the present application;

[0064] Figure 12 First structural schematic diagram of a computer device provided by an embodiment of the present application;

[0065] Figure 13 Structural schematic of a computer device provided by an embodiment of the present application Figure 2 ;

[0066] Figure 14 Structural schematic of a computer device provided by an embodiment of the present application Figure 3 。 Detailed implementation manners

[0067] To better understand the technical solutions provided by the embodiments of the present application, the following will be described in detail in conjunction with the accompanying drawings of the specification and specific implementation manners.

[0068] To facilitate better understanding of the technical solutions of the present application by those skilled in the art, the terms involved in the present application are introduced below.

[0069] 1. Artificial Intelligence (AI): It is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence also studies the design principles and implementation methods of various intelligent machines, enabling machines to have the functions of perception, reasoning, and decision-making.

[0070] Artificial intelligence technology is an interdisciplinary subject with a wide range of fields involved, including both hardware-level and software-level technologies. Artificial intelligence basic technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, and mechatronics. Artificial intelligence software technologies mainly include several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0071] 2. Natural Language Processing (NLP): It is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between humans and computers in natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, the research in this field will involve natural language, that is, the language people use in daily life, so it has a close connection with the research of linguistics. Natural language processing technologies usually include technologies such as text processing, semantic understanding, machine translation, robot question answering, and knowledge graphs.

[0072] 3. Bilingual parallel corpus: A corpus in which source language texts and their translated texts are in contrast. A database composed of bilingual parallel corpora can also be called a Bilingual Parallel Corpus. Bilingual parallel corpora can be divided into various types according to the languages of the source language texts or the translated texts. There is at least one different language between any two types of bilingual parallel corpora. For example, the languages corresponding to the source language texts are different, the languages corresponding to the translated texts of the source language texts are different, or the languages corresponding to the source language texts are different and the languages corresponding to the translated texts of the source language texts are also different. The languages corresponding to the source language texts and the translated texts in a type of bilingual parallel corpus are the two languages associated with the bilingual parallel languages of this type.

[0073] 4. Bilingual sentence pairs: A bilingual sentence pair refers to two sentences in two languages that contrast with each other. The bilingual parallel corpus in the embodiments of this application includes at least one bilingual sentence pair. For example, a bilingual sentence pair is: it's a nice day today: The weather is nice today.

[0074] 5. Untranslated Sentences and Translated Sentences: When training a model, bilingual sentence pairs can be divided into untranslated sentences and translated sentences. Untranslated sentences are the sentences in a bilingual sentence pair that are used as input into the model. Based on this input, the model outputs the model's predicted translation result. Translated sentences are the actual translation results corresponding to the untranslated sentences. If the source language text in the bilingual parallel corpus can be used as the untranslated sentence, then the corresponding translated text of the source language text can be used as the translated sentence. If the translated text of the source language text in the bilingual parallel corpus can be used as the untranslated sentence, then the source language text can be used as the translated sentence.

[0075] 6. Language families and language families: Language family classification refers to the method of classifying languages based on their evolutionary relationships. Languages with the same ancestors are grouped together, similar to biological classification. Classification is based on the corresponding features and evolutionary patterns of the phonetics, vocabulary, and grammar of each language. In the Languages of the World (Ethnologue), languages are divided into multiple language families. The next level of classification within a language family is called a language family, or language family. The next level of classification within a language family is called a language branch, and under a language branch are specific languages. For example, language families include the European language family, which includes the Celtic language family and the Germanic language family. The Germanic language family includes the West Germanic branch and the North Germanic branch. The West Germanic branch includes English, German, and Dutch, among others.

[0076] 7. First Translation Model and Second Translation Model: Both are translation models. The first translation model can be used for translation between two or more languages, for example, Chinese-English translation and Chinese-German translation. The second translation model can be used for translation from one language to another, for example, Chinese-English translation, or translation between two languages.

[0077] 8. MUSE: MUSE is an open-source multilingual bilingual word list and word embedding library from Facebook AI Labs. It primarily trains word embeddings using separate data from each language and then extracts bilingual words by aligning the vector space using Arabic numerals. This is one of the most effective unsupervised alignment methods in the industry. MUSE offers open-source bilingual dictionaries from over 100 languages to English.

[0078] 9. Zero-shot: It refers to the situation where the model has never learned about the task to be processed before. For example, for a translation model, when it needs to translate text in a certain language currently, and the training corpus used for training the model does not include this language. If the translation model can accurately translate this text, it indicates that the model has good zero-shot performance.

[0079] 10. Language identifier: It is used to uniquely represent the corresponding language. There can be various specific representation methods for language identifiers. For example, it can be represented by numbers or strings, etc. For example, English is represented by "0", and Chinese is represented by "1", etc.

[0080] 11. Transformer model: A type of translation model. This model includes an encoder and a decoder. The encoder includes 6 encoding units, and the decoder includes 6 decoding units. The encoder is used to perform deep encoding on the input, and the decoder decodes the output of the encoder to obtain the final output of the model.

[0081] The following introduces the related technologies:

[0082] The following separately introduces the processes of training one-to-one translation models and multi-language translation models involved in the related technologies:

[0083] I. Process of training one-to-one translation models:

[0084] Generally, a one-to-one neural machine translation model optimizes the translation effect of the translation model by optimizing the model structure, adjusting parameters, and collecting more bilingual data. During training, generally, the words in the bilingual data are replaced with computable digital vectors. For example, "I love you" is represented as "(1, 2, 3)". The replaced digital vectors are sent into the translation model, and the translation result is obtained through the processing of the translation model. According to the error between the translation result and the corresponding translation in the bilingual data, the parameters of the translation model are adjusted until the translation model converges, so as to obtain a translation model for translating this type of language.

[0085] In this method, a separate translation model needs to be trained for each language for translation, which makes the computing power and time cost required for training very large. When using the translation model, multiple translation models also need to be separately deployed for each language, and the involved deployment process is rather troublesome and complex. When training a single translation model, the bilingual data corresponding to other languages cannot be fully utilized. Moreover, since a single translation model is trained using a single type of bilingual data, the actually trained translation model is prone to overfitting, resulting in poor accuracy of the translation results output when using the translation model for translation.

[0086] II. Process of training multi-language translation models:

[0087] When training a multilingual translation model, bilingual data in multiple languages can be used to train the translation model. However, the data volumes of the bilingual data in different languages are different, resulting in a better translation effect of the trained translation model for languages with a larger data volume, while the accuracy of the translation results output for languages with a smaller bilingual data volume is poor.

[0088] In view of this, an embodiment of the present application provides a translation model training method. In this method, some words in the bilingual parallel corpus are replaced with synonyms in different languages, so as to place words in different languages in the same context environment, narrowing the semantic space between different languages, enabling the first translation model to simultaneously learn the semantics between two or more languages, and improving the output accuracy of the first translation model.

[0089] Based on the above design concept, the application scenarios of the translation model training method in the embodiments of the present application are introduced below.

[0090] The first translation model trained in the embodiments of the present application can be applied to any translation scenario. The first translation model can be deployed on various application programs or the corresponding background servers of various application programs to implement the corresponding translation functions. For example, the first translation model is used to real-time translate social information in various languages posted by users on social application programs, or the first translation model is used to real-time translate content in various languages posted by users on content service application programs. The first translation model can also be deployed on various terminals to provide services in different languages for users, etc. The terminals are, for example, intelligent robots, smart TVs, smart speakers or in-vehicle terminals, etc., and the present application does not limit this.

[0091] Please refer to Figure 1A , which is Application Scenario Diagram 1 of a translation model training method provided by an embodiment of the present application. The application scenario includes a terminal 110, an application program 111 running in the terminal 110, a first server 120, and a database 130.

[0092] The database 130 can be deployed in the first server 120 or on other devices independently set up with the first server 120. The database 130 can store multiple types of bilingual parallel corpora. These multiple types of bilingual parallel corpora can be obtained by the first server 120 from network resources and written into the database 130. Subsequently, the first server 120 can obtain the multiple types of bilingual parallel corpora from the database 130 and train the first translation model according to the multiple types of bilingual parallel corpora to obtain the trained first translation model. The specific process of training the first translation model can be discussed below.

[0093] Users can use corresponding functions through the application 111 in the terminal 110. The application 111 can be, for example, pre-installed in the terminal 110, embedded in a third-party application, or run as a web page in a browser, etc. This application does not limit this. Figure 1A The first server 120 can be used to support the functions corresponding to the application 111. For example, when a user needs to translate a certain sentence, the first server 120 can call the trained first translation model to obtain the translation result of the sentence and feedback the translation result to the terminal.

[0094] Among them, the first server and the terminal can be connected through a communication network, such as the Internet or a local area network, etc. This application does not limit this.

[0095] Please refer to Figure 1B , for an application scenario of a translation model training method provided by an embodiment of this application Figure 2 , this application scenario includes a terminal 110, an application 111 running in the terminal 110, a first server 120, a database 130, and a second server 140.

[0096] Similarly, the first server 120 can obtain the trained first translation model, and the first server 120 sends the trained first translation model to the second server 140.

[0097] Different from Figure 1A is that in the Figure 1B shown embodiment, the second server 140 is used to support the corresponding functions of the application 111. Therefore, when actually applying the first translation model, the second server 140 can call the trained first translation model to obtain the corresponding translation result.

[0098] In another possible implementation scenario, after training the first translation model, the first server 120 can directly send the trained first translation model to the terminal 110, and the terminal 110 directly obtains the translation result according to the trained first translation model.

[0099] Among them, the second server and the terminal can be connected through a communication network, such as the Internet or a local area network, etc. This application does not limit this. The second server and the first server can also be connected through a communication network, such as the Internet or a local area network, etc. This application does not limit this.

[0100] Either the first server or the second server described above can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms.

[0101] The terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a gaming device, a smart TV, a smart sound system, a smart bracelet, etc., but is not limited thereto.

[0102] To further illustrate Figure 1B the structures of the various devices, the following will be described in conjunction with Figure 1C the structural schematic diagrams of the various devices shown:

[0103] Please refer to Figure 1C , the second server 140 includes a translation request distribution module 143, a language detection module 144, and a translation model invocation module 145. The three modules of the translation request distribution module 143, the language detection module 144, and the translation model invocation module 145 can be deployed on the same process, or the three modules can be respectively deployed on different processes, or two of the three modules can be deployed on the same process. This application does not limit this. In Figure 1C it takes the translation request distribution module 143 and the language detection module 144 as an example to be deployed on the first process 141, and the translation model invocation module 145 is deployed on the second process 142.

[0104] When the user needs to perform a translation, the terminal 110 determines the target text that needs to be translated currently according to the translation request operation performed by the user on the target text, such as long-pressing the target text or entering the target text in the application 111, etc., and sends the target text to the translation request distribution module 143.

[0105] The translation request distribution module 143 can first feedback the target text to the language detection module 144. The language detection module 144 detects the language of the target text. Then, the translation request distribution module 143 generates a translation request according to the language of the target text and the target text. The translation request can carry the language of the target text and the target text, and can also carry the specified language specified by the user for translation. Then, the translation request is sent to the translation model invocation module 145. After receiving the translation request, the translation model invocation module 145 can invoke the first translation model to obtain the translation result of the target text, and then feedback the translation result to the terminal 110.

[0106] Based on the above Figure 1A or Figure 1B For the application scenarios shown above, taking the first server to execute the translation model training method as an example, the translation model training method of the embodiments of the present application will be introduced below. Please refer to Figure 2 , which is a flowchart of a translation model method provided by the embodiments of the present application. The specific process of this method includes:

[0107] S21, Obtain multiple types of bilingual parallel corpora.

[0108] The meaning of bilingual parallel corpora can be referred to the content discussed above and will not be elaborated here. It should be noted that the bilingual parallel corpora in the embodiments of the present application include at least one bilingual sentence pair. The specific meaning of bilingual sentence pairs can be referred to the content discussed above and will not be elaborated here. The first server can directly obtain multiple types of bilingual parallel corpora from the database, or the first server can obtain them from network resources. For example, the first server can obtain multiple types of bilingual parallel corpora from an open-source bilingual dictionary. Specifically, for example, the first server obtains multiple types of bilingual parallel corpora from the bilingual dictionary provided by muse.

[0109] As an embodiment, the bilingual sentence pair can also be associated with a language identification for each sentence. The meaning of the language identification can be referred to the content discussed above and will not be elaborated here.

[0110] To more clearly illustrate multiple types of bilingual parallel corpora, the bilingual parallel corpora shown in Table 1 will be used for example introduction below.

[0111] Table 1

[0112]

[0113] Please refer to Table 1 above. "EN", "FR", and "ZH" respectively represent the language identifications corresponding to English, French, and Chinese. For example, the source language text is the Chinese "The food tastes good", and the translated text of this source language text corresponding to English is "The food tastes good".

[0114] S22, For each bilingual sentence pair in each type of bilingual parallel corpus, perform the following operations respectively to obtain the updated multiple types of bilingual parallel corpora: Replace some words of the sentence to be translated in a bilingual sentence pair in one type of bilingual parallel corpus with synonyms in the target language.

[0115] After obtaining multiple types of bilingual parallel corpora, the first server can replace some words in the source sentence of each bilingual sentence pair in each type of bilingual parallel corpus. For example, it can use synonyms in the target language corresponding to a language different from the source sentence associated with the bilingual sentence pair for replacement. In this way, it is equivalent to introducing a new language into a source sentence, enabling the subsequent first translation model to learn the relationships between more languages. By analogy, after replacing the source sentences of each bilingual sentence pair in each type of bilingual parallel corpus, updated multiple types of bilingual parallel corpora can be obtained.

[0116] S23. Based on the updated multiple types of bilingual parallel corpora, train the first translation model until the first translation model meets the first model convergence condition, and obtain the trained first translation model.

[0117] After the first server obtains the updated multiple types of bilingual parallel corpora, it can input the source sentences in the updated bilingual sentence pairs into the first translation model to obtain the translation results of the first translation model. Then, according to the translation results and the true translation sentences in the updated bilingual sentence pairs, calculate the loss value, and adjust the parameters of the first translation model according to the loss value until the first model convergence condition is met, so as to obtain the trained first translation model. The first model convergence condition can be set by the first server. For example, it can be that the loss value reaches the first preset value, or the number of iterative training times for training the first translation model meets the first preset number, etc. This application does not limit this. Subsequently, the trained first translation model can be used to perform mutual translation between texts in multiple languages.

[0118] In the embodiments of this application, when training the first translation model, since some words in the source sentence of the bilingual sentence pair in each type of bilingual parallel corpus are replaced with synonyms in the target language, it is equivalent to being able to introduce some words in other languages into the source sentence. In this way, the first translation model can learn the relationships between multiple languages simultaneously, enhance the connections between distant languages, and improve the learning ability of the first translation model. Moreover, this method is conducive to introducing words in more rare languages and improving the translation ability of the first translation model for rare languages. Moreover, since the first translation model can learn the connections between more languages, the zero-shot performance of the first translation model can be improved.

[0119] When actually training the first translation model, the replacement is performed separately for the source sentences of each bilingual sentence in each type of bilingual parallel corpus. Here, taking the replacement of some words in a source sentence as an example, an example is given for illustration. When replacing the source sentence, it is necessary to determine the target language for replacing the source sentence. Here, an example is given to illustrate how to determine the target language for replacing some words in the source sentence of the bilingual sentence pair.

[0120] Determination method 1:

[0121] The first server randomly samples a target language from each language set.

[0122] Each language set includes a first language set, a second language set, and a third language set. The number of languages included in each language set can be none, one, or more than one, and the present application does not limit this. The first language set includes languages that belong to the same language family as the language associated with the sentence to be translated in a bilingual sentence pair. The second language set includes languages that belong to the same language family as the language associated with the sentence to be translated in a bilingual sentence pair. The third language set includes languages among the languages associated with the multiple types of bilingual parallel corpora except for the language associated with the sentence to be translated in a bilingual sentence pair. The meanings of the same language family and the same language family can refer to the content discussed above and will not be elaborated here.

[0123] In the embodiments of the present application, both the first language set and the second language set are languages that have a certain association with the language of the sentence to be translated that is currently being replaced. Therefore, any language in the first language set and the second language set is used to replace the sentence to be translated. In this way, while introducing the characteristics of the third language, some characteristics of the replaced word can be indirectly retained to strengthen the relationship between the replaced word and the replacement word, and improve the accuracy of the first translation model. Moreover, in the embodiments of the present application, in addition to introducing the first language set and the second language set, the third language set is also introduced, making the replacement process have a certain degree of randomness, thereby increasing the processing ability of the first translation model for random situations and improving the generalization ability of the first translation model.

[0124] Furthermore, when randomly selecting a target language from each language set, the sampling probability of each language set can be set.

[0125] Specifically, the sampling probability of the first language set can be set to be larger than the sampling probability of the second language set, and the sampling probability of the second language set can be set to be larger than the sampling probability of the third language set. In this way, the possibility that the randomly selected target language belongs to the first language set and the second language set is greater, which is more conducive to determining a language that is more relevant to the language of the sentence to be translated. For example, the sampling probabilities corresponding to the first language set, the second language set, and the third language set are respectively set to 0.6, 0.3, and 0.1.

[0126] In the embodiments of the present application, the sampling probability of the first language set can be set to be larger than the sampling probability of the second language set, and the sampling probability of the second language set can be set to be larger than the sampling probability of the third language set, which is more conducive to determining a language that is more relevant to the language associated with the sentence to be translated, and can relatively improve the training effect of the first translation model.

[0127] Determination method 2:

[0128] The first server may randomly select a target language from the languages associated with the multiple types of bilingual parallel corpora, excluding the two languages associated with one type of bilingual parallel corpora.

[0129] In an embodiment of the present application, the first server can directly randomly select a target language from multiple languages without having to determine multiple language sets in advance, which improves the randomness of the determined target language and can simplify the processing of the first server.

[0130] As an embodiment, regardless of the method used to randomly sample the target languages, the first server can determine the number of target languages. The number of target languages can be one or more, and this application does not limit this. The first server can then randomly sample the corresponding number of target languages through any of the above methods.

[0131] Furthermore, in order to expand the updated bilingual parallel data used for training as much as possible, in an embodiment of the present application, the first server can replace some words in the sentence to be translated with different numbers of target languages, so that one sentence to be translated can correspond to multiple updated sentences to be translated, thereby achieving the purpose of expanding the bilingual corpus.

[0132] For example, if the sentence to be translated is specifically "I like singing and dancing", when the first server determines that one target language is specifically Chinese, the replacement result corresponding to the sentence to be translated is "I like singing and dancing". If the first server determines that two target languages are specifically Chinese and French, the replacement result corresponding to the sentence to be translated is "I like chanter and dancing".

[0133] In the embodiment of the present application, replacing some words in the translation sentence with different numbers of target languages can not only quickly expand the bilingual parallel corpus, but also simultaneously put more languages into the same sentence, which is conducive to enhancing the expression between various languages.

[0134] When replacing some words in a translation sentence, in addition to determining the target language, you also need to determine which words in the sentence to be translated should be replaced. The following example describes how to determine the words to be replaced in the sentence to be translated:

[0135] Example 1: Randomly sample a fixed proportion of words from the sentence to be translated as the replaced words.

[0136] The first server may pre-store a fixed ratio, which refers to the ratio between the number of selected words to be replaced and the total number of words in the sentence to be translated. The first server may randomly select words that meet the fixed ratio from the sentence to be translated as the words to be replaced.

[0137] In the embodiments of the present application, different numbers of words to be replaced can be screened out from different sentences to be translated, so as to replace as many words as possible and improve the training effect of the first translation model.

[0138] Furthermore, since the semantics expressed by nouns and verbs in a sentence are generally more valuable, in the embodiments of the present application, the first server may set the sampling probabilities corresponding to nouns and verbs in the sentence to be translated to be greater than those of words of other natures. For example, the first server sets the sampling probabilities of nouns, verbs, and interrogative words in the sentence to be translated to be 0.4, 0.4, and 0.1 respectively, so as to replace words with important semantics as much as possible.

[0139] Example 2: Randomly sample a fixed number of words from the sentence to be translated as the words to be replaced.

[0140] The first server may pre-store a fixed number, and the value of the fixed number can be set according to actual needs. The value of the fixed number is less than the total number of words included in the sentence to be translated. When the first server needs to replace words in the sentence to be translated, it can randomly sample a fixed number of words from the sentence to be translated as the words to be replaced.

[0141] Similarly, in the embodiments of the present application, the first server may set the sampling probabilities corresponding to nouns and verbs in the sentence to be translated to be greater than those of words of other natures.

[0142] After the first server determines the target language and the words to be replaced in the sentence to be translated, it can determine the synonyms corresponding to the words to be replaced in the target language, and replace the words to be replaced with the determined synonyms, so as to obtain an updated sentence. The updated sentence and the translation sentence in the bilingual sentence pair form an updated bilingual sentence pair. When obtaining the updated bilingual sentence pairs under each type of bilingual parallel corpus, the updated multiple types of bilingual parallel corpus are correspondingly obtained.

[0143] After obtaining the updated multiple types of bilingual parallel corpus, the first server may execute S32. The specific manner of executing S32 will be described below.

[0144] When training the first translation model, multiple iterative trainings can be performed on the first translation model based on the updated multiple types of bilingual parallel corpus. The process of each iterative training is the same. The process of one iterative training will be introduced below:

[0145] One iteration of training can use one or more updated bilingual sentence pairs as training samples for the first translation model. The following takes the training of the first translation model with one updated bilingual sentence as an example for introduction:

[0146] The first server converts the sentence to be translated in an updated bilingual sentence pair into a first vector, and converts the translated sentence in the updated bilingual sentence pair into a second vector. For example, the first server can use one-hot encoding to encode each word in the sentence separately to obtain the corresponding vector. The first vector is input into the first translation model. The parameters of the first translation model are the adjusted parameters after the previous iteration of training, or if this is the first iteration of training, the parameters of the first translation model are the initial parameters. The first translation model encodes and decodes the first vector, thereby outputting a third vector. Furthermore, according to the third vector, a predicted translation result in the corresponding language can be obtained. The third vector output by the first translation model actually corresponds to the translation result. The first translation model can be configured to convert the third vector to obtain the translation result, or the first server can directly convert the third vector to obtain the translation result. The first server calculates the loss value of this training based on the third vector and the second vector, and thereby adjusts the parameters of the first translation model.

[0147] To ensure the accuracy of the first translation model, in addition to using the updated multi-class bilingual parallel languages to train the first translation model, the unupdated multi-class bilingual parallel languages can also be used together to train the first translation model to achieve a better training effect.

[0148] The first translation model involved in the embodiments of the present application can adopt a network model with any structure, and the present application does not limit this. The first translation model can include an encoder and a decoder. The encoder is used to deeply encode the first vector, and the decoder is used to decode the output of the encoder to obtain the third vector.

[0149] For example, please refer to Figure 3, is an example diagram of the process of the first translation model outputting the translation result provided in an embodiment of the present application. The first translation model includes an encoder and a decoder. Taking the sentence to be translated in a bilingual parallel language as "I like singing and dancing" as an example, the first server replaces "singing" and "dancing" with Japanese respectively, that is, obtaining "I like 歌うandダンス". The first server can also replace "singing" with Japanese and "dancing" with Chinese to obtain "I like 歌うand 舞舞". The first server can then convert the updated sentence to be translated into a first vector and input it into the first translation model to obtain the French translation result output by the first translation model, specifically "J'adore chanter et danser <eos>”。 Figure 3 The statement after replacing "1lang" in it with a target language, and the statement after replacing "2lang" with two target languages.

[0150] Taking the first translation model using the Transformer model as an example, the training process will be introduced by way of example.

[0151] The Transformer model includes an encoder and a decoder. The encoder includes a plurality of encoding units connected in sequence, and the decoder includes a plurality of decoding units connected in sequence. The final output of the encoder is input to each decoding unit.

[0152] Please refer to Figure 4 , which is the structural schematic diagram of the Transformer model. Figure 4 In it, Nx represents the number of encoding units or decoding units, and the value of Nx is, for example, 6. The structures of one encoding unit and one decoding unit will be introduced below:

[0153] Each encoding unit mainly includes two layers, which are the multi-head attention layer (multi-head self-attention mechanism) and the feed-forward layer respectively. The encoding unit also includes an Add&Norm layer, and this Add&Norm layer specifically includes a residual connection layer and a layer normalization layer. The residual connection layer combines the output of the self-attention layer with the input of the multi-head attention layer to generate the encoder multi-head attention residual output, and the layer normalization layer applies layer normalization to the self-attention residual output.

[0154] As an embodiment, before inputting the first vector into the encoding unit, the encoding unit can perform positional embedding on the first vector, such as sine positional embedding. The use of sine positional embedding can allow the Transformer model to process longer vectors, which can increase the application scope of the Transformer model.

[0155] As an embodiment, the decoding unit includes a multi-head attention layer, a feed-forward layer, an Add&Norm layer, a linearization layer, a normalization layer, a self-attention layer, etc. The decoding unit performs decoding output according to the output of the previous decoding unit obtained and the final output of the encoder.

[0156] Continue to refer to Figure 4 , the decoding unit is used to receive the first output of the previous decoding unit, and successively passes through the self-attention layer and the Add&Norm layer to obtain the second output. The second output and the third output of the encoding unit are input into the multi-head sub-attention layer, the Add&Norm layer, the feed-forward layer, the Add&Norm layer, the linearization layer, and the normalization layer in sequence, so as to obtain the output of this decoding unit.

[0157] Similarly, when the decoding unit receives the first output of the previous decoding unit, the decoding unit can perform positional embedding on the first vector, such as sine positional embedding. The way of positional embedding can refer to the content discussed above and will not be elaborated here.

[0158] After the first translation model outputs the third vector, the first server can calculate the loss value based on the third vector and the second vector. There are various ways to represent the loss value. For example, it can be represented by cross entropy. The following gives an example of the calculation formula of cross entropy:

[0159]

[0160] Among them, p(x) represents the second vector, that is, the vector corresponding to the true translation sentence, and q(x) represents the third vector, that is, the vector corresponding to the predicted translation sentence output by the multilingual model.

[0161] After determining the gradient derivative of the loss value to obtain the update direction of the parameters, an optimizer, such as the Adam optimizer, can be used to optimize the parameters to complete one iteration of training until the multilingual model converges to obtain the trained multilingual model.

[0162] When training the first translation model, multiple languages are involved. To facilitate the first translation model to distinguish the language of the sentence to be translated and the language of the translation sentence, in the embodiments of the present application, when inputting the first vector into the first translation model, the first language identifier associated with the sentence to be translated in the updated bilingual sentence pair and the second language identifier associated with the translation sentence in the updated bilingual sentence can be input into the first translation model together. For example, the first server can embed the first language identifier and the second language identifier at fixed positions in the first vector. Specifically, for example, the first language identifier is embedded at the start position of the first vector, and the second language identifier is embedded at the end position of the first vector. The meaning of the language identifier can refer to the content discussed above and will not be elaborated here. After the first server obtains the first language identifier and the second language identifier, it can determine the language of the sentence to be translated and the language to be translated into, so that the first translation model can obtain the third vector corresponding to the second language identifier according to the second language identifier and the third vector.

[0163] Based on the translation model training method discussed above, the embodiments of the present application provide a translation model training method. The following combines Figure 5 The flowchart of a translation model training method shown below to introduce the process of this method taking the first server executing this translation model training method as an example:

[0164] S51, select target bilingual parallel corpora from multiple types of bilingual parallel corpora.

[0165] As discussed above, the first server has obtained multiple categories of bilingual parallel corpora and can select one of these categories as a target bilingual parallel corpus. The first server can determine the target bilingual parallel corpus from the multiple categories based on the bilingual type for which the second translation model needs to be trained.

[0166] S52: retrain the trained first translation model obtained based on the previous text using the target bilingual parallel corpus until the trained first translation model meets the second model convergence condition, thereby obtaining a trained second translation model.

[0167] The first server retrains the trained first translation model discussed above based on the target bilingual parallel corpus until the first translation model meets the second model convergence condition, ultimately obtaining a trained second translation model. The process of retraining the first translation model can refer to the process of training the first translation model described above and will not be repeated here. The second model convergence condition can be, for example, that the number of iterations of the retraining meets a second preset number, or that the loss value during the training process reaches a second preset value.

[0168] exist Figure 5 In the illustrated embodiment, a previously trained first translation model can be fine-tuned to obtain a second translation model for translating a specific language. Because the second translation model has been trained on corpora corresponding to various languages, it generalizes better and learns more general grammatical knowledge. After pre-training, the second translation model obtained in the embodiment of the present application performs better in the translation process than directly training a single model with bilingual parallel corpora.

[0169] Based on the translation model training method discussed above, the present application embodiment provides a translation model training method. Figure 6 The flowchart of a translation training method shown in FIG. 1 is used as an example to introduce the process of the method by taking the terminal executing the translation training method as an example:

[0170] S61: Obtain a trained first translation model.

[0171] The terminal may obtain the trained first translation model from the first server. The process of the first server training the first translation model may refer to the content discussed above and will not be repeated here.

[0172] As an example, the terminal can deploy the first translation model in a separate process. When translation is needed, the terminal can directly call this process to obtain the corresponding translation result.

[0173] S62. In response to a translation request operation for the target text, obtain a translation result through the trained first translation model.

[0174] In specific implementation, the terminal can determine the need to translate the target text according to the user's translation request operation on the target text. The translation request operation is, for example, a translation trigger operation for the target text, specifically, for example, the user performs a long press operation on the target text, and then calls the trained first translation model to obtain a translation result.

[0175] When the user does not select a specified language to be translated into, the terminal can translate the target text into various languages for the user to refer to. The terminal can also translate the target text into the translation result corresponding to the language with the highest usage frequency of the user. The language with the highest usage frequency of the user can be determined according to the user's historical behavior data on the terminal or obtained through user portrait analysis.

[0176] In a possible example of implementation, the terminal can respond to a selection operation on the target text. For example, when the user performs a long press operation on the target text, the terminal detects the language identifier corresponding to the target text. The terminal can determine the language corresponding to the target text according to the characteristics of the target text. For example, the terminal matches the characteristics of the target text with the text characteristics of various pre-stored languages, and determines the language with the highest similarity as the language of the target text. The characteristics of the target text are, for example, the shape or contour of the target text, etc.

[0177] Meanwhile, the terminal can also display multiple languages, which include all the languages that the terminal can translate. The multiple languages displayed here can actually be understood as the language identifiers of multiple languages, for the user to select the language to be translated into. After the terminal displays multiple languages, the user can perform a language selection operation on the multiple languages to obtain the language identifier corresponding to the selected specified language. The terminal inputs the target text corresponding to the language identifier, the language identifier corresponding to the specified language, and the target text into the trained first translation model to obtain the translation result in the specified language.

[0178] For example, please refer to Figure 7 , which is an example diagram of the process of translating a target text. Please refer to Figure 7 In (1), a contact C sends a message to the user, and the terminal displays the message content corresponding to the message "Bonjour, je suis responsablede la société A et je suis venu en France pour y travailler". If the user wants to translate the message content 701, he can long press the message, which is equivalent to selecting the message content 701 as the target text, and then the user can click Figure 7 The translation button 702 shown in (1) is equivalent to performing a translation request operation. The terminal can directly respond to the translation request operation and obtain the Chinese translation result 704 of the target text. Figure 7 As shown in (3), "Hello, I am the person in charge of Company A, and I am here to coordinate the relevant work in France."

[0179] In another case, when the user triggers Figure 7 After pressing the translation button 702 shown in (1), the terminal can display multiple languages 703, as shown in FIG. Figure 7 In Chinese, English, etc. shown in (2), when the user selects one of the multiple languages 703, it is equivalent to selecting the specified language. The terminal detects the language of the target text and the specified language, and calls the trained first translation model to obtain the following: Figure 7 The Chinese translation result shown in (3) is shown in (3).

[0180] exist Figure 6 In the embodiment shown, the trained first translation model can be directly used for translation, which not only can achieve more accurate translation results, but also does not require the deployment of a model for each language, which can relatively reduce the resource overhead required for deploying the model.

[0181] In order to more clearly illustrate the translation method involved in the embodiment of the present application, Figure 8 The example diagram of the interaction between the terminal and the second server in 1A is shown for explanation:

[0182] S801: In response to a selection operation performed on a target text, the terminal detects a language identifier corresponding to the target text and displays multiple languages.

[0183] The contents of the selection operation, multiple languages, and the language identification corresponding to the detection target text can be referred to the contents discussed above and will not be repeated here.

[0184] S802: In response to a language selection operation for multiple languages, the terminal obtains a language identifier corresponding to a selected designated language.

[0185] S803: The terminal generates a translation request.

[0186] The terminal can generate a translation request based on the language identifier of the target text, the language identifier of the specified language, and the target text. This translation request is used to request translating the target text into the text corresponding to the specified language.

[0187] In a possible embodiment, the terminal may not specify the language identifier corresponding to the detected target text, but directly feed the target text and the specified language back to the second server, and the second server detects the language corresponding to the target text.

[0188] S804, the terminal feeds the translation request back to the second server.

[0189] S805, the second server calls the trained first translation model to obtain the translation result.

[0190] In the second server, a first translation model can be deployed in one of its own processes, and when needed, this process can be called.

[0191] As an embodiment, a deployment environment of this first translation model can be referred to as shown in Table 2 below:

[0192] Table 2

[0193] Operating System Memory Language Environment Linux >16G Python / c++

[0194] Please refer to Table 2. The trained first translation model can be deployed in the linux operating system with a memory greater than 16G, and deployed in an environment with a language environment of Python or c++.

[0195] S806, the second server sends the translation result to the terminal.

[0196] S807, the terminal displays the translation result.

[0197] In Figure 8 In the embodiment shown, the terminal and the second server cooperate to complete the translation process, which can relatively simplify the processing volume of the terminal. Moreover, the second server can obtain a more accurate translation result through the first translation model. Moreover, the second server only needs to deploy one first translation model to achieve translation of multiple languages, reducing the overhead required for model deployment.

[0198] Based on the same inventive concept, an embodiment of the present application provides a translation model training device, which can be used to implement the functions of the first server discussed above. Please refer to Figure 9 , this device includes:

[0199] A corpus acquisition module 901: used to acquire multiple types of bilingual parallel corpora, where each type of bilingual parallel corpus includes at least one bilingual sentence pair, and each bilingual sentence pair is two sentences that correspond to each other and belong to two different languages;

[0200] The corpus replacement module 902 is configured to perform the following operations respectively for each bilingual sentence pair in each type of bilingual parallel corpus to obtain updated multi-type bilingual parallel corpus: replace some words of the sentence to be translated in a bilingual sentence pair in a type of bilingual parallel corpus with synonyms in the target language, where the languages associated with the sentence to be translated in a bilingual sentence pair are different;

[0201] The model training module 903 is configured to train the first translation model based on the updated multi-type bilingual parallel corpus until the first translation model meets the first model convergence condition, and obtain the trained first translation model.

[0202] In a possible embodiment, the corpus replacement module 902 is specifically configured to:

[0203] Randomly sample the target language from the first language set, the second language set, and the third language set, where the first language set includes languages belonging to the same language family as the language associated with the sentence to be translated in a bilingual sentence pair, the second language set includes languages belonging to the same language family as the language associated with the sentence to be translated in a bilingual sentence pair, and the third language set includes languages in the languages associated with the multi-type bilingual parallel corpus except the language associated with the sentence to be translated in a bilingual sentence pair;

[0204] Replace some words of the sentence to be translated in a bilingual sentence pair in a type of bilingual parallel corpus with the corresponding synonyms in the target language.

[0205] In a possible embodiment, the corpus replacement module 902 is specifically configured to:

[0206] Randomly sample the target language from the first language set, the second language set, and the third language set respectively according to the respective sampling probabilities corresponding to the first language set, the second language set, and the third language set, where the sampling probability corresponding to the first language set is greater than the sampling probability corresponding to the second language set, and the sampling probability corresponding to the second language set is greater than the sampling probability corresponding to the third language set.

[0207] In a possible embodiment, the model training module 903 is specifically configured to:

[0208] Perform multiple iterative trainings on the first translation model based on the updated multi-type bilingual parallel corpus, where each iterative training process includes the following operations:

[0209] Perform the following operations respectively for each updated bilingual sentence pair in the updated multi-type bilingual parallel corpus:

[0210] Convert the two sentences in an updated bilingual sentence pair into a first vector and a second vector respectively;

[0211] Input the first vector into a first translation model to obtain a third vector;

[0212] Determine a loss value based on the third vector and the second vector;

[0213] Adjust the parameters of the first translation model based on the obtained loss value.

[0214] In a possible embodiment, the model training module 903 is specifically configured to:

[0215] Obtain a first language identifier associated with a sentence to be translated in an updated bilingual sentence pair, and a second language identifier associated with a sample translation sentence in the updated bilingual sentence pair;

[0216] Input the first language identifier, the second language identifier, and the first vector into the first translation model to obtain a third vector, where the third vector is used to obtain a translation result corresponding to the second language identifier.

[0217] It should be noted that Figure 9 The shown device can also be used to implement any of the translation model training methods described above, which will not be elaborated here.

[0218] Based on the same inventive concept, an embodiment of the present application provides a translation model training device, which can implement the functions of the first server described above. Please refer to Figure 10 , and the device includes:

[0219] A corpus selection module 1001, configured to select a target bilingual parallel corpus from multiple types of bilingual parallel corpora;

[0220] A model training module 1002, which uses the target bilingual parallel corpus to retrain the trained first translation model obtained by the translation model training method described above until the trained first translation model meets the second model convergence condition, and obtains a trained second translation model.

[0221] It should be noted that Figure 10 The shown device can also be used to implement any of the translation model training methods described above, which will not be elaborated here.

[0222] Based on the same inventive concept, an embodiment of the present application provides a translation device, which can be implemented by the second server described above. Please refer to Figure 11 , and the device includes:

[0223] A translation response module 1101, configured to respond to a translation request operation for a target text;

[0224] A translation acquisition module 1102, configured to obtain a translation result through a trained first translation model, where the trained first translation model is obtained through any of the translation model training methods described above.

[0225] In a possible embodiment, the translation response module 1101 is further configured to respond to a selected operation performed on the target text;

[0226] The translation acquisition module 1102 is specifically configured to detect a language identifier corresponding to the target text and display multiple languages;

[0227] The translation response module 1101 is specifically configured to obtain a language identifier corresponding to a specified language selected in response to a language selection operation among multiple languages;

[0228] The translation acquisition module 1102 is specifically configured to input the language identifier corresponding to the target text, the language identifier corresponding to the specified language, and the target text into the trained first translation model to obtain a translation result in the specified language.

[0229] It should be noted that Figure 11 The device shown can also be used to implement any of the translation methods described above, which will not be elaborated here.

[0230] Based on the same inventive concept, an embodiment of the present application provides a computer device, which can be used to implement the functions of the first server described above. Please refer to Figure 12 , and the computer device includes a processor 1201 and a memory 1202.

[0231] The processor 1201 may be a central processing unit (CPU) or a digital processing unit, etc. In the embodiment of the present application, the specific connection medium between the memory 1202 and the processor 1201 is not limited. In the embodiment of the present application Figure 12 , the memory 1202 and the processor 1201 are connected through a bus 1203. The bus 1203 is represented by a thick line in Figure 12 . The connection manners between other components are only for illustrative purposes and are not to be construed as limiting. The bus 1203 can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 12 only a thick line is used to represent it in

[0232] The memory 1202 can be a volatile memory, such as a random-access memory (RAM); the memory 1202 can also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD), or the memory 1202 is any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 1202 can be a combination of the above memories.

[0233] The processor 1201, when used to call the computer program stored in the memory 1202, executes any of the translation model training methods discussed above, and can also be used to implement Figure 9 the functions of the device shown.

[0234] Based on the same inventive concept, an embodiment of the present application provides a computer device, which can be used to implement the functions of the first server discussed above. Please refer to Figure 13 This computer device includes a processor 1301 and a memory 1302.

[0235] The specific implementation forms of the processor 1301 and the memory 1302 can refer to the content discussed above and will not be elaborated here. The processor 1301 can be used to execute any of the translation model training methods discussed above when calling the computer program stored in the memory 1302, and can also be used to implement Figure 10 the functions of the device shown.

[0236] Based on the same inventive concept, an embodiment of the present application provides a computer device, which can be used to implement the functions of the second server or the terminal discussed above. Please refer to Figure 14 This computer device includes a processor 1401 and a memory 1402.

[0237] The specific implementation forms of the processor 1401 and the memory 1402 can refer to the content discussed above and will not be elaborated here. The processor 1401 can be used to execute any of the translation methods discussed above when calling the computer program stored in the memory 1402, and can also be used to implement Figure 11 the functions of the device shown.

[0238] Based on the same inventive concept, an embodiment of the present application provides a computer storage medium storing computer instructions, which, when run on a computer, cause the computer to execute any of the foregoing translation model training methods, translation model training methods, or translation methods.

[0239] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0240] Based on the same inventive concept, an embodiment of the present application provides a computer program product, which includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the computer device to execute any of the foregoing translation model training methods, translation model training methods, or translation methods.

[0241] Those of ordinary skill in the art can understand that all or part of the steps of implementing the foregoing method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps including the foregoing method embodiments; and the foregoing storage medium includes: removable storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, etc., which can store program code.

[0242] Alternatively, if the foregoing integrated unit is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the embodiments of the present application. And the foregoing storage medium includes: removable storage devices, ROM, RAM, magnetic disks, or optical disks, etc., which can store program code.

[0243] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalent technologies, this application is also intended to include these modifications and variations.< / eos>

Claims

1. A method for training a translation model, characterized in that, Including: Obtain multiple types of bilingual parallel corpora, where each type of bilingual parallel corpus includes at least one bilingual sentence pair, and each bilingual sentence pair consists of two sentences that correspond to each other and belong to two different languages; For each bilingual sentence pair in each type of bilingual parallel corpus, perform the following operations respectively to obtain the updated multiple types of bilingual parallel corpora: Replace some words of the sentence to be translated in a bilingual sentence pair in a type of bilingual parallel corpus with synonyms in the target language, where the target language is different from the language associated with the sentence to be translated in a bilingual sentence pair, and the target language is randomly sampled from the first language set, the second language set, and the third language set. The first language set includes languages that belong to the same language family as the language associated with the sentence to be translated in a bilingual sentence pair. The second language set includes languages that belong to the same language family as the language associated with the sentence to be translated in a bilingual sentence pair. The third language set includes languages in the languages associated with the multiple types of bilingual parallel corpora except for the language associated with the sentence to be translated in a bilingual sentence pair; Based on the updated multiple types of bilingual parallel corpora, train the first translation model until the first translation model meets the first model convergence condition to obtain the trained first translation model.

2. The method according to claim 1, characterized in that, The randomly sampling the target language from the first language set, the second language set, and the third language set includes: Randomly sample the target language from the first language set, the second language set, and the third language set respectively according to the sampling probabilities corresponding to the first language set, the second language set, and the third language set respectively, where the sampling probability corresponding to the first language set is greater than the sampling probability corresponding to the second language set, and the sampling probability corresponding to the second language set is greater than the sampling probability corresponding to the third language set.

3. The method according to claim 1, characterized in that The training the first translation model based on the updated multiple types of bilingual parallel corpora includes: Based on the updated multiple types of bilingual parallel corpora, perform multiple iterative trainings on the first translation model, where each iterative training process includes the following operations: For each updated bilingual sentence pair in the updated multiple types of bilingual parallel corpora, perform the following operations respectively: Convert the two sentences in an updated bilingual sentence pair into a first vector and a second vector respectively; Input the first vector into the first translation model to obtain a third vector; Determine the loss value based on the third vector and the second vector; Adjust the parameters of the first translation model based on the obtained loss value.

4. The method according to claim 3, wherein The inputting the first vector into the first translation model to obtain the third vector includes: Obtain the first language identifier associated with the sentence to be translated in an updated bilingual sentence pair, and the second language identifier associated with the sample translation sentence in an updated bilingual sentence pair; Input the first language identifier, the second language identifier, and the first vector into a first translation model to obtain a third vector, where the third vector is used to obtain a translation result corresponding to the second language identifier.

5. A method for training a translation model, characterized in that It includes: Select target bilingual parallel corpora from multiple types of bilingual parallel corpora; Use the target bilingual parallel corpora to retrain the trained first translation model obtained by any one of the methods according to claims 1 to 4 until the trained first translation model meets the second model convergence condition, and obtain a trained second translation model.

6. A translation method, characterized in that, It includes: In response to a translation request operation for a target text, obtain a translation result through a trained first translation model, where the trained first translation model is obtained by the method described in any one of claims 1 to 4.

7. The method according to claim 6, wherein The step of obtaining a translation result through a trained first translation model in response to a translation request operation for a target text includes: In response to a selection operation for the target text, detect a language identifier corresponding to the target text and display multiple languages; In response to a language selection operation for one of the multiple languages, obtain a language identifier corresponding to the selected specified language; Input the language identifier corresponding to the target text, the language identifier corresponding to the specified language, and the target text into the trained first translation model to obtain a translation result in the specified language.

8. A translation model training device, characterized in that It includes: A corpus acquisition module: used to acquire multiple types of bilingual parallel corpora, where each type of bilingual parallel corpus includes at least one bilingual sentence pair, and each bilingual sentence pair is two sentences that correspond to each other and belong to two different languages; A corpus replacement module, which is used to perform the following operations respectively for each bilingual sentence pair in each type of bilingual parallel corpus to obtain updated multiple types of bilingual parallel corpora: replace some words of the sentence to be translated in a bilingual sentence pair in a type of bilingual parallel corpus with synonyms in the target language, where the target language is different from both of the two languages associated with the type of bilingual parallel corpus, and the target language is randomly sampled from a first language set, a second language set, and a third language set, where the first language set includes languages that belong to the same language family as the language associated with the sentence to be translated in the bilingual sentence pair, the second language set includes languages that belong to the same language family as the language associated with the sentence to be translated in the bilingual sentence pair, and the third language set includes languages other than the language associated with the sentence to be translated in the bilingual sentence pair among the languages associated with the multiple types of bilingual parallel corpora; A model training module, which is used to train a first translation model based on the updated multiple types of bilingual parallel corpora until the first translation model meets the first model convergence condition, and obtain a trained first translation model.

9. The device according to claim 8, characterized in that, The corpus replacement module is specifically used for: Randomly sample the target language from the first language set, the second language set, and the third language set respectively according to the sampling probabilities corresponding to the first language set, the second language set, and the third language set respectively, where the sampling probability corresponding to the first language set is greater than the sampling probability corresponding to the second language set, and the sampling probability corresponding to the second language set is greater than the sampling probability corresponding to the third language set.

10. A computer storage medium, characterized in that, The computer storage medium stores computer instructions, which when run on a computer cause the computer to execute the method according to any one of claims 1 to 4 or 5 or 6 to 7.

Citation Information

Patent Citations

  • Text translation method and device, electronic equipment and storage medium

    CN111931517A