Translation term word form adaptation replacement method and device, and electronic equipment
By replacing terms and training models for the translated text, and using the T5 model for word-by-word encoding and decoding, the problem of inconsistent terminology in machine translation is solved, and the translation quality and grammatical correctness are improved.
Patent Information
- Application Number
- CN202310088953.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-17
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2043-01-17
AI Technical Summary
Existing machine translation technology has difficulty maintaining the consistency of the word form of the translated terms when faced with texts containing a large number of professional terms in specific fields, resulting in poor translation quality.
By performing term replacement processing on the text to be translated, a synthetic translation text is generated, and the T5 model and bidirectional attention mask mechanism are used for word-by-word encoding and decoding. Combined with the preset loss function training model, the adaptive replacement of term forms is achieved.
It improves the quality of machine translation, ensures the correctness of terminology and grammatical correctness of translation, and achieves high-quality translation results, especially in text translation scenarios containing professional terminology in specific fields.
Smart Images

Figure CN116306695B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device and electronic equipment for adaptively replacing word forms of translated terms. Background Art
[0002] Machine translation technology uses computers and other computing devices to translate text from one natural language into another. Because this translation process is performed by machines, it can handle large volumes of translation work in a relatively short time compared to human translation. However, when using machine translation technology to translate texts containing a high proportion of specialized terminology, general-purpose machine translation systems often encounter errors and produce poor translation quality, as the training corpus for these domain-specific terms often lacks translations for these terms, or translations of these terms appear only infrequently.
[0003] To address this issue, prior art typically involves defining unified definitions for terms and their translations before translation. During machine translation, these translations are automatically replaced to maintain consistency throughout the text. While this approach works well for translations without inflection, it can lead to grammatical errors in the replaced sentences when inflection is required based on the context of the sentence, impacting translation quality.
[0004] Therefore, when faced with text translation scenarios containing a large number of professional terms in specific fields, how to better perform machine translation has become a technical problem that the industry urgently needs to solve. Summary of the Invention
[0005] The present invention provides a method, device and electronic device for adaptively replacing the word form of translated terms, which are used to better perform machine translation and improve translation quality in text translation scenarios containing a large number of professional terms in specific fields.
[0006] The present invention provides a method for adaptively replacing word forms of translated terms, comprising:
[0007] Performing term replacement processing on the original target text to be translated to obtain a synthetic target text;
[0008] Inputting the synthesized translation text into a first translation term replacement model to obtain a target translation text corresponding to the text to be translated output by the first translation term replacement model;
[0009] The first translation term replacement model is trained based on synthetic translation text samples and corresponding real translation text labels, and the synthetic translation text samples are obtained by performing term replacement processing on original translation text samples.
[0010] According to a method for adaptively replacing word forms of translated terms provided by the present invention, the method performs term replacement processing on an original translated text to obtain a synthesized translated text, including:
[0011] Segmenting the original translation text to obtain a plurality of sentences corresponding to the original translation text;
[0012] Using a term extraction tool to extract terms from each of the sentences, marking the terms extracted from each of the sentences, and determining the marking positions of the terms in each of the sentences;
[0013] A lemma restoration tool is used to restore each term in the sentence to a corresponding original term according to the marked position of the term in each sentence, thereby obtaining the synthesized translation text.
[0014] According to a method for adaptively replacing word forms of translated terms provided by the present invention, after performing term replacement processing on the original translated text to obtain a synthesized translated text, the method further comprises:
[0015] Inputting the synthesized translation text into a second translation term replacement model to obtain a target term corresponding to the original translation text output by the second translation term replacement model; the second translation term replacement model is trained based on the synthesized translation text sample and the corresponding term label;
[0016] The original terms in the synthesized translation text are replaced with the corresponding target terms to obtain the target translation text corresponding to the text to be translated.
[0017] According to a method for adaptively replacing word forms of target terms provided by the present invention, before inputting the synthesized target text into a first target term replacement model, the method further includes:
[0018] Taking the synthetic translation text sample and the real translation text label corresponding to the synthetic translation text sample as a group of training samples, obtaining multiple groups of training samples;
[0019] The T5 model is trained using the multiple groups of training samples to obtain the first translation term replacement model.
[0020] According to a method for adaptively replacing word forms of translated terms provided by the present invention, the T5 model is trained using the plurality of training samples to obtain the first translated term replacement model, including:
[0021] For any set of training samples, the training samples are segmented to obtain training samples after segmentation;
[0022] Input the training sample after word segmentation processing into the T5 model, and output the predicted probability corresponding to the training sample after word segmentation processing;
[0023] Calculating a loss value using a preset loss function based on the predicted probability corresponding to the training sample after word segmentation processing and the actual translation text label corresponding to the training sample;
[0024] Based on the loss value, adjusting the model parameters of the T5 model until the loss value is less than a preset threshold or the number of iterations reaches a preset number;
[0025] The model parameters obtained when the loss value is less than a preset threshold or the number of iterations reaches a preset number are used as the model parameters of the trained T5 model to obtain the first translation term replacement model.
[0026] According to a method for adaptively replacing word forms of translated terms provided by the present invention, the training sample after word segmentation processing is input into the T5 model, and the predicted probability corresponding to the training sample after word segmentation processing is output, including:
[0027] Using the multi-layer encoder of the T5 model, the training samples after word segmentation are encoded word by word using a bidirectional attention mask mechanism to obtain a hidden layer state vector corresponding to the training samples after word segmentation;
[0028] The multi-layer decoder of the T5 model is used to decode the hidden layer state vector word by word using a unidirectional attention mask mechanism to obtain the predicted probability corresponding to the training sample after word segmentation processing.
[0029] The present invention also provides a device for adaptively replacing word forms of translated terms, comprising:
[0030] A synthesis module is used to perform term replacement processing on the original target text to obtain a synthesized target text;
[0031] Inputting the synthesized translation text into a first translation term replacement model to obtain a target translation text corresponding to the text to be translated output by the first translation term replacement model;
[0032] The first translation term replacement model is trained based on synthetic translation text samples and corresponding real translation text labels, and the synthetic translation text samples are obtained by performing term replacement processing on original translation text samples.
[0033] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for adaptively replacing the word form of a translated term as described above is implemented.
[0034] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-mentioned methods for adaptively replacing the word form of a translated term.
[0035] The present invention also provides a computer program product, comprising a computer program, which, when executed by a processor, implements any of the above-mentioned methods for adaptively replacing translated term forms.
[0036] The method, device, and electronic device for adaptively replacing translation term forms provided by the present invention obtain synthetic translation text samples by performing term replacement processing on original translation text samples, thereby obtaining a large amount of training corpus composed of synthetic translation text samples. These training corpora and the real translation text labels corresponding to each training corpus are used for model training to obtain a first translation term replacement model, which can achieve adaptive replacement of the original translation term form. By performing term replacement processing on the original translation text to be translated to obtain a synthetic translation text, and inputting the synthetic translation text into the first translation term replacement model for replacement, a translation with correct term form can be automatically generated, ensuring the correctness of the final translation grammar. In the face of text translation scenarios containing a large number of specialized terms in specific fields, high-quality translation effects can be achieved, effectively improving the quality of machine translation results. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0038] Figure 1 1 is a flow chart of the method for adaptively replacing the word form of a translated term provided by the present invention;
[0039] Figure 2 It is a schematic diagram of the structure of the device for adaptively replacing the word form of a translated term provided by the present invention;
[0040] Figure 3 It is a schematic diagram of the physical structure of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0041] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0042] The following combination Figure 1-Figure 3 The present invention describes a method, device and electronic device for adaptively replacing word forms of translated terms.
[0043] Figure 1 FIG. 1 is a flow chart of the method for adaptively replacing the word form of a translated term provided by the present invention. Figure 1 As shown, it includes: step 110 and step 120.
[0044] Step 110, performing term replacement processing on the original target text of the text to be translated to obtain a synthesized target text;
[0045] Step 120: input the synthesized translation text into the first translation term replacement model to obtain the target translation text corresponding to the to-be-translated text output by the first translation term replacement model;
[0046] The first translation term replacement model is trained based on synthetic translation text samples and corresponding real translation text labels. The synthetic translation text samples are obtained by performing term replacement processing on the original translation text samples.
[0047] Specifically, the text to be translated described in the embodiment of the present invention refers to the original text that needs to be translated, which can specifically be the text to be translated containing professional terms, wherein the text to be translated can include texts in multiple languages, such as Chinese text, French text, German text, etc.
[0048] The original translation text described in the embodiments of the present invention refers to the English text obtained by the system's initial machine translation of the text to be translated. This text may contain translation errors of terms, such as incorrect singular or plural forms or tenses. It is understood that the original translation text is the text that requires term replacement.
[0049] The term replacement process described in the embodiment of the present invention refers to an operation of replacing terms in an original translation text with their corresponding original terms in a term database based on a manually pre-defined term database.
[0050] The synthesized translation text described in the embodiment of the present invention refers to a translation text obtained by performing term replacement processing on the original translation text, replacing the terms in the original translation text with the forms of the corresponding original terms in the term database.
[0051] The original translation text samples described in the embodiment of the present invention refer to translation text samples obtained after initial machine translation of multiple types of text corpora containing professional terms that need to be translated.
[0052] The first translation term replacement model described in this embodiment of the present invention is trained based on synthetic translation text samples and corresponding real translation text labels. This model is used to identify synthetic translation text samples, learn the translation grammar of correct terms, and thus output translation text with correct word forms. The synthetic translation text samples are obtained by performing the aforementioned term replacement process on terms in the original translation text samples.
[0053] In an embodiment of the present invention, the first translation term replacement model can be constructed based on a deep neural network. By training the deep neural network model, the nonlinear system of the input or output is identified and has good stability. Taking into account the task characteristics of the translation term word form replacement, a generative pre-trained language model can be selected for fine-tuning to achieve accurate replacement of the professional term word form in the translation. For example, Google's text-to-text Transformer (Text-To-Text Transfer Transformer, T5) pre-trained language model can be selected as the basis for subsequent fine-tuning. The T5 model is an English generative pre-trained language model. To speed up the training speed, the basic version model T5-base model can be selected. Of course, other deep neural networks that can be used for term word form replacement can also be selected, such as long short-term memory (LSTM) networks, gated recurrent units (GRU) and other neural networks, and the present invention does not make specific limitations on this.
[0054] The real translation text is the translation text in which the terms in the synthetic translation text sample are correct terms. The training samples of the first translation term replacement model are composed of multiple groups of synthetic translation text samples carrying real translation text labels.
[0055] The real translation text labels described in the present invention are pre-determined based on the synthetic translation text samples and have a one-to-one correspondence with the synthetic translation text samples. In other words, each synthetic translation text sample in the training sample has a pre-assigned real translation text label corresponding to it.
[0056] The target translation text described in the embodiment of the present invention refers to a correct translation text obtained by performing terminology word form replacement on the original translation text of the text to be translated by the first translation term replacement model.
[0057] Furthermore, in an embodiment of the present invention, after the user inputs a text to be translated, the text to be translated is initially translated to obtain an original translation text, and then term replacement processing is performed on the original translation text to obtain a synthesized translation text.
[0058] In a specific embodiment of the present invention, the text to be translated can be expressed as "All idlers shall be equipped with antifriction bearings, which are sealed and lubricated for life." The corresponding original translation text can be expressed as "All idlers shall be equipped with antifriction bearings, which are sealed and lubricated for life." Furthermore, the original translation text of the text to be translated undergoes term replacement processing, replacing the term "antifriction bearings" in the original translation text with the original term "anti-friction bearing" and marking it, thereby obtaining a synthesized translation text:
[0059] “All idlers shall be equipped with <s> anti-friction bearing< / s> ,which are sealed and lubricated for life”.
[0060] Furthermore, term word form replacement is implemented through the first translation term replacement model. The above-mentioned synthesized translation text is input into the first translation term replacement model to obtain the target translation text corresponding to the text to be translated:
[0061] "All idlers shall be equipped with anti-friction bearings, which are sealed and lubricated for life."
[0062] The method for adaptive replacement of translation terminology provided by an embodiment of the present invention performs term replacement processing on original translation text samples to obtain synthetic translation text samples, thereby obtaining a large amount of training corpus composed of synthetic translation text samples. These training corpora and the real translation text labels corresponding to each training corpus are used for model training to obtain a first translation term replacement model, which can achieve adaptive replacement of the original translation terminology. By performing term replacement processing on the original translation text to be translated to obtain a synthetic translation text, and inputting the synthetic translation text into the first translation term replacement model for replacement, a translation with correct terminology can be automatically generated, ensuring the correctness of the final translation grammar. In the face of text translation scenarios containing a large number of specialized terms in specific fields, high-quality translation effects can be achieved, effectively improving the quality of machine translation results.
[0063] Based on the content of the above embodiment, as an optional embodiment, term replacement processing is performed on the original target text of the translation text to obtain a synthesized target text, including:
[0064] Segmenting the original target text to be translated to obtain multiple sentences corresponding to the original target text;
[0065] Use a term extraction tool to extract terms from each sentence, mark the terms extracted from each sentence, and determine the mark position of the terms in each sentence;
[0066] Using the word form restoration tool, the terms in each sentence are restored to the corresponding original terms according to the marked positions of the terms in each sentence to obtain the synthetic translation text.
[0067] Specifically, the original terms described in the embodiment of the present invention refer to the terms in the sentence corresponding to the terms in the pre-defined term database.
[0068] The term extraction tool described in the embodiment of the present invention is used to extract terms from each sentence of the original translation text. It can adopt existing commonly used term extraction tools, such as Syn-Tactic technology.
[0069] The lemmatization tool described in the embodiments of the present invention is used to restore the terms in each sentence of the original translation text to the corresponding original terms. This can be done using existing commonly used lemmatization tools, such as the lemmatization module of the Natural Language Toolkit (NLTK).
[0070] In a specific embodiment of the present invention, the text to be translated is represented as "All idlers shall be equipped with antifriction bearings, which are sealed and lubricated for life." The corresponding original translation text can be represented as "All idlers shall be equipped with antifriction bearings, which are sealed and lubricated for life." Furthermore, "All idlers shall be equipped with antifriction bearings, which are sealed and lubricated for life" is split into "All idlers shall be equipped with antifriction bearings" and "which are sealed and lubricated for life," obtaining two sentences corresponding to the original translation text.
[0071] Furthermore, a term extraction tool is used to extract terms from each of the above sentences. The term "antifriction bearings" contained in the sentence is obtained through term extraction, and the term "antifriction bearings" is used. <s> "and"< / s> "Mark the terms in the sentence to determine the mark position of the terms in the sentence, and finally obtain the following text sequence:
[0072] “All idlers shall be equipped with <s> antifriction bearings< / s> ,which are sealed and lubricated for life”.
[0073] Furthermore, we use a lemmatization tool to restore the term “antifriction bearings” to its original term “anti-friction bearing”. Based on the token position of the term in each sentence, we replace the original term with the term in the sentence to obtain the synthetic translation text:
[0074] “All idlers shall be equipped with <s> anti-friction bearing< / s> ,which are sealed and lubricated for life”.
[0075] It should be noted that the purpose of term replacement processing is to ensure that in each sentence, terms such as "anti-friction bearing" are translated into a consistent translation "anti-friction bearing", but direct replacement may lead to grammatical errors. For example, in the above sentence, the term "anti-friction bearing" should be transformed into the plural form "anti-friction bearings". Therefore, after the replacement, the term translation can be adaptively adjusted through the first translation term replacement model to achieve adaptive term form replacement.
[0076] The method of the embodiment of the present invention obtains a synthetic translation text by performing sentence segmentation, term extraction and morphological restoration operations on the original translation text, which facilitates the subsequent use of a term replacement model to accurately replace terms in the original translation text, ensuring that the model outputs high-quality translation results and improving translation quality.
[0077] Based on the content of the above embodiment, as an optional embodiment, after performing term replacement processing on the original target text of the translation text to obtain a synthesized target text, the method further includes:
[0078] Inputting the synthesized translation text into a second translation term replacement model to obtain the target term corresponding to the original translation text output by the second translation term replacement model; the second translation term replacement model is trained based on the synthesized translation text samples and the corresponding term labels;
[0079] The original terms in the synthesized translation text are replaced with the corresponding target terms to obtain the target translation text corresponding to the text to be translated.
[0080] Specifically, the second translation term replacement model described in the embodiment of the present invention is trained based on synthetic translation text samples and corresponding term labels. The model is used to identify synthetic translation text samples, learn the translation grammar of correct terms, and output the correct term morphology.
[0081] Similarly, in embodiments of the present invention, the second translation term replacement model can also be constructed based on a deep neural network. A generative pre-trained language model can be selected for fine-tuning to achieve word form replacement of specialized terminology in the translation, such as using a T5 pre-trained language model as the basis for subsequent fine-tuning. Of course, other deep neural networks, such as LSTM networks and GRU networks, can also be selected, and this is not specifically limited by the present invention.
[0082] Among them, the training samples of the second translation term replacement model are composed of multiple groups of synthetic translation text samples carrying term labels.
[0083] The term labels described in the present invention are predetermined based on synthetic translation text samples and have a one-to-one correspondence with the synthetic translation text samples. Each synthetic translation text sample in the training sample is pre-set with a corresponding term label.
[0084] The target term described in the embodiment of the present invention refers to the correct word form corresponding to the term in the original translation text obtained after the second translation term replacement model performs word form replacement on the original translation text of the text to be translated.
[0085] Furthermore, in an embodiment of the present invention, after the user inputs the text to be translated, the text to be translated is initially translated to obtain the original translation text, and then the original translation text to be translated is subjected to term replacement processing, and when replacing, " <s> "and"< / s> " mark to obtain the synthesized translation text.
[0086] Furthermore, term replacement is achieved through the second translation term replacement model. By inputting the synthesized translation text into the second translation term replacement model, the target term corresponding to the original translation text can be obtained, that is, the correct form of the term in the original translation text can be obtained. By replacing the target term with the correct form into the sentence of the synthesized translation text, <s> "and"< / s> " mark, replace the original term and remove the " <s> "and"< / s> " mark, and obtain the target translation text corresponding to the text to be translated, that is, the term replacement based on word form adaptation of the synthetic translation text is completed, and the correct translation result is obtained.
[0087] The method of the embodiment of the present invention uses synthetic translation text samples and corresponding term labels for model training to obtain a second translation term replacement model, which can achieve adaptive replacement of term forms in the original translation. By inputting the synthetic translation text into the second translation term replacement model for term form replacement, the corresponding correct term form is automatically generated. This simple term replacement results in a correct translation result. Compared to the previously described method of outputting a complete translation text, this method can significantly reduce the amount of data processing, effectively improving the quality of the machine translation results while also increasing the efficiency of the machine translation process.
[0088] Based on the content of the above embodiment, as an optional embodiment, before inputting the synthesized translation text into the first translation term replacement model, the method further includes:
[0089] Taking the synthetic translation text samples and the real translation text labels corresponding to the synthetic translation text samples as a set of training samples, and obtaining multiple sets of training samples;
[0090] The T5 model is trained using multiple sets of training samples to obtain the first translation term replacement model.
[0091] Specifically, in an embodiment of the present invention, the second translation term replacement model can be built based on the T5 model, and the T5-base model can be fine-tuned using standard processes. The T5-base model only supports English and uses a standard Transformer architecture consisting of an encoder and a decoder.
[0092] In an embodiment of the present invention, before inputting the synthesized translation text into the first translation term replacement model, the T5 model needs to be trained to obtain a trained first translation term replacement model. The specific training process is as follows:
[0093] The synthetic translation text samples and the real translation text labels corresponding to the synthetic translation text samples are taken as a group of training samples, that is, each synthetic translation text sample with a real translation text label is taken as a group of training samples, thereby obtaining multiple groups of training samples.
[0094] In the embodiment of the present invention, there is a one-to-one correspondence between the synthesized translation text sample and the real translation text label carried by the synthesized translation text sample.
[0095] Then, after obtaining multiple groups of training samples, the multiple groups of training samples are input into the T5 model in sequence, and the T5 model is trained using the multiple groups of training samples. That is, the synthetic translation text samples in each group of training samples and the real translation text labels they carry are input into the T5 model at the same time. According to each output result of the T5 model, the model parameters in the T5 model are adjusted by calculating the loss function value, and finally the training process of the T5 model is completed to obtain the trained first translation term replacement model.
[0096] The method of the embodiment of the present invention uses synthetic translation text samples and the real translation text labels corresponding to the synthetic translation text samples as a group of training samples, and uses multiple groups of training samples to train the T5 model, which is conducive to improving the model accuracy of the trained translation term replacement model.
[0097] Based on the content of the above embodiment, as an optional embodiment, the T5 model is trained using multiple sets of training samples to obtain a first translation term replacement model, including:
[0098] For any set of training samples, the training samples are segmented to obtain training samples after segmentation;
[0099] Input the training samples after word segmentation processing into the T5 model, and output the predicted probability corresponding to the training samples after word segmentation processing;
[0100] Using the preset loss function, the loss value is calculated based on the predicted probability corresponding to the training sample after word segmentation processing and the actual translation text label corresponding to the training sample;
[0101] Based on the loss value, adjust the model parameters of the T5 model until the loss value is less than the preset threshold or the number of iterations reaches the preset number;
[0102] The model parameters obtained when the loss value is less than a preset threshold or the number of iterations reaches a preset number are used as the model parameters of the trained T5 model to obtain the first translation term replacement model.
[0103] Specifically, after obtaining multiple sets of training samples, for any set of training samples, the Wordpiece algorithm is first used to perform word segmentation processing on the synthetic translation text samples in the training samples to obtain synthetic translation text samples after word segmentation processing.
[0104] Furthermore, the synthetic translation text samples after word segmentation processing in each group of training samples and the real translation text labels they carry are simultaneously input into the T5 model, and the predicted probability of the correct translation corresponding to the training sample is output.
[0105] Based on the content of the above embodiment, as an optional embodiment, the training sample after word segmentation processing is input into the T5 model, and the prediction probability corresponding to the training sample after word segmentation processing is output, including:
[0106] Through the multi-layer encoder of the T5 model, the bidirectional attention mask mechanism is used to encode the training samples after word segmentation processing word by word, and the hidden layer state vector corresponding to the training samples after word segmentation processing is obtained; through the multi-layer decoder of the T5 model, the unidirectional attention mask mechanism is used to decode the hidden layer state vector word by word, and the prediction probability corresponding to the training samples after word segmentation processing is obtained.
[0107] Specifically, in an embodiment of the present invention, the training samples after word segmentation processing are input into the T5 model. Through the multi-layer encoder of the T5 model, each layer of encoder can adopt a left and right bidirectional attention mask mechanism to encode the synthetic translation text samples after word segmentation processing word by word and encode them into the corresponding hidden layer state vector.
[0108] Furthermore, in an embodiment of the present invention, based on the hidden layer state vector output by the encoder, the hidden layer state vector is decoded word by word through the multi-layer decoder of the T5 model. A left-side unidirectional attention mask mechanism is adopted during decoding, and the predicted probability of the correct translation corresponding to the training sample is output according to the obtained decoding content.
[0109] The method of the embodiment of the present application is advantageous to improve the model training effect by using the attention mask medium, encoding and decoding the training sample after word segmentation by the multi-layer encoder and decoder of the T5 model, and predicting and generating the corresponding translation text of the training sample after word segmentation.
[0110] Further, the preset loss function described in the embodiment of the present application refers to the loss function preset in the T5 model, which is used for model evaluation; the preset threshold refers to the threshold preset by the model, which is used to obtain the minimum loss value and complete model training; and the preset number of times refers to the maximum number of times of iterative training of the model preset.
[0111] On this basis, the loss value is calculated by using the preset loss function, according to the prediction probability corresponding to the training sample after word segmentation and the real translation text label corresponding to the training sample.
[0112] Further, after the loss value is calculated and obtained, the current training process is ended. Then, the model parameters of the T5 model are adjusted based on the loss value by using the BackPropagation (BP) algorithm, to update the weight parameters of each layer of the model in the T5 model, and then the next training is performed, and the training of the model is completed by repeating the iteration.
[0113] In the training process, if the loss value calculated for a certain group of training samples is less than the preset threshold, or the current number of iterations reaches the preset number of times, the loss value of the model can be controlled within the convergence range, and the model training is ended. At this time, the obtained model parameters can be used as the final model parameters of the trained T5 model, and thus the trained first translation term replacement model is obtained.
[0114] The method of the embodiment of the present application is advantageous to improve the accuracy of the use of terms in the translation text output by the model and improve the quality of the machine translation text by repeatedly iteratively training the T5 model by using multiple groups of training samples to control the loss value of the T5 model within the convergence range.
[0115] The translation term word form adaptive replacement device provided by the present application is described below, and the translation term word form adaptive replacement device described below can be referred to in correspondence with the translation term word form adaptive replacement method described above.
[0116] Figure 2 is a structural schematic diagram of the translation term word form adaptive replacement device provided by the present application, as shown in Figure 2 , comprising:
[0117] The synthesis module 210 is configured to perform term replacement processing on the original translation text of the text to be translated to obtain a synthesized translation text.
[0118] The replacement module 220 is configured to input the synthesized translation text into the first translation term replacement model to obtain a target translation text corresponding to the to-be-translated text output by the first translation term replacement model;
[0119] The first translation term replacement model is trained based on synthetic translation text samples and corresponding real translation text labels. The synthetic translation text samples are obtained by performing term replacement processing on the original translation text samples.
[0120] The apparatus for adaptively replacing word forms of translated terms described in this embodiment can be used to execute the aforementioned method for adaptively replacing word forms of translated terms. Its principles and technical effects are similar and will not be described in detail here.
[0121] The device for adaptively replacing the word forms of translated terms provided by an embodiment of the present invention performs term replacement processing on original translated text samples to obtain synthetic translated text samples, thereby obtaining a large amount of training corpus composed of synthetic translated text samples. These training corpora and the real translated text labels corresponding to each training corpus are used for model training to obtain a first translated term replacement model, which can achieve adaptive replacement of the word forms of the original translated term. By performing term replacement processing on the original translated text to be translated to obtain a synthetic translated text, and inputting the synthetic translated text into the first translated term replacement model for replacement, a translation with correct term forms can be automatically generated, ensuring the correctness of the final translated grammar. In the case of text translation scenarios containing a large number of specialized terms in specific fields, high-quality translation effects can be achieved, effectively improving the quality of machine translation results.
[0122] Figure 3 This is a schematic diagram of the physical structure of the electronic device provided by the present invention, such as Figure 3 As shown, the electronic device may include: a processor 310, a communications interface 320, a memory 330, and a communications bus 340. The processor 310, the communications interface 320, and the memory 330 communicate with each other via the communications bus 340. The processor 310 may invoke logic instructions in the memory 330 to execute the adaptive translation method for translation term forms provided by the aforementioned methods. The method includes: performing term replacement processing on an original translation text to be translated to obtain a synthesized translation text; inputting the synthesized translation text into a first translation term replacement model to obtain a target translation text corresponding to the translation text to be translated, output by the first translation term replacement model; the first translation term replacement model is trained based on synthesized translation text samples and corresponding real translation text labels; the synthesized translation text samples are obtained by performing term replacement processing on the original translation text samples.
[0123] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0124] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the translation term form adaptive replacement method provided by the above methods, which includes: performing term replacement processing on an original translation text to be translated to obtain a synthesized translation text; inputting the synthesized translation text into a first translation term replacement model to obtain a target translation text corresponding to the text to be translated output by the first translation term replacement model; the first translation term replacement model is trained based on a synthesized translation text sample and a corresponding real translation text label, and the synthesized translation text sample is obtained by performing term replacement processing on the original translation text sample.
[0125] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for adaptively replacing translation term forms provided by the above-mentioned methods, the method comprising: performing term replacement processing on an original translation text of a text to be translated to obtain a synthesized translation text; inputting the synthesized translation text into a first translation term replacement model to obtain a target translation text corresponding to the text to be translated output by the first translation term replacement model; the first translation term replacement model is trained based on a synthesized translation text sample and a corresponding real translation text label, and the synthesized translation text sample is obtained by performing term replacement processing on the original translation text sample.
[0126] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0127] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.
[0128] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A method for adaptively replacing the word form of a translated term, characterized in that: include: Performing term replacement processing on the original target text to be translated to obtain a synthetic target text; Inputting the synthesized translation text into a first translation term replacement model to obtain a target translation text corresponding to the text to be translated output by the first translation term replacement model; the target translation text is a translation text of the correct term form; The first translation term replacement model is trained based on synthetic translation text samples and corresponding real translation text labels, wherein the synthetic translation text samples are obtained by performing term replacement processing on the original translation text samples; The step of performing term replacement processing on the original target text to be translated to obtain a synthesized target text includes: Segmenting the original translation text to obtain a plurality of sentences corresponding to the original translation text; Using a term extraction tool to extract terms from each of the sentences, marking the terms extracted from each of the sentences, and determining the marking positions of the terms in each of the sentences; A lemma restoration tool is used to restore each term in the sentence to a corresponding original term according to the marked position of the term in each sentence, thereby obtaining the synthesized translation text.
2. The method for adaptively replacing the word form of a translated term according to claim 1, characterized in that: After performing term replacement processing on the original target text to be translated to obtain a synthesized target text, the method further includes: Inputting the synthesized translation text into a second translation term replacement model to obtain a target term corresponding to the original translation text output by the second translation term replacement model; the second translation term replacement model is trained based on the synthesized translation text sample and the corresponding term label; The original terms in the synthesized translation text are replaced with the corresponding target terms to obtain the target translation text corresponding to the text to be translated.
3. The method for adaptively replacing the word form of a translated term according to claim 1, characterized in that: Before inputting the synthesized translation text into the first translation term replacement model, the method further includes: Taking the synthetic translation text sample and the real translation text label corresponding to the synthetic translation text sample as a group of training samples, obtaining multiple groups of training samples; The T5 model is trained using the multiple groups of training samples to obtain the first translation term replacement model.
4. The method for adaptively replacing the word form of a translated term according to claim 3, characterized in that: The T5 model is trained using the multiple sets of training samples to obtain the first translation term replacement model, including: For any set of training samples, the training samples are segmented to obtain training samples after segmentation; Input the training sample after word segmentation processing into the T5 model, and output the predicted probability corresponding to the training sample after word segmentation processing; Calculating a loss value using a preset loss function based on the predicted probability corresponding to the training sample after word segmentation processing and the actual translation text label corresponding to the training sample; Based on the loss value, adjusting the model parameters of the T5 model until the loss value is less than a preset threshold or the number of iterations reaches a preset number; The model parameters obtained when the loss value is less than a preset threshold or the number of iterations reaches a preset number are used as the model parameters of the trained T5 model to obtain the first translation term replacement model.
5. The method for adaptively replacing the word form of a translated term according to claim 4, characterized in that: Inputting the training sample after word segmentation processing into the T5 model and outputting the predicted probability corresponding to the training sample after word segmentation processing includes: Using the multi-layer encoder of the T5 model, the training samples after word segmentation are encoded word by word using a bidirectional attention mask mechanism to obtain a hidden layer state vector corresponding to the training samples after word segmentation; The multi-layer decoder of the T5 model is used to decode the hidden layer state vector word by word using a unidirectional attention mask mechanism to obtain the predicted probability corresponding to the training sample after word segmentation processing.
6. A device for adaptively replacing word forms of translated terms, characterized in that: include: A synthesis module is used to perform term replacement processing on the original target text to obtain a synthesized target text; Inputting the synthesized translation text into a first translation term replacement model to obtain a target translation text corresponding to the text to be translated output by the first translation term replacement model; the target translation text is a translation text of the correct term form; The first translation term replacement model is trained based on synthetic translation text samples and corresponding real translation text labels, wherein the synthetic translation text samples are obtained by performing term replacement processing on the original translation text samples; The step of performing term replacement processing on the original target text to be translated to obtain a synthesized target text includes: Segmenting the original translation text to obtain a plurality of sentences corresponding to the original translation text; Using a term extraction tool to extract terms from each of the sentences, marking the terms extracted from each of the sentences, and determining the marking positions of the terms in each of the sentences; A lemma restoration tool is used to restore each term in the sentence to a corresponding original term according to the marked position of the term in each sentence, thereby obtaining the synthesized translation text.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method for adaptively replacing translated term forms according to any one of claims 1 to 5 is implemented.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for adaptively replacing the word form of a translated term is implemented as claimed in any one of claims 1 to 5.
9. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method for adaptively replacing the word form of a translated term is implemented as claimed in any one of claims 1 to 5.
Citation Information
Patent Citations
Term replacement method and device
CN111191468A
Insertion of Translation in Displayed Text
US20120245922A1