Machine translation method, device, equipment and storage medium
By introducing text history information into machine translation, especially the keywords of the preceding adjacent sentences, the problem of translation errors in oral simultaneous interpretation scenarios is solved, achieving more accurate and authentic translation results.
Patent Information
- Application Number
- CN202210871989.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-19
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2042-07-19
AI Technical Summary
In specific application scenarios such as simultaneous interpretation, machine translation may have translation errors, which affects the user experience.
By obtaining the historical information of the source language sentence, including the keywords of the previous adjacent sentences, and translating with the help of this information, the machine translation model is used for translation.
It improves the accuracy and authenticity of translation and reduces the problems of mistranslation and literal translation.
Smart Images

Figure CN115238714B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of translation technology, and in particular to a machine translation method, apparatus, device and storage medium. Background Art
[0002] Machine translation, also known as automatic translation, is the process of using computers to convert one natural language (the source language) into another (the target language). With the development of deep learning technology and the continuous improvement of computing power, machine translation technology has rapidly advanced. Neural machine translation technology, represented by Transformer, has significantly improved machine translation performance, even surpassing human performance in general domains. This has also led to an increasing number of machine translation applications and products appearing in people's daily lives.
[0003] In recent years, with the practical application of machine translation technology, machine translation has gradually improved people's work and life efficiency. One application scenario for machine translation is when sentences in the first and second languages appear alternately, and the sentences need to be translated one by one in the order in which they appear, such as in simultaneous oral interpretation. Machine translation for these application scenarios (such as simultaneous oral interpretation) has now reached a level of usability and even ease of use. Related products, such as smart translators, have emerged on the market. People from different countries can communicate freely through translators, greatly improving communication efficiency.
[0004] Although machine translation in the above-mentioned application scenarios (such as simultaneous oral interpretation) has reached a level of usability and even ease of use, translation errors sometimes occur. When translation errors occur, they will greatly affect the user experience. Summary of the Invention
[0005] In view of this, the present invention provides a machine translation method, apparatus, device, and storage medium to solve the problem of translation errors in translation solutions for specific application scenarios (such as simultaneous oral interpretation scenarios). The technical solution is as follows:
[0006] A machine translation method, comprising:
[0007] Obtain the source language sentence to be translated;
[0008] Obtaining passage history information corresponding to the source language sentence, wherein the passage history information includes keywords extracted from a first historical sentence and a second historical sentence, wherein the first historical sentence is a sentence preceding the second historical sentence, the second historical sentence is a preceding adjacent sentence of the source language sentence, and the second historical sentence is a target language sentence;
[0009] The source language sentence is translated with the aid of the passage history information corresponding to the source language sentence to obtain a target language translation corresponding to the source language sentence.
[0010] Optionally, translating the source language sentence with the aid of the historical information of the passage corresponding to the source language sentence to obtain a target language translation corresponding to the source language sentence includes:
[0011] Constructing input data including chapter history information corresponding to the source language sentence and the source language sentence;
[0012] Inputting the input data into a pre-trained machine translation model to obtain a target language translation corresponding to the source language sentence output by the machine translation model;
[0013] When a sentence and the passage history information corresponding to the sentence are input into the machine translation model, the machine translation model has the ability to use the passage history information corresponding to the sentence to assist in translating the sentence.
[0014] Optionally, the training process of the machine translation model includes:
[0015] With the goal of achieving bilingual translation, bilingual training sentence pairs are used to train the constructed translation model to obtain a basic bilingual translation model, wherein the training sentences in the first language and the training sentences in the second language in the bilingual training sentence pairs are each other's standard translations;
[0016] With the goal of enabling the real passage information corresponding to the training sentences to assist in the translation of the training sentences, the basic bilingual translation model is trained, and the trained model is used as the machine translation model.
[0017] Optionally, the basic bilingual translation model is trained with the goal of enabling the real text information corresponding to the training sentences to assist in the translation of the training sentences, including:
[0018] The basic bilingual translation model is trained to obtain a first bilingual translation model with the goal of outputting only translation results of the training sentences when input data including training sentences and pseudo-paragraph history information corresponding to the training sentences is input;
[0019] With the goal of focusing on the input real passage history information when input data including training sentences and real passage history information corresponding to the training sentences is input, the first bilingual translation model is trained to obtain a second bilingual translation model as the machine translation model.
[0020] Optionally, the method of training the constructed translation model with the goal of achieving bilingual translation by using bilingual training sentence pairs to obtain a basic bilingual translation model includes:
[0021] Inputting one of the bilingual training sentence pairs into a translation model to obtain a translation result output by the translation model;
[0022] Determining a prediction loss of the translation model based on a translation result output by the translation model and another training sentence in the bilingual training sentence pair;
[0023] The translation model parameters are updated based on the prediction loss of the translation model.
[0024] Optionally, the training of the basic bilingual translation model with the goal of outputting only translation results of the training sentences when input data including training sentences and pseudo-chapter history information corresponding to the training sentences is input includes:
[0025] Randomly extract keywords from the keyword library and randomly extract sentences in a language different from the training sentences from the corpus, and construct pseudo-chapter history information including the extracted keywords and the extracted sentences as the pseudo-chapter history information corresponding to the training sentences;
[0026] Constructing input data including pseudo-chapter history information corresponding to the training sentences and the training sentences, and inputting the constructed input data into the basic bilingual translation model to obtain a translation result output by the basic bilingual translation model;
[0027] Determining the prediction loss of the basic bilingual translation model according to the translation result output by the basic bilingual translation model and the standard translation of the input training sentence;
[0028] Parameters of the basic bilingual translation model are updated according to the prediction loss of the basic bilingual translation model.
[0029] Optionally, the training of the first bilingual translation model with the goal of focusing on the input real passage history information when inputting input data including training sentences and real passage history information corresponding to the training sentences comprises:
[0030] Constructing input data including real passage history information corresponding to training sentences and training sentences, and inputting the constructed input data into the first bilingual translation model to obtain a translation result output by the first bilingual translation model;
[0031] Determining a prediction loss of the first bilingual translation model based on a translation result output by the first bilingual translation model and a standard translation of an input training sentence;
[0032] Determining, based on the translation result output by the first bilingual translation model and the input real passage history information, a value that can represent the attention paid by the first bilingual translation model to the input real passage history information when translating the input training sentence, as a passage history information attention representation value;
[0033] Parameters of the first bilingual translation model are updated according to the prediction loss of the first bilingual translation model and the representation value of the attention situation of the passage history information.
[0034] Optionally, determining, based on the translation result output by the first bilingual translation model and the input real passage history information, a value that can represent the attention paid by the first bilingual translation model to the input real passage history information when translating the input training sentence includes:
[0035] Determining a hit rate of keywords in the input real passage history information for the translation result output by the first bilingual translation model;
[0036] And, determining the probability that the translation result output by the first bilingual translation model is the next sentence of the historical sentence in the input real passage history information.
[0037] Optionally, the training sentences and the historical information of the real passages corresponding to the training sentences are constructed based on the constructed bilingual passage data;
[0038] The process of constructing the bilingual text data includes:
[0039] Constructing text data of one of the first language and the second language as the first text data;
[0040] translating the constructed chapter data into chapter data in the other of the first language and the second language as second chapter data;
[0041] Bilingual passage data in which sentences in a first language and sentences in a second language appear alternately is constructed based on the first passage data and the second passage data.
[0042] Optionally, constructing bilingual passage data in which sentences in the first language and sentences in the second language appear alternately based on the first passage data and the second passage data includes:
[0043] Replace the even-numbered sentences in the first chapter data with the corresponding sentences in the second chapter data;
[0044] Alternatively, the odd-numbered sentences in the first chapter data are replaced with corresponding sentences in the second chapter data;
[0045] Alternatively, the sentences ranked as even numbers in the second chapter data are replaced with the corresponding sentences in the first chapter data;
[0046] Alternatively, sentences in the second chapter data that are sorted as odd numbers are replaced with corresponding sentences in the first chapter data.
[0047] A machine translation device, comprising: a module for acquiring sentences to be translated, a module for acquiring historical information of a text, and a translation module;
[0048] The to-be-translated sentence acquisition module is used to acquire the source language sentence to be translated;
[0049] The chapter history information acquisition module is used to acquire chapter history information corresponding to a source language sentence, wherein the chapter history information includes keywords extracted from a first history sentence and a second history sentence, wherein the first history sentence is a sentence preceding the second history sentence, the second history sentence is a previous adjacent sentence of the source language sentence, and the second history sentence is a target language sentence;
[0050] The translation module is configured to translate the source language sentence with the aid of the passage history information corresponding to the source language sentence to obtain a target language translation corresponding to the source language sentence.
[0051] A machine translation device, comprising: a memory and a processor;
[0052] The memory is used to store programs;
[0053] The processor is configured to execute the program to implement each step of any one of the above-mentioned translation methods.
[0054] A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, each step of any one of the above-mentioned translation methods is implemented.
[0055] The machine translation method, apparatus, device, and storage medium provided by the present invention can, after obtaining a source language sentence to be translated, obtain the chapter history information corresponding to the source language sentence, and then, using the chapter history information corresponding to the source language sentence, translate the source language sentence to obtain a target language translation corresponding to the source language sentence. To achieve better translation results, the present invention introduces chapter history information, namely the cross-language chapter information mentioned above. When translating the chapter history information corresponding to the source language sentence, the cross-language chapter information mentioned above is used to assist. Translating the source language sentence to be translated using the cross-language chapter information above the source language sentence can produce a more authentic and accurate translation. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0057] Figure 1 A schematic diagram of a flow chart of a machine translation method provided by an embodiment of the present invention;
[0058] Figure 2 A schematic diagram of a process for implementing translation based on a machine translation model provided by an embodiment of the present invention;
[0059] Figure 3 A schematic diagram of a translation framework based on a machine translation model provided by an embodiment of the present invention;
[0060] Figure 4 A schematic diagram of a process flow for training a machine translation model according to an embodiment of the present invention;
[0061] Figure 5 A schematic diagram of a process for training a basic bilingual translation model with the goal of enabling the real text information corresponding to the training sentences to assist in the translation of the training sentences, provided in an embodiment of the present invention;
[0062] Figure 6 A schematic diagram of the process of constructing bilingual text data provided by an embodiment of the present invention;
[0063] Figure 7 A schematic diagram of the structure of a machine translation device provided by an embodiment of the present invention;
[0064] Figure 8 A schematic diagram of the structure of a machine translation device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0065] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0066] One application scenario of machine translation is that sentences in the first language and the second language appear alternately, and the sentences need to be translated one by one in the order in which they appear. Take the oral simultaneous interpretation scenario as an example: Speaker A speaks, and the speech S in speaker A's first language is obtained. A1, the speech S of speaker A’s first language is transformed into A1 Sentences converted to first language T A1 , the first language sentence T A1 Sentence T translated into the second language A2 , output the second language sentence T A2 , or output a sentence T based on the second language A2 Synthesized second language speech A2 After speaker A speaks, speaker B speaks and obtains the second language speech S of speaker B. B2 , using ASR technology to convert speaker B's second language speech B2 Sentences converted to the second language T B2 , the second language sentence T B2 Sentence T translated into the first language B1 , output the sentence T in the first language B1 , or output a sentence T based on the first language B1 Synthesized first language speech S B1 , thus completing a round of information interaction, while oral simultaneous interpretation scenarios often require multiple rounds of information interaction.
[0067] The inventors of this case conducted research on machine translation in specific application scenarios (such as oral simultaneous interpretation) and found that machine translation in specific application scenarios (such as oral simultaneous interpretation) has the following characteristics: (1) There is no crosstalk between multiple rounds of information interaction, that is, translation is done one by one (for example, obtaining the sentence T in the first language to be translated). 11 , the first language sentence T 1-1 Translate the sentence into the second language → Get the sentence T in the second language to be translated 12 , the second language sentence T 12 Translate the sentence into the first language → Get the sentence T in the first language to be translated 21 , the first language sentence T 21 Translate the sentence into the second language → Get the sentence T in the second language to be translated 22 , the second language sentence T 22 (2) There is information interaction between the translation of the upper and lower sentences.
[0068] At present, the translation scheme for specific application scenarios (such as oral simultaneous interpretation scenarios) is mainly a sentence-level translation scheme, that is, the sentence to be translated is input and the translation of the input sentence is output. During the research process, the inventors of this case found that in specific application scenarios (such as oral simultaneous interpretation scenarios), the context is often strongly correlated, and the sentence-level translation scheme does not utilize the cross-language text information above. Sentence-level translation that is separated from the text context cannot avoid problems such as mistranslation and literal translation. In response to the problems existing in the above-mentioned sentence-level translation scheme, the inventors of this case conducted in-depth research. Through continuous research, they finally proposed a machine translation method, which perfectly overcomes the defects of the existing sentence-level translation scheme.
[0069] Before introducing the machine translation method provided by the present invention, the hardware architecture involved in the present invention is first described.
[0070] In a possible implementation, the hardware architecture involved in the present invention may include: an electronic device and a server.
[0071] Exemplarily, the electronic device may be any electronic product that can perform human-computer interaction with a user, such as a tablet computer, a PDA, a PAD, a mobile phone, a translator, etc.
[0072] For example, the server may be a single server, a server cluster consisting of multiple servers, or a cloud computing server center. The server may include a processor, a memory, a network interface, and the like.
[0073] Exemplarily, the electronic device may establish a connection and communicate with the server via a wireless communication network; exemplarily, the electronic device may establish a connection and communicate with the server via a wired communication network.
[0074] The electronic device can obtain source language sentences to be translated, and send the source language sentences to be translated to a server. The server translates the obtained sentences according to the translation method provided by the present invention, and sends the translation results to the electronic device.
[0075] In another possible implementation, the hardware architecture of the present invention may include an electronic device. The electronic device is an electronic product with strong data processing capabilities, such as a tablet computer, a PDA, a mobile phone, a translator, etc. The electronic device translates a source language sentence according to the translation method provided by the present invention.
[0076] Those skilled in the art should understand that the above-mentioned electronic devices and servers are only examples, and other existing or future electronic devices or servers that are applicable to the present invention should also be included in the scope of protection of the present invention and are included here by reference.
[0077] Next, the machine translation method provided by the present invention is introduced through the following embodiments.
[0078] First embodiment
[0079] See also Figure 1 , which shows a flowchart of a translation method provided by an embodiment of the present invention, which may include:
[0080] Step S101: Obtain a source language sentence to be translated.
[0081] The source language may be a sentence in one of the first and second languages, that is, the source language sentence may be a sentence in the first language or a sentence in the second language. If the source language is the first language, the target language is the second language; if the source language is the second language, the target language is the first language.
[0082] For example, if the first language is Chinese and the second language is English, the source language can be Chinese or English, that is, the source language sentence can be a Chinese sentence or an English sentence. If the source language is Chinese, the target language is English; if the source language is English, the target language is Chinese.
[0083] Step S102: Obtaining the chapter history information corresponding to the source language sentence.
[0084] The text history information corresponding to the source language sentence is the cross-language text information preceding the source language sentence.
[0085] In this embodiment, the passage history information may include keywords extracted from a first historical sentence and a second historical sentence. The first historical sentence is the sentence preceding the second historical sentence, the second historical sentence is the preceding adjacent sentence of the source language sentence, and the second historical sentence is the target language sentence. For example, if the source language sentence to be translated is the fifth sentence, the second historical sentence is the fourth sentence, and the first historical sentence is the sentence preceding the fourth sentence.
[0086] In the process of implementing this case, the inventors of this case found that the source language sentence to be translated is more closely related to the preceding adjacent sentence in terms of tense consistency and sentence coherence, and the source language sentence to be translated is related to longer sentences in terms of keyword consistency. Based on this discovery, the inventors of this case initially thought of combining the preceding adjacent sentence of the source language sentence to be translated and the sentence before the preceding adjacent sentence of the source language sentence to be translated to form the chapter history information corresponding to the source language sentence to be translated. However, introducing longer sentences is not friendly to translation. On the one hand, it will lead to low translation efficiency, and on the other hand, it will introduce a lot of useless information. In view of this, the inventors of this case proposed to retain only one complete sentence, that is, the preceding adjacent sentence of the source language sentence to be translated. For the long sentence, that is, the sentence before the preceding adjacent sentence of the source language sentence to be translated, keywords are extracted from it, and finally the chapter history information including the extracted keywords and the preceding adjacent sentence of the source language sentence to be translated is constructed. In this way, the chapter history information can be effectively utilized without affecting the translation efficiency.
[0087] In a possible implementation, the first historical sentence may be all sentences preceding the second historical sentence. For example, if there are five sentences preceding the second historical sentence, these five sentences are taken as the first historical sentence.
[0088] In another possible implementation, the first historical sentence can be a set number of sentences preceding the second historical sentence. For example, if the set number is 8 and there are 10 sentences preceding the second historical sentence, then 8 of the 10 sentences will be used as the first historical sentences. For example, if the second historical sentence is the 11th sentence, then the 3rd to 10th sentences will be used as the first historical sentences. It should be noted that if the number of sentences preceding the second historical sentence is less than the set number, then all sentences preceding the second historical sentence will be used as the first historical sentences. For example, if the set number is 8 and there are 6 sentences preceding the second historical sentence, then these 6 sentences will be used as the first historical sentences.
[0089] This embodiment does not impose any specific limitation on the method for selecting the first historical sentence, as long as the first historical sentence is the sentence before the second historical sentence.
[0090] In this embodiment, the second historical sentence is a sentence in a language different from the source language sentence to be translated. For example, if the source language sentence to be translated is a Chinese sentence, the second historical sentence is an English sentence.
[0091] It should be noted that the source language sentence to be translated may not have both the first and second historical sentences. For example, if the source language sentence to be translated is the first sentence of a conversation, in this case, since the first and second historical sentences are not present, that is, there is no chapter history information, so the source language sentence will be directly translated. The source language sentence to be translated may also only have the second historical sentence but not the first historical sentence. For example, if the source language sentence to be translated is the second sentence of a conversation, in this case, the chapter history information includes the second historical sentence but not the keywords.
[0092] Step S103: translating the source language sentence with the aid of the historical information of the passage corresponding to the source language sentence to obtain a target language translation corresponding to the source language sentence.
[0093] When translating source language sentences, attention is paid to the historical information of the passage corresponding to the source language sentences, and the historical information of the passage corresponding to the source language sentences is used to assist translation, so as to obtain better translation results.
[0094] Next, the above translation method is explained with a specific example.
[0095] The conversation between speaker A, who is a native Chinese speaker, and speaker B, who is a native English speaker, is as follows:
[0096] A: Hello, Jim, welcome to iFLYTEK.
[0097] [English Translation: Hello, Jim, welcome to iFLYTEK.]
[0098] B: Thank you. I'm also very happy to come to iFLYTEK. It's really beautiful here.
[0099] [Chinese Translation: Thank you. I'm also very happy to come to iFLYTEK. It's so beautiful here.]
[0100] A: Yes, Jim, the iFLYTEK campus is a small park with a listening lake, a lawn, a playground, and a food court.
[0101] [English translation: Yes, Jim, the iFLYTEK campus is a small park with alistening lake, a meadow, a play area, and afood court.]
[0102] B: Is it? I want to go to the food court.I'm a little hungry.
[0103] [Chinese translation: Really? I want to go to the food court. I’m a little hungry.]
[0104] A: Okay, come with me. We can also take a walk along the lake after dinner.
[0105] [English translation: Okay, come with me. After dinner, you can listen to the lake and take a walk.]
[0106] B: That sounds great! Do you have any recommendations for the foodcourt?
[0107] [English translation: Sounds great! Any recommendations for food courts?]
[0108] A: We have Lao Xiang Ji here. It is clean, hygienic and delicious.
[0109] [English translation: There is fellow-townsman chicken here, which is clean and delicious.]
[0110] B: Okay, looking for it!
[0111] [Chinese Translation: Okay, looking forward to it!]
[0112] Assume that the source language sentence to be translated is the first sentence of speaker A in the above conversation, "Hello, Jim, welcome to iFLYTEK.":
[0113] Since there is no sentence before the first sentence of speaker A, that is, the source language sentence to be translated does not have the first historical sentence and the second historical sentence, there is no passage history information corresponding to the first sentence of speaker A. In this case, the first sentence of speaker A is directly translated to obtain the English translation corresponding to the first sentence of speaker A, "Hello, Jim, welcome to iFLYTEK."
[0114] Assume that the current source language sentence to be translated is the first sentence of speaker B in the above conversation, "Thank you. I'm also very happy to come to iFLYTEK. It's really beautiful here.":
[0115] Since there is only one sentence before the first sentence of speaker B, that is, the first sentence of speaker A, "Hello, Jim, welcome to iFLYTEK.", that is, there is only the second historical sentence and no first historical sentence. Therefore, there is no need to obtain keywords. In this case, the chapter history information including speaker A's first sentence is constructed as the chapter history information corresponding to speaker B's first sentence. The first sentence of speaker B is translated with the help of the chapter history information corresponding to the first sentence of speaker B to obtain the Chinese translation corresponding to the first sentence of speaker B, "Thank you. I am also very happy to come to iFLYTEK. It is so beautiful here."
[0116] Assume that the source language sentence to be translated is the second sentence of speaker A in the above conversation: "Yes, Jim, the iFLYTEK campus is a small park with a listening lake, a lawn, a playground, and a food court.":
[0117] Since speaker B's second sentence is preceded by two sentences (speaker A's first sentence and speaker B's first sentence), that is, there is a first historical sentence (speaker A's first sentence) and a second historical sentence (speaker B's first sentence). Therefore, it is necessary to extract keywords from speaker A's first sentence and then construct discourse history information including the extracted keywords and speaker B's first sentence as the discourse history information corresponding to speaker A's second sentence. If the keywords "Jim" and "iFlytek" are extracted from speaker A's first sentence, discourse history information including "Jim," "iFlytek," and "Thank you. I'm also very happy to come to iFLYTEK. It's really beautiful here" is constructed. Speaker A's second sentence is then translated using this discourse history information to obtain the English translation corresponding to speaker A's second sentence: "Yes, Jim, the iFLYTEK campus is a small park with a listening lake, a meadow, a play area, and a food court."
[0118] Assume that the source language sentence to be translated is the second sentence of speaker B in the above conversation: "Is it? I want to go to the food court. I'm a little hungry.":
[0119] Since there are three sentences before the second sentence of speaker B (the first sentence of speaker A, the first sentence of speaker B and the second sentence of speaker A), that is, there is a first historical sentence (for example, the first sentence of speaker A and the first sentence of speaker B), and there is also a second historical sentence (that is, the second sentence of speaker A). Therefore, it is necessary to extract keywords from the first historical sentence, and then construct the chapter history information including the extracted keywords and the second sentence of speaker A as the chapter history information corresponding to the second sentence of speaker B. Assuming that the first historical sentence uses the first sentence of speaker A and the first sentence of speaker B, from the first sentence of speaker A The keywords "Jim" and "iFlytek" are extracted from the sentence, and the keyword "iFLYTEK" is extracted from speaker B's first sentence. The text history information corresponding to speaker A's second sentence includes "Jim," "iFlytek," "iFLYTEK," and "Yes, Jim, the iFlytek campus is a small park with a listening lake, a lawn, a playground, and a food court." After obtaining the text history information corresponding to speaker A's second sentence, speaker B's second sentence can be translated with this text history information to obtain the Chinese translation of speaker B's second sentence, "Really? I want to go to the food court. I'm a little hungry."
[0120] The translation process of other sentences in the above dialogue is similar.
[0121] It should be noted that in the simultaneous interpretation scenario, the above-mentioned dialogue content is generated sentence by sentence (first the first sentence of speaker A is generated, then the first sentence of speaker B is generated, then the second sentence of speaker A is generated, then the second sentence of speaker B is generated...), and each sentence is translated using the above-mentioned translation method until the translation of the last sentence is completed after the dialogue ends.
[0122] The translation method provided by the embodiment of the present invention can obtain the chapter history information corresponding to the source language sentence after obtaining the source language sentence to be translated, and then translate the source language sentence with the help of the chapter history information corresponding to the source language sentence to obtain the target language translation corresponding to the source language sentence. Considering that directly translating a sentence out of the context of the chapter may lead to problems such as mistranslation and literal translation, the embodiment of the present invention introduces chapter history information, that is, the cross-language chapter information mentioned above. When translating the chapter history information corresponding to the source language sentence, the cross-language chapter information mentioned above is used to assist. Compared with directly translating the source language sentence to obtain a translation, translating the source language sentence to obtain a translation with the help of the cross-language chapter information above the source language sentence produces a more authentic and accurate translation.
[0123] Second embodiment
[0124] In a possible implementation, translation may be implemented based on a machine translation model. This embodiment focuses on introducing the process of implementing translation based on the machine translation model.
[0125] See also Figure 2 , which shows a schematic diagram of the process of implementing translation based on a machine translation model, which may include:
[0126] Step S201: Obtain a source language sentence to be translated.
[0127] For the relevant description of step S201, reference may be made to the relevant description of step S101 in the above embodiment, which will not be described in detail in this embodiment.
[0128] Step S202: Obtaining the chapter history information corresponding to the source language sentence.
[0129] The chapter history information corresponding to the source language sentence is the cross-language chapter information preceding the source language sentence. The chapter history information corresponding to the source language sentence may include keywords extracted from a first historical sentence and a second historical sentence, where the first historical sentence is the sentence preceding the second historical sentence, the second historical sentence is the preceding adjacent sentence of the source language sentence, and the second historical sentence is the target language sentence.
[0130] A more detailed description of the first historical sentence and the second historical sentence can be found in the above embodiment, which will not be elaborated here.
[0131] Specifically, the process of obtaining the chapter history information corresponding to the source language sentence may include: obtaining the forward adjacent sentence of the source language sentence as the second historical sentence, and obtaining the sentence before the forward adjacent sentence of the source language sentence as the first historical sentence; obtaining keywords from the first historical sentence; and constructing the chapter history information including the obtained keywords and the second historical sentence as the chapter history information corresponding to the source language sentence.
[0132] Optionally, there are various ways to extract keywords from the first historical sentence. For example, keywords can be extracted from the first historical sentence based on an entity word extraction model. Another example is to extract keywords from the first historical sentence based on a syntactic dependency or part-of-speech recognition model. It should be noted that this embodiment does not limit the specific method for extracting keywords from the first historical sentence; any method that can extract keywords from a text is applicable to the present invention.
[0133] Optionally, the process of constructing the chapter history information including the keyword and the second historical sentence may include: splicing the keyword obtained from the first historical sentence with the second historical sentence, and using the spliced information as the chapter history information.
[0134] It should be noted that if multiple keywords are obtained from the first historical sentence, the multiple keywords are spliced together and then spliced with the second historical sentence.
[0135] For example, if the keywords obtained from the first historical sentence are "Jim", "iFLYTEK", and the second historical sentence is "Thank you. I'm also very happy to come to iFLYTEK. It's really beautiful here.", then<w_sep> Combine "Jim" with "iFLYTEK" and then use<s_sep> Splice the spliced keywords with the second historical sentence "Thank you. I'm also very happy to come to iFLYTEK. It's really beautiful here." to get the spliced information "<w_sep> Jim<w_sep> iFLYTEK<s_sep> Thank you. I'm also very happy to come to iFLYTEK. It's really beautiful here." The spliced information serves as the historical information of the chapter.
[0136] Step S203: constructing input data including chapter history information corresponding to the source language sentence and the source language sentence.
[0137] Optionally, the chapter history information corresponding to the source language sentence may be concatenated with the source language sentence, and the concatenated information is used as input data.
[0138] For example, the source language sentence is "Yes, Jim, the iFLYTEK campus is a small park with a listening lake, a lawn, a playground, and a food court." The chapter history information corresponding to the source language sentence is "<w_sep> Jim<w_sep> iFLYTEK<s_sep> Thank you.I'm also very happy to come to iFLYTEK.It'sreally beautiful here.", then available <bos>Concatenate the chapter history information corresponding to the source language sentence with the source language sentence to obtain the concatenated information"<w_sep> Jim<w_sep> iFLYTEK<s_sep> Thank you. I'm also very happy to come to iFLYTEK. It's really beautiful here. <bos>Yes, Jim, the iFLYTEK campus is a small park with a listening lake, a lawn, a playground, and a food court. This spliced information is used as input data.
[0139] Step S204: inputting the input data into the machine translation model to obtain the target language translation corresponding to the source language sentence output by the machine translation model.
[0140] Figure 3 A schematic diagram of a translation framework based on a machine translation model is shown, Figure 4 As shown, the keywords obtained from the first historical sentence, the second historical sentence, and the source language sentence to be translated are concatenated and input into the machine translation model.
[0141] Optionally, the machine translation model can be an encoder-decoder based translation model, that is, the machine translation model can include an encoder and a decoder. The encoder maps the input data into a set of continuous dense vector representations Z = (z_1, z_2, …, z_n). At time t, the decoder uses the generated word sequence Y_(t-1) = (y_1, y_2, …, y_(t-1)) and the context vector c_t (c_t is determined based on Z) as conditional input in an autoregressive manner to calculate and generate the current word y_t.
[0142] Considering that the Transformer effectively models long-range dependencies between words in a sentence through its self-attention mechanism and maps and transforms different semantic spaces through multi-head attention, and possesses strong representational capabilities, the machine translation model in this embodiment is preferably a translation model based on the Transformer framework. Of course, this embodiment is not limited to this, and the machine translation model in this embodiment may also employ translation models based on other frameworks.
[0143] It should be noted that the machine translation model in this embodiment is obtained through training data, and has the ability to use the chapter history information corresponding to the sentence to assist in translating the sentence when a sentence and the chapter history information corresponding to the sentence are input.
[0144] The translation method provided by an embodiment of the present invention, after obtaining a source language sentence to be translated, first obtains the chapter history information corresponding to the source language sentence, then constructs input data including the chapter history information corresponding to the source language sentence and the source language sentence, and finally inputs the input data into a machine translation model, so that the machine translation model can translate the source language sentence using the chapter history information corresponding to the source language sentence, thereby obtaining a target language translation corresponding to the source language sentence. Considering that directly inputting a sentence into a machine translation model for translation without considering the context of the chapter can lead to problems such as mistranslation and literal translation, an embodiment of the present invention introduces the cross-language chapter information described above, that is, inputting the source language sentence into the machine translation model together with the cross-language chapter information described above. Compared to the translation obtained by inputting only the source language sentence into the machine translation model, the translation obtained by inputting the source language sentence into the machine translation model together with the cross-language chapter information described above is more authentic and accurate.
[0145] Third embodiment
[0146] The above embodiment provides that the machine translation model is obtained by training with training data. This embodiment introduces the training process of the machine translation model.
[0147] See also Figure 4 , which shows a flow chart of the training process of a machine translation model, which may include:
[0148] Step S401: With the goal of achieving bilingual translation, bilingual training sentence pairs are used to train the constructed translation model to obtain a basic bilingual translation model.
[0149] In specific application scenarios, such as simultaneous oral interpretation, it is necessary to translate sentences in the first language into sentences in the second language, and also to translate sentences in the second language into sentences in the first language, that is, to achieve two-way translation. Currently, most solutions for achieving two-way translation are based on two independent translation models, that is, one translation model is used to translate sentences in the first language into sentences in the second language, and the other model is used to translate sentences in the second language into sentences in the first language. However, the solution based on two independent translation models has high memory requirements (the memory needs to load both models at the same time), and it is necessary to determine the language of the sentence to be translated, and to continuously switch between the two models based on the determined language.
[0150] In view of the many problems with translation solutions based on two independent translation models, the present invention proposes to train a bilingual translation model that can translate sentences in the first language into sentences in the second language and translate sentences in the second language into sentences in the first language, that is, a bilingual translation model that can realize bilingual translation.
[0151] Specifically, with the goal of achieving bilingual translation, the process of training the constructed translation model using bilingual training sentence pairs may include:
[0152] Step a1: input one of the bilingual training sentence pairs obtained from the first training data set into the translation model to obtain a translation result output by the translation model.
[0153] The first training data set includes a plurality of bilingual training sentence pairs, each bilingual training sentence pair includes a training sentence in a first language and a training sentence in a second language, and the training sentences in the first language and the training sentences in the second language are each other's standard translations.
[0154] Step a2: Determine the prediction loss of the translation model based on the translation result output by the translation model and the other training sentence in the obtained bilingual training sentence pair.
[0155] The prediction loss determined in step a2 can represent the similarity between the translation result output by the translation model and the standard translation of the training sentence. Optionally, the prediction loss determined in step a2 can be, but is not limited to, a cross entropy loss.
[0156] Step a3: Update the parameters of the translation model according to the prediction loss of the translation model.
[0157] According to steps a1 to a4, multiple iterative training is performed using the training data in the first training data set until the training end condition is met (for example, a preset number of training times is reached). After the training is completed, a translation model is obtained as a basic bilingual translation model.
[0158] It should be noted that when training the constructed translation model with the goal of achieving bilingual translation and using bilingual training sentence pairs, it is necessary to use the training sentences in the first language of the bilingual training sentence pairs as input and the training sentences in the second language of the bilingual training sentence pairs as labels to train the translation model, and it is also necessary to use the training sentences in the second language of the bilingual training sentence pairs as input and the training sentences in the first language of the bilingual training sentence pairs as labels to train the translation model. Only in this way can a bilingual translation model be obtained that can translate sentences in the first language into sentences in the second language and translate sentences in the second language into sentences in the first language.
[0159] Step S402: With the goal of enabling the real passage information corresponding to the training sentences to assist in the translation of the training sentences, the basic bilingual translation model is trained, and the trained model is used as a machine translation model.
[0160] See also Figure 5 , shows a schematic diagram of the process of training a basic bilingual translation model with the goal of enabling the real text information corresponding to the training sentences to assist in the translation of the training sentences, which may include:
[0161] Step S501: With the goal of outputting only the translation results of the input training sentences when input data including training sentences and pseudo-chapter history information corresponding to the training sentences is input, a basic bilingual translation model is trained to obtain a first bilingual translation model.
[0162] Specifically, with the goal of outputting only the translation result of the training sentence when inputting the concatenation of the training sentence and the pseudo-paragraph history information corresponding to the training sentence, the process of training the basic bilingual translation model may include:
[0163] Step b1: Obtain training sentences from the second training data set.
[0164] The second training data set includes a plurality of training sentences. The second training data set may include both training sentences in the first language and training sentences in the second language. Each training sentence in the second training data set has a standard translation.
[0165] Step b2: randomly extract keywords from the keyword library, and randomly extract sentences in a language different from the training sentences obtained in step b1 from the corpus, and combine the extracted keywords and the extracted sentences to form pseudo-chapter history information corresponding to the training sentences.
[0166] For the extraction of keywords in step b2, the number of keywords can be set. When extracting keywords from the keyword library, keywords that do not exceed the set number of keywords can be extracted. For example, if the number of keywords is set to 10, 6 keywords can be randomly extracted from the keyword library.
[0167] For the extraction of sentences in step b2, it is necessary to extract sentences in a language different from the training sentences obtained in step b1 from the corpus. If the training sentences obtained in step b1 are sentences in the first language, step b2 randomly extracts sentences in the second language from the corpus. If the training sentences obtained in step b1 are sentences in the second language, step b2 randomly extracts sentences in the first language from the corpus.
[0168] After extracting keywords from the keyword library and sentences from the corpus, pseudo-chapter history information is constructed, including the extracted keywords and sentences, as the pseudo-chapter history information corresponding to the training sentences obtained in step b1. Optionally, the extracted keywords and sentences can be concatenated, and the concatenated information serves as the pseudo-chapter history information corresponding to the training sentences obtained in step b1.
[0169] It should be noted that the pseudo chapter history information in this embodiment has the same structure as the real historical chapter information.
[0170] Step b3: construct input data including pseudo-chapter history information corresponding to the training sentences and the training sentences, input the constructed input data into the basic bilingual translation model, and obtain the translation result output by the basic bilingual translation model.
[0171] Optionally, the pseudo-chapter history information corresponding to the training sentence can be concatenated with the training sentence, and the concatenated information is input into the basic bilingual translation model as input data.
[0172] Step b4: Determine the prediction loss of the basic bilingual translation model based on the translation results output by the basic bilingual translation model and the standard translation of the training sentence.
[0173] The prediction loss determined in step b4 can represent the similarity between the translation result output by the basic bilingual translation model and the standard translation of the training sentence. Optionally, the prediction loss determined in step b4 can be, but is not limited to, a cross-entropy loss.
[0174] Step b5: Update the parameters of the basic bilingual translation model according to the prediction loss of the basic bilingual translation model.
[0175] According to the above steps b1 to b5, multiple iterative training is performed using the training data in the second training data set until the training end condition is met (for example, a preset number of training times is reached). After the training is completed, a bilingual translation model is obtained as the first bilingual translation model.
[0176] Preferably, in the process of training the basic bilingual model using the training data in the second training data set, the training data in the first training data set can be mixed to train the basic bilingual model to ensure the bilingual translation ability of the basic bilingual model. For example, the basic bilingual model can be trained with the training data in the second training data set first, and then the basic bilingual model can be trained with the training data in the first training data set, and then the basic bilingual model can be trained with the training data in the second training data set, and then the basic bilingual model can be trained with the training data in the first training data set...
[0177] Step S502: With the goal of focusing on the input real passage history information when inputting input data including training sentences and real passage history information corresponding to the training sentences, the first bilingual translation model is trained to obtain a second bilingual translation model as the final machine translation model.
[0178] Specifically, with the goal of focusing on the real passage history information corresponding to the training sentences when inputting the concatenation information of the training sentences and the real passage history information corresponding to the training sentences, the process of training the first bilingual translation model includes:
[0179] Step c1: Obtain training sentences and real passage history information corresponding to the training sentences from the third training data set.
[0180] Among them, the third training data set includes multiple training data, each training data includes a training sentence and the real passage information corresponding to the training sentence. The training sentences in the third training data set may include training sentences in the first language or training sentences in the second language. The training sentences in each training data in the third training data set have a standard translation.
[0181] Among them, the real passage history information corresponding to the training sentence includes the forward adjacent sentence of the training sentence and the keywords extracted from the sentence before the forward adjacent sentence of the training sentence. It should be noted that the forward adjacent sentence of the training sentence is a sentence in a different language from the training sentence. Specifically, if the training sentence is a sentence in the first language, the forward adjacent sentence of the training sentence is a sentence in the second language; if the training sentence is a sentence in the second language, the forward adjacent sentence of the training sentence is a sentence in the first language.
[0182] Step c2: construct input data including real passage history information corresponding to the training sentences and the training sentences, input the constructed input data into the first bilingual translation model, and obtain the translation result output by the first bilingual translation model.
[0183] Optionally, the real passage history information corresponding to the training sentence can be concatenated with the training sentence, and the concatenated information is input into the first bilingual translation model as input data.
[0184] Step c3-1: Determine the prediction loss of the first bilingual translation model based on the translation result output by the first bilingual translation model and the standard translation of the input training sentence.
[0185] The prediction loss of the first bilingual translation model can represent the similarity between the translation result output by the first bilingual translation model and the standard translation of the input training sentence. Optionally, the prediction loss determined in step c3-1 can be, but is not limited to, a cross-entropy loss.
[0186] Step c3-2: Based on the translation result output by the first bilingual translation model and the input real passage history information, determine a value that can represent the attention paid by the first bilingual translation model to the input real passage history information when translating the input training sentence, as the passage history information attention representation value.
[0187] Optionally, the process of determining the chapter history information attention representation value based on the translation results output by the first bilingual translation model and the input real chapter history information can include: determining the hit rate of the translation results output by the first bilingual translation model for keywords in the input real chapter history information, and determining the probability that the translation results output by the first bilingual translation model are the next sentence of the historical sentence in the input real chapter history information (i.e., the previous adjacent sentence of the training sentence), and using the determined hit rate and probability as the chapter history information attention representation value. It should be noted that the historical sentence in the real chapter history information and the translation results output by the first bilingual translation model are in the same language.
[0188] Optionally, the process of determining the hit rate of the translation result output by the first bilingual translation model for the keywords in the input real passage history information includes: determining the number of keywords hit by the translation result output by the first bilingual translation model from the real passage history information, and determining the hit rate of the translation result output by the first bilingual translation model for the keywords in the real passage history information as the ratio of the number of hit keywords to the total number of keywords in the real passage history information.
[0189] Optionally, determining the probability that the translation result output by the first bilingual translation model is the next sentence of a historical sentence in the actual passage history information may include: inputting the translation result output by the first bilingual translation model and the historical sentence in the actual passage history information into a pre-trained language model (such as a BERT model), and determining the probability that the translation result output by the first bilingual translation model is the next sentence of the historical sentence in the actual passage history information. The language model is trained on training corpus in the same language to predict whether two sentences have a contextual relationship.
[0190] Step c4: updating the parameters of the first bilingual translation model according to the prediction loss of the first bilingual translation model and the representation value of the attention status of the passage history information.
[0191] Specifically, the prediction loss of the first bilingual translation model can be fused with the representation value of the attention situation of the historical information of the passage, and the fusion result can be used as the total prediction loss. The parameters of the first bilingual translation model can be updated based on the total prediction loss.
[0192] If the representation value of the attention situation of the historical information of the article is the hit rate Q of the translation result output by the first bilingual translation model for the keywords in the real historical information of the article word , and the probability Q that the translation result output by the first bilingual translation model is the next sentence of the historical sentence in the real chapter history information (i.e., the forward adjacent sentence of the training sentence) sent , the prediction loss of the first bilingual translation model is the cross entropy loss CE loss , then CE loss , Q word , Q sent The total prediction loss Loss is obtained by fusion in the following way:
[0193] Loss=CE loss -α*Q word -β*Q sent
[0194] Among them, α and β are hyperparameters, α is Q word The corresponding weight, β is Q sent The corresponding weight.
[0195] According to the above steps c1 to c4, the first bilingual translation model is iteratively trained multiple times using the training data in the third training data set until the training end condition is met (for example, a preset number of training times is reached). After the training is completed, the model obtained is used as the final machine translation model.
[0196] The machine translation model trained in the above manner has the ability to translate sentences to be translated in the first language into sentences in the second language, and to translate sentences to be translated in the second language into sentences in the first language (bilingual translation can be achieved through one model without the need for language recognition, truly achieving bilingual switching-free, and greatly saving memory resources). Moreover, when a sentence and the real text history information corresponding to the sentence (i.e., the cross-language text information above the sentence) are input, the model can translate the sentence with the help of the real text history corresponding to the sentence, and then output the translation result of the sentence.
[0197] Fourth embodiment
[0198] The training data (training sentences and the real passage history information corresponding to the training sentences) in the third training dataset mentioned in the above embodiment is constructed based on bilingual passage data. Generally speaking, bilingual passage data can be collected from actual scenarios. Considering that bilingual passage data in actual scenarios is often scarce, the present invention proposes constructing bilingual passage data and then constructing the training data in the third training dataset based on the constructed bilingual passage data, or constructing the training data in the third training dataset based on bilingual passage data collected from real scenarios and the constructed bilingual passage data.
[0199] Next, the implementation process of constructing bilingual text data is introduced.
[0200] See also Figure 6 , which shows a schematic diagram of the process of constructing bilingual text data, which may include:
[0201] Step S601: Constructing passage data in one of the first language and the second language as first passage data.
[0202] Optionally, text data of one of the first language and the second language may be constructed based on a question-answering system or a dialogue system.
[0203] For example, if the first language is Chinese and the second language is Chinese, Chinese text data or English text data can be constructed based on the question-answering system or the dialogue system.
[0204] Step S602: Translate the constructed chapter data into chapter data in the other language of the first language and the second language as second chapter data.
[0205] If the chapter data constructed in step S601 is in the first language, then step S602 translates the chapter data in the first language into chapter data in the second language.
[0206] For example, the first language is Chinese and the second language is Chinese. Step S601 constructs the following Chinese chapter data:
[0207] H: Could you please tell me where iFLYTEK is located?
[0208] QA: iFLYTEK’s headquarters is located at No. 666, Wangjiang West Road, High-tech Zone, Hefei City, Anhui Province.
[0209] H: What’s the weather like in Hefei?
[0210] QA: It’s raining in Hefei today, please remember to bring an umbrella.
[0211] Translate the above Chinese chapter data into English chapter data:
[0212] H:Where is iFLYTEK located?
[0213] QA:The headquarters of iFLYTEK is located at No.666Wangjiang WestRoad,High-tech Zone,Hefei City,Anhui Province.
[0214] H: What's the weather like in Hefei?
[0215] QA: It's raining in Hefei today,please bring an umbrella.
[0216] Step S603: constructing bilingual passage data in which sentences in the first language and sentences in the second language appear alternately based on the first passage data and the second passage data.
[0217] Specifically, the process of constructing bilingual passage data in which sentences in the first language and sentences in the second language appear alternately based on the first passage data and the second passage data may include: replacing sentences ranked as even numbers in the first passage data with corresponding sentences in the second passage data; or replacing sentences ranked as odd numbers in the first passage data with corresponding sentences in the second passage data; or replacing sentences ranked as even numbers in the second passage data with corresponding sentences in the first passage data; or replacing sentences ranked as odd numbers in the second passage data with corresponding sentences in the first passage data.
[0218] For the above example, if the first method is used to construct bilingual passage data, the construction process is as follows: replace the second sentence in the first passage data, "iFLYTEK headquarters is located at No. 666 Wangjiang West Road, High-tech Zone, Hefei City, Anhui Province" with the corresponding sentence in the second passage data, "The headquarters of iFLYTEK is located at No. 666 Wangjiang West Road, High-tech Zone, Hefei City, Anhui Province.", and replace the fourth sentence in the first passage data with the corresponding sentence in the second passage data, "It's raining in Hefei today, please bring an umbrella.". In this way, bilingual passage data is obtained in which sentences in the first language and sentences in the second language appear alternately:
[0219] "Excuse me, where is iFLYTEK located?
[0220] The headquarters of iFLYTEK is located at No.666Wangjiang West Road,High-tech Zone,Hefei City,Anhui Province.
[0221] What's the weather like in Hefei?
[0222] It's raining in Hefei today,please bring an umbrella."
[0223] Other implementations are similar and will not be described in detail in this embodiment.
[0224] Fifth embodiment
[0225] An embodiment of the present invention further provides a translation device. The translation device provided by the embodiment of the present invention is described below. The translation device described below and the translation method described above can be referenced to each other.
[0226] See also Figure 7 , shows a schematic structural diagram of a machine translation device provided by an embodiment of the present invention, which may include: a sentence acquisition module 701 to be translated, a chapter history information acquisition module 702 and a translation module 703.
[0227] The sentence to be translated obtaining module 701 is used to obtain the source language sentence to be translated.
[0228] The chapter history information acquisition module 702 is used to acquire the chapter history information corresponding to the source language sentence.
[0229] The chapter history information includes keywords extracted from a first historical sentence and a second historical sentence, wherein the first historical sentence is the sentence before the second historical sentence, the second historical sentence is the forward adjacent sentence of the source language sentence, and the second historical sentence is the target language sentence.
[0230] The translation module 703 is configured to translate the source language sentence with the aid of the passage history information corresponding to the source language sentence to obtain a target language translation corresponding to the source language sentence.
[0231] Optionally, the translation module 703 is configured to translate the source language sentence with the aid of the passage history information corresponding to the source language sentence to obtain the target language translation corresponding to the source language sentence:
[0232] Constructing input data including chapter history information corresponding to the source language sentence and the source language sentence;
[0233] Inputting the input data into a pre-trained machine translation model to obtain a target language translation corresponding to the source language sentence output by the machine translation model;
[0234] When a sentence and the passage history information corresponding to the sentence are input into the machine translation model, the machine translation model has the ability to use the passage history information corresponding to the sentence to assist in translating the sentence.
[0235] The machine translation apparatus provided by the embodiment of the present invention may further include a model training module for training a machine translation model.
[0236] Optionally, the model training module may include: a first training module and a second training module.
[0237] The first training module is used to train the constructed translation model using bilingual training sentence pairs with the goal of achieving bilingual translation, thereby obtaining a basic bilingual translation model, wherein the training sentences in the first language and the training sentences in the second language in the bilingual training sentence pairs are each other's standard translations.
[0238] The second training module is used to train the basic bilingual translation model with the goal of enabling the real passage information corresponding to the training sentences to assist in the translation of the training sentences, and the trained model is used as the machine translation model.
[0239] Optionally, the second training module is specifically configured to:
[0240] The basic bilingual translation model is trained to obtain a first bilingual translation model with the goal of outputting only translation results of the training sentences when input data including training sentences and pseudo-paragraph history information corresponding to the training sentences is input;
[0241] With the goal of focusing on the input real passage history information when input data including training sentences and real passage history information corresponding to the training sentences is input, the first bilingual translation model is trained to obtain a second bilingual translation model as the machine translation model.
[0242] Optionally, when the first training module is used to train the constructed translation model with bilingual training sentence pairs for the purpose of achieving bilingual translation, it is specifically used to:
[0243] Inputting one of the bilingual training sentence pairs into a translation model to obtain a translation result output by the translation model;
[0244] Determining a prediction loss of the translation model based on a translation result output by the translation model and another training sentence in the bilingual training sentence pair;
[0245] The translation model parameters are updated based on the prediction loss of the translation model.
[0246] Optionally, the second training module is specifically configured to:
[0247] Randomly extract keywords from the keyword library and randomly extract sentences in a language different from the training sentences from the corpus, and construct pseudo-chapter history information including the extracted keywords and the extracted sentences as the pseudo-chapter history information corresponding to the training sentences;
[0248] Constructing input data including pseudo-chapter history information corresponding to the training sentences and the training sentences, and inputting the constructed input data into the basic bilingual translation model to obtain a translation result output by the basic bilingual translation model;
[0249] Determining the prediction loss of the basic bilingual translation model according to the translation result output by the basic bilingual translation model and the standard translation of the input training sentence;
[0250] Parameters of the basic bilingual translation model are updated according to the prediction loss of the basic bilingual translation model.
[0251] Optionally, the second training module, when inputting input data including training sentences and real passage history information corresponding to the training sentences, is capable of focusing on the input real passage history information, and when training the first bilingual translation model, is specifically configured to:
[0252] Constructing input data including real passage history information corresponding to training sentences and training sentences, and inputting the constructed input data into the first bilingual translation model to obtain a translation result output by the first bilingual translation model;
[0253] Determining a prediction loss of the first bilingual translation model based on a translation result output by the first bilingual translation model and a standard translation of an input training sentence;
[0254] Determining, based on the translation result output by the first bilingual translation model and the input real passage history information, a value that can represent the attention paid by the first bilingual translation model to the input real passage history information when translating the input training sentence, as a passage history information attention representation value;
[0255] Parameters of the first bilingual translation model are updated according to the prediction loss of the first bilingual translation model and the representation value of the attention situation of the passage history information.
[0256] Optionally, the second training module, when determining, based on the translation result output by the first bilingual translation model and the input real passage history information, a value that can represent the attention paid by the first bilingual translation model to the input real passage history information when translating the input training sentence, is specifically configured to:
[0257] Determining a hit rate of keywords in the input real passage history information for the translation result output by the first bilingual translation model;
[0258] And, determining the probability that the translation result output by the first bilingual translation model is the next sentence of the historical sentence in the input real passage history information.
[0259] Optionally, the training sentences and the real text history information corresponding to the training sentences are constructed based on the constructed bilingual text data.
[0260] The machine translation apparatus provided by the embodiment of the present invention may further include: a bilingual text data construction module for constructing bilingual text data. When constructing bilingual text data, the bilingual text data construction module is specifically used to:
[0261] Constructing text data of one of the first language and the second language as the first text data;
[0262] translating the constructed chapter data into chapter data in the other of the first language and the second language as second chapter data;
[0263] Bilingual passage data in which sentences in a first language and sentences in a second language appear alternately is constructed based on the first passage data and the second passage data.
[0264] Optionally, when constructing bilingual passage data in which sentences in the first language and sentences in the second language appear alternately based on the first passage data and the second passage data, the bilingual passage data construction module is specifically configured to:
[0265] Replace the even-numbered sentences in the first chapter data with the corresponding sentences in the second chapter data;
[0266] Alternatively, the odd-numbered sentences in the first chapter data are replaced with corresponding sentences in the second chapter data;
[0267] Alternatively, the sentences ranked as even numbers in the second chapter data are replaced with the corresponding sentences in the first chapter data;
[0268] Alternatively, sentences in the second chapter data that are sorted as odd numbers are replaced with corresponding sentences in the first chapter data.
[0269] The machine translation device provided by the embodiment of the present invention can obtain the chapter history information corresponding to the source language sentence after obtaining the source language sentence to be translated, and then translate the source language sentence with the aid of the chapter history information corresponding to the source language sentence to obtain the target language translation corresponding to the source language sentence. The source language sentence to be translated is translated with the aid of the cross-language chapter information of the source language sentence, which can obtain a more authentic and accurate translation. The translation device provided by the embodiment of the present invention can translate the source language sentence to be translated based on the machine translation model obtained through training. Since the machine translation model obtained through training can achieve bilingual translation, it can also translate the sentence with the aid of the real chapter history corresponding to the sentence when a sentence and the real chapter history information corresponding to the sentence are input. Therefore, translation based on the above translation model can obtain better translation effect and occupy less memory resources.
[0270] Sixth embodiment
[0271] The present invention also provides a machine translation device. Figure 8 , shows a schematic structural diagram of the machine translation device, which may include: at least one processor 801, at least one communication interface 802, at least one memory 803 and at least one communication bus 804;
[0272] In the embodiment of the present invention, the number of the processor 801, the communication interface 802, the memory 803, and the communication bus 804 is at least one, and the processor 801, the communication interface 802, and the memory 803 communicate with each other through the communication bus 804;
[0273] The processor 801 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention;
[0274] The memory 803 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;
[0275] The memory stores a program, and the processor can call the program stored in the memory, wherein the program is used to:
[0276] Obtain the source language sentence to be translated;
[0277] Obtaining passage history information corresponding to the source language sentence, wherein the passage history information includes keywords extracted from a first historical sentence and a second historical sentence, wherein the first historical sentence is a sentence preceding the second historical sentence, the second historical sentence is a preceding adjacent sentence of the source language sentence, and the second historical sentence is a target language sentence;
[0278] The source language sentence is translated with the aid of the passage history information corresponding to the source language sentence to obtain a target language translation corresponding to the source language sentence.
[0279] Optionally, the detailed functions and extended functions of the program may refer to the above description.
[0280] Seventh embodiment
[0281] An embodiment of the present invention further provides a readable storage medium, which may store a program suitable for execution by a processor, wherein the program is used to:
[0282] Obtain the source language sentence to be translated;
[0283] Obtaining passage history information corresponding to the source language sentence, wherein the passage history information includes keywords extracted from a first historical sentence and a second historical sentence, wherein the first historical sentence is a sentence preceding the second historical sentence, the second historical sentence is a preceding adjacent sentence of the source language sentence, and the second historical sentence is a target language sentence;
[0284] The source language sentence is translated with the aid of the passage history information corresponding to the source language sentence to obtain a target language translation corresponding to the source language sentence.
[0285] Optionally, the detailed functions and extended functions of the program may refer to the above description.
[0286] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprise," "include," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a set of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
[0287] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0288] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.< / bos> < / bos>
Claims
1. A machine translation method, characterized in that: include: Obtain the source language sentence to be translated; Obtaining passage history information corresponding to the source language sentence, wherein the passage history information is cross-language passage information preceding the source language sentence, the passage history information including keywords extracted from a first historical sentence and a second historical sentence, wherein the first historical sentence is a sentence preceding the second historical sentence, the second historical sentence is a preceding adjacent sentence of the source language sentence, and the second historical sentence is a target language sentence; Using a pre-trained machine translation model, supplemented by the historical information of the passage corresponding to the source language sentence, the source language sentence is translated to obtain a target language translation corresponding to the source language sentence; The training process of the machine translation model includes: With the goal of achieving bilingual translation, bilingual training sentence pairs are used to train the constructed translation model to obtain a basic bilingual translation model, wherein the training sentences in the first language and the training sentences in the second language in the bilingual training sentence pairs are each other's standard translations; The basic bilingual translation model is trained to obtain a first bilingual translation model with the goal of outputting only translation results of the training sentences when input data including training sentences and pseudo-paragraph history information corresponding to the training sentences is input; Constructing input data including real passage history information corresponding to training sentences and training sentences, and inputting the constructed input data into the first bilingual translation model to obtain a translation result output by the first bilingual translation model; Determining a prediction loss of the first bilingual translation model based on a translation result output by the first bilingual translation model and a standard translation of an input training sentence; Determining, based on the translation result output by the first bilingual translation model and the input real passage history information, a value that can represent the attention paid by the first bilingual translation model to the input real passage history information when translating the input training sentence, as a passage history information attention representation value; wherein the passage history information attention representation value includes a hit rate of the translation result output by the first bilingual translation model for keywords in the input real passage history information, and a probability that the translation result output by the first bilingual translation model is the next sentence of a historical sentence in the input real passage history information; Parameters of the first bilingual translation model are updated according to the prediction loss of the first bilingual translation model and the representation value of the attention situation of the passage history information.
2. The machine translation method according to claim 1, wherein: The method of using a pre-trained machine translation model and the passage history information corresponding to the source language sentence to translate the source language sentence to obtain a target language translation corresponding to the source language sentence includes: Constructing input data including chapter history information corresponding to the source language sentence and the source language sentence; Inputting the input data into a pre-trained machine translation model to obtain a target language translation corresponding to the source language sentence output by the machine translation model; When a sentence and the passage history information corresponding to the sentence are input into the machine translation model, the machine translation model has the ability to use the passage history information corresponding to the sentence to assist in translating the sentence.
3. The machine translation method according to claim 1, wherein: The goal of achieving bilingual translation is to train the constructed translation model using bilingual training sentence pairs to obtain a basic bilingual translation model, including: Inputting one of the bilingual training sentence pairs into a translation model to obtain a translation result output by the translation model; Determining a prediction loss of the translation model based on a translation result output by the translation model and another training sentence in the bilingual training sentence pair; The translation model parameters are updated based on the prediction loss of the translation model.
4. The machine translation method according to claim 1, wherein: The training of the basic bilingual translation model with the goal of outputting only the translation results of the training sentences when input data including the training sentences and the pseudo-chapter history information corresponding to the training sentences is input includes: Randomly extract keywords from the keyword library and randomly extract sentences in a language different from the training sentences from the corpus, and construct pseudo-chapter history information including the extracted keywords and the extracted sentences as the pseudo-chapter history information corresponding to the training sentences; Constructing input data including pseudo-chapter history information corresponding to the training sentences and the training sentences, and inputting the constructed input data into the basic bilingual translation model to obtain a translation result output by the basic bilingual translation model; Determining the prediction loss of the basic bilingual translation model according to the translation result output by the basic bilingual translation model and the standard translation of the input training sentence; Parameters of the basic bilingual translation model are updated according to the prediction loss of the basic bilingual translation model.
5. The machine translation method according to claim 1, wherein: The training sentences and the historical information of the real passages corresponding to the training sentences are constructed based on the constructed bilingual passage data; The process of constructing the bilingual text data includes: Constructing text data of one of the first language and the second language as the first text data; translating the constructed chapter data into chapter data in the other of the first language and the second language as second chapter data; Bilingual passage data in which sentences in a first language and sentences in a second language appear alternately is constructed based on the first passage data and the second passage data.
6. The machine translation method according to claim 5, characterized in that The step of constructing bilingual passage data in which sentences in the first language and sentences in the second language appear alternately based on the first passage data and the second passage data includes: Replace the even-numbered sentences in the first chapter data with the corresponding sentences in the second chapter data; Alternatively, the odd-numbered sentences in the first chapter data are replaced with corresponding sentences in the second chapter data; Alternatively, the sentences ranked as even numbers in the second chapter data are replaced with the corresponding sentences in the first chapter data; Alternatively, sentences in the second chapter data that are sorted as odd numbers are replaced with corresponding sentences in the first chapter data.
7. A machine translation device, characterized in that: include: Module for acquiring sentences to be translated, module for acquiring historical information of passages, and module for translating; The to-be-translated sentence acquisition module is used to acquire the source language sentence to be translated; The passage history information acquisition module is configured to acquire passage history information corresponding to a source language sentence, wherein the passage history information is cross-language passage information preceding the source language sentence, and the passage history information includes keywords extracted from a first historical sentence and a second historical sentence, wherein the first historical sentence is the sentence preceding the second historical sentence, the second historical sentence is the preceding adjacent sentence of the source language sentence, and the second historical sentence is the target language sentence; The translation module is configured to translate the source language sentence using a pre-trained machine translation model and the passage history information corresponding to the source language sentence to obtain a target language translation corresponding to the source language sentence; The machine translation device further includes a model training module; the model training module is used to: With the goal of achieving bilingual translation, bilingual training sentence pairs are used to train the constructed translation model to obtain a basic bilingual translation model, wherein the training sentences in the first language and the training sentences in the second language in the bilingual training sentence pairs are each other's standard translations; The basic bilingual translation model is trained to obtain a first bilingual translation model with the goal of outputting only translation results of the training sentences when input data including training sentences and pseudo-paragraph history information corresponding to the training sentences is input; Constructing input data including real passage history information corresponding to training sentences and training sentences, and inputting the constructed input data into the first bilingual translation model to obtain a translation result output by the first bilingual translation model; Determining a prediction loss of the first bilingual translation model based on a translation result output by the first bilingual translation model and a standard translation of an input training sentence; Determining, based on the translation result output by the first bilingual translation model and the input real passage history information, a value that can represent the attention paid by the first bilingual translation model to the input real passage history information when translating the input training sentence, as a passage history information attention representation value; wherein the passage history information attention representation value includes a hit rate of the translation result output by the first bilingual translation model for keywords in the input real passage history information, and a probability that the translation result output by the first bilingual translation model is the next sentence of a historical sentence in the input real passage history information; Parameters of the first bilingual translation model are updated according to the prediction loss of the first bilingual translation model and the representation value of the attention situation of the passage history information.
8. A machine translation device, characterized in that: include: memory and processor; The memory is used to store programs; The processor is configured to execute the program to implement the steps of the machine translation method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the machine translation method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method and device for processing session information and terminal equipment
CN110209774A
Text translation method and device, electronic equipment and readable storage medium
CN111859998A
Machine translation model training method, language translation method and equipment
CN113705251A